Groups | Search | Server Info | Login | Register
Groups > comp.compilers > #105
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news.kjsl.com!usenet.stanford.edu!news.iecc.com!nerds-end |
|---|---|
| From | Robert A Duff <bobduff@shell01.TheWorld.com> |
| Newsgroups | comp.compilers |
| Subject | Re: Maintaining scope while parsing C with a YACC grammar |
| Date | Tue, 26 Apr 2011 12:22:45 -0400 |
| Organization | The World Public Access UNIX, Brookline, MA |
| Lines | 26 |
| Sender | news@iecc.com |
| Approved | comp.compilers@iecc.com |
| Message-ID | <11-04-038@comp.compilers> (permalink) |
| References | <11-04-036@comp.compilers> |
| NNTP-Posting-Host | news.iecc.com |
| X-Trace | gal.iecc.com 1303837537 27385 64.57.183.58 (26 Apr 2011 17:05:37 GMT) |
| X-Complaints-To | abuse@iecc.com |
| NNTP-Posting-Date | Tue, 26 Apr 2011 17:05:37 +0000 (UTC) |
| Keywords | parse, symbols, comment |
| Posted-Date | 26 Apr 2011 13:05:37 EDT |
| X-submission-address | compilers@iecc.com |
| X-moderator-address | compilers-request@iecc.com |
| X-FAQ-and-archives | http://compilers.iecc.com |
| Xref | x330-a1.tempe.blueboxinc.net comp.compilers:105 |
Show key headers only | View raw
eliben <eliben@gmail.com> writes: > [There's a couple of possibilities. One is to add separate rules for > the open and close braces with action code that increments and > decrements the nesting level, so you know when you reduce the > declaration what scope it is in. Another is to parse the whole thing > into an AST without trying to interpret the symbols other than making > pointers to a generic symbol table entry per name, then walk the AST > and add the scope and type info. Perhaps people will have other > suggestions. -John] I strongly recommend the "build a tree" solution. It might seem like a lot of trouble at first, but it will simplify things in the long run. Do all the interesting work during a subsequent walk of the tree. Or multiple walks. I'd do the "making pointers to a generic symbol table..." part during the tree walk, too, except that C requires some sort of kludgery to deal with typedefs. - Bob [The point of the generic symbol table stuff is that you have to remember the names somehow, and that seems less awful than doing a strdup() for each name and hanging the strings off the AST. -John]
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
Maintaining scope while parsing C with a YACC grammar eliben <eliben@gmail.com> - 2011-04-25 05:14 -0700
Re: Maintaining scope while parsing C with a YACC grammar Robert A Duff <bobduff@shell01.TheWorld.com> - 2011-04-26 12:22 -0400
Re: Maintaining scope while parsing C with a YACC grammar Robert A Duff <bobduff@shell01.TheWorld.com> - 2011-04-26 14:08 -0400
Re: Maintaining scope while parsing C with a YACC grammar eliben <eliben@gmail.com> - 2011-04-28 23:20 -0700
Re: Maintaining scope while parsing C with a YACC grammar Robert A Duff <bobduff@shell01.TheWorld.com> - 2011-05-02 20:19 -0400
Re: Maintaining scope while parsing C with a YACC grammar "Ira Baxter" <idbaxter@semdesigns.com> - 2011-05-13 17:46 -0500
Maintaining scope while parsing C with a Yacc grammar Chris F Clark <cfc@shell01.TheWorld.com> - 2011-06-12 20:43 -0400
Re: Maintaining scope while parsing C with a YACC grammar torbenm@diku.dk (Torben Ægidius Mogensen) - 2011-05-03 09:51 +0200
Re: Maintaining scope while parsing C with a YACC grammar Paul B Mann <paul@paulbmann.com> - 2011-05-06 10:43 -0700
csiph-web