Skip to content

Compiler for CSTR, a subset of C with support for strings

Notifications You must be signed in to change notification settings

OmarArain/cstr_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.





About

Compiler for CSTR, a subset of C with support for strings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published