Related articles |
---|
multiple assignment mklarson@gte.net (Michael Larson) (2000-02-28) |
Re: multiple assignment Jens_Kilian@agilent.com (Jens Kilian) (2000-03-06) |
Re: multiple assignment rkrayhawk@aol.com (2000-03-06) |
Re: multiple assignment bonzini@gnu.org (2000-03-06) |
From: | Jens Kilian <Jens_Kilian@agilent.com> |
Newsgroups: | comp.compilers |
Date: | 6 Mar 2000 00:26:33 -0500 |
Organization: | Agilent Technologies Deutschland GmbH |
References: | 00-02-160 |
Keywords: | code |
Michael Larson <mklarson@gte.net> writes:
> I have a testbed compiler for a simple C dialect (Renderman Shading
> Language). One of the problems I am having with evaluating the parse
> tree is with multiple assignement. It should be clean but it really is
> a hack for a recusive evaluator.
>
> Say you have an expression like this
>
> a = b = c + 1;
>
> this would result in a node assignment like this using my parser,
> similar to the syntax driven parse example in the dragon book.
>
> Printing node list, 9 nodes
> Node #0001: 080506E0 type IDENTIFIER a
> Node #0002: 080506F8 type IDENTIFIER b
> Node #0003: 08050710 type = left 080506E0 right 080506F8
> Node #0004: 08050728 type IDENTIFIER c
> Node #0005: 08050740 type CONSTANT 1.000000
> Node #0006: 08050758 type + left 08050728 right 08050740
> Node #0007: 08050770 type = left 08050710 right 08050758
> Node #0008: 08050788 type EXPR left 08050770
> Node #0009: 080507A0 type STMT left 08050788
If I understand you correctly, your problem is the associativity of '=':
You want "a = (b = c+1)", but you got "(a = b) = c+1". Is this correct?
If so, it should be fixable in the grammar.
HTH,
Jens.
--
mailto:jjk@acm.org phone:+49-7031-464-7698 (HP TELNET 778-7698)
http://www.bawue.de/~jjk/ fax:+49-7031-464-7351
Return to the
comp.compilers page.
Search the
comp.compilers archives again.