How n230881/minic-compiler works
MiniC is a small C-like language compiler with a Streamlit front end. A user submits source text; the interface writes it to a temporary file and launches the compiler, which lexes and parses it, checks semantics, generates and optimizes intermediate code, reports a control-flow graph, and executes the program when semantic checks pass. The UI presents each report and program output. The sampled source establishes the CLI’s stage calls and the optimizer/VM’s shared operator helpers; the tree and interface caption support the broader language capabilities.
Main entry points: main.c Compiler CLI · parser.c Parser · codegen.c IR generator · optimizer.c IR optimizer
Components 15
Web interface
- Streamlit interface
app.py
Language front end
- Compiler CLI
main.c - Lexer
lexer.c - Token list
token.h - Parser
parser.c - AST utilities
ast.c - AST
ast.h - Semantic checks
semantic.c
IR and analysis
- IR generator
codegen.c - IR program
codegen.h - IR optimizer
optimizer.c - CFG reporter
cfg.c
Execution
- Virtual machine
vm.c - Operator helpers
ops.c
Other components
- Program author
Connections 27
- Program author → Streamlit interface: submits source
- Streamlit interface → Compiler CLI: runs compiler
- Compiler CLI → Lexer: lexes source
- Lexer → Token list: produces tokens
- Compiler CLI → Lexer: prints tokens
- Compiler CLI → Parser: parses tokens
- Parser → Token list: reads tokens
- Parser → AST utilities: builds nodes
- AST utilities → AST: creates AST
- Parser → AST: returns AST
- Compiler CLI → AST utilities: prints AST
- Compiler CLI → Semantic checks: checks AST
- Semantic checks → AST: reads AST
- Compiler CLI → IR generator: generates IR
- IR generator → AST: reads AST
- IR generator → IR program: emits IR
- Compiler CLI → IR generator: prints IR
- Compiler CLI → IR optimizer: optimizes IR
- IR optimizer → IR program: rewrites IR
- Compiler CLI → IR optimizer: prints optimized IR
- Compiler CLI → CFG reporter: reports CFG
- CFG reporter → IR program: reads IR
- Compiler CLI → Virtual machine: runs IR
- Virtual machine → IR program: reads IR
- Virtual machine → Operator helpers: evaluates operators
- IR optimizer → Operator helpers: folds operators
- Streamlit interface → Compiler CLI: reads reports