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, 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
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2009-02-09 - ChenDing
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback