This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Parser rewritting


On 03/30/10 14:46, Sergio Durigan Junior wrote:
Hello!

As you may have noticed, in the last Archer meeting I brought a topic into
discussion: the rewritting of the GDB's parser.  The current parser is written
using Bison, and unfortunately it is insufficient to satisfy our current
needs, especially for C++ productions.

With that in mind, Tom asked me to start this discussion in the mailing-list
to see what you think about it. We decided to send an e-mail to the archer
list at first; this topic will eventually be discussed at the gdb list as
well.

A lot of years ago I wrote a fairly elaborate parser using antlr--definitely a cool tool and I recommend you consider it. It's a predicated LL(*) parser generator--the "predicated" bit making it possible, among other things, to handle the context-dependent bits of C/C++ grammar.


Just as an example, I've attached a rudimentary antlr grammar that parses a subset of C/C++ decls--if you look, you'll see that the rules look a lot like the specifications in the C++, and in fact started out as a cut'n'paste of those specs. Also, if you look in the grammar for "is_cpp," you can see how rule predicates can be used to have the parser do different things depending on circumstances.

Anyway, it's probably worth considering.

(In addition to the .g file attached, I wrote a couple other .c and .h files that make it all work. I'll make them available if anyone wants him.)

Chris

Attachment: CPPparser.g
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]