How migikun474/compiler-design works
This is a phased C-like compiler project. The present user workflow is to provide source text to either the standalone lexer or the parser, which scans and parses directly, resolves identifier categories with scoped symbols, then reports tokens, an AST and symbols—or diagnostics on failure. Shared token vocabulary keeps lexical classifications aligned. The README describes three-address-code and MIPS stages, but marks both as not started, so they are shown as planned rather than wired into the implemented workflow. Parser relationships reflect the excerpts; unsampled phase internals are represented only where documented.
Main entry points: main.cpp Parser entry · lexer.l Flex lexer · scanner.l Parser scanner · parser.y Grammar and actions
Components 15
Lexical analysis
- Flex lexer
phase1-lexer/src/lexer.l - Token table
phase1-lexer/include/token.h - Lexical diagnostics
phase1-lexer/include/diagnostics.h
Syntax analysis
- Parser entry
phase2-parser/src/main.cpp - Parser scanner
phase2-parser/src/scanner.l - Bison token adapter
phase2-parser/src/token_converter.cpp - Grammar and actions
phase2-parser/src/parser.y - Scopes and symbols
phase2-parser/src/common.cpp - AST construction
phase2-parser/src/ast.cpp - Tokens AST symbols
phase2-parser/src/main.cpp - Syntax diagnostics
phase2-parser/src/common.cpp
Shared vocabulary
- Token vocabulary
shared/src/token_type.cpp
Planned stages
- Three-address code
phase3-ir - MIPS generation
phase4-codegen
Other components
- Source author
Connections 15
- Source author → Flex lexer: provides source
- Flex lexer → Token vocabulary: classifies with
- Flex lexer → Token table: emits tokens
- Flex lexer → Lexical diagnostics: records errors
- Source author → Parser entry: provides source
- Parser entry → Parser scanner: starts scanning
- Parser scanner → Token vocabulary: classifies with
- Parser scanner → Bison token adapter: maps token types
- Parser scanner → Grammar and actions: supplies tokens
- Grammar and actions → Scopes and symbols: resolves identifiers
- Grammar and actions → AST construction: builds syntax tree
- Grammar and actions → Syntax diagnostics: records errors
- Parser entry → Tokens AST symbols: prints reports
- Parser entry → AST construction: prints tree
- Parser entry → Scopes and symbols: prints symbols