Related articles |
---|
Generating Source Code. dara_gallagher@my-deja.com (1999-10-06) |
Re: Generating Source Code. rod.bates@boeing.com (Rodney M. Bates) (1999-10-11) |
Re: Generating Source Code. chase@world.std.com (David Chase) (1999-10-11) |
Re: Generating Source Code. smith@gandalf.uni-trier.de (Craig Smith) (1999-10-11) |
Re: Generating Source Code. cmilner@virginia.edu (Christopher W. Milner) (1999-10-11) |
Re: Generating Source Code. anton@mips.complang.tuwien.ac.at (1999-10-13) |
Re: Generating Source Code. thetick@jguru.com (Scott Stanchfield) (1999-10-13) |
Re: Generating Source Code. ele@freesurf.ch (H. Ellenberger) (1999-10-14) |
Re: Generating Source Code. vadik@siber.com (Vadim Maslov) (1999-10-16) |
Re: Generating Source Code. chstapfer@bluewin.ch (Christian Stapfer) (1999-10-21) |
From: | Craig Smith <smith@gandalf.uni-trier.de> |
Newsgroups: | comp.compilers |
Date: | 11 Oct 1999 02:36:41 -0400 |
Organization: | Programming Languages Group, U. of Trier |
References: | 99-10-036 |
Keywords: | practice, code |
dara_gallagher@my-deja.com writes:
> 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:
*(p->Pattern_ref()->Slot(2))
Similarly for the address-of operator '&'.
But you probably already thought of this already!
(raig
--
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
comp.compilers page.
Search the
comp.compilers archives again.