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

Sam Harwell sharwell at pixelminegames.com
Thu Mar 24 07:19:45 PDT 2011


Hi Kevin,

 

The plugin information is included in the "Visual Studio and the ANTLR C#
Target" documentation referenced on the ANTLR wiki:

http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases

 

Thanks,

Sam

 

From: Kevin Cherry [mailto:kcherr1 at tigers.lsu.edu] 
Sent: Thursday, March 24, 2011 9:12 AM
To: Sam Harwell
Cc: Ranco Marcus; antlr-interest at antlr.org
Subject: Re: [antlr-interest] [CSharp3] @namespace and composite grammars

 

@Sam, what is the name of the Visual Studio extension you are talking about?
I tried to search for anything with ANTLR in it and it couldn't find
anything.

On Thu, Mar 24, 2011 at 8:50 AM, Sam Harwell <sharwell at pixelminegames.com>
wrote:

Hi Ranco,

As mentioned in the CSharp3 documentation, you need to use both
@lexer::namespace{...} and @parser::namespace{...} in a composite grammar.
If you use the templates included in my Visual Studio extension, then these
are automatically inserted for you (including using the correct namespace
based on the location in the project where you placed them).

I'll check into the namespace issue when it comes to imported grammars. The
expected functionality is this should work once you have
@lexer::namespace{...} and @parser::namespace{...} in the composite grammar
, plus @namespace{...} in each of P and L.

Thanks,
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


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