(* README * Author: Frank Pfenning <fp@cs.cmu.edu> * Modified: Anand Subramanian <asubrama@andrew.cmu.edu> * Modified for Haskell: Rokhini Prabhu <rokhinip@andrew.cmu.edu> *) ----------------------------------------------------------------------- Welcome to 15-411! ----------------------------------------------------------------------- This is some starter code for the L1 compiler you have to build for the Lab1. It contains a lexer, parser, translator, and even a code generator, except that the code generator creates pseudo assembly language with fictitious instructions and an unlimited number of registers. We took some care to use good style (according to the instructor); you may consider this a model for your own coding. Feel free to modify any and all of this code as you see fit. Bug reports to the course staff are particularly welcome and will be noted in the extra credit category. ----------------------------------------------------------------------- Haskell Notes ----------------------------------------------------------------------- This starter code assumes GHC 7.6.3 which is the version on AFS. Please make sure your code compiles under specifically the version installed on the lab machines where it can be invoked simply with "ghci" in a shell. ------------------------------------------------------------------------ Source Files ------------------------------------------------------------------------ The following are the source files for the L1 compiler README -- this file c0c.cabal -- This is the configuration for the standard package system for Haskell software. Makefile -- makefile for the compiler For a quick test % make l1c (generates file bin/l1c) % bin/l1c ../tests0/return01.l1. should generate ../tests0/test1.s in pseudo assembly % make clean (removes generated files) bin/l1c -- the native executable generated by Haskell src/ Source code for the compiler c0c This is effectively main() function for your compiler Compile This does all the steps necessary in your compiler - from parsing till writng out assembly to a file Args Parses command line arguments LiftIOE Utility helper functions Util Utility helper functions Compile/ Parse parser CheckAST typechecker CodeGen code generation - conversion to abstract assembly Types includes all the types specified in Types/ folder Types/ Includes the data structures and types used in the code in Compile/ AST Abstract Syntax Tree from parsing AbstractAssembly The assembly produced by code generation Ops The binops and monops used in AST and AbstractAssembly Jobs Each source code file you parse is its own job Text/ Libraries used for Parsec ------------------------------------------------------------------------ Debugging Hints ------------------------------------------------------------------------ You can pass different arguments to your binary so that it produces outputs of different forms. -S Abstract Assembly format -c ELF intermediate format -E C0 pretty printing after parsing and typechecking -e Full fledged ELF executable to run Feel free to add your own arguments and output them at different stages of your compiler.