readme

来自「一个编译器修改的例子」· 代码 · 共 28 行

TXT
28
字号
This is a compiler for the Asterix language.  It consists of a front-endcompiler and a run time system (RTS).Both the compiler and the generated code are ANSI-C.  The lexical analyzeris written in Flex, the parser in Bison.  Use gmake to compile.  The use ofgcc is highly encouraged, because gcc is able to automatically generate .dfiles with file dependencies.The structure of the compiler is simple: there are declarations, expressions,statements, and types.  Each of these types has a field "subtype" whichstates the exact nature of the object.There is also a generic list type.  It is implemented as an infinitelygrowable array of void *.  C lacks generic types, so it is not possible tospecify the exact type of an element.  All elements of a list are pointersto the same type; for example a list of formal parameters containsDeclaration *, while a list of actual arguments contains Expression *.Be careful using pointers.  Whenever something goes wrong due to bad input,null pointers are used for missing expressions, unresolved types, and so on.During semantic analyses do not expect a pointer to be non-null.  The onlyexception is a pointer to a token, and to token->name, which always pointsto something valid.  If there are no lexical, parse, and semantic errors,the compiler starts generating code; in this phase one can safely assumeno null-pointers.Finally, be sure to read the comments in the header files!

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?