5 ms·
Nondeterministic regular expressions library for Arc (don't miss the cartoon)
- hhm 18y agoHow could anyone possibly miss the cartoon?
- henning 18y ago"The only common languages that have this ability are arc and scheme, a close relative to arc." Arc is common?
- drcode 18y ago:-) Well, compared to other languages with true continuations, like New Jersey SML.
- dfranke 18y agoFor that matter, Ruby and C both have continuation support.
- drcode 18y agoRuby has continuations, but with significant limitations. Ruby continuations cannot roll back modified variables, from what I understand- I think my email example would fail in a ruby implementation. As for C, I haven't seen any real continuation support- Just some partial simulations using longjmp.
- 13ren 18y agoA bare-bones nondeterministic regular expression engine for Python in 14 lines http://paste.lisp.org/display/24849 http://paste.lisp.org/display/24849
- drcode 18y agoThat's cool- I'll have to study that code. But it does look like you need an explicit sequencing command. My version works within arbitrary code.
- gregwebs 18y agoA bare-bones engine that interprets a regex http://blog.thoughtfolder.com/2008-02-04-even-more-beautiful-code-c-haskell-.html http://blog.thoughtfolder.com/2008-02-04-even-more-beautiful...
- 13ren 18y agoI don't know much Haskell (it's on my list), but am I right in thinking that code doesn't implement parenthetical grouping or alternation? eg: (ab)* a|b I think it's aiming at Perl or command-line style of regex, not mathematical regular expressions (EDIT not saying either is good or bad). (BTW: I didn't write the 14 line Python one, I'm just studying it).
- gregwebs 18y agogroupings and alternation can't be implemented in such a simplistic regex engine that matches the target while parsing the regex. Here is a more sophisticated toy haskell engine that uses a real parsing library http://jcreigh.blogspot.com/2006/12/simple-regex-engine-in-haskell.html http://jcreigh.blogspot.com/2006/12/simple-regex-engine-in-h...
- 13ren 18y agoThat's very interesting, because I've always felt that it should be possible to parse the regex and match the target at the same time... (though nobody ever does it that way, instead doing it with 2 passes). Do you know of a proof that grouping and alternation cannot be implemented in this way? (formal or informal).
- lisp_padawan 18y agofantastic work! many thanks