NFA/DFA implementation in C#
Asked Answered
G

1

12

Does anyone know of any good NFA and DFA implementation in C#, possibly implementing as well conversions between both? What I would like would be to be able to construct a NFA and then convert it automatically to a DFA, but without having to write my own code which would take a very long time. There is this Python code which perhaps I could use and integrate with C# using IronPython, but Python is slow.

Gynarchy answered 23/10, 2010 at 21:45 Comment(5)
Looking that the python code, it should be relatively easy to convert to C#. Have you considered doing that?Mcgriff
The question is that I understand nothing about Python...Gynarchy
Slow is relative... anyway, the NFA->DFA algorithm is rather trivial (with some general caveats in general) and is a topic of many Junior CS Automata-Theory courses -- I had to do this :) There any many good links off of "convert NFA to DFA" on google. Look at those relating to courses in particular. It should be less than a day of coding; perhaps only a few an hour or two and likely less painful than trying to hopscotch through different languages.Beiderbecke
The algorithm to convert NFAs to DFAs is exponential in the number of NFA states in the worst case, so... slow is not going to be a phenomenon due to Python.Boots
You may also want to look at project Fare. https://mcmap.net/q/501927/-convert-nfa-to-dfa/…Adventurism
F
21

Take a look at my series of posts about this subject:

Regular Expression Engine in C# (the Story)

Regex engine in C# - the Regex Parser

Regex engine in C# - the NFA

Regex engine in C# - the DFA

Regex engine in C# - matching strings

Fullmouthed answered 23/10, 2010 at 22:25 Comment(2)
I would like to use your code, but it does not have a license listed. If you are ok with people using it, would you distribute a version with an explicit license?Mastat
@FireLizzard you can use it the way you want. In my blog I have included a Creative Commons badge right below my G+ profile. :) Feel free to use the code.Fullmouthed

© 2022 - 2024 — McMap. All rights reserved.