FunctionCraft Compiler Projects Spring 2024

This repository contains a collection of compiler projects completed as part of the PLC (Programming Language Concepts) Course at UT-CE in Spring 2024. The projects involve building a compiler for the functional programming language, FunctionCraft. Each project covers different phases of compiler construction, from lexical analysis to code generation.

Project Descriptions

  1. CA1: Lexical/Syntactic Analyzer
  2. CA2: Name Analyzer
  3. CA3: Type Analyzer
  4. CA4: Code Generation

Description: In this phase, we designed the grammar and defined lexical tokens for FunctionCraft. The lexical and syntactic analyzer parses the source code into a structured format that the compiler can process.

Features:

  • Lexical analysis: Tokenizes the input source code.
  • Syntax analysis: Checks for syntactic correctness according to the defined grammar.

Description: In this phase, we implemented a name analyzer to catch naming errors in FunctionCraft programs. The name analyzer ensures that all identifiers are declared before use and that there are no duplicate declarations in the same scope.

Features:

  • Scope management: Handles variable scopes and nested scopes.
  • Error detection: Identifies undeclared variables and duplicate declarations.

Description: This phase involves type checking and type inference for FunctionCraft, an interpreted language where types are determined at runtime. The type analyzer ensures that type rules are followed and infers the types of variables.

Features:

  • Type checking: Validates operations based on operand types.
  • Type inference: Deduces the types of variables based on usage.

Description: In the final phase, we integrated all previous phases and implemented code generation. The compiler translates FunctionCraft code into pseudo Java code using Jasmin bytecode, which is then executed on the Java Virtual Machine (JVM).

Features:

  • Integration: Combines lexical analysis, name analysis, and type analysis.
  • Code generation: Converts FunctionCraft code to Jasmin bytecode.
  • Execution: Runs the generated code on the JVM.

Contributing

Feel free to fork this repository, open issues, or submit pull requests. Any contributions are welcome!