Fela C Compiler
Overview
A compiler for a subset of the C language developed to explore parser theory, abstract syntax tree (AST) construction, and low-level code generation internals. Follows the design philosophy of mainstream production compilers with a clear two-pass architecture.
Compiler Architecture
- Lexical Analysis (Lexer): Tokenizes raw C source code into typed token streams while tracking source locations for precise error reporting.
- Parsing & AST Construction: Recursive descent parsing that constructs a clean Abstract Syntax Tree representing expressions, statements, and declarations.
- Semantic Validation: Type checking, scoping resolution, and validation pass across the AST nodes.
- Current Status & Next Steps: The compiler frontend is functional; intermediate representation (LLVM IR) generation and backend code emission are currently under development.
Repository
Przegląd projektu
Kompilator podzbioru języka C stworzony w celu zgłębienia teorii parserów, budowy drzewa składniowego (AST) oraz podstaw generowania kodu maszynowego. Projekt opiera się na architekturze nowoczesnych kompilatorów z podziałem na przejścia (2-pass).
Architektura kompilatora
- Analiza leksykalna (Lexer): Przekształca kod źródłowy C na strumień tokenów ze śledzeniem pozycji w pliku pod precyzyjne komunikaty błędów.
- Parsing i budowa AST: Parser zstępujący (recursive descent) budujący drzewo AST dla wyrażeń, instrukcji i deklaracji.
- Weryfikacja semantyczna: Sprawdzanie typów, kontrola zasięgów zmiennych i walidacja węzłów AST.
- Aktualny stan i plany: Frontend kompilatora jest ukończony; w trakcie implementacji jest generowanie reprezentacji pośredniej (LLVM IR) oraz backend.