[antlr-interest] Sequential Javadoc Comments in Grammar Files
Loring Craymer
lgcraymer at yahoo.com
Mon Jul 21 18:11:39 PDT 2008
Javadoc comments are recognized by the ANTLR parser grammar; non-Javadoc comments are filtered out by the lexer. The grammar allows one Javadoc comment for the grammar after an optional action block but before the grammar declaration and one javadoc comment before each rule. They are also passed on to the generated target code (which is why they are recognized by the parser in the first place).
--Loring
----- Original Message ----
From: "Jones, Larry" <Larry.Jones at aspentech.com>
To: antlr-interest at antlr.org
Sent: Monday, July 21, 2008 2:36:36 PM
Subject: [antlr-interest] Sequential Javadoc Comments in Grammar Files
Message
To my surprise, I
discovered that ANTLR produces an error if a grammer file contains two
consecutive Javadoc comments.
For example, the
following grammar:
grammar T;
/**
* Does Java accept two consecutive comments?
*/
/** Match things like 'call foo;' */
r : 'call' ID ';' {System.out.println("invoke " + $ID.text);} ;
ID : 'a'..'z'+ ;
WS : ( ' ' | '\n' | '\r' )+ { $channel=HIDDEN; } ; // ignore whitespace
Produces the
following errors (built using Ant):
generate:
[java] ANTLR Parser Generator Version 3.1b2 (July 17, 2008) 1989-2008
[java] error(100): T.g:7:1: syntax error: antlr: T.g:7:1: unexpected token: /** Match things like 'call foo;' */
[java] Java Result:
1
I did notice that if the first comment block is not a
Javadoc style comment, it compiles correctly.
What am I missing?
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
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/00559fc0/attachment.html
More information about the antlr-interest
mailing list