Making two lines of code work took years of effort but I finally did it!
-
var nfa = FA.Parse(@"(foo|(bar)+|ba[rz])|foobar");
Console.WriteLine(nfa.ToString("e"));(bar|barba(rba)*r|baz|foo|foobar)
It was always the loops that would just nail me to the wall. I still have to clean up the expressions it produces but they are essentially correct! I used the state removal method[^] but I couldn't find an adequate explanation. Finally, I found this: GitHub - wolever/nfa2regex: Converts NFAs (and DFAs) to a regular expressions using the state removal method.[^] It's in Go, so I taught myself some Go :) Not a bad language in that it only took me a few hours from start to finish to learn enough of it and port away from it to C#. Unfortunately when I think I am too smart for my own good I used to try to do this algorithm to remind me of my intellectual shortcomings - I no longer have that opportunity. :laugh: I guess I'll have to try LL(k) or LL(*) parsing next. The trouble with that is parser generators aren't usually good enough to make real world parsers, or the code they generate is too big. Oh well. I'll find something.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
var nfa = FA.Parse(@"(foo|(bar)+|ba[rz])|foobar");
Console.WriteLine(nfa.ToString("e"));(bar|barba(rba)*r|baz|foo|foobar)
It was always the loops that would just nail me to the wall. I still have to clean up the expressions it produces but they are essentially correct! I used the state removal method[^] but I couldn't find an adequate explanation. Finally, I found this: GitHub - wolever/nfa2regex: Converts NFAs (and DFAs) to a regular expressions using the state removal method.[^] It's in Go, so I taught myself some Go :) Not a bad language in that it only took me a few hours from start to finish to learn enough of it and port away from it to C#. Unfortunately when I think I am too smart for my own good I used to try to do this algorithm to remind me of my intellectual shortcomings - I no longer have that opportunity. :laugh: I guess I'll have to try LL(k) or LL(*) parsing next. The trouble with that is parser generators aren't usually good enough to make real world parsers, or the code they generate is too big. Oh well. I'll find something.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
Your mind never ceases to amaze me :thumbsup:
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
I am already happy if I manage to barely understand what gets posted :-D
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
I am already happy if I manage to barely understand what gets posted :-D
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
So am I. :laugh:
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
So am I. :laugh:
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
I know... .and please do not change :)
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
var nfa = FA.Parse(@"(foo|(bar)+|ba[rz])|foobar");
Console.WriteLine(nfa.ToString("e"));(bar|barba(rba)*r|baz|foo|foobar)
It was always the loops that would just nail me to the wall. I still have to clean up the expressions it produces but they are essentially correct! I used the state removal method[^] but I couldn't find an adequate explanation. Finally, I found this: GitHub - wolever/nfa2regex: Converts NFAs (and DFAs) to a regular expressions using the state removal method.[^] It's in Go, so I taught myself some Go :) Not a bad language in that it only took me a few hours from start to finish to learn enough of it and port away from it to C#. Unfortunately when I think I am too smart for my own good I used to try to do this algorithm to remind me of my intellectual shortcomings - I no longer have that opportunity. :laugh: I guess I'll have to try LL(k) or LL(*) parsing next. The trouble with that is parser generators aren't usually good enough to make real world parsers, or the code they generate is too big. Oh well. I'll find something.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
-
I do.
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix