26 Star 5 Fork 1

华东师范大学计算机拔尖基地2.0 / tiger-compiler-24sp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Tiger Compiler Labs in C++

Overview

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.

Difference Between C Labs and C++ Labs

  1. 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.

  2. Tiger compiler in C++ uses namespace for modularization and uses inheritance and polymorphism to replace unions used in the old labs.

  3. Tiger compiler in C++ uses CMake instead of Makefile to compile and build the target.

Installing Dependencies

We provide you a Docker image that has already installed all the dependencies. You can compile your codes directly in this Docker image.

  1. Install Docker.

  2. 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

Compiling and Debugging

There are five makeable targets in total, including test_slp, test_lex, test_parse, test_semant, and tiger-compiler.

  1. Run container environment and attach to it
# 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}
  1. Build in the container environment
mkdir build && cd build && cmake .. && make test_xxx  # or `make build`
  1. Debug using gdb or any IDEs
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

Testing Your Labs

Use make

make gradelabx

You can test all the labs by

make gradeall

Other Commands

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.

空文件

简介

Tiger Compiler source code for 24sp modern compiler implementation course. 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/east-china-normal-university_ttb_cs/tiger-compiler-24sp.git
git@gitee.com:east-china-normal-university_ttb_cs/tiger-compiler-24sp.git
east-china-normal-university_ttb_cs
tiger-compiler-24sp
tiger-compiler-24sp
lab5-2

搜索帮助