/MiniC-Compiler

MiniC is minimalistic compiler designed as a part of the Compilers course project. This is simple and is inspired by the programming languages, Python and C.

Primary LanguageJava

MiniC Compiler

MiniC Compiler built using LLVM and Antlr parse generator as a part of the Compilers course project at IIIT Hyderabad. MiniC is a minimalistic compiler inspired by the programming languages Python and C.

Repo Structure

MiniC Compiler
|__ Language specifications manual - contains the details about Micro and Macro syntax and Semantics of MiniC.
|__ Parser - Parses MiniC expressions using Antlr Parse Generator which can be visualised in java GUI
|__ MiniC-Compiler - Complete compiler which includes Syntax Analyser, Expression Parser, AST Construction, Semantic checks, LLVM IR
|__ Sample programs written in MiniC can be found here

Installation

Antlr:

Refer to the antlr main website.You can find how to install on Linux, OS X, Windows.

PS: Make sure you put following lines in your source file(.bashrc, .zshrc etc.,)

export CLASSPATH=".:/usr/local/lib/antlr-4.8-complete.jar:$CLASSPATH"
alias antlr4='java -jar /usr/local/lib/antlr-4.8-complete.jar'
alias grun='java org.antlr.v4.gui.TestRig'
$ source ~/.bashrc

Java:

You can refer to Installation guide here.

To check if Java is installed:

$ java -version
$ javac -version

LLVM:

You can refer to Installation guide here.

Usage

To Run the GUI parser

To Compile:

$ cd parser
$ make 

To Run:

General command:

$ grun <name_of_grammar> <root_node/Start Symbol> <path_to_test_file> <option>

Command here:

$ grun Expr prog ../tests/<test_file> -gui

To Run the MiniC Compiler

To Compile:

$ cd miniC-project
$ make 

To Run:

./expr <test-code>