Compiler Project (Group 14)
This is a compiler built for a toy language as a part of the course CS F363 - Compiler Construction.
CSF363-Project

This project is a custom-built compiler designed to process a toy programming language as a part of the course CS F363 - Compiler Construction. The compiler consists of two phases, including lexical analysis and syntax analysis. It takes source code as input, processes it through these stages, and outputs either a Parse tree or meaningful error messages. The project is implemented in C.

Table of Contents:

Key Features

  • Lexical Analysis: Converts source code into tokens using a lexer.
  • Syntax Analysis: Constructs a syntax tree from the tokenized input.
  • Error Handling & Recovery: Implements strategies to detect and recover from lexical and syntax errors.

Installation:

  1. Clone the repository:
    git clone https://github.com/AbhiramHande/CSF363-Project.git
  2. Ensure you have GCC, Make, and a Linux environment installed.
  3. Run make to build the project.
  4. Run ./bin/prog.exe to execute the project.

Usage

Building the Compiler

  1. make → Compiles the project, generating prog.exe in ./bin/.
  2. make test → Compiles and runs tester.exe with test_target.exe.
  3. make docs → Rebuilds documentation and launches the website locally.
  4. make clean → Removes all object files and executables.
  5. make debug → Compiles prog.exe and runs it with gdb for debugging.
  6. make help → Displays all available options.

Running the Compiler

To execute the compiler, use:

./bin/prog.exe <testcase>.txt <output>.txt

where:

  • <testcase>.txt → Path to the file containing the source code.
  • <output>.txt → Path to the file where the generated parse tree will be saved.

Program Options

Once executed with valid arguments, the program presents a menu with the following options:

  1. Press 0 → Exit the program.
  2. Press 1 → Remove comments and display the comment-free code.
  3. Press 2 → Print the token list generated by the lexer.
  4. Press 3 → Parse the input code and display the parse tree.
  5. Press 4 → Print the total execution time of the program.

Contributors:

The contributing members are

  1. (2021B4A71134P) Abhiram H
  2. (2021B5A71159P) Ankur Renduchintala
  3. (2021B3A71111P) Avyakth Kumar
  4. (2021B1A72281P) Suchit Chebolu
  5. (2022A7PS0013P) Vikram Hariharan

References:

  • Built using concepts from Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and Ullman.