-
Notifications
You must be signed in to change notification settings - Fork 0
OmarArain/cstr_compiler
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
CSTR Compiler ==================== #### MPCS 51300 Compilers ##### Omar Arain #### 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 To see a printout of the Abstract Sytnax tree that is generated, run: python3 CSTR_Compiler/cstr_parser.py clean_targetfile.c assembly_file.s This will output a clean_targetfile.s file in the asm directory, which you can then compile normally with gcc. The .s file uses x86 assembly targeted to the University of Chicago linux machines available at linux1.cs.uchicago.edu. ### 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 My code currently fails on the following: - compteur.c - erato - opti.c - string.c - string2.c - string3.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 files that I wrote myself (without the aid of a script), are: - CSTR_Compiler/cstr_parser.py - CSTR_Compiler/cstr_lexer.py - CSTR_Compiler/cstr_symtab.py - CSTR_Compiler/cstr_codewriter.py - CSTR_Compiler/ast_cfg.cfg (the AST specification) I included the Python Lex-Yacc module in the CSTR_Compiler/ply_lib directory. I DID NOT WRITE THAT CODE. 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 0
No packages published