[antlr-interest] ANTLR NUB

John B. Brodie jbb at acm.org
Tue Jan 29 11:05:10 PST 2008


Greetings!

Jan Nielsen wrote:
>So I rewrote the grammar with return values after implementing the
>underlying APIs. I'm still having some basic issues with recognition,
>however. I think the excludeClause and includeClause lists are not
>being handled correctly - perhaps because of the comma?

The handling of the comma in excludeClause and includeClause looks
okay to me.

>I have included my test cases and grammar below. If you have any
>insights about what I've done wrong, I'd be delighted to entertain
>them. :)

monthClause REQUIRES a '/' before the name of the month. so the test
input of "include June to July" will be illegal. according to the
grammar that should instead be "include /June to /July".

as for the other errors, I am really confused. is your test rig
proper? since your grammar only handles a single availablityClause you
should be starting with a brand new fresh lexer and parser for each of
your inputs, right? or are you trying to re-use a prior lexer&parser
instance? if re-using, perhaps encountering the above error puts the
parser into a bad state so that it is unable to deal with subsequent
input (just guessing here).

maybe changing the program rule to look for EOF after the
availabilityClause might help to figure things out... e.g:

program : availabilityClause EOF ;



>Many thanks,

Hope this helps...

>...grammar and test cases snipped...

   -jbb


More information about the antlr-interest mailing list