[Fwd: Re: [ale] OT: Lex pattern expression struggles]

Joe Steele joe at madewell.com
Tue Oct 26 18:53:59 EDT 2004


> >
> > [:alnum:]{1,8} * (PARAM)|(TABLE)|(UPDATE)  { return TOKEN_BLAH; }
> >

I think this pattern needs another set of brackets [], like so:

[[:alnum:]]{1,8} * (PARAM)|(TABLE)|(UPDATE)  { return TOKEN_BLAH; }

Without the extra brackets, "[:alnum:]" has no special meaning, and 
could just as well be "[na:mlu]".  In other words, it ends up 
matching only on the letters "a", "l", "n", "u", "m", and ":".

Also, because the alternation operator "|" has the lowest precedence 
in the pattern, I think this pattern is equivalent to (note the added 
parentheses):

([[:alnum:]]{1,8} * (PARAM))|(TABLE)|(UPDATE)

which is equivalent to:

(TABLE)|(UPDATE)|([[:alnum:]]{1,8} * (PARAM))

In other words, the expression ends up looking for an alphanumeric 
token and a space before a "PARAM" token, but not before "TABLE" and 
"UPDATE" tokens.  

--Joe



More information about the Ale mailing list