How cyiuhim/goose works
Goose is a C++20 compiler for a small language. Its documented workflow takes a source file through DFA lexing, LL(1) parsing, parse-tree-to-AST transformation, semantic analysis, and LLVM IR generation. The graph retains the documented type-checking and visitor-based backend capabilities, plus the lexer’s DFA and keyword trie and the parser’s grammar. Some implementation details were not sampled; uncertain internal links are omitted or marked unverified.
Main entry points: main.cpp Compiler entry · semantic_analyzer.cpp Semantic analysis · dfa.cpp DFA lexer · parser.cpp LL(1) parser
Components 22
Frontend
- Compiler entry
src/main.cpp - DFA lexer
src/lexer/dfa.cpp - DFA transitions
include/lexer/state_list.h - Lexer state
src/lexer/state.cpp - Keyword trie
src/lexer/trie_node.cpp - Token stream
include/symbol.h - Language grammar
include/parser/grammar.h - LL(1) parser
src/parser/parser.cpp - Concrete parse tree
include/parser/parser_node.h
AST
- AST transformer
src/tree_transformer/tree_transformer.cpp - AST nodes
src/ast_nodes - AST printer
src/tree_transformer/ast_printer.cpp
Analysis
- Semantic analysis
src/semantic_analyzer/semantic_analyzer.cpp - Type checker
src/semantic_analyzer/type_check_visitor.cpp - Type model
include/type.h - Symbol model
include/symbol.h - AST visitor
include/visitor.h
Backend
- LLVM lowering
src/semantic_analyzer/semantic_analyzer.cpp - LLVM IR
Other components
- Compiler user
- Goose source
- Native binary
Connections 24
- Compiler user → Compiler entry: runs
README.md - Goose source → Compiler entry: provides input
README.md - Compiler entry → DFA lexer: starts lexing
README.md - DFA lexer → DFA transitions: uses transitions
src/lexer/dfa.cpp - DFA transitions → Lexer state: configures states
include/lexer/state_list.h - DFA lexer → Keyword trie: checks keywords
src/lexer/dfa.cpp - DFA lexer → Token stream: produces tokens
src/lexer/dfa.cpp - Compiler entry → LL(1) parser: starts parsing
README.md - Token stream → LL(1) parser: feeds tokens
README.md - Language grammar → LL(1) parser: defines grammar
README.md - LL(1) parser → Concrete parse tree: builds tree
README.md - Compiler entry → AST transformer: starts transformation
README.md - Concrete parse tree → AST transformer: feeds tree
README.md - AST transformer → AST nodes: constructs AST
src/tree_transformer/tree_transformer.cpp - AST nodes → AST printer: prints AST
- Compiler entry → Semantic analysis: starts analysis
README.md - AST nodes → Semantic analysis: provides AST
README.md - Semantic analysis → Type checker: checks types
- Semantic analysis → Type model: uses types
- Semantic analysis → Symbol model: uses symbols
- Type checker → AST visitor: visits AST
- Semantic analysis → LLVM lowering: lowers program
README.md - LLVM lowering → LLVM IR: generates IR
README.md - LLVM IR → Native binary: generates binary
README.md