Settings

Theme

A Regular Expression Matcher (2007)

cs.princeton.edu

12 points by sagargv 10 years ago · 1 comment

Reader

colanderman 10 years ago

"[star] matches zero or more occurrences of the previous character"

…those aren't regular expressions. Those are fancy globs. Regular expressions have a formal definition that is strictly more expressive than that.

They mention they use recursion (which you can use to actually implement regular expressions, albeit poorly) but…

…they use the recursion as a way of implementing a state machine in C? You can get away with this (and it's somewhat common) in a language like Lisp or ML that guarantees tail-call optimization, but this is poor form at best in C, where some compilers are unable to optimize tail calls, and you will blow your stack with long-lived state machines. Code recursion is really only appropriate when your data structures are recursive.

This is poor pedagogy. Students internalize stuff; you can't present them incorrect definitions and poor coding practices. C'mon guys, can't I expect better from the inventors of C and Unix??

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection