[antlr-interest] Strange MismatchedTokenException(0!=0)

John B. Brodie jbb at acm.org
Mon Oct 15 14:59:54 PDT 2007


Peizhao Hu wrote:
>//============================
>tokens{
>	TEMPLATE='TEMPLATE';
>}
>
>template_statement
>	:	TEMPLATE
>		manufacturer_code comma
>		id_number_of_bits comma
>		template_id COMMA
>		optional_description
>	;
>
>manufacturer_code
>	:	INTEGER	;
>
>INTEGER	:	(Sign)? Digit ;
>
>protected Digit 	: ('0' | '1'..'9' ('0'..'9')*) ;
>
>//============================
>
>to match the following statements:
>
>TEMPLATE 0,8,29,"Capacitive Microphone"
>
>however, it throws out MismatchTokenException(0!=0) when it tried to 
>match 0 after the token TEMPLATE.
>

You forgot to specify how whitespace should be handled, so the blank
after TEMPLATE is an error. (untested)



More information about the antlr-interest mailing list