[antlr-interest] How to make this work ??

mzukowski at yci.com mzukowski at yci.com
Wed Dec 18 08:35:35 PST 2002


Like this:

protected
BDIG		: ('0'|'1') ;
protected
HDIG		:	(options {warnWhenFollowAmbig = false;} :('0'..'9')
)
			|	('A'..'F')
			|	('a'..'f')
			;

protected B_STRING : "'"   (BDIG)+  "'B"  ;
protected H_STRING : "'"   (HDIG)+  "'H"  ;

BIN_OR_HEX_STRING: (B_STRING)=>B_STRING {$setType(B_STRING);}
			 | H_STRING {$setType(H_STRING);}
			 ;

Monty

-----Original Message-----
From: v_vivekg <v_vivekg at yahoo.com> [mailto:v_vivekg at yahoo.com]
Sent: Wednesday, December 18, 2002 12:50 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] How to make this work ??


Hi all,

I have binary and hex digits defined as follows :

protected
BDIG		: ('0'|'1') ;
protected
HDIG		:	(options {warnWhenFollowAmbig = false;} :('0'..'9')
)
			|	('A'..'F')
			|	('a'..'f')
			;

and Binary String and Hex String defined as follows in the lexer

B_STRING : "'"   (BDIG)+  "'B"  ;
H_STRING : "'"   (HDIG)+  "'H"  ;

Now the problem is that this definition is not able to
parse the string of type '01010111'H . The code goes into
binary string parsing and gives error that 'B was expected
but 'H was found instead.
I tried with semantic and syntatic predicates with lot of
options but unable to make this work.

Kindly help on how this simple thing can be made to work.










 

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