------ Original Message (Thursday, August 05, 2010 11:41:57 
PM) From: Dervin Thunk ------
Subject: [antlr-interest] grammar problem with recursion?
> Hello. I am new to ANTLR. Below is a grammar I wrote, and I'm trying to
> test it with the following string, but it just stops before it even
> consumes the n_pp... identifier, so it stops at the "conjunction"
> rule. Any idea about what I could be doing wrong?
>
>
> conjunction
>         :  term
>         | (term '&' conjunction)
>         ;
Once 'term' gets matched in alt 1, Antlr has no where to go next.  You 
could reverse the order of the alts, but better would be

         conjunction : term ( '&' conjunction )? ;

You have this problem in most of your compound rules.  There is an Antlr 
Wiki page on left factoring that you should read.



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to