|Generating Source Code. firstname.lastname@example.org (1999-10-06)|
|Re: Generating Source Code. email@example.com (Rodney M. Bates) (1999-10-11)|
|Re: Generating Source Code. firstname.lastname@example.org (David Chase) (1999-10-11)|
|Re: Generating Source Code. email@example.com (Craig Smith) (1999-10-11)|
|Re: Generating Source Code. firstname.lastname@example.org (Christopher W. Milner) (1999-10-11)|
|Re: Generating Source Code. email@example.com (1999-10-13)|
|Re: Generating Source Code. firstname.lastname@example.org (Scott Stanchfield) (1999-10-13)|
|Re: Generating Source Code. email@example.com (H. Ellenberger) (1999-10-14)|
|Re: Generating Source Code. firstname.lastname@example.org (Vadim Maslov) (1999-10-16)|
|Re: Generating Source Code. email@example.com (Christian Stapfer) (1999-10-21)|
|From:||Craig Smith <firstname.lastname@example.org>|
|Date:||11 Oct 1999 02:36:41 -0400|
|Organization:||Programming Languages Group, U. of Trier|
> 2) Adding extra parenthesis even if they are not strictly
> necessary from a grammatical point of view but might
> improve the readability.
I don't know what language you are generating code for, but if it were
C/C++ I'd make a couple of rules based on precedence. Some people,
myself included, aren't entirely familiar with the precedence rules.
I therefore tend to add parenthesis when the precedence isn't clear (I
believe John Ousterhoot was the first person I heard say this). Some
simple rules for this would be easy to add for a AST for C. Take for
instance the dereference operator, if the expression is very simple
parenthesis are not necessary:
int * p = ...;
*p = 5
If the expression is more complex then, add parens:
Similarly for the address-of operator '&'.
But you probably already thought of this already!
Craig Smith 'Discussion is an exchange of knowledge;
Mitarbeiter, Informatik argument an exchange of ignorance.'
University of Trier - Robert Quillen
Trier, Germany www.informatik.uni-trier.de/~smith
Return to the
Search the comp.compilers archives again.