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

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 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

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