|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
ArgList | An argument list is a list of expressions that are to be evaluated as actual parameters to a function call. |
ArrayRefNode | An array reference expression. |
ArrayType | |
Assembler | An object that knows how to spit out (MIPS) assembly code. |
AssignNode | Assignment statement. |
BinExprNode | Binary expression node. |
BlockNode | A sequence of statements. |
CallNode | A function call. |
CharType | |
ExprNode | Basic superclass for all expression nodes. |
FuncDefNode | A function definition. |
IdNode | Basic identifier expression. |
IfNode | A conditional. |
IntType | |
Module | This is really the toplevel container node. |
Node | The superclass of all AST Nodes. |
ParmList | Represents a formal parameter list belonging to a function definition. |
PointerType | |
RegBank | Manages a set of registers for use during code generation. |
ReturnNode | Return a value from a function. |
Scc | Entry point to the C-- compiler. |
Scope | Manages a lexical scope. |
StringValNode | String literal expression node. |
Type | Represents a type in our language. |
TypeFactory | The typefactory takes a string representation of a type and produces type objects. |
ValNode | Integer literal expression node. |
VarDecl | Represents a variable declaration. |
VarDef | Represents a variable definition in a given Scope. |
WhileNode | A while loop. |
This package contains classes for compiling Cebollita C-- programs. The compiler spits out MIPS assembly code.
java comp.parser file.cIt will create a file called file.s as well as a file called out.html which is an HTML representation of the parse tree.
java comp.parser --versionWill print out the version of the toolset.
Below are the major features/bugs/differences from C:
if
and while
are supported. The body
clauses must be surrounded by curly braces, even if there is one statement.
The following is not legal:
if (x == 10) // syntax error! y = x; while (x != 0) // syntax error! x = x - 1;The above would need to be rewritten as:
if (x == 10) { y = x; } while (x != 0) { x = x - 1; }Note that the commonly used dangling form of if-statement is illegal in C-- syntax:
if (foo) { // do one thing } else if (bar) { // do another thing } else { // do yet another thing }
extern
in a file that wishes to
reference it (as in regular C programs).
main() { char* msg = "hello there\n"; printString(msg); printInt(strlen(msg)); }
Function calls are not checked -- that is, the number and types of
arguments do not need to match the number and type of parameters. For
this reason, while external functions are allowed, they do not (should
not) need to be declared as extern
.
To return a value from a function, the reserved word return
should be used.
NO OTHER OPERATORS (eg. ++, --, ^, &, |, etc) are supported.
fact(int n) { int result = 1; while (n != 0) { result = result * n; n = n - 1; } return result; } main() { int n = 9; int result = fact(n); printString("The factorial is: "); printInt(result); }The above program would need to be linked against a library that provides the I/O functions printString and printInt.
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |