[antlr-interest] why will this be parsed (no exception)?

Oliver.Kowalke at infineon.com Oliver.Kowalke at infineon.com
Thu Nov 24 04:55:57 PST 2005


Hello,
if I let parse the string "adder && repeater quatsch" I doen't get an
exception thrown. Why? 'quatsch' is not be recognized in the
productions.
I hope you can give me some advice how to get this right (throw an
exception).
With best regards,
Oliver

options
{
	language="Cpp";
	namespace="ymfl";
}

class FilterLexer extends Lexer;
options 
{
    k=2;
    exportVocab=YMFL;
    charVocabulary='\u0000'..'\u007F';
    caseSensitive=false;
    caseSensitiveLiterals=false;
}

tokens
{
	ADDER = "adder";
	REPEATER = "repeater";
}

AND
	options { paraphrase = "&&"; }
	: "&&"
;

OR
	options { paraphrase = "||"; }
	: "||"
;

NOT
	options { paraphrase = "!"; }
	: '!'
;

DELIM 
	options { paraphrase = "an delimeter (' ' \t \f \r \n)"; }
	: ( ' '
	| '\t'
	| '\f'
	|	( "\r\n"
		| '\r'
		| '\n'
		)
		{ newline(); }
	)
	{ $setType( antlr::Token::SKIP ); }
;

IDENT
	options {testLiterals=true;}
	: ('a'..'z') ('a'..'z'|'0'..'9')*
;

/////////////////////////////////////////////////////////////////////
//	Parser
/////////////////////////////////////////////////////////////////////

class FilterParser extends Parser;

options 
{	
    k=2;
    exportVocab=YMFL;
}

existence_op
	: 
	(
		ADDER
	|	REPEATER
	)
;

primitive
	: 
	existence_op
;

negation_expression
	: 
	(
		primitive
		| NOT primitive
	)
;

expression
	: negation_expression
	( 
		(
			AND	
		|	OR	
		) 
		negation_expression
	)*
;

run
	: expression
;


More information about the antlr-interest mailing list