Related articles 

LL(1) Grammar for Expressions with Assignment bergmann@elvis.rowan.edu (19950627) 
Re: LL(1) Grammar for Expressions with Assignment jos@and.nl (19950630) 
Re: LL(1) Grammar for Expressions with Assignment parrt@lonewolf.parrresearch.com (19950701) 
Newsgroups:  comp.compilers 
From:  jos@and.nl (Jos A. Horsmeier) 
Keywords:  parse, LL(1) 
Organization:  AND Software B.V. Rotterdam 
References:  9506075 
Date:  Fri, 30 Jun 1995 09:56:51 GMT 
bergmann@elvis.rowan.edu (Seth Bergmann) wrote:
I've been trying to find an LL(1) grammar for the language of
expressions involving addition, subtraction, multiplication, division,
unary minus, unary plus, and assignment (as in C). Included would be
expressions such as:

 (a=3+b) * (c = 3)

but excluded would be things like:

 3+a=4 and 2 = a

The compiler books I've checked all seem to either use lookahead (i.e.
LL(2)) or check for a proper lvalue for the assignment during semantic
analysis. I suspect this language of expressions is not LL(1). Can
anyone point me to a reference on this?
How about this grammar:
E > T E' ;
E' > [+] T E'  ;
T > U T'
T' > [*/] U T'  ;
U > [+] U'  F ;
U' > [+] U'  F' ;
F > constant  ident I  ( E ) ;
F' > constant  ident  ( E ) ;
I > = E  ;
If I'm not mistaken (I just checked this thingy manually) this
grammar does exactly what you want ...
kind regards,
Jos aka jos@and.nl

Return to the
comp.compilers page.
Search the
comp.compilers archives again.