I need to match something like the Perl regexp matcher
m/my regex!*/
where the quotes can be any character from a range. So the above is the same as
m%my regex!*%
A naive guess of a lexer rule would be
REGEX: 'm' quote=. (~(quote))* quote;
but that does not work, because the latter quote
is not referring to the quote=
but to some rule.
I can do it with a lot of own code, like
REGEX: 'm' quote=. { ... implement the loop and final match myself ... } ;
but somehow I think there should be a canonical way to do such things.
There is not. You'll have to do this with custom code.
Take a look at PL/SQL parser (here). Oracle also supports those Perl style quoted strings.
Like:
Use the custom code as an example. (It contains C and Java implementation). Maybe in your case it can be even simplified.
Ivan