Introduce a C Compiler ucc

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dj3vande@csclub.uwaterloo.ca.invalid

    #46
    Re: Introduce a C Compiler ucc

    In article <68rrekF2uf7l9U 1@mid.individua l.net>,
    Ian Collins <ian-news@hotmail.co mwrote:
    >Keith Thompson wrote:
    >Ian Collins <ian-news@hotmail.co mwrites:
    >>Not on a Unix systems, where there isn't a "text mode".
    >>
    >Yes, it does apply. On an output operation, '\n' is replaced by an
    >ASCII LF character. (As it happens, '\n' already is an ASCII LF
    >character, so the replacement is particularly easy to do.)
    >>
    >'a' is also replaced by ASCII 'a' character, so what's the difference?
    On ASCII systems, 'a' IS an ASCII 'a' character, in all contexts a C
    program cares about.
    In the context of I/O operations on a file opened in text mode, '\n' is
    a C end-of-line character, which is converted to a host-OS end-of-line
    on output. The fact that '\n' is an ASCII LF on ASCII systems and that
    a Unix end-of-line is an ASCII LF at the end of the line makes the
    conversion in this case trivial, but it IS a conversion.
    (If that bothers you, consider: I have a char *, and I assign it to a
    void *. Did a conversion happen? Did anything change as a result?[1])

    In other words: On Unix, text mode is indistinguishab le from binary
    mode, but they are still two distinct modes.


    dave

    [1] Answers: Yes, a conversion happened; and yes, the type of the
    pointer changed, but (unless you're on a DS9K.x where they've found
    a loophole in the "same representation" requirement), nothing about
    the actual bits making up the pointer has changed.

    --
    Dave Vandervies dj3vande at eskimo dot com
    >I am trying to move 3 bits from left to right with >operator
    Try holding the 3 bits in place, but shift the rest of your computer's memory
    right to left. --Kaz Kylheku gives stupid answers to stupid questions in CLC

    Comment

    • Keith Thompson

      #47
      Re: Introduce a C Compiler ucc

      Ian Collins <ian-news@hotmail.co mwrites:
      Keith Thompson wrote:
      >Ian Collins <ian-news@hotmail.co mwrites:
      >>Spiros Bousbouras wrote:
      >>>On 12 May, 15:12, santosh <santosh....@gm ail.comwrote:
      >>>>The C escape sequence '\n' is translated by the C compiler and the
      >>>>runtime library into whatever sequence the target platform uses for
      >>>>separatin g lines. Thus on Windows a '\n' in an output operation is
      >>>>translate d into a CRLF sequence, while under Unix it is replaced by a
      >>>>LF character, and so on.
      >>>Of course all that applies if the file was opened in
      >>>text mode.
      >>>>
      >>Not on a Unix systems, where there isn't a "text mode".
      >>
      >Yes, it does apply. On an output operation, '\n' is replaced by an
      >ASCII LF character. (As it happens, '\n' already is an ASCII LF
      >character, so the replacement is particularly easy to do.)
      >>
      'a' is also replaced by ASCII 'a' character, so what's the difference?
      I don't recall claiming that there is one, but now that you mention it
      .... actually, there isn't much of a difference. C99 7.19.2p2:

      Characters may have to be added, altered, or deleted on input and
      output to conform to differing conventions for representing text
      in the host environment. Thus, there need not be a one-to-one
      correspondence between the characters in a stream and those in the
      external representation.

      which covers both '\n' conversion and any conversion that might be
      necessary for 'a' and other "ordinary" characters.

      --
      Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
      Nokia
      "We must do something. This is something. Therefore, we must do this."
      -- Antony Jay and Jonathan Lynn, "Yes Minister"

      Comment

      • Flash Gordon

        #48
        Re: Introduce a C Compiler ucc

        Spiros Bousbouras wrote, On 12/05/08 22:50:
        On 12 May, 21:24, Flash Gordon <s...@flash-gordon.me.ukwro te:
        >Spiros Bousbouras wrote, On 12/05/08 20:45:
        <snip>
        >In any case, I would consider my comment valid whether the OP had
        >mentioned ANSI C, ISO C or just C.
        >
        I wasn't suggesting that your comment isn't valid
        I was just curious which standard the OP is aiming
        for.
        OK, no problem.
        --
        Flash Gordon

        Comment

        • dreamAnders

          #49
          Re: Introduce a C Compiler ucc

          On May 13, 1:24 am, rich...@cogsci. ed.ac.uk (Richard Tobin) wrote:
          Another problem: the program below reports
          >
          (test.c,10):err or:struct or union member key doesn't exsist
          (test.c,10):war ning:conversion between pointer and integer without a cast
          >
          The error goes away if the "const" in the declaration of hp is
          removed.
          >
          typedef struct hash_entry {
          void *key;
          >
          } HashEntryStruct ;
          >
          HashEntryStruct h;
          >
          int main(void)
          {
          const HashEntryStruct *hp = &h;
          void *key = hp->key;
          >
          return 0;
          >
          }
          >
          -- Richard
          --
          :wq
          Sorry this bug should be found before beta release. I wrote this
          compiler at my spare time. Now I released its beta version
          for more test. Now I received some feedbacks. If you will, hope that
          you can send bug report to the address mentions at the document, or
          you can submit it in sourceforge. I will try to set up the developer
          community, update the release as soon as I can.

          Comment

          • CBFalconer

            #50
            Re: Introduce a C Compiler ucc

            "noagbodjivicto r@gmail.com" wrote:
            "noagbodjivic.. .@gmail.com" <noagbodjivic.. .@gmail.comwrot e:
            >dreamAnders <dream_and...@y ahoo.com.cnwrot e:
            >>
            >>ucc is an ANSI C Compiler. Its code size is about 15,000 lines.
            >>>
            .... snip ...
            >>
            >Congratulation s. I hope this project will evolve quickly.
            >
            Also, I don't really like the fact that one must have Ms Studio
            to compile the compiler :) Can't you distribute binaries?
            You mean it isn't even written in C? If so, that is the end of
            that project.

            --
            [mail]: Chuck F (cbfalconer at maineline dot net)
            [page]: <http://cbfalconer.home .att.net>
            Try the download section.


            ** Posted from http://www.teranews.com **

            Comment

            • Richard Heathfield

              #51
              Re: Introduce a C Compiler ucc

              CBFalconer said:
              "noagbodjivicto r@gmail.com" wrote:
              >"noagbodjivic. ..@gmail.com" <noagbodjivic.. .@gmail.comwrot e:
              >>dreamAnders <dream_and...@y ahoo.com.cnwrot e:
              >>>
              >>>ucc is an ANSI C Compiler. Its code size is about 15,000 lines.
              >>>>
              ... snip ...
              >>>
              >>Congratulatio ns. I hope this project will evolve quickly.
              >>
              >Also, I don't really like the fact that one must have Ms Studio
              >to compile the compiler :) Can't you distribute binaries?
              >
              You mean it isn't even written in C?
              I don't see how you deduce that. It is precisely because it /is/ written in
              C that you need a C compiler if you wish to compile it.
              If so, that is the end of that project.
              I don't see why. If I wanted to write a compiler for some arbitrary
              language X, I'd almost certainly choose C to do it, rather than X. So why
              someone else can't choose to write a C compiler in language X rather than
              C is beyond me. And in any case, this C compiler /is/ written in C...

              ....except for one tiny annoying bit that uses an anonymous struct which, on
              my system, halts compilation (using UCC's own makefile, so we can't blame
              my martinet switches this time).

              --
              Richard Heathfield <http://www.cpax.org.uk >
              Email: -http://www. +rjh@
              Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
              "Usenet is a strange place" - dmr 29 July 1999

              Comment

              • CBFalconer

                #52
                Re: Introduce a C Compiler ucc

                Richard Heathfield wrote:
                CBFalconer said:
                >"noagbodjivict or@gmail.com" wrote:
                >>"noagbodjivic ...@gmail.com" <noagbodjivic.. .@gmail.comwrot e:
                >>>dreamAnder s <dream_and...@y ahoo.com.cnwrot e:
                >>>>
                >>>>ucc is an ANSI C Compiler. Its code size is about 15,000 lines.
                >>>>>
                >... snip ...
                >>>>
                >>>Congratulati ons. I hope this project will evolve quickly.
                >>>
                >>Also, I don't really like the fact that one must have Ms Studio
                >>to compile the compiler :) Can't you distribute binaries?
                >>
                >You mean it isn't even written in C?
                >
                I don't see how you deduce that. It is precisely because it /is/
                written in C that you need a C compiler if you wish to compile it.
                I asked a question, as indicated by the terminal '?'. If one
                _needs_ some peculiar MS stuff to compile it, can it possibly be
                written in C, as understood in this newsgroup?

                --
                [mail]: Chuck F (cbfalconer at maineline dot net)
                [page]: <http://cbfalconer.home .att.net>
                Try the download section.

                ** Posted from http://www.teranews.com **

                Comment

                • Richard Heathfield

                  #53
                  Re: Introduce a C Compiler ucc

                  CBFalconer said:

                  <snip>
                  If one
                  _needs_ some peculiar MS stuff to compile it,
                  It doesn't. gcc compiles most of it just fine. My version barfs on
                  anonymous structs, but I guess I could go fix those if I cared enough.
                  can it possibly be
                  written in C, as understood in this newsgroup?
                  Modulo the anonymous structs, yes, sure. Why not take a look at the code
                  yourself?

                  --
                  Richard Heathfield <http://www.cpax.org.uk >
                  Email: -http://www. +rjh@
                  Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                  "Usenet is a strange place" - dmr 29 July 1999

                  Comment

                  • dreamAnders

                    #54
                    Re: Introduce a C Compiler ucc

                    On May 13, 1:18 am, rich...@cogsci. ed.ac.uk (Richard Tobin) wrote:
                    In article <ea49768e-6e7a-4426-a93b-e244eb978...@y1 8g2000pre.googl egroups.com>,
                    >
                    dreamAnders <dream_and...@y ahoo.com.cnwrot e:
                    Thank you very much for tesing the compiler. I have corrected the bugs.
                    >
                    That was quick!
                    >
                    But I still find the conditional operator doesn't work when the
                    second operand is 0 and the third is a pointer. (It now works
                    with them the other way round.)
                    >
                    I also have a problem with files that include sys/socket.h (this
                    is on Linux). I don't know if it's a problem with your compiler as
                    such or with the compatibility of the header files. I get this
                    error:
                    >
                    (/usr/include/bits/socket.h,165):e rror:Expect type specifier or qualifier
                    (/usr/include/bits/socket.h,165):e rror:Expect ;
                    (/usr/include/bits/socket.h,165):e rror:Expect type specifier or qualifier
                    (/usr/include/bits/socket.h,166):e rror:Undeclared identifier: __uint64_t
                    >
                    -- Richard
                    --
                    :wq
                    I checked the conditional operator problem and found the problem:a
                    typo error, shame me.
                    And for the socket.h, __uint64_t is the keyword in gcc, not in ucc.
                    Now ucc can't support 64bit.

                    And ucc does support a tricky method to work around these extensions
                    provided by gcc and vc.
                    If you will check the win32.c under driver, you will find the trick.

                    ucc can pass -keyword __uint64_t to ucl and add one line on the
                    keyword.h under ucl, the __uint64_t will work.
                    (Ugly, but now works)

                    Comment

                    • Richard Heathfield

                      #55
                      Re: Introduce a C Compiler ucc

                      dreamAnders said:

                      <snip>
                      >
                      I checked the conditional operator problem and found the problem:a
                      typo error, shame me.
                      No shame at all. Your attitude to bug reports is commendably positive.

                      Now, I know you like anonymous unions, and I understand that you want to
                      support them in your compiler, and that's fine - but *using* them in your
                      compiler prevents me from compiling the compiler itself, because /my/
                      compiler doesn't support them.

                      Is there any likelihood that you will be releasing a version of the code
                      that does not require the host compiler to support anonunions?

                      I understand that you don't currently supply headers or a library, relying
                      on the host environment to supply these. Again, that's fine - but if you
                      were to make your compiler's source code conform to ANSI C (and especially
                      to the 1989 ANSI (1990 ISO) Standard), you *might* find that some people
                      in comp.lang.c would be very willing to help you fill that gap.

                      <snip>

                      --
                      Richard Heathfield <http://www.cpax.org.uk >
                      Email: -http://www. +rjh@
                      Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                      "Usenet is a strange place" - dmr 29 July 1999

                      Comment

                      • dreamAnders

                        #56
                        Re: Introduce a C Compiler ucc

                        On 5ÔÂ13ÈÕ, ÏÂÎç5ʱ00·Ö, Richard Heathfield <r...@see.sig.i nvalidwrote:
                        dreamAnders said:
                        >
                        <snip>
                        >
                        >
                        >
                        I checked the conditional operator problem and found the problem:a
                        typo error, shame me.
                        >
                        No shame at all. Your attitude to bug reports is commendably positive.
                        >
                        Now, I know you like anonymous unions, and I understand that you want to
                        support them in your compiler, and that's fine - but *using* them in your
                        compiler prevents me from compiling the compiler itself, because /my/
                        compiler doesn't support them.
                        >
                        Is there any likelihood that you will be releasing a version of the code
                        that does not require the host compiler to support anonunions?
                        >
                        I understand that you don't currently supply headers or a library, relying
                        on the host environment to supply these. Again, that's fine - but if you
                        were to make your compiler's source code conform to ANSI C (and especially
                        to the 1989 ANSI (1990 ISO) Standard), you *might* find that some people
                        in comp.lang.c would be very willing to help you fill that gap.
                        >
                        <snip>
                        >
                        --
                        Richard Heathfield <http://www.cpax.org.uk >
                        Email: -http://www. +rjh@
                        Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                        "Usenet is a strange place" - dmr 29 July 1999

                        That's great! I wish that some people in comp.lang.c to help me fill
                        that gap very much.
                        I will try to set up the developer community and evolve the project.

                        Comment

                        • Walter Banks

                          #57
                          Re: Introduce a C Compiler ucc



                          Richard Heathfield wrote:
                          I don't see why. If I wanted to write a compiler for some arbitrary
                          language X, I'd almost certainly choose C to do it, rather than X. So why
                          someone else can't choose to write a C compiler in language X rather than
                          C is beyond me.
                          C might not be the best language to implement a compiler in. C's weak typing
                          for example.

                          ucc is written in C as you have pointed out. It is an interesting project
                          that takes compilers back to some fundaments. Wenjun Wang is to be
                          commended for a nice piece of work.

                          Increasingly I expect we are going to see home grown Asian development
                          tools like ucc appearing.

                          Regards,

                          --
                          Walter Banks
                          Byte Craft Limited
                          Tel. (519) 888-6911

                          walter@bytecraf t.com










                          Comment

                          • CBFalconer

                            #58
                            Re: Introduce a C Compiler ucc

                            Richard Heathfield wrote:
                            CBFalconer said:
                            >
                            <snip>
                            >
                            >If one _needs_ some peculiar MS stuff to compile it,
                            >
                            It doesn't. gcc compiles most of it just fine. My version barfs on
                            anonymous structs, but I guess I could go fix those if I cared enough.
                            >
                            >can it possibly be written in C, as understood in this newsgroup?
                            >
                            Modulo the anonymous structs, yes, sure. Why not take a look at the
                            code yourself?
                            Well, I had it lined up to download, but when I saw the messages
                            about total lack of comment, and then need for MS stuff, I took it
                            down.

                            --
                            [mail]: Chuck F (cbfalconer at maineline dot net)
                            [page]: <http://cbfalconer.home .att.net>
                            Try the download section.


                            ** Posted from http://www.teranews.com **

                            Comment

                            • Gene

                              #59
                              Re: Introduce a C Compiler ucc

                              On May 11, 11:41 am, "noagbodjivic.. .@gmail.com"
                              <noagbodjivic.. .@gmail.comwrot e:
                              On May 11, 11:36 am, "noagbodjivic.. .@gmail.com"
                              >
                              <noagbodjivic.. .@gmail.comwrot e:
                              On May 10, 9:15 pm, dreamAnders <dream_and...@y ahoo.com.cnwrot e:
                              >
                              ucc is an ANSI C Compiler. Its code size is about 15,000 lines.
                              The lexer, parser and code generator are all hand-written.
                              The code structure is very clear and straightforward . And there is an
                              interesting value numbering algorithm.
                              It also has a document explaining the internal implementation.
                              If you are interested at this compiler, you can download it fromhttp://sourceforge.net/projects/ucc, which will help you to master the
                              C language.
                              >
                              Congratulations . I hope this project will evolve quickly.
                              >
                              Also, I don't really like the fact that one must have Ms Studio to
                              compile the compiler :) Can't you distribute binaries?
                              You guys are real pieces of work. (I've replied only to the most
                              egregious.) This is obviously an initial offering of a substantial
                              personal project with lots of potential. The code really is a marvel
                              of clarity. (It reminds me of http://www.t3x.org/bits/s9fes/. And I
                              commend the literate programming style/tools of s9fes to
                              dreamAnders.)

                              Give the guy a break. Celebrate the new resource and--if you see fit
                              to criticize--do so with contributions that fix the apparent bugs or
                              omissions.

                              Jeez...


                              Comment

                              • dreamAnders

                                #60
                                Re: Introduce a C Compiler ucc

                                On May 14, 8:32 am, Gene <gene.ress...@g mail.comwrote:
                                On May 11, 11:41 am, "noagbodjivic.. .@gmail.com"
                                >
                                >
                                >
                                <noagbodjivic.. .@gmail.comwrot e:
                                On May 11, 11:36 am, "noagbodjivic.. .@gmail.com"
                                >
                                <noagbodjivic.. .@gmail.comwrot e:
                                On May 10, 9:15 pm, dreamAnders <dream_and...@y ahoo.com.cnwrot e:
                                >
                                ucc is an ANSI C Compiler. Its code size is about 15,000 lines.
                                The lexer, parser and code generator are all hand-written.
                                The code structure is very clear and straightforward . And there is an
                                interesting value numbering algorithm.
                                It also has a document explaining the internal implementation.
                                If you are interested at this compiler, you can download it fromhttp://sourceforge.net/projects/ucc, which will help you to master the
                                C language.
                                >
                                Congratulations . I hope this project will evolve quickly.
                                >
                                Also, I don't really like the fact that one must have Ms Studio to
                                compile the compiler :) Can't you distribute binaries?
                                >
                                You guys are real pieces of work. (I've replied only to the most
                                egregious.) This is obviously an initial offering of a substantial
                                personal project with lots of potential. The code really is a marvel
                                of clarity. (It reminds me ofhttp://www.t3x.org/bits/s9fes/. And I
                                commend the literate programming style/tools of s9fes to
                                dreamAnders.)
                                >
                                Give the guy a break. Celebrate the new resource and--if you see fit
                                to criticize--do so with contributions that fix the apparent bugs or
                                omissions.
                                >
                                Jeez...
                                Thanks a lot. The literate programming style/tools is interesting.

                                Comment

                                Working...