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

Charles Shapiro charles.shapiro at nubridges.com
Wed Oct 27 12:06:39 EDT 2004


Yeh, I think you are right here. It's been a few years since I played
with (f)lex.

-- CHS

On Tue, 2004-10-26 at 18:53, Joe Steele wrote:
> > >
> > > [: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
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale



More information about the Ale mailing list