介绍一个C编译器ucc [英] Introduce a C Compiler ucc
问题描述
ucc是ANSI C编译器。它的代码大小约为15,000行。
词法分析器,解析器和代码生成器都是手写的。
代码结构非常清晰明了。还有一个
有趣的值编号算法。
它还有一个解释内部实现的文档。
如果你对这个编译器感兴趣,您可以从
http://sourceforge.net/projects/ucc <下载/ a>,这将帮助你掌握
C语言。
5月11日,4:15 am,dreamAnders< dream_and ... @ yahoo.com.cnwrote:
ucc是ANSI C编译器。它的代码大小约为15,000行。
词法分析器,解析器和代码生成器都是手写的。
代码结构非常清晰明了。还有一个
有趣的值编号算法。
它还有一个解释内部实现的文档。
如果你对这个编译器感兴趣,您可以从http://sourceforge.net/projects/ucc下载它,它将帮助您掌握
C语言。
你在ucc / ucl / linux / include / assert.h中执行assert不是
ANSI C,(或ISO C)因为如果没有定义NDEBUG,它会多次评估它的参数。
示例:assert(printf(" hello world \ n"));会打印两次。
我建议你重写_assert(并重命名为_Assert)返回
void,并在那里进行两次检查。 />
5月10日晚上9:15,dreamAnders< dream_and ... @ yahoo.com.cn写道:
ucc是ANSI C编译器。它的代码大小约为15,000行。
词法分析器,解析器和代码生成器都是手写的。
代码结构非常清晰明了。还有一个
有趣的值编号算法。
它还有一个解释内部实现的文档。
如果你对这个编译器感兴趣,您可以从http://sourceforge.net/projects/ucc下载它,它将帮助您掌握
C语言。
每1000行代码大约有1条评论,这可能很难获得用于研究和教学用途的
。
-
Robert Gamble
5月11日上午9:35,vipps。 .. @ gmail.com写道:
5月11日凌晨4:15,dreamAnders< dream_and ... @ yahoo.com.cnwrote:
ucc是ANSI C编译器。它的代码大小约为15,000行。
词法分析器,解析器和代码生成器都是手写的。
代码结构非常清晰明了。还有一个
有趣的值编号算法。
它还有一个解释内部实现的文档。
如果你对这个编译器感兴趣,您可以从http://sourceforge.net/projects/ucc下载它,它将帮助您掌握
C语言。
你在ucc / ucl / linux / include / assert.h中执行assert不是
ANSI C,(或ISO C)因为如果没有定义NDEBUG,它会多次评估它的参数。
示例:assert(printf(" hello world \ n"));会打印两次。
我建议你重写_assert(并重命名为_Assert)返回
void,并在那里进行两次检查。
不,它不会多次评估其参数。
#define assert(e)((void) ((e)|| _assert(#e,__ FILE __,__LINE__)))
请注意第二个e'的外观,它是''#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 from
http://sourceforge.net/projects/ucc, which will help you to master the
C language.
On May 11, 4:15 am, dreamAnders <dream_and...@yahoo.com.cnwrote: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.
On May 10, 9:15 pm, dreamAnders <dream_and...@yahoo.com.cnwrote: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
On May 11, 9:35 am, vipps...@gmail.com wrote:On May 11, 4:15 am, dreamAnders <dream_and...@yahoo.com.cnwrote:
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''
这篇关于介绍一个C编译器ucc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!