I am trying to generate a scanner using JFlex.
One of the identifier rules for the grammar I am trying to implement is as follows (in regex syntax):
[a-zA-Z]((_(?!_)|[a-zA-Z0-9])*[a-zA-Z0-9])?
I have verified that the above expression is actually valid and works. However, it seems jFlex 1.4.3 does not like my use of the lookahead assertion (?!_)
as it keeps complaining of the "question mark". Is there something I am doing wrong or is there a different to use lookaheads in JFlex?
I am using the "lookahead" to satisfy the rule that says I cannot have two consecutive underscores in the identifier name.
Any help would be appreciated.
Instead of
[a-zA-Z]((_(?!_)|[a-zA-Z0-9])*[a-zA-Z0-9])?
use optimized pattern
[a-zA-Z]+(_[a-zA-Z0-9]+|[a-zA-Z0-9]+)*