[antlr-interest] Distinguish between number and value

David Holroyd dave at badgers-in-foil.co.uk
Sat Nov 3 13:46:18 PDT 2007


On Sat, Nov 03, 2007 at 09:44:38PM +0200, shmuel siegel wrote:
> >Usually, you would do such things in the parser, but in this instance 
> >you can actually do it in the lexer if you want. If you leave it to 
> >the pasere then you would need a keyword ?px?, which may be awkward 
> >elsewhere of course:
> >
> It is actually not so easy in the parser unless "123 px" is a legal 
> pixel size (notice the space). It really is best to do this in the lexer.

...unless whitespace is significant in the parser.  Actually, the
published grammar for CSS suggests it should be,

  http://www.w3.org/TR/2003/WD-css3-syntax-20030813/#grammar0

(though indeed 'length', etc. values are handed lexically according to
that spec).

I no longer recall why whitespace is handled like this.


ta,
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list