Matthew Smillie
8/3/2006 12:22:00 AM
On Aug 2, 2006, at 22:44, Caleb Clausen wrote:
> On 8/1/06, Gilles Lacroix <lacroix7@free.fr> wrote:
>>
>> Does anyone know if there is a nice way to build the Finite State
>> Machine
>> (FSM) of a Ruby regexp ?
>
> I don't know of anything specifically oriented to Ruby Regexps that
> does this, but surely such tools exist for (say) Perl...?
Strictly speaking, there isn't anything that does this, since modern
'extended' regexes (a set which includes Ruby's regexes) aren't
always representable as finite state automata (i.e., they can
recognise more than the class of regular languages).
>> As an alternative solution, I wonder if someone knows about a
>> module that
>> could parse Ruby regexps (accepting exactly the same regexp
>> grammar as
>> Ruby) and let me read the associated FSM (or whatever graph-like
>> structure
>> representing the regexp).
Sorry, can't help you there either - I don't know and couldn't dig up
anything that exposes Ruby's regex internals (or Oniguruma's) in the
way you're asking for, which strikes me as the only way to use
*exactly* the same grammar as Ruby does. Like Caleb Clausen
suggested, though, there are probably partial solutions out there,
depending on how flexible your criteria are and exactly what
information you need - are you looking for an aid in building
regexes? just visualising them? some other sort of analysis?
matthew smillie.