[antlr-interest] Partial grammars/include

Gyula László gyula.laszlo at profund.hu
Fri Jan 5 08:04:05 PST 2007


Hi,

Just a small idea, especially useful for tree parsers (I have more  
then one of those for the same AST):

Much of the tree parser code is shared between the different tree  
parsers (the rules for statements are a good example), and my  
grammars are just getting toooooo long for comfortable editing.

The solution I think is simple: partial grammars, or even more  
simple: an #include-like macro to include other files:

	#inlude "partials/statements.g"
	#inlude "partials/expressions.g"

, or something in options:

	options { language=ObjC; partials=["statements", "expressions",  
"annotations" ]; }

This could cut down the clutter of grammars.
Any toughts? Should I write a proof-of-concept java bit, or does this  
whole thing stink?

Gyula László

email:gyula.laszlo AT profund.hu
http://profund.hu

ps: the first one can be done using a C preprocessor on the grammar,  
however I think that's not a real solution of the issue...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070105/daa258fd/attachment.html 


More information about the antlr-interest mailing list