[antlr-interest] Syntax for C# Namespaces

Jones, Larry Larry.Jones at aspentech.com
Mon Jul 21 14:08:43 PDT 2008


I recently downloaded 3.1b2 and am implementing the tour/trees examples
for _The Definitive ANTLR Reference_.
 
I successfully built the examples using Java; however, I eventually want
to target C#.
 
My driver program uses a namespace. The wiki article on the CSharp
target describes the syntax to add a namespace; however, when I add
"@parser::namespace { Expr }" to my grammar file, ANTLR generates the
following error:

	ANTLR Parser Generator  Version 3.1b2 (July 17, 2008)  1989-2008
	error(100): Expr.g:17:1: syntax error: antlr: Expr.g:17:1:
unexpected token: @
	error(100): Expr.g:17:20: syntax error: antlr: Expr.g:17:20:
unexpected token:  Expr 
	error(100): Expr.g:18:19: syntax error: antlr: Expr.g:18:19:
unexpected token:  Expr 
	 

The preceeding grammar lines are:
 

	grammar Expr;
	 
	options {
	 language=CSharp2;
	 
	 output=AST;
	 
	 // ANTLR can literally handle any tree node type.
	 // For convenience, specify the Java type.
	 ASTLabelType=CommonTree;   // type of $stat.tree ref etc.
	 
	}
	 
	/**
	 * Put both the parser and lexer in the same namespace as the
driver.
	 */
	@parser::namespace { Expr }
	@lexer::namespace { Expr }

What is the syntax for adding a C# namespace?
 
Thanks.
 
 
--

Lawrence Allan Jones
Senior Developer / Technical Advisor
Aspen Technology, Inc.
2500 CityWest Blvd. Suite 1500
Houston, Texas 77042
USA
281-504-3324 (work)
281-504-3395 (fax)
larry.jones at aspentech.com
www.aspentech.com <http://www.aspentech.com/> 

 
 	
 

This e-mail and any attachments are intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified any dissemination, distribution or copying of this email, and any attachments thereto, is strictly prohibited. If you receive this email in error please immediately notify the sender and permanently delete the original copy and any copy of any e-mail, and any printout thereof.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080721/028ae7b5/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 2078 bytes
Desc: email_2_03.gif
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080721/028ae7b5/attachment.gif 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 200 bytes
Desc: email_2_04.gif
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080721/028ae7b5/attachment-0001.gif 


More information about the antlr-interest mailing list