Related articles |
---|
Parsing questions e8rasmus@etek.chalmers.se (Rasmus Anthin) (2000-01-06) |
Parsing Questions sewing@uvic.ca (Stefan Ewing) (2002-06-13) |
Re: Parsing Questions sting@linguist.dartmouth.edu (Michael J. Fromberger) (2002-06-14) |
Re: Parsing Questions ian@cfmu.eurocontrol.be (Ian Wild) (2002-06-14) |
Re: Parsing Questions joachim_d@gmx.de (Joachim Durchholz) (2002-06-14) |
Re: Parsing Questions rcbilson@plg2.math.uwaterloo.ca (Richard C Bilson) (2002-06-14) |
Re: Parsing Questions vbdis@aol.com (VBDis) (2002-06-14) |
Re: Parsing Questions sewing@uvic.ca (Stefan Ewing) (2002-06-17) |
Re: Parsing Questions sewing@uvic.ca (Stefan Ewing) (2002-06-17) |
From: | "Joachim Durchholz" <joachim_d@gmx.de> |
Newsgroups: | comp.compilers |
Date: | 14 Jun 2002 15:20:10 -0400 |
Organization: | Compilers Central |
References: | 02-06-034 |
Keywords: | parse |
Posted-Date: | 14 Jun 2002 15:20:10 EDT |
Stefan Ewing wrote:
> How can the postfix increment/decrement operators in C, C++, and Java
> be represented in a parse tree? For example, if we have the
> epxression
>
> a = b++ + c;
The parse tree for this would be
+
/ \
.++ c
|
b
(.++ indicating the postfix ++; you'd have different encodings for
prefix and postfix ++.)
> b will be incremented after b + c has been calculated.
Nearly, but not quite.
The .++ operator should return the value of b, then increment b. (This
may sound nonsensical, but on an implementation level, functions can
prepare the return value, do a few other things, and then actually return.)
> Also, how should one represent the Java field access operator (.) in
> a parse tree? At first glance, it seems like a binary operator to
> me (given the object name and the field name, a memory address is
> returned), but one operator precedence chart I saw online shows . as
> a unary operator.
The chart is wrong (there's always the possibility of a typo after all),
or it is based on a grammar that doesn't follow the normal operator
precedence patterns (e.g. if the grammar defines an access path as a
sequence of "access elements", each element being a name prefixed with a
dot).
Regards,
Joachim
--
This is not an official statement from my employer.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.