Related articles |
---|
Re: Simple constant folding in bison parser drw@kronecker.mit.edu (1992-08-10) |
constant folding at parse time wjw@eb.ele.tue.nl (1992-08-17) |
Re: constant folding at parse time markh@csd4.csd.uwm.edu (1992-08-17) |
Re: constant folding at parse time twpierce@amhux1.amherst.EDU (Tim Pierce) (1992-08-19) |
Re: constant folding at parse time scott@bbx.basis.com (1992-08-20) |
Re: constant folding at parse time wjw@eb.ele.tue.nl (1992-08-21) |
Re: constant folding at parse time buehlman@iwf.mabp.ethz.ch (1992-08-21) |
Re: constant folding at parse time drw@euclid.mit.edu (1992-08-24) |
Newsgroups: | comp.compilers |
From: | scott@bbx.basis.com (Scott Amspoker) |
Organization: | BASIS International, Ltd., Albuquerque NM USA |
Date: | Thu, 20 Aug 1992 15:41:14 GMT |
References: | 92-08-040 92-08-097 |
Keywords: | parse, attribute |
markh@csd4.csd.uwm.edu (Hunk) writes:
>A expression evaluation routine I wrote for an expression parser in a
>recently released assembler (C-expression syntax is handled) is set up in
>such a way that all constant subexpressions will be reduced to leaf nodes
>during parsing. The question about whether a given expression is constant
>or not doesn't even arise because it's already been handled by the parser.
>Basically, if the expression tree returned by the parser is a leaf node
>then it's a constant, otherwise it's not.
It all depends on what you call a constant. The address of a global
object is a constant and may be used in an initializer list:
char c[10];
char *cp = &c[2];
The address of c[2] is a constant but cannot be folded by the compiler.
Because of this, we have had to use a flag in a parse tree node to
indicate the 'constant' status of the sub-expression.
--
Scott Amspoker, Basis International, Albuquerque, NM
scott@bbx.basis.com
[I've worked with compilers that considered a constant to be a numeric
offset plus an optional static symbol address. This can be very convenient
for generating addressing code. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.