Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Enterprise regular expression API

Name: Anonymous 2011-11-16 0:37


local scanner_ = epsilon_nfa.union(epsilon_nfa.make_set_accepter(ascii_utils.setify('!?,.;:\"[]{}@#$%^&*()-=+\|`~')),
                                   epsilon_nfa.make_set_accepter(t.union(ascii_utils.range('a', 'z'),
                                                                         ascii_utils.range('A', 'Z'),
                                                                         ascii_utils.range('0', '9'),
                                                                         ascii_utils.setify('_\''))):convert_self_to_one_or_more()
                 ):transform_to_closed_nfa();


Would you use it?

Name: Anonymous 2011-11-16 2:02

sage

Name: Anonymous 2011-11-16 5:59

No. Just accept some form of regex strings and shut the fuck up.

Name: Anonymous 2011-11-16 6:18

>>1
Is that Lua? By the way, I would use it if it was the output of some macro.

Name: Anonymous 2011-11-16 23:31

>>4

yeah, it's lua. I implemented a simple regular expression engine in lua. Writing a regex parser is kind of annoying, and I think I'm going to get by with manually constructing the epsilon nfa with function calls, and then calling conversion functions to get it to an nfa. It is pretty slow at the moment though. I need to convert the nfa to a dfa now.

But this made me think though, what if regular expressions were represented as syntax trees? Would they be any more readable?


/[A-Za-z_][A-Za-z0-9_]*/


or


(regex (concat (union (range A Z)
                      (range a z)
                      _)
               (zero-or-more (union (range A Z)
                                    (range a z)
                                    (range 0 9)
                                    _))))


or maybe stack based?


/A /Z range /a /z range union /_ union
/A /Z range /a /z range union /0 /9 range union /_ union zero-or-more
  concat

Name: Anonymous 2011-11-16 23:37

If it ain't Lisp, it's crap.

Name: Anonymous 2011-11-17 3:04

>>6
Lisp is shit.

Name: Anonymous 2011-11-17 3:38

>>6
LispBot?
>>7
AntiLispBot?
The first one posts something about Lisp superiority, then 1-5 minute delay and "Lisp is shit" bot chimes in

Name: Anonymous 2011-11-17 3:53

>>8
Back in the days of fanfold, there was a type of programmer who would only put five or ten lines of code on a page, preceded by twenty lines of elaborately formatted comments. Object-oriented programming is like crack for these people: it lets you incorporate all this scaffolding right into your source code. So it is a good tool if you want to convince yourself, or someone else, that you are doing a lot of work. -- Paul Graham

Name: Anonymous 2011-11-17 5:47

>>5
The point of regexes isn't to be readable

Don't change these.
Name: Email:
Entire Thread Thread List