[antlr-interest] Looking for a simple answer. :)

Bogdan Mitu bogdan_mt at yahoo.com
Mon May 27 07:37:57 PDT 2002


ooobles wrote:

> Hi..
>
> > httpd[13748]: 121 Statistics: duration=0.47 id=HI5l sent=586 rcvd=699
> > srcif=eth0 src=192.168.42.232/3399 svsrc=10.0.0.2/2444 dstif=eth1
> > dst=64.154.80.50/80 op=GET arg=http://hg1.hitbox.com/HG?
> > hc=w147&l=y&hb=WQ500202CFDV94EN0&cd=1&n=ProdAd result="302 Moved
> > Temporarily" proto=http rule=4
> >
> > The problem is in the value of various statistics.  For instance the
> > arg value is a http request value.  Its value has the potential to
> > contain all the nasty characters like = that completely destroys
> > otherwise nicely formated line.
> >
> > Ideally I'd like my grammer to be:
> >
> > (ID ASSIGN VALUE)+       // for each name value pair.
> >
> > The problem is how do I make the VALUE in the lexer match everything
> > including the = up to the first WS character but not have VALUE match
> > against everything else?

Why don't you make your grammar 
(ID VALUE)+

where VALUE is something like:
VALUE: '='! (~(' ' | '\t' | '\r' | '\n'))*  ;

This assumes that VALUE starts imediately after '=' and ends with the first
white space, which seems to be always true, in your example.

Regards,
Bogdan

> > After reading much of the documents the best answer I could find was
> > to create a seperate lexer, but this seems like overkill for a single
> > rule???  Any other ideas?
> >
> > Thanks,
> > David.
> >
> >
> >
> > 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/ 
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list