Skip to content

About

This project implements a multi-stage compiler for the simplified C- programming language as part of the CIS*4650 Compilers course. The compiler incrementally performs lexical analysis, syntactic analysis, semantic analysis, and code generation targeting the Tiny Machine (TM) architecture.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

CM-Compiler

A compiler for the C-minus language, built using JFlex (lexical analysis) and CUP (parser generation).

Prerequisites

  • Java
  • JFlex
  • CUP (java-cup-0.11b.jar)

Limitations

  • Global variables are not supported; all variable declarations must be within a function scope.
  • Array pointers are not supported; array declarations and indexing will not compile correctly.

Build and Test Instructions

To compile and generate the CM executable, run:

make

After that, you can run the following command to execute the compiled program:

java -cp .:/usr/share/java/java-cup-0.11b.jar CM test.cm

This will compile the test.cm file. You can replace test.cm with any C-minus source file you want to compile. Moreover, you can use the -a flag to perform syntactic analysis and output an abstract syntax tree:

java -cp .:/usr/share/java/java-cup-0.11b.jar CM test.cm -a

Flags

Flag Description
-a Perform syntactic analysis and output an abstract syntax tree (.abs file)
-s Perform type checking and output symbol tables (.sym file)
-c Compile and output TM assembly language code (.tm file)

Cleaning Up

To remove all generated files:

make clean

Acknowledgements

The CM-Compiler is based directly on the work of Fei Song.

About

This project implements a multi-stage compiler for the simplified C- programming language as part of the CIS*4650 Compilers course. The compiler incrementally performs lexical analysis, syntactic analysis, semantic analysis, and code generation targeting the Tiny Machine (TM) architecture.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages