grmtools icon indicating copy to clipboard operation
grmtools copied to clipboard

Support lex-style definitions

Open FranklinChen opened this issue 1 year ago • 1 comments

I didn't see a way to do the following that can be done in lex:

DIGIT    [0-9]
ID       [a-z][a-z0-9]*
NUMBER {DIGIT}+"."{DIGIT}*

%%

{NUMBER} ...

so that patterns can be composed in definitions and definitions can be used in rules.

FranklinChen avatar Aug 30 '23 20:08 FranklinChen

Yes, this isn't currently supported. Given that we currently use the Rust regex crate, if we wanted to do something like this, we'd have some interesting fun and games getting escaping right. So a basic version is pretty easy; a version with good error messages might be challenging.

ltratt avatar Aug 30 '23 20:08 ltratt