Introduce a C Compiler ucc

Discussion in 'C Programming' started by dreamAnders, May 11, 2008.

  1. dreamAnders

    dreamAnders Guest

    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 from
    http://sourceforge.net/projects/ucc, which will help you to master the
    C language.
     
    dreamAnders, May 11, 2008
    #1
    1. Advertising

  2. dreamAnders

    Guest

    On May 11, 4:15 am, dreamAnders <> wrote:
    > 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.


    Your implementation of assert in ucc/ucl/linux/include/assert.h is not
    ANSI C, (or ISO C) as it evaluates it's parameter more than once if
    NDEBUG is not defined.
    Example: assert(printf("hello world\n")); would call print twice.

    I suggest you rewrite _assert (and also rename to _Assert) to return
    void, and make the check twice there.
     
    , May 11, 2008
    #2
    1. Advertising

  3. On May 10, 9:15 pm, dreamAnders <> wrote:
    > 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.


    At about 1 comment per 1000 lines of code it may be difficult to get
    this adopted for "research and instructional use".

    --
    Robert Gamble
     
    Robert Gamble, May 11, 2008
    #3
  4. dreamAnders

    dreamAnders Guest

    On May 11, 9:35 am, wrote:
    > On May 11, 4:15 am, dreamAnders <> wrote:
    >
    > > 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.

    >
    > Your implementation of assert in ucc/ucl/linux/include/assert.h is not
    > ANSI C, (or ISO C) as it evaluates it's parameter more than once if
    > NDEBUG is not defined.
    > Example: assert(printf("hello world\n")); would call print twice.
    >
    > I suggest you rewrite _assert (and also rename to _Assert) to return
    > void, and make the check twice there.


    No, It will not evaluate its parameter more than once.

    #define assert(e) ((void)((e)||_assert(#e, __FILE__, __LINE__)))

    please notice that the second e's appearance, it is '#e'
     
    dreamAnders, May 11, 2008
    #4
  5. dreamAnders

    dreamAnders Guest

    yes, I accept this . Nearly no comments. I wanted to write this code
    in a self-explanatory way. And I provide an internal implementation
    document, hope that will help developers understanding the code.

    On May 11, 9:42 am, Robert Gamble <> wrote:
    > On May 10, 9:15 pm, dreamAnders <> wrote:
    >
    > > 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.

    >
    > At about 1 comment per 1000 lines of code it may be difficult to get
    > this adopted for "research and instructional use".
    >
    > --
    > Robert Gamble
     
    dreamAnders, May 11, 2008
    #5
  6. dreamAnders

    Dan Guest

    "dreamAnders" <> wrote in message
    news:...
    > 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 from
    > http://sourceforge.net/projects/ucc, which will help you to master the
    > C language.


    Can it compile itself?
     
    Dan, May 11, 2008
    #6
  7. dreamAnders

    Gene Guest

    On May 10, 11:20 pm, "Dan" <> wrote:
    > "dreamAnders" <> wrote in message
    >
    > news:...
    >
    > > 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 from
    > >http://sourceforge.net/projects/ucc, which will help you to master the
    > > C language.

    >
    > Can it compile itself?


    From User's Manual:

    (3) run make test, this will test if ucc can compile itself and run
    successfully.
    The command performs the following operations:
    1) use ucc to build ucl, the output is named as ucl1
    2) backup ucl under /usr/local/lib/ucc, copy ucl1 to this
    directory and rename it to ucl
    3) use ucc to build ucl again, the output is named as ucl2
    4) run cmp /b ucl1 ucl2, these two files should be identical
     
    Gene, May 11, 2008
    #7
  8. dreamAnders

    Rui Maciel Guest

    On Sat, 10 May 2008 18:15:57 -0700, dreamAnders wrote:

    > 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 from http://sourceforge.net/projects/ucc, which will help
    > you to master the C language.


    Do you have a site dedicated to your project?


    Rui Maciel
     
    Rui Maciel, May 11, 2008
    #8
  9. dreamAnders

    Bart Guest

    On May 11, 2:15 am, dreamAnders <> wrote:
    > 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.


    As I understand it, this is just a bare compiler source code?

    There are no binaries, so another compiler is needed to get started.

    There appear to be no standard header files or library files,
    presumably you are relying on these things from another compiler?


    --
    Bartc
     
    Bart, May 11, 2008
    #9
  10. dreamAnders

    Guest

    On May 10, 9:15 pm, dreamAnders <> wrote:
    > 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.
     
    , May 11, 2008
    #10
  11. dreamAnders

    Guest

    On May 11, 11:36 am, ""
    <> wrote:
    > On May 10, 9:15 pm, dreamAnders <> wrote:
    >
    > > 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?
     
    , May 11, 2008
    #11
  12. dreamAnders

    Ian Collins Guest

    dreamAnders wrote:
    > 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 from
    > http://sourceforge.net/projects/ucc, which will help you to master the
    > C language.


    Your files all have DOS line endings, not good for a cross platform project.

    --
    Ian Collins.
     
    Ian Collins, May 11, 2008
    #12
  13. dreamAnders

    Ian Collins Guest

    Ian Collins wrote:
    > dreamAnders wrote:
    >> 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 from
    >> http://sourceforge.net/projects/ucc, which will help you to master the
    >> C language.

    >
    > Your files all have DOS line endings, not good for a cross platform project.
    >

    I see you also used unnamed unions in structs, which isn't standard.

    You really should use standard C for a standard C compiler!

    --
    Ian Collins.
     
    Ian Collins, May 11, 2008
    #13
  14. In article <>,
    Ian Collins <> wrote:
    >You really should use standard C for a standard C compiler!


    Why? Would it be wrong to write a C compiler in, say, Lisp? The
    considerations for what language or dialect to use for a C compiler
    are no stricter than for any other project. In fact, they're less
    strict, since so long as you support the extensions you use you can be
    sure that there's a compiler that will compile it for the platforms
    you support.

    -- Richard
    --
    :wq
     
    Richard Tobin, May 11, 2008
    #14
  15. dreamAnders

    Ian Collins Guest

    Richard Tobin wrote:
    > In article <>,
    > Ian Collins <> wrote:
    >> You really should use standard C for a standard C compiler!

    >
    > Why? Would it be wrong to write a C compiler in, say, Lisp? The
    > considerations for what language or dialect to use for a C compiler
    > are no stricter than for any other project. In fact, they're less
    > strict, since so long as you support the extensions you use you can be
    > sure that there's a compiler that will compile it for the platforms
    > you support.
    >

    Why? Because one of the claims for the source was it "will help you to
    master the C language."

    Maybe that should read "will help you to master the gcc language." :)

    --
    Ian Collins.
     
    Ian Collins, May 11, 2008
    #15
  16. dreamAnders

    Rui Maciel Guest

    On Sun, 11 May 2008 22:50:56 +0000, Richard Tobin wrote:

    > Why? Would it be wrong to write a C compiler in, say, Lisp?


    I believe that you've entirely missed the point. What was pointed out was
    that the use of a non-standard extensions, which not only goes against
    the objective that you set yourself to accomplish but also needlessly
    screws things up for those who want to build it with any compiler that
    doesn't support those non-standard extensions.


    Rui Maciel
     
    Rui Maciel, May 12, 2008
    #16
  17. In article <>,
    Ian Collins <> wrote:

    >Why? Because one of the claims for the source was it "will help you to
    >master the C language."


    Fair enough, but you said something far more general:

    >>> You really should use standard C for a standard C compiler!


    -- Richard


    --
    :wq
     
    Richard Tobin, May 12, 2008
    #17
  18. dreamAnders

    dreamAnders Guest

    On May 11, 11:41 pm, ""
    <> wrote:
    > On May 11, 11:36 am, ""
    >
    > <> wrote:
    > > On May 10, 9:15 pm, dreamAnders <> wrote:

    >
    > > > 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?


    Thanks. I am afraid that ucc is a stand-alone compiler. On Windows, It
    rely on VC'header
    files, library files, the preprocessor,assembler and linker. On Linux,
    It rely on gcc
    for that. So If I distribute binaries, users will find it cannot work.

    I hope the project will evolve quickly. I need more help.
     
    dreamAnders, May 12, 2008
    #18
  19. dreamAnders

    dreamAnders Guest

    On May 12, 4:13 am, Ian Collins <> wrote:
    > dreamAnders wrote:
    > > 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 from
    > >http://sourceforge.net/projects/ucc, which will help you to master the
    > > C language.

    >
    > Your files all have DOS line endings, not good for a cross platform project.
    >
    > --
    > Ian Collins.


    Thank you for your suggestion.

    And yes, ucc supports anonymous union. Personally, I like anonymous
    union so much,
    and most compilers support it. So I want to support it too.
     
    dreamAnders, May 12, 2008
    #19
  20. dreamAnders

    dreamAnders Guest

    On May 11, 11:41 pm, ""
    <> wrote:
    > On May 11, 11:36 am, ""
    >
    > <> wrote:
    > > On May 10, 9:15 pm, dreamAnders <> wrote:

    >
    > > > 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?


    Thanks. I am afraid that ucc is not a stand-alone compiler. On
    Windows, It
    rely on VC'header files, library files, the preprocessor,assembler and
    linker. On Linux, It rely on gcc for that. So If I distribute
    binaries, users will find it cannot work.

    I hope the project will evolve quickly. I need more help.
     
    dreamAnders, May 12, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peng Yu
    Replies:
    0
    Views:
    1,162
    Peng Yu
    Aug 14, 2003
  2. Sander Zuidema

    Bazix introduce One Chip FPGA computer

    Sander Zuidema, Jul 11, 2005, in forum: VHDL
    Replies:
    3
    Views:
    667
    valentin tihomirov
    Jul 16, 2005
  3. priya
    Replies:
    3
    Views:
    1,118
    Ralf Hildebrandt
    Oct 8, 2005
  4. =?Utf-8?B?UGF1bA==?=

    Introduce new filetype with httphandler

    =?Utf-8?B?UGF1bA==?=, Jun 15, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    1,284
    =?Utf-8?B?UGF1bA==?=
    Jun 15, 2005
Loading...

Share This Page