[antlr-interest] Parsing a time expression

Rick Mann rmann at latencyzero.com
Sat Apr 24 20:37:28 PDT 2010


So, starting from a basic grammar that parses the two kinds of time expression, I tried to add the ability to add two intervals. I attempted to follow the example in the book for the expr language. Here's my grammar (the lexer/parser is concatenated below the tree grammar):

	http://pastie.org/private/k9holwmls7emhfpgzo1oxw

If I uncomment line 15, it complains that:

[20:34:25] Checking Grammar TimeEval.g...
[20:34:25] warning(200): TimeEval.g:34:4: Decision can match input such as "INT INT" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
[20:34:25] warning(200): TimeEval.g:34:3: Decision can match input such as "INT" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input


With line 15 commented out, it works great, but I need to understand why it becomes ambiguous with the sum operation in there, and how to fix it, so that I can add some other operations.

I feel like I need to do something to let the tree walker know when it hits an RTL expression, but I wasn't able to just insert a token into the stream as I have wanted to do more than once.

Thanks much!
-- 
Rick



More information about the antlr-interest mailing list