Project for CSC 255/455, Ruby Track (using URCC), Spring 2009


We are glad to announce that our URCC code is ready for Project Part 2 as of Feb. 11. As Chen said in the class, you have a week for this assignment. Counting from Feb. 12, the deadline for Part 2 is set for Feb. 18. You may request further extensions by sending both Instructor and TA an email with reasons for the request.

URCC is an experimental C compiler written in Ruby. It provides the font-end and back-end for the compiler project. The front-end takes a C file as input, calls GCC (version 4.2.x) to generate a gimple raw format file, parses the gimple file into rawEntries, and converts rawEntries to the intermediate language. (Ast/Decl modules). The back-end transforms the URCC intermediate form back into a C program and calls GCC to compile the new C file into executable. Optimization is done on the URCC intermediate representation, between the front-end and the back-end.

See RochesterCCompiler for the class hierarchy of the URCC intermediate form, i.e. the Ast/Decl modules, and instructions for generating class/method documentation in html using rdoc.

Check out, Installation and Run

  • Check out the code from file:///p/compiler/repos/urcc by using subversion. Undergrads can get a copy from /home/hoover/u1/cs255/urcc.tar.bz2, which is from version 26. Our URCC is still under development, more bug fixings and improvements are expected in the future. We will send out notices when we have major updates. Then svn update can always get the latest version, and also we will update the corresponding copy in cs255 account.
  • Our top directory has a How_To_Install file to provide instructions for installation. Basically, in order to use urcc from directories other than urcc, you need to add the bin directory into your environment variable PATH, and add the ast directory into your RUBYLIB, which the Ruby interpreter uses to search for needed modules. For instance, you have the top directory, urcc, under your home directory, and you are using C Shell. Add the following lines into your .cshrc file
       setenv PATH "$PATH":"$HOME/urcc/bin"
       setenv RUBYLIB "$HOME/urcc/ast"
  • If you are working on the undergrad network, you need to change ast/driver.rb file to specify your own GCC 4.2.2 directory (what you built in Project Part 1), since the default GCC 4.1.2 does not well. (The default GCC on grad network works fine.) In ast/driver.rb, replace the gcc invocation to use a copy of GCC 4.2.x. We suggest you use the GCC you built in the last assignment.
  • To Run URCC, just type urcc following with your file name, e.g. urcc ab.c. By default, it will generate a ab.c.*.gimple file, the c file generated by urcc ab_urcc.c, and the binary file ab.

Where to Start


  • You can use "ruby -rdebug" to run the interpreter in debugging mode. See this section of the Thomas-Hunt book. There are gdb like commands to set breakpoints.
  • Most convenient is to use the interactive Ruby shell, irb, and insert p or print to print the values you care. If you have more systematic solutions to debugging, please share.

Reporting problems

  • If you find any bug in our code, please post to the class discussion page CS255Spring09Discussions with a description and your test case. Even better if you can post fixes.
  • Known Problems
    • Insert Ast::Const nodes with the same numeric value will cause problem. Thus we have slightly changed the loop.c for Project Part 2. We will provide a solution soon.
    • If the end of the string is "\n", sometimes we will lose it during the transformation. This might cause problem for scanf. E.g. run ab we generated from ab.c will require any extra input after providing two numbers. Under fixing.
    • Array supporting will come soon.


Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2009-02-12 - 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