rascal
rascal copied to clipboard
Ambiguity errors for productions annotated with a tag
Describe the bug
Productions annotated with a tag (@category in the examples below, but presumably any tag) sometimes give rise to ambiguity errors.
To Reproduce
Example 1:
rascal>lexical Test1a = "0";
ok
rascal>lexical Test1b = @category="number" "0";
ok
rascal>lexical Test1c = [0];
ok
rascal>lexical Test1d = @category="number" [0];
Unexpected failure during parsing of current command:
Ambiguous code (internal error), @category="number" [0]
org.rascalmpl.interpreter.asserts.Ambiguous: Ambiguous code (internal error), @category="number" [0]
...
Example 2:
rascal>lexical Test2a = @category="number" ([0] | [1]);
ok
rascal>lexical Test2b = @category="number" ([0-1]);
Unexpected failure during parsing of current command:
Ambiguous code (internal error), @category="number" ([0-1])
org.rascalmpl.interpreter.asserts.Ambiguous: Ambiguous code (internal error), @category="number" ([0-1])
...
rascal>lexical Test2c = @category="number" [0-1];
Unexpected failure during parsing of current command:
Ambiguous code (internal error), @category="number" [0-1]
org.rascalmpl.interpreter.asserts.Ambiguous: Ambiguous code (internal error), @category="number" [0-1]
...
Example 3:
rascal>lexical Test3a = @category="number" ([0] | [1])+;
ok
rascal>lexical Test3b = @category="number" [0-1]+;
Unexpected failure during parsing of current command:
Ambiguous code (internal error), @category="number" [0-1]+
org.rascalmpl.interpreter.asserts.Ambiguous: Ambiguous code (internal error), @category="number" [0-1]+
...
rascal>lexical Test3c = @category="number" ([0-1]+);
ok
But:
rascal>import ParseTree;
ok
rascal>parse(#Test3c, "101");
|std:///ValueIO.rsc|(1814,205,<60,0>,<62,63>): ParseError(|unknown:///|(15,1))
at *** somewhere ***(|std:///ValueIO.rsc|(1814,205,<60,0>,<62,63>))
at readTextValueString(|std:///ValueIO.rsc|(1802,5,<56,37>,<56,42>))
at mod2attr(|std:///lang/rascal/grammar/definition/Attributes.rsc|(1683,53,<37,57>,<37,110>))
at mods2attrs(|std:///lang/rascal/grammar/definition/Attributes.rsc|(687,4,<19,66>,<19,70>))
at prod2prod(|std:///lang/rascal/grammar/definition/Productions.rsc|(3009,78,<74,15>,<74,93>))
at rule2prod(|std:///lang/rascal/grammar/definition/Productions.rsc|(2103,41,<53,15>,<53,56>))
at syntax2grammar(|std:///lang/rascal/grammar/definition/Productions.rsc|(955,14,<29,14>,<29,28>))
at modules2grammar(|std:///lang/rascal/grammar/definition/Modules.rsc|(1095,265,<24,26>,<29,38>))
at $parsergenerator$(|main://$parsergenerator$|ok
Expected behavior
No ambiguity errors
Stack traces
Full stack trace of the ambiguity errors:
org.rascalmpl.interpreter.asserts.Ambiguous: Ambiguous code (internal error), @category="number" [0-1]*
at org.rascalmpl.parser.uptr.UPTRNodeFactory.buildAmbiguityNode(UPTRNodeFactory.java:76)
at org.rascalmpl.parser.uptr.UPTRNodeFactory.createAmbiguityNode(UPTRNodeFactory.java:85)
at org.rascalmpl.parser.uptr.UPTRNodeFactory.createAmbiguityNode(UPTRNodeFactory.java:23)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.convertToUPTR(SortContainerNodeFlattener.java:183)
at org.rascalmpl.parser.gtd.result.out.DefaultNodeFlattener.convert(DefaultNodeFlattener.java:63)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.buildAlternative(SortContainerNodeFlattener.java:90)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:65)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherAlternatives(SortContainerNodeFlattener.java:53)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.convertToUPTR(SortContainerNodeFlattener.java:166)
at org.rascalmpl.parser.gtd.result.out.DefaultNodeFlattener.convert(DefaultNodeFlattener.java:63)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.buildAlternative(SortContainerNodeFlattener.java:90)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:65)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherAlternatives(SortContainerNodeFlattener.java:53)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.convertToUPTR(SortContainerNodeFlattener.java:166)
at org.rascalmpl.parser.gtd.result.out.DefaultNodeFlattener.convert(DefaultNodeFlattener.java:63)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.buildAlternative(SortContainerNodeFlattener.java:90)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:65)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherAlternatives(SortContainerNodeFlattener.java:53)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.convertToUPTR(SortContainerNodeFlattener.java:166)
at org.rascalmpl.parser.gtd.result.out.DefaultNodeFlattener.convert(DefaultNodeFlattener.java:63)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.buildAlternative(SortContainerNodeFlattener.java:90)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:65)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherProduction(SortContainerNodeFlattener.java:71)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.gatherAlternatives(SortContainerNodeFlattener.java:53)
at org.rascalmpl.parser.gtd.result.out.SortContainerNodeFlattener.convertToUPTR(SortContainerNodeFlattener.java:166)
at org.rascalmpl.parser.gtd.result.out.DefaultNodeFlattener.convert(DefaultNodeFlattener.java:63)
at org.rascalmpl.parser.gtd.result.out.DefaultNodeFlattener.convert(DefaultNodeFlattener.java:79)
at org.rascalmpl.parser.gtd.SGTDBF.buildResult(SGTDBF.java:1297)
at org.rascalmpl.parser.gtd.SGTDBF.parse(SGTDBF.java:1236)
at org.rascalmpl.parser.gtd.SGTDBF.parse(SGTDBF.java:1240)
at org.rascalmpl.parser.gtd.SGTDBF.parse(SGTDBF.java:1252)
at org.rascalmpl.interpreter.Evaluator.parseCommand(Evaluator.java:1023)
at org.rascalmpl.interpreter.Evaluator.parseCommand(Evaluator.java:1013)
at org.rascalmpl.repl.RascalInterpreterREPL.isStatementComplete(RascalInterpreterREPL.java:174)
at org.rascalmpl.repl.BaseRascalREPL.handleInput(BaseRascalREPL.java:105)
at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL$1.handleInput(LSPTerminalREPL.java:281)
at org.rascalmpl.repl.BaseREPL.handleInput(BaseREPL.java:180)
at org.rascalmpl.repl.BaseREPL.run(BaseREPL.java:347)
at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL.main(LSPTerminalREPL.java:363)