URCC: Rochester C Compiler
Introduction
URCC is an experimental C compiler written in Ruby. A major goal is to see how small the intermediate language can be. The current version includes 2 modules and 22 classes.
To access documentation in html format, download the repository (
file:///p/compiler/repos/urcc under svn), go to
ast directory, run
rdoc *.rb, and point your browser to file
ast/doc/index.html.
Ruby rdoc does not organize classes by inheritance relations. A manually constructed class hierarchy is shown next (which may become out of date if not maintained).
Class Hierarchy
Ast module
- Ast::Node: can have one parent and any number of chidren
- Ast::Scope: representing program and file, with symbol table
- Ast::Block: code block and function body
- Ast::Func: function
- Ast::Stat: statement, i.e. anything that ends with
;
- Ast::AssignStat: assignment or just an expression (no LHS, e.g. a function call)
- Ast::GotoStat: go-to or conditional go-to
- Ast::LabelStat: target of go-to
- Ast::ReturnStat: return expression
- Ast::Expr: expression
- Ast::OpExpr: unary or binary
- Ast::Call: function call
- Ast::VarAcc: variable access
- Ast::Const: divided into Ast::NumConst and Ast::StrConst
Decl module
- Decl::Type: base type, with any number of indirection
- Decl::PrimType: primitive types
- Decl::StructType: to be implemented
- Decl::ArrayType:
- Decl::FuncType:
- Decl::Var: variable declaration, name plus Decl::Type
Topic revision: r3 - 12 Feb 2009 - 01:19:38 -
BinBao