Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Making two lines of code work took years of effort but I finally did it!

Making two lines of code work took years of effort but I finally did it!

Scheduled Pinned Locked Moved The Lounge
designcsharpcomgraphicsiot
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    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

    pkfoxP J 2 Replies Last reply
    0
    • H honey the codewitch

      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

      pkfoxP Offline
      pkfoxP Offline
      pkfox
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • pkfoxP pkfox

        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

        N Offline
        N Offline
        Nelek
        wrote on last edited by
        #3

        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.

        H 1 Reply Last reply
        0
        • N Nelek

          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.

          H Offline
          H Offline
          honey the codewitch
          wrote on last edited by
          #4

          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

          N 1 Reply Last reply
          0
          • H honey the codewitch

            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

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • H honey the codewitch

              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

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              Hopefully you have a lot more test cases.

              H 1 Reply Last reply
              0
              • J jschell

                Hopefully you have a lot more test cases.

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups