Skip to content

A compiler for the academic MINI language (essentially C with far fewer features) written in Javascript for Node

Notifications You must be signed in to change notification settings

strbean/mini-compiler

Repository files navigation

Mini compiler in JavaScript (c) 2018 Joseph Thomas

Requirements

Node.js 10.14.x here

Installation

Run npm install in root directory of project.

Usage

For complete usage information, run node ./src/js/app.js --help

To compile a mini program to ARM assembly with optimization, run node app.js all --arm -o <outfile> <infile>

A note: -O disabled optimization for some reason. It is enabled by default.

A variety of commands are provided to allow running only early phases of the compiler. For example, the parse command outputs the AST json file, and the static command takes an AST json file and performs static analysis.

Usage: all [options] <mini>

Options:

  -U, --no-collapse-double-unary  Do not collapse double-negations and double-nots
  -T, --no-type-analysis          Do not perform type analysis  
  -R, --no-return-analysis        Do not perform function return checking
  --Wall                          Enable all warnings
  --Wboolean-comparison           Warn on boolean comparison
  --stack                         Generate stack-based code
  --llvm                          Generate LLVM code
  --old-llvm                      Target old LLVM syntax
  -O, --no-optimization           Do not perform any optimization
  --no-sscp                       Do not perform Sparse Simple Constant Propagation (SSCP)
  --no-uce                        Do not perform Unused Code Elimination (SSA Unused Result)
  --no-cfg-simplification         Do not perform CFG Simplification
  --arm                           Generate ARM assembly
  -h, --help                      output usage information

Caveat

Due to time constraints (full load of CS classes) this project got sloppier as it progressed. Avoid using it as an example of the right way to do things.

About

A compiler for the academic MINI language (essentially C with far fewer features) written in Javascript for Node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published