Index of /theses/cinf
      Name                    Last modified       Size  Description

[DIR] Parent Directory 12-May-2008 10:33 - [TXT] LICENSE.txt 06-Jun-2006 15:45 1k [DIR] backend/ 06-Jun-2006 15:45 - [   ] cinf.rb 06-Jun-2006 15:45 3k [DIR] common/ 06-Jun-2006 15:45 - [DIR] frontend/ 06-Jun-2006 15:45 - [DIR] tree/ 06-Jun-2006 15:45 -

This compiler is written in Ruby and requires the Rex and Racc lexer
and parser generators.

Setup for Ruby on Linux or other Unix-like OSes:
- install Ruby and the corresponding 
  development package(s) through your distribution's package manager
- ensure that you have a working C compiler

Setup for Ruby on OS X:
 - Install the Apple Developer Tools

Once you've done that, download Racc:

mkdir ~/tmp
cd ~/tmp
curl http://i.loveruby.net/archive/racc/racc-1.4.5-all.tar.gz | tar xfz -
cd racc-1.4.5-all
ruby setup.rb config
ruby setup.rb setup
sudo ruby setup.rb install

If this step fails on OS X, you have a broken version of Ruby. Do the
following to remedy it:

cd ~/tmp
curl http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgz | tar xfz -
cd rubygems-0.8.10
sudo ruby setup.rb
sudo gem install fixrbconfig
sudo fixrbconfig

Once you have Racc installed, install Rex:
cd ~/tmp
curl http://homepage1.nifty.com/arima/ruby/rex-0.9.tar.gz | tar xfz -
cd rex
ruby setup.rb config
ruby setup.rb setup
sudo ruby setup.rb install

We need one last thing before we can really get going with Cinf and
that is the SPIM simulator to run the compiler's output on.

cd ~/tmp
curl http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz | tar xfz -
cd spim-7.2.1

To install the X11 version of SPIM with a graphical interface:

cd xspim
xmkmf
make
sudo make install

To install the plain console version:
cd spim
make
sudo make install


Now, cd back to the directory where you unpacked the Cinf sources so
we can build the lexical analyzer and parser:

cd frontend/
rex cinf.rl

If you get a message like ".: Bad interpreter", it is an OSX bug that
is much too tedious to fix to be worth going into the details of
here. A workaround  is to simply:

ruby /usr/bin/rex cinf.rl

instead.

Now, run: 
racc -v -g cinf.ry

It will warn of "1 reduce/reduce conflict." This is all right.

Now, cd back into the root directory of the Cinf source tree. The
compiler is cinf.rb; to run it and see the usage message:

chmod +x cinf.rb
./cinf.rb --help

To compile a file called program.cinf:

./cinf.rb program.cinf

To run the output program.s:

xspim -file program.s


A sample program is available online at
http://crossproduct.net/~adam/f2c2.s. It sits in a loop converting
temperatures from Fahrenheit to Celsius.