[antlr-interest] left recursion removal

John B. Brodie jbb at acm.org
Thu Jul 7 08:51:52 PDT 2011


Greetings!

On Thu, 2011-07-07 at 17:04 +0200, Sébastien Kirche wrote:
> Le 7 juillet 2011 05:08, John B. Brodie <jbb at acm.org> a écrit :
> > see attached.
> 
> Many, many thanks, as your corrections on my example helped me
> considerably and the initial recursion is gone.

you are welcome. i actually enjoy doing this stuff.

> I had also an obvious bug in my "NOT" expression. Now I have added
> some other structures like for/next and choose/case
> 
> My current problem is that your refactor of my funCall rule by
> following an expression by a postfix notation seems not working on my
> test code.
> That looks clever, but during parsing, the Parser seem to look for a
> missing assignment between the function identifier and the parameter
> list. I did not found why yet.
> 
> I join my grammar in its current state.

change the singleStatement rule to this:

singleStatement
	:	IDENT ( OPEQ expression | '(' expressionList? ')' )
	|	'return' expression
	;

and delete the now unnecessary assignment rule.
   -jbb




More information about the antlr-interest mailing list