Groups | Search | Server Info | Login | Register
Groups > comp.compilers > #112
| From | eliben <eliben@gmail.com> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: Maintaining scope while parsing C with a YACC grammar |
| Date | 2011-04-28 23:20 -0700 |
| Organization | Compilers Central |
| Message-ID | <11-05-003@comp.compilers> (permalink) |
| References | <11-04-036@comp.compilers> <11-04-038@comp.compilers> |
On Apr 26, 7:22 pm, Robert A Duff <bobd...@shell01.TheWorld.com> wrote: > eliben <eli...@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. Since it's parsing of C I'm talking about, this approach will have to somehow handle ambiguity of this kind: T * x; This can be either a declaration or a multiplication, depending on earlier symbol table information (whether T is a type or not). So are you proposing to build an ambiguous AST that contains *both* parses and resolve between them in later passes? Or just pick one and maybe modify it later? Do you have references (papers, books, etc.) explaining this technique? Thanks in advance
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