-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
58 lines (39 loc) · 1.4 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
CSTR Compiler
====================
#### EXAMPLE
To run my compiler:
cpp -E -P targetfile.c -o clean_targetfile.c
python3 CSTR_Compiler/cstr_parser.py clean_targetfile.c assembly_file.s
gcc clean_targetfile.s lib/lib.c -o executable
This will output a clean_targetfile.s file in the asm directory, which
you can then compile normally with gcc. The .s file is GAS x86 assembly
targeted to the University of Chicago linux machines available at
linux1.cs.uchicago.edu.
To see a printout of the Abstract Sytnax tree that is generated, run with --ast flag:
python3 CSTR_Compiler/cstr_parser.py --ast clean_targetfile.c assembly_file.s
### PASSED TESTS
My code currently passes the following tests that were provided:
- add.c
- cond.c
- div.c
- expr.c
- functions.c
- expr.c
- functions.c
- loops.c
- lsh.c
- mod.c
- mul.c
- neg.c
- rsh.c
### DEPENDENCIES AND DETAILS
I used the following tools to build my compiler:
- python (tested with python3, python2 may work)
- Python Lex-Yacc
(http://www.dabeaz.com/ply/)
- A script to generate code for an AST object in Python.
(https://github.com/eliben/pycparser/blob/master/pycparser/_ast_gen.py)
The code for my compiler, along with the Python Lex-Yacc library and
the AST generation script, are in the CSTR_Compiler directory.
The cstr_ast.py file was generated by running the make_ast.py script, which
uses the info in the ast_cfg.cfg file to generate Python code.