Skip to content

Project files for building a compiler on a subset of C language (nanoC) completed as a part of the course '[CS-1319] Programming Language Design and Implementation' taught by Dr. Partha Pratim Das (PPD)

Notifications You must be signed in to change notification settings

performant23/compiler-design-nanoC

Repository files navigation

Project Overview

This repository contains the project for building a compiler for a subset of the C programming language, referred to as nanoC. The project is divided into four main parts:

1. Lexer

Description:

The lexer component tokenizes input source code written in nanoC, recognizing various token categories such as keywords, identifiers, constants, punctuators, and more. It handles comments and reports any invalid tokens encountered during the tokenization process.

Detailed Documentation

2. Parser

Description:

The parser parses the token stream generated by the lexer according to the grammar rules defined in the Bison specification. It constructs a parse tree based on the syntax of the nanoC language, performing actions specified in the grammar rules.

Detailed Documentation

3. Machine Independent Code Generation

Description:

This component translates the parse tree or syntax tree obtained from parsing into intermediate code represented as quadruples. It manages a symbol table for variable and function management, handles type checking, and generates intermediate code for expressions, statements, and control flow constructs.

Detailed Documentation

4. Target Code Generation

Description:

The target code generator takes the intermediate code generated by the machine-independent code generation phase and translates it into assembly code for the x86-64 architecture. It supports various features such as arithmetic operations, control flow statements, function calls, and more.

Detailed Documentation


Limitations

  • The project may have limitations in handling certain language constructs or error conditions.
  • Error handling and input validation may be minimal.

About

Project files for building a compiler on a subset of C language (nanoC) completed as a part of the course '[CS-1319] Programming Language Design and Implementation' taught by Dr. Partha Pratim Das (PPD)

Topics

Resources

Stars

Watchers

Forks