[antlr-interest] How viable is the Csharp3 target? (more specific questions)

Voelkel, Andy andy.voelkel at plantronics.com
Wed Oct 19 11:25:39 PDT 2011


Hi,



First, thanks for the encouragement. Knowing there are active users out there makes all the difference.



I've now taken the first example from "the definitive ANTLR reference" and tried to get it to work, first using the Visual Studio Extensions and templates, and then also manually running the ANTLR3.exe file at the command line, just to verify that my problems are in the generated code and are not errors generated during the generation of code (since the Visual Studio Extensions and associated instructions seem to produce projects that both generate code and then build it).



So my grammar is this simple:



grammar Lexer1;



options {

    language=CSharp3;

}



/** Match things like "call foo;" */

r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;

ID: 'a'..'z'+ ;

WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace



When I compile the code generated by ANTLR3, I get these errors:


K:\Plantronics\Development Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2): warning CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute
K:\Plantronics\Development Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1041: Identifier expected; 'out' is a keyword
K:\Plantronics\Development Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1525: Invalid expression term 'out'
K:\Plantronics\Development Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning CS3021: 'Lexer1Lexer' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute
K:\Plantronics\Development Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error CS0103: The name 'HIDDEN' does not exist in the current context



The errors regarding "System.out" make sense, that seems like a call to a Java function that does not exist in C#. However the error with HIDDEN is confusing to me, and it is the result of sub a basic construct ({$channel=HIDDEN:};). I can't imagine what I am doing wrong to cause this, and since it is the first example pulled out of the book, you would think it would work!



Can someone help me here? I'm gaining confidence, but I'm having trouble even walking before I can run!



Oh, also: What are the files Antlr3.Targets.CSharp2.dll and Antlr3.Targets.CSharp3.dll for?



-          Andy





-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Sam Harwell
Sent: Wednesday, October 19, 2011 7:59 AM
To: 'pragmaik'; antlr-interest at antlr.org
Subject: Re: [antlr-interest] How viable is the Csharp3 target?



Hi Andy & Maik,



I agree that the C# target documentation is lacking in many ways. I try to keep enough documentation at the following page to get you started on the right path:

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



I've been using the CSharp3 target in a commercial product for 3 years now.

At this point, most of the remaining the issues I have with it are basic/technical limitations of ANTLR 3 that will hopefully be resolved in later versions.



Sam



-----Original Message-----

From: antlr-interest-bounces at antlr.org<mailto:antlr-interest-bounces at antlr.org>

[mailto:antlr-interest-bounces at antlr.org]<mailto:[mailto:antlr-interest-bounces at antlr.org]> On Behalf Of pragmaik

Sent: Wednesday, October 19, 2011 9:36 AM

To: antlr-interest at antlr.org<mailto:antlr-interest at antlr.org>

Subject: Re: [antlr-interest] How viable is the Csharp3 target?



Hi Andy!



I am using ANTLR's C# target for a couple of weeks now to create a domain specific language that is a subset of the C programming language.



My experience is similar to yours, but I can assure you that the C# target works and that it is actively maintained. It differs from the Java target in a few places, but it works.



The biggest problem is finding documentation. I've both of Terence Parr's books on my desk and the folks on this mailing list are very friendly and competent.



Cheers,

Maik





--

View this message in context:

http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp690889

0p6908949.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





List: http://www.antlr.org/mailman/listinfo/antlr-interest

Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



________________________________

CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain information that is confidential and/or legally privileged. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, please DO NOT disclose the contents to another person, store or copy the information in any medium, or use any of the information contained in or attached to this transmission for any purpose. If you have received this transmission in error, please immediately notify the sender by reply email or at privacy at plantronics.com, and destroy the original transmission and its attachments without reading or saving in any manner.

For further information about Plantronics - the Company, its products, brands, partners, please visit our website www.plantronics.com.


More information about the antlr-interest mailing list