How is a compiler created?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agsupriya86
    New Member
    • Mar 2007
    • 34

    How is a compiler created?

    hi,

    can anybody explain me..
    If compiler for c is written in c language, which is used to complie the compiler?
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by agsupriya86
    hi,

    can anybody explain me..
    If compiler for c is written in c language, which is used to complie the compiler?
    Very interesting question!!

    It is like "who first? hen or egg? " :)
    Hope somebody has the answer.

    Comment

    • ssorower
      New Member
      • May 2007
      • 23

      #3
      You may want to have a look at here

      a similar post on the same place long back -:)

      --Sorower

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by zodilla58
        Very interesting question!!

        It is like "who first? hen or egg? " :)
        Hope somebody has the answer.
        Check out Yacc and Bison. I think it's more Yacc but I remember writing a Pascal compiler that was translated through one or both of them to get C++ code...

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          The first compilers for any language were first written in another language.
          When that initial bootstrap step was over and done with one can write a compiler
          in the language itself and compile it using the previous version of the compiler.

          After that one can throw away that first version of the compiler and you'd end up
          with a compiler for a language written in that very same language.

          kind regards,

          Jos

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            This is a very primal process.

            First, you build the electronic processor.

            Then, I'm not kidding here, you build an electronic compiler from electronic parts that will convert assembly code to machine language. The assembly code used as input to this electronic compiler is the logic of the circuits themselves.

            Once the the assembly code can reproduce itself in machine language, you reach the "self-sustaining" point and discard the the electronic compiler. The you have been using is now a compiler called an assembler.

            You now implement other processor commands using the features of the current assembler.

            So, to do a C compiler, you write an assembly program that will translate C code into the assembly program itself. When this is successful, you discard the assembly program and you have your C compiler written in C.

            Compilers are usually written in the language they compile.

            Comment

            • TRScheel
              Recognized Expert Contributor
              • Apr 2007
              • 638

              #7
              Originally posted by weaknessforcats
              This is a very primal process.

              First, you build the electronic processor.

              Then, I'm not kidding here, you build an electronic compiler from electronic parts that will convert assembly code to machine language. The assembly code used as input to this electronic compiler is the logic of the circuits themselves.

              Once the the assembly code can reproduce itself in machine language, you reach the "self-sustaining" point and discard the the electronic compiler. The you have been using is now a compiler called an assembler.

              You now implement other processor commands using the features of the current assembler.

              So, to do a C compiler, you write an assembly program that will translate C code into the assembly program itself. When this is successful, you discard the assembly program and you have your C compiler written in C.

              Compilers are usually written in the language they compile.

              Hmmm, this sounds familiar...

              On the first day, God created the electronic processor, and it was good...
              On the second day....

              Comment

              • Silent1Mezzo
                New Member
                • Feb 2007
                • 208

                #8
                Originally posted by TRScheel
                Hmmm, this sounds familiar...

                On the first day, God created the electronic processor, and it was good...
                On the second day....
                On the second day god created dual-core processors :D

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  Originally posted by Silent1Mezzo
                  On the second day god created dual-core processors :D
                  And on the seventh day god didn't do anything at all because all those cheap and
                  fast RISC processors took care of it all.

                  kind regards,

                  Jos

                  Comment

                  • Silent1Mezzo
                    New Member
                    • Feb 2007
                    • 208

                    #10
                    Originally posted by JosAH
                    And on the seventh day god didn't do anything at all because all those cheap and
                    fast RISC processors took care of it all.

                    kind regards,

                    Jos
                    LOL!!!

                    And the next week robots took over.

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by Silent1Mezzo
                      LOL!!!

                      And the next week robots took over.
                      Genesis 1:41 and on the day immediately following the fourty first day and
                      just before the fourty third day, Eve was happily trotting down the river Tigris:
                      trottety-trottety-trot when, by Jove, the Serpent Intel reared its ugiy head
                      from the malodorous Microsoft tree.

                      Genesis 1:42 it was more subtle than any other beast created by god; it said
                      unto Eve: "Yea, hath God said, Ye shall not buy my multi core processor?

                      Genesis1:43 Because Adam was still recovering from his holy rib operation,
                      until this day Earth, a valley of tears, is in deepeth misery. Wooo on us all.

                      kind regards,

                      Jos ;-)

                      Comment

                      • Silent1Mezzo
                        New Member
                        • Feb 2007
                        • 208

                        #12
                        Originally posted by JosAH
                        Genesis 1:41 and on the day immediately following the fourty first day and
                        just before the fourty third day, Eve was happily trotting down the river Tigris:
                        trottety-trottety-trot when, by Jove, the Serpent Intel reared its ugiy head
                        from the malodorous Microsoft tree.

                        Genesis 1:42 it was more subtle than any other beast created by god; it said
                        unto Eve: "Yea, hath God said, Ye shall not buy my multi core processor?

                        Genesis1:43 Because Adam was still recovering from his holy rib operation,
                        until this day Earth, a valley of tears, is in deepeth misery. Wooo on us all.

                        kind regards,

                        Jos ;-)
                        That sounds like the KUV
                        King Unix Version

                        Comment

                        • JosAH
                          Recognized Expert MVP
                          • Mar 2007
                          • 11453

                          #13
                          A Reading from the Book of Armaments, Chapter 4, Verses 16 to 20:

                          Then did he raise on high the Holy Disk Manager of Antioch, saying, "Bless
                          this, O Lord, that with it thou mayst blow the Filing Sytem to tiny bits, in thy
                          mercy." And the people did rejoice and did feast upon the lambs and toads and
                          tree-sloths and fruit-bats and orangutans and breakfast cereals ... Now did the
                          Lord say, "First thou syncest the disks. Then thou must count to three. Three
                          shall be the number of the syncing and the number of the syncing shall be
                          three. Four shalt thou not sync, neither shalt thou count two, excepting that
                          thou then proceedeth to three. Five is right out. Once the number three, being
                          the number of the syncing, be reached, then turnest thou the Holy System Key
                          in the direction of thine foe, who, being naughty in my sight, shall snuff it."

                          kind regards,

                          Jehov^H^H^H^Hos

                          Comment

                          • TRScheel
                            Recognized Expert Contributor
                            • Apr 2007
                            • 638

                            #14
                            Originally posted by JosAH
                            A Reading from the Book of Armaments, Chapter 4, Verses 16 to 20:

                            Then did he raise on high the Holy Disk Manager of Antioch, saying, "Bless
                            this, O Lord, that with it thou mayst blow the Filing Sytem to tiny bits, in thy
                            mercy." And the people did rejoice and did feast upon the lambs and toads and
                            tree-sloths and fruit-bats and orangutans and breakfast cereals ... Now did the
                            Lord say, "First thou syncest the disks. Then thou must count to three. Three
                            shall be the number of the syncing and the number of the syncing shall be
                            three. Four shalt thou not sync, neither shalt thou count two, excepting that
                            thou then proceedeth to three. Five is right out. Once the number three, being
                            the number of the syncing, be reached, then turnest thou the Holy System Key
                            in the direction of thine foe, who, being naughty in my sight, shall snuff it."

                            kind regards,

                            Jehov^H^H^H^Hos
                            lol...

                            Oh good lord, what have I started?

                            Comment

                            • Silent1Mezzo
                              New Member
                              • Feb 2007
                              • 208

                              #15
                              Originally posted by TRScheel
                              lol...

                              Oh good lord, what have I started?
                              On that note...I wonder if the good lord would choose C or C++...or maybe he'd just turn both languages into actual beings and have them fight to the death.....

                              mmmmm Programming Languages fighting....

                              Comment

                              Working...