Re: Having trouble converting composite variables to intermediate form

Momchil Velikov <momchil.velikov@gmail.com>
Fri, 28 Feb 2014 08:27:00 -0800 (PST)

          From comp.compilers

Related articles
Having trouble converting composite variables to intermediate form noitalmost@cox.net (noitalmost) (2014-02-22)
Re: Having trouble converting composite variables to intermediate form momchil.velikov@gmail.com (Momchil Velikov) (2014-02-28)
Re: Having trouble converting composite variables to intermediate form noitalmost@cox.net (noitalmost) (2014-03-10)
| List of all articles for this month |
From: Momchil Velikov <momchil.velikov@gmail.com>
Newsgroups: comp.compilers
Date: Fri, 28 Feb 2014 08:27:00 -0800 (PST)
Organization: Compilers Central
References: 14-02-029
Injection-Date: Fri, 28 Feb 2014 16:27:00 +0000
Keywords: analysis
Posted-Date: 01 Mar 2014 13:32:18 EST

On Saturday, February 22, 2014 7:32:01 PM UTC+2, noitalmost wrote:
>
> x := r.a[2] + 5;
>


> After parsing, the Wirl AST fragment looks like:
>
> Assign
> Ident x
> Op +
> RecAccess
> Ident r
> ArrAccess
> Ident a
> Num 2


You have currently


RecAccess(r, ArrAccess(Ident(a), Num(2)))


Note, however, that the array is not `a`, it's `r.a`. The subtree
`ArrAccess(Ident(a), Num(2)) `is incorrect, because you don't have in fact
a variable named `a` of an array type.


Here the record access should take precedence over array access, i.e.
the AST should look like:


ArrAccess(RecAccess(r, Ident(a)), Num(2))


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.