[antlr-interest] Grammar reuse without dynamic binding

Tomasz Uliński tu219717 at gmail.com
Thu Feb 5 15:07:20 PST 2009


Hi,

I would like to reuse a grammar in this kind of way:
I have Pascal grammar 'pas.g' and I need to create Estelle grammar 'est.g'.
Some rules from Pascal must be extended in Estelle.

For example:
'pas.g'
assignment_statement:
     (variable_access | function_identifier) ":=" expression;


'est.g'
assignment_statement:
     pas.assignment_statement
   | module_variable ":=" module_variable;

I would like that alternative pas.assignment_statement in 'est.g'
assignment_statement rule expand to rules from 'pas.g', even though we
call rule in 'est.g' grammar and some of rules (variable_access |
function_identifier) ":=" expression are also redefined in 'est.g'.
I would like to get effect of namespace rather than inheritance.
Is there better solution than unique renaming all nonterminals in 'pas.g'?

Sorry for my poor English.
Best Regards!
Tomasz Ulinski


More information about the antlr-interest mailing list