[antlr-interest] left recursion removal

Sébastien Kirche sebastien.kirche at gmail.com
Wed Jul 6 16:27:33 PDT 2011


Le 7 juillet 2011 00:14, John B. Brodie <jbb at acm.org> a écrit :
> Greetings!
>
> [...]
>
> unable to reproduce.
>
> given your admittedly partial grammar, i tried to construct a complete
> example by adding the missing elements and creating an AST (so i could
> know the resultant parse).
>
> my test rig is attached.
>
> it runs without error when Tool'd, compiled, and executed from the
> command-line (FWIW i use Ubunto 11.04 Linux running Sun Java 6 and the
> Antlr version from the antlr-3.4-complete.jar file).
>
> Please try to post the *smallest* yet *complete* example of your
> problem.

Sorry for not having posted a more complete code before, I though that
should have been enough...

I have worked further on my grammar, with trying to define more
precisely what an expression should be, with operator precedence. This
made me rewrite the singleStatement by moving the funCall  rule to the
primary rule. But my problem about the if-then-else construct is not
gone.

I have stripped down my grammar, keeping only the expression and
subsequent rules, removed all that define loops, switches, etc.
Given that simplified grammar, the following script should pass the
parsing, but it can't yet :

---------------------------------------
string s1, s2

if s1='42' then s2='421'

if s2='421' then
	string s3
	s3='123'
else
	string s4
	s4='666'
end if

---------------------------------------

Also, to Jim Idle : the language I would be able to parse is
Powerbuilder. You can see it as a sort of basic, while it accepts
syntax like i++ or s += 'foo' He has also the ability to accept inline
sql statements... I tried to play on the EndOfLine delimiter to handle
the two if-then-else syntaxes but without success.

-- 
Sébastien Kirche
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pbifthenelse.g
Type: application/octet-stream
Size: 2646 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20110707/4b4433d8/attachment.obj 


More information about the antlr-interest mailing list