[antlr-interest] Re: Question about using Nongreedy Subrules

spenserkao spenserkao at optushome.com.au
Tue Apr 2 07:23:39 PST 2002


It works! Thanks for the useful hint.

Spenser
--- In antlr-interest at y..., mzukowski at b... wrote:
> You don't have ' ' in your lexer vocabulary, I'm suprised it even 
recognized
> the B and A.  Anyways add this to your lexer options, as 
documented in
> http://www.antlr.org/doc/options.html#charVocabulary:
> 
> charVocabulary = '\3'..'\377';
> 
> Monty
> www.codetransform.com
> 
> > -----Original Message-----
> > From: spenserkao [mailto:spenserkao at o...]
> > Sent: Tuesday, April 02, 2002 6:47 AM
> > To: antlr-interest at y...
> > Subject: [antlr-interest] Question about using Nongreedy Subrules
> > 
> > 
> > I tried to test Nongreedy Subrules, under ANTLR v2.7.1, onto a C-
> > style comment. The compilation was successful, but I kept 
receiving 
> > runtime error. Can someone give me a hint? Thanks for any help 
in 
> > advance!
> > 
> > --- Start of Runtime error message ---
> > Exception: antlr.TokenStreamRecognitionException: expecting '*', 
> > found ' '
> > --- End of Runtime error message ---
> > 
> > --- Start of Input test data ---
> > /* BA */
> > --- End of Input test data ---
> > 
> > --- Start of grammar code(.g) ---  
> > header {
> > 	import java.io.*;
> > 	import java.util.*;
> > }
> > 
> > class P extends Parser;
> > 
> > startRule
> >     :   
> > 	n:COMMENT_BLOCK
> > 	;
> > 
> > class L extends Lexer;
> > options {
> > 	k=2;
> > }
> > 
> > COMMENT_BLOCK
> > 	:	"/*" 
> > 		(
> > 			options {
> > 				greedy=false;
> > 			}
> > 		:	.
> > 		)* 
> > 		"*/" 
> > 	{ System.out.println($getText); }
> > 	;
> > --- End of grammar code(.g) ---
> > 
> > 
> > 
> >  
> > 
> > Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list