4 ms·
I've written lexers without a regex engine before, it's only a few hundred lines of a state machine. I can't think of any other places in a compiler where a re
by marshray 13y ago
I've written lexers without a regex engine before, it's only a few hundred lines of a state machine.
I can't think of any other places in a compiler where a regex library would be terribly useful.
- verroq 13y agoSpecifying tokens in the grammar would be the obvious usage.
- evincarofautumn 13y agoAgreed. Having done a lot of language work, I don’t find regexes suitable at all. State machines are generally simple both to write and to understand, can be made more efficient when you don’t need the full generality or dynamism of a regex, and force you to be explicit about things like which Unicode code points you actually meant.