[antlr-interest] SYNTAX predicates in lexer

Shalini Sharma shalini.sh at gmail.com
Wed Mar 30 19:23:00 PST 2005


header
{
# include<iostream>		
using namespace std;
}
options {
	language="Cpp";

}
class testParser extends Parser;


c: A X 
;	



class testLexer extends Lexer;
options
{
k=2;
}


A:    (Z  "b")=> Z 'b' { cout<<"matched with B"<<endl;}	
	  |Z	{cout<<"matched without B"<<endl;}	  
	 ;
X	:'x'
	;
protected
Z:   ('a')* 
	;


when i give aaaaa  or aaaaaaaaab (wrong input ) parser hangs writing 
"matched without B" . but on correct input it works fine .  i want it
to exit with some error .


More information about the antlr-interest mailing list