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:
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.
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.
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.
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.
- The project may have limitations in handling certain language constructs or error conditions.
- Error handling and input validation may be minimal.