[antlr-interest] [CSharp3] @namespace and composite grammars

Ranco Marcus ranco.marcus at epirion.nl
Thu Apr 7 04:32:38 PDT 2011


Hi Sam, that sounds sensible to me. Thanks, Ranco

> -----Original Message-----
> From: Sam Harwell [mailto:sharwell at pixelminegames.com]
> Sent: woensdag 6 april 2011 17:30
> To: Ranco Marcus; antlr-interest at antlr.org
> Subject: RE: [antlr-interest] [CSharp3] @namespace and composite
> grammars
> 
> Hi Ranco,
> 
> I updated the CSharp3 target so imported grammars are always generated in
> the same namespace as specified in the root grammar.
> 
> Sam
> 
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Ranco Marcus
> Sent: Thursday, March 24, 2011 5:55 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] [CSharp3] @namespace and composite grammars
> 
> To maximize reuse of our grammars we generally create separate lexer and
> parser grammars which are target agnostic (i.e. contain no target specific
> code). We then combine them into a composite grammar in which the target
> language and other implementation specific details are specified
> (header,members,namespace,etc.). This way, grammars can be used for
> multiple targets and we have maximum freedom to combine multiple
> lexers/parsers into larger ones.
> 
> If a composite grammar C imports a parser grammar P and a lexer grammar L,
> the tool generates CParser, CLexer, C_P and C_L.
> 
> Adding @namespace { <X> } to the composite grammar should IMHO put all
> four recognizers in namespace <X>. Currently, at least with the CSharp3
> target, only CParser is put into the specified namespace.
> 
> Specifying @lexer::namespace { <X> } to the composite grammar causes only
> the outermost lexer CLexer to be added to the specified namespace, not the
> imported lexer C_L. The same holds for @parser::namespace.
> 
> Btw, if I'm not mistaken, there's no way to put recognizers in packages with
> the Java target. Is that correct?
> 
> Best regards,
> 
> Ranco Marcus
> Epirion Knowledge Solutions B.V.
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list