[antlr-interest] C# target header global actions - before ANTLR includes or after?
Sam Harwell
sharwell at pixelminegames.com
Thu Jul 8 11:29:29 PDT 2010
The C# target declares the parser as a partial class. If your parser
MyParser is generated in a file called MyParser.cs, create another file in
your project called MyParserHelper.cs with contents like this:
namespace MyParserNamespace
{
[YourAttributeHere]
partial class MyParser { }
}
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of
Tony.Gray at ca.schneider-electric.com
Sent: Thursday, July 08, 2010 1:05 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] C# target header global actions - before ANTLR
includes or after?
In the C# target, global actions in the @parser::header{} block go _before_
the ANTLR standard header.
In C#, this section is full of 'using' statements that import namespaces of
interest.
The problem I'm having is that I want to adorn the class declaration for my
parser with some [attributes]. To do that, I need to embed some code
immediately before the class definition, but I can't do that because the
ANTLR standard headers are between my header block and the class
declaration.
If I'm reading this right, other language targets put the @header{} global
action contents immediately before the class definition and after the stock
ANTLR headers.
Was this choice in the C# target deliberate? Is there anything I can do to
emit code immediately above my generated parser definition?
oh, and as always, ANTLR rocks!
Tony Gray Schneider Electric
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