[antlr-interest] Problem when generating ANTLRv3.g for C Sharp target?

Mari Matinlassi mmatinlassi at icinetic.com
Tue Aug 9 02:31:18 PDT 2011


Dear fellows,

 

Our research project wants to create meta-language for defining domain
specific languages. And, we have chosen to take ANTLR as a tool and
ANTLRv3.g as a starting point for our meta-language.

 

Therefore, I want to generate ANTLRv3Parser.cs and ANTLRv3Lexer.cs and build
them in Visual Studio (using C# target). However, I have a build error as
below:

"Error    1              The type or namespace name 'String' could not be
found (are you missing a using directive or an assembly reference?)
C:\VisualStudioProject\Testi\Testi\obj\Debug\ANTLRv3Parser.cs
2151       10           Testi"

 

And, indeed, there is a line in ANTLRv3Parser.cs as follows:

 

protected sealed partial class rule_scope

       {

              public String name;

 

              public rule_scope(ANTLRv3Parser grammar) { OnCreated(grammar);
}

              partial void OnCreated(ANTLRv3Parser grammar);

       }

 

Any idea what I am doing wrong?

 

I have followed this document (http://www.antlr.org/download/CSharp3.pdf) to
install and configure my Visual Studio project to work with Antlr.

 

This works fine, thanks for excellent guide! I get a simple grammar (such as
one below) to generate lexer and parser and compile them successfully.

Example grammar:

-----------------------------------Start of
T.g-----------------------------------------------------

grammar T;

 

options

{

       language=CSharp3;

       TokenLabelType=CommonToken;

       output=AST;

       ASTLabelType=CommonTree;

}

 

 

@lexer::namespace {ANTLRlanguage}

@parser::namespace {ANTLRlanguage}

 

public compileUnit 

       : ('x')+

       ;

 

 

IDENTIFIER

       :      ('a'..'z' | 'A'..'Z' |'_')('a'..'z' | 'A'..'Z' |'0'..'9'|'_')*

       ;

-----------------------------------End of
T.g--------------------------------------------------

 

Thanks for your help in advance,

 

Mari



More information about the antlr-interest mailing list