On Mon, May 17, 2010 at 4:14 PM, Marcel Schaible <[email protected]> wrote: > Hi, > > I am currently reworking some old big YACC grammar files. Each of them > (about 15 different YACC files with 5kB to 80Kb size) are describing a > command language for a specific hardware device and share a lot of > common rules. Now I was wondering if it is feasable to do some kind of > object-oriented approach like put all shared rules in some kind of a > base class and all the special command and command derivations in a > derived class. Another idea I am thinking of is using StringTemplate to > generate the YACC grammar files. > > Maybe one of you stumbled over a similar problem and has a nice solution > and could push me in the rigth direction?
My immediate thought is to use split grammars, and import the common rules into the specifics. http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars I've used this with TreeWalkers and Parsers. Each phase of my TreeWalker did one or two mundane things to 3-4 rules out of ~100, rather then duplicate all 100 rules, I just imported the base "walker", and override any rules I needed to in the specific file. This is probably a really bad idea from a performance perspective, but it was really easy to debug and mentally manage each "phase" my walkers implemented independently. However, you wouldn't have the performance concerns. I'm pretty sure I made the Lexers all act the same, not sure how well that would work. Kirby > > Thanks for sharing your thoughts in advance! > > Marcel > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
