[antlr-interest] ASTLabelType C# Problem

Sam Harwell sharwell at pixelminegames.com
Sun Jul 10 10:05:02 PDT 2011


What version of ANTLR are you using? Are you using Antlr3.exe or the java
version to generate your grammar?

I just ran the example you mentioned (changing only the options), and the
class statement_return doesn't even exist in the generated code, so
obviously we're using different versions of something.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of DJB MASTER
Sent: Sunday, July 10, 2011 3:55 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] ASTLabelType C# Problem

Hi, I'm using the vector math grammar example from the language patterns
book to practise with ASTs. The grammar is this one >
media.pragprog.com/titles/tpdsl/code/IR/Vec/VecMathAST.g.

I'm trying to let ANTLR build my custom nodes rather than CommonToken, so I
set ASTLabelType accordingly...

options
{
  language = CSharp3;
  output = AST;
  ASTLabelType = ASTNode;
}

...but then I get the following compile errors on every rule... E.g, the
statement rule...

'MyParser.statement_return' does not implement interface member
'Antlr.Runtime.IAstRuleReturnScope.Tree'. 

'MyParser.statement_return.Tree' cannot implement
'Antlr.Runtime.IAstRuleReturnScope.Tree' because it does not have the
matching return type of 'object'.

My ASTNode class is fine. I think this is more of a case of ANTLR not
generating the code properly as all the errors are in the parser. Everything
works fine just using CommonTree.

--
View this message in context:
http://antlr.1301665.n2.nabble.com/ASTLabelType-C-Problem-tp6567453p6567453.
html
Sent from the ANTLR mailing list archive at Nabble.com.

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