We rewrote the Tiger Compiler labs using C++ programming language. This is because C++ has some features like inheritance and polymorphism, which we think is more suitable for these labs and less error-prone.
We provide you all the codes of all labs in one time. In each lab, you only need to code in some of the directories.
The Tiger Compiler Labs are not perfect, but we have tried our best and spent a lot of time on it. If you find any bugs or have a better design, please inform us.
-
This new labs use flexc++ and bisonc++ instead of flex and bison because flexc++ and bisonc++ is more flexc++ and bisonc++ are able to generate pure C++ codes instead of C codes wrapped in C++ files.
-
The new labs use namespace for modularization and use inheritance and polymorphism to replace unions used in the old labs.
-
This new labs use CMake instead of Makefile to compile and build the target.
git clone https://ipads.se.sjtu.edu.cn:1312/lab/tiger-compiler-2019-fall.git
Note: We may update the framework codes later so you may need to do some code merging.
flexc++ and bisonc++ will be needed in lab2 and later. Although these libraries are not needed in lab1, you have to install them before you start lab1.
sudo apt install cmake g++ gcc gdb flexc++ bisonc++
For students who use MacOS or Windows, we provide you a Docker image which has already installed all the dependencies. You can compile your codes directly in this Docker image.
-
Install Docker.
-
Build the docker image using the Dockerfile that we provide.
cd tiger-compiler-2019-fall docker build -t se302/tigerlabs_env .
-
Run a docker container and mount the lab directory on it.
docker run -it --privileged -v /path/to/tiger-compiler-2019-fall:/home/stu/tiger-compiler-2019-fall se302/tigerlabs_env:latest /bin/bash cd tiger-compiler-2019-fall
mkdir build
cd build
cmake ..
make test_xxx # e.g. `make test_slp`
# in build direcotry
cmake -DCMAKE_BUILD_TYPE=Debug ..
make test_xxx # e.g. `make test_slp`
gdb test_xxx # e.g. `gdb test_slp`
# cd to the lab root directory, i.e. tiger-compiler-2019-fall
./gradelabx.sh # e.g. `./gradelab1.sh`
./handin.sh