peter-winter / ctpg

Compile Time Parser Generator is a C++ single header library which takes a language description as a C++ code and turns it into a LR1 table parser with a deterministic finite automaton lexical analyzer, all in compile time.
MIT License
456 stars 24 forks source link

[Question] how to make the lexer NOT match a particular string #70

Closed haasdo95 closed 1 year ago

haasdo95 commented 1 year ago

As title. I am wondering if we currently have the ability of not matching a particular string/prefix, like the "?!" in standard regex. Thinking it might be useful for implementing keywords. Thanks! All the best.

peter-winter commented 1 year ago

Not at the moment. At least not in an easy way. You don't need this to implement keywords though, just place them in front of the more general 'identifier' regex and you'll be fine. Terms order determines their precedence.

haasdo95 commented 1 year ago

That's actually great to know... Thanks a lot! Have a good one.