├── README.md ├── chap1 ├── main.c ├── makefile ├── prog1.c ├── prog1.h ├── slp.c ├── slp.h ├── util.c └── util.h ├── chap10 ├── flowgraph.h ├── graph.c └── graph.h ├── chap11 ├── color.h └── regalloc.h ├── chap12 └── runtime.c ├── chap2 ├── driver.c ├── errormsg.c ├── errormsg.h ├── makefile ├── tiger.lex ├── tokens.h ├── util.c └── util.h ├── chap3 ├── errormsg.c ├── errormsg.h ├── lex.yy.c ├── makefile ├── parsetest.c ├── tiger.grm ├── util.c ├── util.h └── y.output ├── chap4 ├── absyn.c ├── absyn.h ├── lex.yy.c ├── makefile ├── parse.c ├── parse.h ├── prabsyn.c ├── prabsyn.h ├── symbol.c ├── symbol.h ├── table.c ├── table.h └── tiger.grm ├── chap5 ├── types.c └── types.h ├── chap6 ├── temp.c └── temp.h ├── chap7 ├── printtree.c ├── printtree.h ├── tree.c └── tree.h ├── chap8 ├── canon.c └── canon.h ├── chap9 ├── assem.c ├── assem.h ├── canon.c ├── canon.h └── main.c └── testcases ├── merge.tig ├── queens.tig ├── test1.tig ├── test10.tig ├── test11.tig ├── test12.tig ├── test13.tig ├── test14.tig ├── test15.tig ├── test16.tig ├── test17.tig ├── test18.tig ├── test19.tig ├── test2.tig ├── test20.tig ├── test21.tig ├── test22.tig ├── test23.tig ├── test24.tig ├── test25.tig ├── test26.tig ├── test27.tig ├── test28.tig ├── test29.tig ├── test3.tig ├── test30.tig ├── test31.tig ├── test32.tig ├── test33.tig ├── test34.tig ├── test35.tig ├── test36.tig ├── test37.tig ├── test38.tig ├── test39.tig ├── test4.tig ├── test40.tig ├── test41.tig ├── test42.tig ├── test43.tig ├── test44.tig ├── test45.tig ├── test46.tig ├── test47.tig ├── test48.tig ├── test49.tig ├── test5.tig ├── test6.tig ├── test7.tig ├── test8.tig └── test9.tig /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/README.md -------------------------------------------------------------------------------- /chap1/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | } -------------------------------------------------------------------------------- /chap1/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap1/makefile -------------------------------------------------------------------------------- /chap1/prog1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap1/prog1.c -------------------------------------------------------------------------------- /chap1/prog1.h: -------------------------------------------------------------------------------- 1 | A_stm prog(void); 2 | -------------------------------------------------------------------------------- /chap1/slp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap1/slp.c -------------------------------------------------------------------------------- /chap1/slp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap1/slp.h -------------------------------------------------------------------------------- /chap1/util.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap1/util.c -------------------------------------------------------------------------------- /chap1/util.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap1/util.h -------------------------------------------------------------------------------- /chap10/flowgraph.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap10/flowgraph.h -------------------------------------------------------------------------------- /chap10/graph.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap10/graph.c -------------------------------------------------------------------------------- /chap10/graph.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap10/graph.h -------------------------------------------------------------------------------- /chap11/color.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap11/color.h -------------------------------------------------------------------------------- /chap11/regalloc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap11/regalloc.h -------------------------------------------------------------------------------- /chap12/runtime.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap12/runtime.c -------------------------------------------------------------------------------- /chap2/driver.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/driver.c -------------------------------------------------------------------------------- /chap2/errormsg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/errormsg.c -------------------------------------------------------------------------------- /chap2/errormsg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/errormsg.h -------------------------------------------------------------------------------- /chap2/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/makefile -------------------------------------------------------------------------------- /chap2/tiger.lex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/tiger.lex -------------------------------------------------------------------------------- /chap2/tokens.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/tokens.h -------------------------------------------------------------------------------- /chap2/util.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/util.c -------------------------------------------------------------------------------- /chap2/util.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap2/util.h -------------------------------------------------------------------------------- /chap3/errormsg.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/errormsg.c -------------------------------------------------------------------------------- /chap3/errormsg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/errormsg.h -------------------------------------------------------------------------------- /chap3/lex.yy.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/lex.yy.c -------------------------------------------------------------------------------- /chap3/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/makefile -------------------------------------------------------------------------------- /chap3/parsetest.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/parsetest.c -------------------------------------------------------------------------------- /chap3/tiger.grm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/tiger.grm -------------------------------------------------------------------------------- /chap3/util.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/util.c -------------------------------------------------------------------------------- /chap3/util.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/util.h -------------------------------------------------------------------------------- /chap3/y.output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap3/y.output -------------------------------------------------------------------------------- /chap4/absyn.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/absyn.c -------------------------------------------------------------------------------- /chap4/absyn.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/absyn.h -------------------------------------------------------------------------------- /chap4/lex.yy.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/lex.yy.c -------------------------------------------------------------------------------- /chap4/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/makefile -------------------------------------------------------------------------------- /chap4/parse.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/parse.c -------------------------------------------------------------------------------- /chap4/parse.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/parse.h -------------------------------------------------------------------------------- /chap4/prabsyn.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/prabsyn.c -------------------------------------------------------------------------------- /chap4/prabsyn.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/prabsyn.h -------------------------------------------------------------------------------- /chap4/symbol.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/symbol.c -------------------------------------------------------------------------------- /chap4/symbol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/symbol.h -------------------------------------------------------------------------------- /chap4/table.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/table.c -------------------------------------------------------------------------------- /chap4/table.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/table.h -------------------------------------------------------------------------------- /chap4/tiger.grm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap4/tiger.grm -------------------------------------------------------------------------------- /chap5/types.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap5/types.c -------------------------------------------------------------------------------- /chap5/types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap5/types.h -------------------------------------------------------------------------------- /chap6/temp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap6/temp.c -------------------------------------------------------------------------------- /chap6/temp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap6/temp.h -------------------------------------------------------------------------------- /chap7/printtree.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap7/printtree.c -------------------------------------------------------------------------------- /chap7/printtree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap7/printtree.h -------------------------------------------------------------------------------- /chap7/tree.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap7/tree.c -------------------------------------------------------------------------------- /chap7/tree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap7/tree.h -------------------------------------------------------------------------------- /chap8/canon.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap8/canon.c -------------------------------------------------------------------------------- /chap8/canon.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap8/canon.h -------------------------------------------------------------------------------- /chap9/assem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap9/assem.c -------------------------------------------------------------------------------- /chap9/assem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap9/assem.h -------------------------------------------------------------------------------- /chap9/canon.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap9/canon.c -------------------------------------------------------------------------------- /chap9/canon.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap9/canon.h -------------------------------------------------------------------------------- /chap9/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/chap9/main.c -------------------------------------------------------------------------------- /testcases/merge.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/merge.tig -------------------------------------------------------------------------------- /testcases/queens.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/queens.tig -------------------------------------------------------------------------------- /testcases/test1.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test1.tig -------------------------------------------------------------------------------- /testcases/test10.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test10.tig -------------------------------------------------------------------------------- /testcases/test11.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test11.tig -------------------------------------------------------------------------------- /testcases/test12.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test12.tig -------------------------------------------------------------------------------- /testcases/test13.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test13.tig -------------------------------------------------------------------------------- /testcases/test14.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test14.tig -------------------------------------------------------------------------------- /testcases/test15.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test15.tig -------------------------------------------------------------------------------- /testcases/test16.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test16.tig -------------------------------------------------------------------------------- /testcases/test17.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test17.tig -------------------------------------------------------------------------------- /testcases/test18.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test18.tig -------------------------------------------------------------------------------- /testcases/test19.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test19.tig -------------------------------------------------------------------------------- /testcases/test2.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test2.tig -------------------------------------------------------------------------------- /testcases/test20.tig: -------------------------------------------------------------------------------- 1 | /* error: undeclared variable i */ 2 | 3 | while 10 > 5 do (i+1;()) 4 | -------------------------------------------------------------------------------- /testcases/test21.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test21.tig -------------------------------------------------------------------------------- /testcases/test22.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test22.tig -------------------------------------------------------------------------------- /testcases/test23.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test23.tig -------------------------------------------------------------------------------- /testcases/test24.tig: -------------------------------------------------------------------------------- 1 | /* error : variable not array */ 2 | let 3 | var d:=0 4 | in 5 | d[3] 6 | end 7 | 8 | -------------------------------------------------------------------------------- /testcases/test25.tig: -------------------------------------------------------------------------------- 1 | /* error : variable not record */ 2 | let 3 | var d:=0 4 | in 5 | d.f 6 | end 7 | 8 | -------------------------------------------------------------------------------- /testcases/test26.tig: -------------------------------------------------------------------------------- 1 | /* error : integer required */ 2 | 3 | 3 + "var" 4 | -------------------------------------------------------------------------------- /testcases/test27.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test27.tig -------------------------------------------------------------------------------- /testcases/test28.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test28.tig -------------------------------------------------------------------------------- /testcases/test29.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test29.tig -------------------------------------------------------------------------------- /testcases/test3.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test3.tig -------------------------------------------------------------------------------- /testcases/test30.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test30.tig -------------------------------------------------------------------------------- /testcases/test31.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test31.tig -------------------------------------------------------------------------------- /testcases/test32.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test32.tig -------------------------------------------------------------------------------- /testcases/test33.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test33.tig -------------------------------------------------------------------------------- /testcases/test34.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test34.tig -------------------------------------------------------------------------------- /testcases/test35.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test35.tig -------------------------------------------------------------------------------- /testcases/test36.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test36.tig -------------------------------------------------------------------------------- /testcases/test37.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test37.tig -------------------------------------------------------------------------------- /testcases/test38.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test38.tig -------------------------------------------------------------------------------- /testcases/test39.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test39.tig -------------------------------------------------------------------------------- /testcases/test4.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test4.tig -------------------------------------------------------------------------------- /testcases/test40.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test40.tig -------------------------------------------------------------------------------- /testcases/test41.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test41.tig -------------------------------------------------------------------------------- /testcases/test42.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test42.tig -------------------------------------------------------------------------------- /testcases/test43.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test43.tig -------------------------------------------------------------------------------- /testcases/test44.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test44.tig -------------------------------------------------------------------------------- /testcases/test45.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test45.tig -------------------------------------------------------------------------------- /testcases/test46.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test46.tig -------------------------------------------------------------------------------- /testcases/test47.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test47.tig -------------------------------------------------------------------------------- /testcases/test48.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test48.tig -------------------------------------------------------------------------------- /testcases/test49.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test49.tig -------------------------------------------------------------------------------- /testcases/test5.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test5.tig -------------------------------------------------------------------------------- /testcases/test6.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test6.tig -------------------------------------------------------------------------------- /testcases/test7.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test7.tig -------------------------------------------------------------------------------- /testcases/test8.tig: -------------------------------------------------------------------------------- 1 | /* correct if */ 2 | if (10 > 20) then 30 else 40 3 | -------------------------------------------------------------------------------- /testcases/test9.tig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejacky/modern-compiler/HEAD/testcases/test9.tig --------------------------------------------------------------------------------