Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1141

Re: Having trouble converting composite variables to intermediate form

From noitalmost <noitalmost@cox.net>
Newsgroups comp.compilers
Subject Re: Having trouble converting composite variables to intermediate form
Date 2014-03-10 15:18 -0400
Organization Compilers Central
Message-ID <14-03-019@comp.compilers> (permalink)
References <14-02-029@comp.compilers> <YJYW1n00f1AptjU01JYXKV>

Show all headers | View raw


On Friday, February 28, 2014 11:27:00 AM Momchil Velikov wrote:
> 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))

Thanks. I eventually figured it out independently by working backward from the
C code I wanted to generate. The compiler can now handle arbitrary
combinations of records, arrays, and pointers. I spent a week jumping up and
down and dancing. Wirl has now graduated from toy to fun toy :)

Back to comp.compilers | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Having trouble converting composite variables to intermediate form noitalmost <noitalmost@cox.net> - 2014-02-22 12:32 -0500
  Re: Having trouble converting composite variables to intermediate form Momchil Velikov <momchil.velikov@gmail.com> - 2014-02-28 08:27 -0800
  Re: Having trouble converting composite variables to intermediate form noitalmost <noitalmost@cox.net> - 2014-03-10 15:18 -0400

csiph-web