3 ms·
Really? Why don't you write your own regex? Regular languages are definitely relevant. It's not that hard to write a basic regex engine (make NFA and convert to
by verroq 13y ago
Really? Why don't you write your own regex? Regular languages are definitely relevant. It's not that hard to write a basic regex engine (make NFA and convert to DFA). This is a compilers course after all.
- marshray 13y agoI'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.
- eliasmacpherson 13y agohttp://swtch.com/~rsc/regexp/regexp1.html http://swtch.com/~rsc/regexp/regexp1.html This was posted a few days ago but I can't find the link, anyway it would be useful to read if implementing regex. Baffled that course takers agree not release their source code?
- anigbrowl 13y agoTo prevent cheating, I assume.