I have one regexp, which is used in a several rules. Can I define alias for it, to keep this regexp definition in one place and just use it across the code? Example:
[A-Za-z0-9].[A-Za-z0-9_-]* (expression) NAME (alias)
...
%%
NAME[=]NAME {
//Do something.
}
%%
It goes in the definitions section of your lex input file (before the %%
) and you use it in a regular expression by putting the name inside curly braces ({…}
). For example:
name [A-Za-z0-9][A-Za-z0-9_-]*
%%
{name}[=]{name} { /* Do something */ }