Related articles 

Parsing expressions without outer parentheses frank@gnu.de (Frank Heckenbach) (20030427) 
Re: Parsing expressions without outer parentheses cfc@world.std.com (Chris F Clark) (20030505) 
Re: Parsing expressions without outer parentheses slk15@earthlink.net (SLK Parsers) (20030506) 
Re: Parsing expressions without outer parentheses pjj@cs.man.ac.uk (Pete Jinks) (20030506) 
Re: Parsing expressions without outer parentheses hannah@schlund.de (Hannah Schroeter) (20030512) 
Re: Parsing expressions without outer parentheses frank@gnu.de (Frank Heckenbach) (20030524) 
Re: Parsing expressions without outer parentheses frank@gnu.de (Frank Heckenbach) (20030524) 
From:  Hannah Schroeter <hannah@schlund.de> 
Newsgroups:  comp.compilers 
Date:  12 May 2003 01:38:18 0400 
Organization:  Schlund + Partner AG 
Keywords:  parse 
PostedDate:  12 May 2003 01:38:18 EDT 
ContentDisposition:  inline 
Hello!
Frank Heckenbach <frank@gnu.de> wrote:
>[...]
>Now I want to accept only expressions which are not completely
>enclosed in a pair of parentheses, e.g. `(1) + (2)' would be
>accepted, but `(1 + 2)' would not.
>[...]
How about creating a syntax tree node for parens, too?
Then you'd have
+
/ \
() ()
 
1 2
for (1) + (2) and
()

+
/ \
1 2
for (1 + 2).
Then you could just check whether the expression tree's root is a
"()" node and if so, reject the input.
Afterwards, you can remove the paren nodes (except if you want to use
them to inhibit optimizing transforms that would change the associative
order, like required in Fortran).
Kind regards,
Hannah.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.