[antlr-interest] grammar problem with recursion?

Kevin J. Cummings cummings at kjchome.homeip.net
Thu Aug 5 21:03:47 PDT 2010


On 08/05/2010 11:41 PM, Dervin Thunk wrote:
> 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)
>        ;

Should be:

conjunction
	: term ('&' term)*
	;

Now you don't have any recursion....

-- 
Kevin J. Cummings
kjchome at rcn.com
cummings at kjchome.homeip.net
cummings at kjc386.framingham.ma.us
Registered Linux User #1232 (http://counter.li.org)


More information about the antlr-interest mailing list