[antlr-interest] Question about using Nongreedy Subrules

mzukowski at bco.com mzukowski at bco.com
Tue Apr 2 07:01:46 PST 2002


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 optushome.com.au]
> Sent: Tuesday, April 02, 2002 6:47 AM
> To: antlr-interest at yahoogroups.com
> 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