[antlr-interest] Simple parsing question

George J. Shannon George.Shannon at raphaelanalytics.com
Fri Sep 5 19:58:35 PDT 2008


Attached is a snippet of the grammar in question, where tagCommentNbr is the
integer value enclosed in brackets that I referred to in my email post.
George

tagCommentElement returns [ParserTagCommentElement pTagCommentElement]
@init 	{
	pTagCommentElement = new ParserTagCommentElement(); //db not req'd
	}
	:
	tagCommentNbr (elementName)?
	{
	pTagCommentElement.tagCommentNbr = $tagCommentNbr.text;
	pTagCommentElement.elementName = $elementName.text;
	}
	;

tagCommentNbr
	:
	'[' IntValue  ']'
	;
	
elementName
	:
	'.' alphaN
	;

IntValue 	
	:
	('0'..'9')+
	;
		

-----Original Message-----
From: Chris Rebert [mailto:cvrebert at gmail.com] 
Sent: Friday, September 05, 2008 9:54 PM
To: George J. Shannon
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Simple parsing question

Including at least part of the grammar in question would probably be
very useful to anyone trying to help you.

Regards,
Chris

On Fri, Sep 5, 2008 at 7:45 PM, George J. Shannon
<George.Shannon at raphaelanalytics.com> wrote:
> I have a parser that gets a MismatchedTokenException error that I would
> appreciate assistance on.
>
> Within the text being parsed is a simple rule that looks for '[' IntValue
> ']' where IntValue is the rule ('0'..'9')+ (i.e., integer value inside
> brackets).
>
> This may not be relevant, but I guess I should mention that this rule is
> called by other rules, so this sequence is embedded inside other text.
>
> Anyway, I get the MismatchedTokenException whenever I run into a '[0]',
but
> not when I run into '[00]' or any single digit other than '0'.
>
> So, what's so special about 0 that I'm obviously missing?
>
> Sorry to bother you with an obvious question; I have brain cramp after
> staring at this for about an hour.
>
> I'm using antlr 3.2 with ANTLRworks 1.2, but the error occurs with the
> 3.1/1.1.7 combination as well.
>
> Thanks in advance for the help.
>
> Regards,
>
> George
>
>
>
>
>
>
>
>
>
> George Shannon
>
> President, Raphael Analytics, Inc.
>
> 16 Spur Drive
>
> Fenton, MO 63026
>
> (314) 550-5589 (cell)
>
> George.Shannon at raphaelanalytics.com
>
> www.raphaelanalytics.com
>
>
>
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material.  Any review, retransmission, dissemination or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited.   If you
received
> this in error, please contact the sender and delete the material from any
> computer.
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
>
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
>



-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the antlr-interest mailing list