Back to workCompilers
MiniPascal Compiler
A Pascal subset compiler frontend and semantic analyzer written in C++.
The problem
Implementing a language parser and semantic analyzer requires deterministic grammar definition, nested scope tracking, and static type safety verification.
Approach
Built a compiler frontend using Flex for tokenization and Bison for LALR(1) syntax analysis. Constructs an Abstract Syntax Tree (AST) and traverses it using the Visitor Pattern to handle static semantic checks, type validation, and nested scope management through a custom symbol table.
At a glance
Flex + Bison
Grammar Tools
Lexer & LALR parser generator
Visitor Pattern
AST Traversal
Decoupled semantic checking
Scoped Symbol Table
Scope Model
Handles shadows & nested declarations
Stack
C++FlexBisonCompiler DesignAbstract Syntax TreesVisitor Pattern