We rewrote the Tiger Compiler labs using the C++ programming language because some features in C++ like inheritance and polymorphism are more suitable for these labs and less error-prone.
We provide you all the codes of all labs at one time. In each lab, you only need to code in some of the directories.
Tiger compiler in C++ uses 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.
Tiger compiler in C++ uses namespace for modularization and uses inheritance and polymorphism to replace unions used in the old labs.
Tiger compiler in C++ uses CMake instead of Makefile to compile and build the target.
We provide you a Docker image that has already installed all the dependencies. You can compile your codes directly in this Docker image.
Install Docker.
Run a docker container and mount the lab directory on it.
# Run this command in the root directory of the project
docker run -it --privileged -p 2222:22 -v $(pwd):/home/stu/tiger-compiler yuexizou/tiger-compiler-env:tiger # or make docker-run
There are five makeable targets in total, including test_slp
, test_lex
, test_parse
, test_semant
, and tiger-compiler
.
# Run container and directly attach to it
docker run -it --privileged -p 2222:22 \
-v $(pwd):/home/stu/tiger-compiler yuexizou/tiger-compiler-env:tiger # or `make docker-run`
# Or run container in the backend and attach to it later
docker run -dt --privileged -p 2222:22 \
-v $(pwd):/home/stu/tiger-compiler yuexizou/tiger-compiler-env:tiger
docker attach ${YOUR_CONTAINER_ID}
mkdir build && cd build && cmake .. && make test_xxx # or `make build`
gdb test_xxx # e.g. `gdb test_slp`
Note: we will use -DCMAKE_BUILD_TYPE=Release
to grade your labs, so make
sure your lab passed the released version
Use make
make gradelabx
You can test all the labs by
make gradeall
Utility commands can be found in the Makefile
. They can be directly run by make xxx
in a Unix shell. Windows users cannot use the make
command, but the contents of Makefile
can still be used as a reference for the available commands.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。