Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #1141
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!.POSTED!nerds-end |
|---|---|
| From | noitalmost <noitalmost@cox.net> |
| Newsgroups | comp.compilers |
| Subject | Re: Having trouble converting composite variables to intermediate form |
| Date | Mon, 10 Mar 2014 15:18:43 -0400 |
| Organization | Compilers Central |
| Lines | 37 |
| Sender | news@iecc.com |
| Approved | comp.compilers@iecc.com |
| Message-ID | <14-03-019@comp.compilers> (permalink) |
| References | <14-02-029@comp.compilers> <YJYW1n00f1AptjU01JYXKV> |
| NNTP-Posting-Host | news.iecc.com |
| Mime-Version | 1.0 |
| Content-Type | Text/Plain; charset="iso-8859-15" |
| Content-Transfer-Encoding | 7bit |
| X-Trace | miucha.iecc.com 1394492248 23337 64.57.183.58 (10 Mar 2014 22:57:28 GMT) |
| X-Complaints-To | abuse@iecc.com |
| NNTP-Posting-Date | Mon, 10 Mar 2014 22:57:28 +0000 (UTC) |
| Keywords | code |
| Posted-Date | 10 Mar 2014 18:57:27 EDT |
| X-submission-address | compilers@iecc.com |
| X-moderator-address | compilers-request@iecc.com |
| X-FAQ-and-archives | http://compilers.iecc.com |
| Xref | csiph.com comp.compilers:1141 |
Show key headers only | 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
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