[antlr-interest] dfa-based lexers versus top-down antlr lexer s

mzukowski at yci.com mzukowski at yci.com
Thu May 1 08:37:47 PDT 2003


Yes, it is hoisted up to the nextToken() rule.  

This is a start:

anythingBetween: {getColumn()>x && getColumn()<y}? .;

It'll be a bit more complicated if you want every character in those colums
at once (my rule gives you one character only).  You'll need another
predicate inside your ()+ rule.

Anyhow, look at the generated code and it should be easy to figure out how
it works.

Monty

-----Original Message-----
From: Greg Lindholm [mailto:glindholm at yahoo.com]
Sent: Thursday, May 01, 2003 8:21 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] dfa-based lexers versus top-down antlr
lexers


Cool, this wasn't available when I needed it but I'll check it out next
time.

Does this mean that this predicate gets "hoisted" for testing before
entering the rule?

The related issue with positional tokens is often the rule is "anything
in columns x thru y",  the "anything" part causes ambiguous-ness
errors.  Will this {getColumn()==1}? predidate help with this?


--- Terence Parr <parrt at jguru.com> wrote:
> 
> On Wednesday, April 30, 2003, at 07:05  AM, Greg Lindholm wrote:
> 
> > I've done a couple projects using ANTLR and have not yet
> > been able to use the lexer.  I've had to hand-craft my own
> > lexer's because of column positional token's issues.
> 
> Hi :)
> 
> 2.7.2 allows predicates on the left edge of lexer rules so you can
> say:
> 
> {getColumn()==1}?
> 
> and have it work :)


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

 

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/ 




More information about the antlr-interest mailing list