Assignment 1, a tiny ast interpreter for a subset of C.
mkdir build
cd build
cmake –DLLVM_DIR=your-llvm-dir -DCMAKE_BUILD_TYPE=Debug ../.
# as an example: cmake –DLLVM_DIR=/usr/local/llvm10d -DClang_DIR=/usr/local/llvm10d/lib/cmake/clang -DCMAKE_BUILD_TYPE=Debug ../.
make
//ast-interpreter will be built in dir your-project-dir/build/bin
Visualize the AST via clang:
clang -Xclang -ast-dump -fsyntax-only
Run our tiny interpreter:
./ast-interpreter "`cat ../test/test01.c`"
I write a simple script to grade the interpreter implementation. It compares the output of ast-interpreter with gcc. The official grading script(grade-official.sh
) is also provided, which is modified from grade.sh
. Run by:
source grade.sh # or grade-official.sh
You can take a look at the note.md if you are interested in implementation details.