[antlr-interest] Newbie question:using lexer grammar

Mauro Pellicioli nightwolf at email.it
Sat Aug 25 10:50:34 PDT 2007


For example, I don't know why this grammar:


document:	DOCUMENT;

DOCUMENT: '<' (options {greedy=false;} : .)* ALTERNATIVE (options
{greedy=false;} : .)* '</html>' WS*;

ALTERNATIVE:	'Destination not found' {System.out.println("OK 1");}
                | 'Please make your choice by clicking on the destination
name below' {System.out.println("OK 2");}
		| 'Hotels found' {System.out.println("OK 3");};
     
WS : ' ' | '\r' | '\n' |'\t' ;	

on this html page:

http://www.booking.com/searchresults.html?return_url=http%3A%2F%2Fwww.booking.com%2Fsearchresults.html&found_addresses=&error_url=http%3A%2F%2Fwww.booking.com%2Findex.html%3Flabel%3Dshort-index.htmlerrorc_search_in_invalid%253Dsi%3Bsid%3D19361acb03c3fe7f1def5374b839e6a9%3B&label=short-index.htmlerrorc_search_in_invalid%3Dsi&sid=19361acb03c3fe7f1def5374b839e6a9&order=&addressAddress=&addressCity=&addressZIP=&addressCountry=&si=ai%2Cco%2Cci%2Cre&ss=xyz&checkin_monthday=25&checkin_year_month=2007-8&checkout_monthday=26&checkout_year_month=2007-8&radius=

gives me the error:

line 1:0 mismatched input '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"\n  "http://www.w3.org/T.....

even if the test prints out the correct kind of page. 

Is there an error in the grammar?

--------- Original Message --------
	Da: Johannes Luber <jaluber at gmx.de>
	To: 
	        Cc: antlr-interest at antlr.org
	Oggetto: Re: [antlr-interest] Newbie question:using lexer grammar
	Data: 25/08/07 18:52
	
	> 
> 
> 
> Mauro Pellicioli wrote:
> > Hi everyone,as the subject says: how do I use a lexer grammar with the
> > option filter=true?There is no method to call like when I use a parser.
> > 
> > Thanks for help. 
> 
> Usually, you don't call the lexer directly, but use the parser. This
> happens regardless of the type of the lexer. Why do you want to call the
> lexer directly anyways?
> 
> Best regards,
> Johannes Luber
> 
> 
>  
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Non perderti nella giungla di facili promesse, Logos ti da credito sempre!

 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6559&d=20070825




More information about the antlr-interest mailing list