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. Other Discussions
  3. The Weird and The Wonderful
  4. DFA code generation

DFA code generation

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpai-coding
9 Posts 5 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.
  • D Offline
    D Offline
    danah gaz
    wrote on last edited by
    #1

    I used to generate c# switch case blocks that were about 2 or 3 pages long. Fun times. =) No, I won't post a sample - it's even uglier than it sounds. It also sometimes included "goto case" statements

    A L P X 4 Replies Last reply
    0
    • D danah gaz

      I used to generate c# switch case blocks that were about 2 or 3 pages long. Fun times. =) No, I won't post a sample - it's even uglier than it sounds. It also sometimes included "goto case" statements

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      danah gaz wrote:

      No, I won't post a sample

      Ok, I won't read your sample. :)

      Life is a computer program and everyone is the programmer of his own life.

      1 Reply Last reply
      0
      • D danah gaz

        I used to generate c# switch case blocks that were about 2 or 3 pages long. Fun times. =) No, I won't post a sample - it's even uglier than it sounds. It also sometimes included "goto case" statements

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3
        • Select all
        • Delete

        Solved :)

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

        D 1 Reply Last reply
        0
        • L Lost User
          • Select all
          • Delete

          Solved :)

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

          D Offline
          D Offline
          danah gaz
          wrote on last edited by
          #4

          Well it was either leave it or rewrite and debug a complex lexer by hand. The thing *worked perfectly* every single time, and was fast. It was just really, really ugly to look at. =) Also, I love that you're A Bastard Programmer from Hell. I used to read the Bastard Operator from Hell series when I was a kid. Loved it.

          "The power cord?" I ask

          "Yes... Woopsy"

          "No worries at all" I say "Is it all working well now?"

          "Yes, I think so. I'm sorry, you WERE right all along"

          "Yes, we're getting a lot of this, it's due to the current Global Warming
          problem. It causes random thermal expansion and contraction resulting in
          temperature induced movement of friction based holding mechanisms.."

          I listen carefully. Nothing. In other words, <DUMMY MODE ON>...

          "You can fix it permanently tho'" I say

          "Really? How?"

          "Well it's all to do with lowering salt deposits on the metal contacts"

          "Oh!" (Dummy mode irrevocably engaged)

          "All you need to do is just take the power plug out deposit some dilute mineral
          salts on it. Do you have some dilute mineral salts on you?"

          "Uh, no?"

          "Ok, no worries, just stick it in your mouth drool into it. But make sure you
          wipe the plug first to get rid of any germs, and TURN THE SWITCH OFF ON THE
          MONITOR before you do - we don't want a nasty accident!

          "Oh. Ok!"

          Fzzzt< >clunk!<

          I hang up as the receiver hits the floor. Disk space is too good for them.

          :-D

          L 1 Reply Last reply
          0
          • D danah gaz

            Well it was either leave it or rewrite and debug a complex lexer by hand. The thing *worked perfectly* every single time, and was fast. It was just really, really ugly to look at. =) Also, I love that you're A Bastard Programmer from Hell. I used to read the Bastard Operator from Hell series when I was a kid. Loved it.

            "The power cord?" I ask

            "Yes... Woopsy"

            "No worries at all" I say "Is it all working well now?"

            "Yes, I think so. I'm sorry, you WERE right all along"

            "Yes, we're getting a lot of this, it's due to the current Global Warming
            problem. It causes random thermal expansion and contraction resulting in
            temperature induced movement of friction based holding mechanisms.."

            I listen carefully. Nothing. In other words, <DUMMY MODE ON>...

            "You can fix it permanently tho'" I say

            "Really? How?"

            "Well it's all to do with lowering salt deposits on the metal contacts"

            "Oh!" (Dummy mode irrevocably engaged)

            "All you need to do is just take the power plug out deposit some dilute mineral
            salts on it. Do you have some dilute mineral salts on you?"

            "Uh, no?"

            "Ok, no worries, just stick it in your mouth drool into it. But make sure you
            wipe the plug first to get rid of any germs, and TURN THE SWITCH OFF ON THE
            MONITOR before you do - we don't want a nasty accident!

            "Oh. Ok!"

            Fzzzt< >clunk!<

            I hang up as the receiver hits the floor. Disk space is too good for them.

            :-D

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Yup, great stories, and nice short too :laugh:

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

            1 Reply Last reply
            0
            • D danah gaz

              I used to generate c# switch case blocks that were about 2 or 3 pages long. Fun times. =) No, I won't post a sample - it's even uglier than it sounds. It also sometimes included "goto case" statements

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              danah gaz wrote:

              It also sometimes included "goto case" statements

              As well it should.

              D 1 Reply Last reply
              0
              • P PIEBALDconsult

                danah gaz wrote:

                It also sometimes included "goto case" statements

                As well it should.

                D Offline
                D Offline
                danah gaz
                wrote on last edited by
                #7

                Yeah, I mean rolling a large DFA into a switch case is going to involve some gotos or a *lot* of duplicated code, but still, the end result looked like the stuff of nightmares. The code screamed "DON'T YOU DARE TOUCH ME!*

                1 Reply Last reply
                0
                • D danah gaz

                  I used to generate c# switch case blocks that were about 2 or 3 pages long. Fun times. =) No, I won't post a sample - it's even uglier than it sounds. It also sometimes included "goto case" statements

                  X Offline
                  X Offline
                  Xmen Real
                  wrote on last edited by
                  #8

                  danah gaz wrote:

                  It also sometimes included "goto case" statements

                  I dont get why devs hate goto so much, I dont use it but its not that bad.

                  TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

                  ----------------------------------------------- 128 bit encrypted signature, crack if you can

                  D 1 Reply Last reply
                  0
                  • X Xmen Real

                    danah gaz wrote:

                    It also sometimes included "goto case" statements

                    I dont get why devs hate goto so much, I dont use it but its not that bad.

                    TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

                    ----------------------------------------------- 128 bit encrypted signature, crack if you can

                    D Offline
                    D Offline
                    danah gaz
                    wrote on last edited by
                    #9

                    It's not wrong as such, but using it breaks control flow (such as gotoing out of a loop, or worse, into another loop) and can contribute to maintenance issues and general spaghetti code. Obviously maintenance isn't really an issue for autogenerated code - as long as you have the tool that generates it whenever you are modifying the source file that creates it, but it is just offensive to one's sensibilities to look at modern code full of goto statements.

                    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