├── .gitignore ├── LICENSE.md ├── Makefile ├── README.md ├── a.s ├── a.s.txt ├── examples ├── arith_add.tac ├── arith_div.tac ├── arith_mul.tac ├── arith_sub.tac ├── arith_sub_add.tac ├── assign_int.tac ├── call.tac ├── main.tac ├── print_numbers.tac ├── shared.tac └── variables.tac ├── src ├── AST.c ├── as_frontend.c ├── asm │ ├── add.asm │ ├── bootstrap.asm │ ├── div.asm │ ├── mul.asm │ ├── root.asm │ ├── sub.asm │ └── templates │ │ ├── access.asm │ │ ├── assign_binop.asm │ │ ├── assign_call.asm │ │ ├── assign_default.asm │ │ ├── assign_int.asm │ │ ├── function_begin.asm │ │ └── int.asm ├── builtins.c ├── compiler_errors.c ├── include │ ├── AST.h │ ├── as_frontend.h │ ├── asm │ │ ├── add.h │ │ ├── bootstrap.h │ │ ├── div.h │ │ ├── mul.h │ │ ├── root.h │ │ ├── sub.h │ │ └── templates │ │ │ ├── access.h │ │ │ ├── assign_binop.h │ │ │ ├── assign_call │ │ │ ├── assign_call.h │ │ │ ├── assign_default.h │ │ │ ├── assign_int.asm │ │ │ ├── assign_int.h │ │ │ ├── function_begin.h │ │ │ └── int.h │ ├── builtins.h │ ├── compiler_errors.h │ ├── io.h │ ├── lexer.h │ ├── list.h │ ├── macros.h │ ├── main.h │ ├── parser.h │ ├── stack_frame.h │ ├── tac.h │ ├── token.h │ ├── types.h │ ├── utils.h │ └── visitor.h ├── io.c ├── lexer.c ├── list.c ├── main.c ├── parser.c ├── stack_frame.c ├── tac.c ├── token.c ├── types.c ├── utils.c └── visitor.c └── tests ├── Makefile ├── a.s ├── a.s.txt ├── main └── src ├── include ├── bootstrap.h └── main.h ├── input_files ├── arith_add.tac ├── arith_div.tac ├── arith_mul.tac ├── arith_sub.tac ├── hello_world.tac └── variables.tac ├── main.c └── output_files ├── arith_add.tac ├── arith_div.tac ├── arith_mul.tac ├── arith_sub.tac ├── hello_world.tac └── variables.tac /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/.gitignore -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/LICENSE.md -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/Makefile -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/README.md -------------------------------------------------------------------------------- /a.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/a.s -------------------------------------------------------------------------------- /a.s.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/a.s.txt -------------------------------------------------------------------------------- /examples/arith_add.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/arith_add.tac -------------------------------------------------------------------------------- /examples/arith_div.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/arith_div.tac -------------------------------------------------------------------------------- /examples/arith_mul.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/arith_mul.tac -------------------------------------------------------------------------------- /examples/arith_sub.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/arith_sub.tac -------------------------------------------------------------------------------- /examples/arith_sub_add.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/arith_sub_add.tac -------------------------------------------------------------------------------- /examples/assign_int.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/assign_int.tac -------------------------------------------------------------------------------- /examples/call.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/call.tac -------------------------------------------------------------------------------- /examples/main.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/main.tac -------------------------------------------------------------------------------- /examples/print_numbers.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/print_numbers.tac -------------------------------------------------------------------------------- /examples/shared.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/shared.tac -------------------------------------------------------------------------------- /examples/variables.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/examples/variables.tac -------------------------------------------------------------------------------- /src/AST.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/AST.c -------------------------------------------------------------------------------- /src/as_frontend.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/as_frontend.c -------------------------------------------------------------------------------- /src/asm/add.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/add.asm -------------------------------------------------------------------------------- /src/asm/bootstrap.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/bootstrap.asm -------------------------------------------------------------------------------- /src/asm/div.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/div.asm -------------------------------------------------------------------------------- /src/asm/mul.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/mul.asm -------------------------------------------------------------------------------- /src/asm/root.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/root.asm -------------------------------------------------------------------------------- /src/asm/sub.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/sub.asm -------------------------------------------------------------------------------- /src/asm/templates/access.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/templates/access.asm -------------------------------------------------------------------------------- /src/asm/templates/assign_binop.asm: -------------------------------------------------------------------------------- 1 | # assign binop 2 | movl %%eax, -%d(%%ebp) 3 | 4 | -------------------------------------------------------------------------------- /src/asm/templates/assign_call.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/templates/assign_call.asm -------------------------------------------------------------------------------- /src/asm/templates/assign_default.asm: -------------------------------------------------------------------------------- 1 | # assign default 2 | movl %%esp, -%d(%%ebp) 3 | 4 | -------------------------------------------------------------------------------- /src/asm/templates/assign_int.asm: -------------------------------------------------------------------------------- 1 | # assign (%s) 2 | popl -%d(%%ebp) 3 | 4 | -------------------------------------------------------------------------------- /src/asm/templates/function_begin.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/templates/function_begin.asm -------------------------------------------------------------------------------- /src/asm/templates/int.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/asm/templates/int.asm -------------------------------------------------------------------------------- /src/builtins.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/builtins.c -------------------------------------------------------------------------------- /src/compiler_errors.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/compiler_errors.c -------------------------------------------------------------------------------- /src/include/AST.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/AST.h -------------------------------------------------------------------------------- /src/include/as_frontend.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/as_frontend.h -------------------------------------------------------------------------------- /src/include/asm/add.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/add.h -------------------------------------------------------------------------------- /src/include/asm/bootstrap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/bootstrap.h -------------------------------------------------------------------------------- /src/include/asm/div.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/div.h -------------------------------------------------------------------------------- /src/include/asm/mul.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/mul.h -------------------------------------------------------------------------------- /src/include/asm/root.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/root.h -------------------------------------------------------------------------------- /src/include/asm/sub.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/sub.h -------------------------------------------------------------------------------- /src/include/asm/templates/access.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/access.h -------------------------------------------------------------------------------- /src/include/asm/templates/assign_binop.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/assign_binop.h -------------------------------------------------------------------------------- /src/include/asm/templates/assign_call: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/include/asm/templates/assign_call.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/assign_call.h -------------------------------------------------------------------------------- /src/include/asm/templates/assign_default.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/assign_default.h -------------------------------------------------------------------------------- /src/include/asm/templates/assign_int.asm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/include/asm/templates/assign_int.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/assign_int.h -------------------------------------------------------------------------------- /src/include/asm/templates/function_begin.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/function_begin.h -------------------------------------------------------------------------------- /src/include/asm/templates/int.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/asm/templates/int.h -------------------------------------------------------------------------------- /src/include/builtins.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/builtins.h -------------------------------------------------------------------------------- /src/include/compiler_errors.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/compiler_errors.h -------------------------------------------------------------------------------- /src/include/io.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/io.h -------------------------------------------------------------------------------- /src/include/lexer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/lexer.h -------------------------------------------------------------------------------- /src/include/list.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/list.h -------------------------------------------------------------------------------- /src/include/macros.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/macros.h -------------------------------------------------------------------------------- /src/include/main.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/include/parser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/parser.h -------------------------------------------------------------------------------- /src/include/stack_frame.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/stack_frame.h -------------------------------------------------------------------------------- /src/include/tac.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/tac.h -------------------------------------------------------------------------------- /src/include/token.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/token.h -------------------------------------------------------------------------------- /src/include/types.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/types.h -------------------------------------------------------------------------------- /src/include/utils.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/utils.h -------------------------------------------------------------------------------- /src/include/visitor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/include/visitor.h -------------------------------------------------------------------------------- /src/io.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/io.c -------------------------------------------------------------------------------- /src/lexer.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/lexer.c -------------------------------------------------------------------------------- /src/list.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/list.c -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/main.c -------------------------------------------------------------------------------- /src/parser.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/parser.c -------------------------------------------------------------------------------- /src/stack_frame.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/stack_frame.c -------------------------------------------------------------------------------- /src/tac.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/tac.c -------------------------------------------------------------------------------- /src/token.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/token.c -------------------------------------------------------------------------------- /src/types.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/types.c -------------------------------------------------------------------------------- /src/utils.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/utils.c -------------------------------------------------------------------------------- /src/visitor.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/src/visitor.c -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/Makefile -------------------------------------------------------------------------------- /tests/a.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/a.s -------------------------------------------------------------------------------- /tests/a.s.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/a.s.txt -------------------------------------------------------------------------------- /tests/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/main -------------------------------------------------------------------------------- /tests/src/include/bootstrap.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/src/include/main.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/src/input_files/arith_add.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/input_files/arith_add.tac -------------------------------------------------------------------------------- /tests/src/input_files/arith_div.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/input_files/arith_div.tac -------------------------------------------------------------------------------- /tests/src/input_files/arith_mul.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/input_files/arith_mul.tac -------------------------------------------------------------------------------- /tests/src/input_files/arith_sub.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/input_files/arith_sub.tac -------------------------------------------------------------------------------- /tests/src/input_files/hello_world.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/input_files/hello_world.tac -------------------------------------------------------------------------------- /tests/src/input_files/variables.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/input_files/variables.tac -------------------------------------------------------------------------------- /tests/src/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/main.c -------------------------------------------------------------------------------- /tests/src/output_files/arith_add.tac: -------------------------------------------------------------------------------- 1 | 25 -------------------------------------------------------------------------------- /tests/src/output_files/arith_div.tac: -------------------------------------------------------------------------------- 1 | 9 -------------------------------------------------------------------------------- /tests/src/output_files/arith_mul.tac: -------------------------------------------------------------------------------- 1 | 29 -------------------------------------------------------------------------------- /tests/src/output_files/arith_sub.tac: -------------------------------------------------------------------------------- 1 | 13 2 | hello! 3 | -------------------------------------------------------------------------------- /tests/src/output_files/hello_world.tac: -------------------------------------------------------------------------------- 1 | Hello World -------------------------------------------------------------------------------- /tests/src/output_files/variables.tac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebbekarlsson/tac/HEAD/tests/src/output_files/variables.tac --------------------------------------------------------------------------------