logos icon indicating copy to clipboard operation
logos copied to clipboard

Sugar for case-insensitive tokens?

Open rodya-mirov opened this issue 4 years ago • 2 comments

I wonder if you would consider adding some syntactic sugar procedural macros for "case insensitive tokens" -- the way we have #[token("foo")], if we want to match Foo and FOO and fOo then we need #[regex("[Ff][Oo][Oo]")].

It's not a huge deal, but (e.g.) if you're lexing a DSL with lots of keywords, all of which are case-insensitive, it becomes a lot of typing (opportunity for mistakes) and much harder to read.

rodya-mirov avatar Apr 30 '20 00:04 rodya-mirov

You can set the case insensitive flag on a group: (?i:foo): https://regex101.com/r/M8YjZ2/1

maciejhirsz avatar May 01 '20 08:05 maciejhirsz

Wow, there's so much I don't know about regular expressions. Thank you!

rodya-mirov avatar May 01 '20 11:05 rodya-mirov