How daichikahtava/wacc-compiler works
This repository implements a WACC compiler: a source file is parsed into an AST, checked for semantic correctness, translated into AArch64 instructions, and written as assembly. Parsing and semantic errors stop the workflow before code generation. The compiler also provides runtime helper routines and register allocation support. The sampled excerpts show the main orchestration and several module interactions; links for unsampled internals are omitted rather than inferred.
Main entry points: treeWalker.scala AST translator · Main.scala Compiler entry · aarch64_formatter.scala AArch64 formatter · semantics.scala Semantic checker
Components 15
Language Frontend
- WACC lexer
src/main/wacc/lexer.scala - WACC parser
src/main/wacc/parser.scala - AST model
src/main/wacc/syntax.scala - Parser bridges
src/main/wacc/parserBridgepos.scala
Semantic Analysis
- Semantic checker
src/main/wacc/semantics.scala - Scopes and types
src/main/wacc/symTable.scala - Semantic diagnostics
src/main/wacc/semErrorReporter.scala
Code Generation
- AST translator
src/main/wacc/treeWalker.scala - Instruction model
src/main/wacc/instructions.scala - AArch64 formatter
src/main/wacc/aarch64_formatter.scala - Register configuration
src/main/wacc/registerConfig.scala - Assembly output
Runtime Support
- Runtime helpers
src/main/wacc/internalFunctions.scala
Other components
- Compiler user
- Compiler entry
src/main/wacc/Main.scala
Connections 19
- Compiler user → Compiler entry: provides source
src/main/wacc/Main.scala - Compiler entry → WACC parser: parses input
src/main/wacc/Main.scala - WACC parser → AST model: builds AST
src/main/wacc/parser.scala - AST model → WACC lexer: uses implicits
src/main/wacc/syntax.scala - AST model → Parser bridges: uses bridges
src/main/wacc/syntax.scala - Compiler entry → Semantic checker: checks AST
src/main/wacc/Main.scala - Semantic checker → Scopes and types: tracks scopes
src/main/wacc/semantics.scala - Semantic checker → Semantic diagnostics: reports errors
src/main/wacc/semantics.scala - Compiler entry → AST translator: translates AST
src/main/wacc/Main.scala - AST translator → Semantic checker: queries types
src/main/wacc/treeWalker.scala - AST translator → AArch64 formatter: registers helpers
src/main/wacc/treeWalker.scala - AST translator → Instruction model: produces instructions
src/main/wacc/treeWalker.scala - AArch64 formatter → Instruction model: formats instructions
src/main/wacc/aarch64_formatter.scala - AArch64 formatter → Register configuration: uses configuration
src/main/wacc/aarch64_formatter.scala - AST translator → Runtime helpers: requests routines
src/main/wacc/treeWalker.scala - Runtime helpers → Instruction model: defines instructions
src/main/wacc/internalFunctions.scala - Runtime helpers → Register configuration: uses configuration
src/main/wacc/internalFunctions.scala - Compiler entry → AArch64 formatter: writes assembly
src/main/wacc/Main.scala - AArch64 formatter → Assembly output: emits file
src/main/wacc/aarch64_formatter.scala