Rewrite compiler: IR-based architecture replacing bootstrap
Replace the bootstrap mixin-based compiler with a new IR-based pipeline:
Source → Lexer → Parser → Resolver → TypeChecker → IR Builder → Optimizer → Backend
New architecture (compiler/):
- semantics/: scope resolution, type system, type checker
- ir/: intermediate representation with stable node IDs
- optimizer/: DCE via call graph BFS, CSE, constant folding
- backend/bash/: bash code generation from IR
- backend/awk/: AWK code generation sharing same IR
- symbols/: symbol table with LSP-ready serialization
Key improvements:
- Explicit shell command detection (IRCall.is_shell_cmd)
- Namespace prefixing only in bash backend, not in resolver
- DCE reduced from 580-line fixed-point to ~40-line BFS
- CSE uses stable node_id instead of Python id()
- Shell commands in assignments use || true for set -e safety
- No local keyword in global scope (when/foreach)
- Coproc uses exec to prevent orphan child processes
All 400 tests pass. Verified with real-world unified-theme-switcher service.
Showing
bootstrap/codegen.py
deleted
100644 → 0
bootstrap/dce.py
deleted
100644 → 0
bootstrap/errors.py
deleted
100644 → 0
bootstrap/lexer.py
deleted
100644 → 0
bootstrap/parser.py
deleted
100644 → 0
bootstrap/stdlib.py
deleted
100644 → 0
bootstrap/tokens.py
deleted
100644 → 0
compiler/__init__.py
0 → 100644
compiler/__main__.py
0 → 100644
compiler/backend/__init__.py
0 → 100644
compiler/backend/bash/awk.py
0 → 100644
compiler/constants.py
0 → 100644
compiler/ir/__init__.py
0 → 100644
compiler/ir/builder.py
0 → 100644
compiler/ir/nodes.py
0 → 100644
compiler/lexer/__init__.py
0 → 100644
compiler/lexer/lexer.py
0 → 100644
compiler/lexer/tokens.py
0 → 100644
compiler/meson.build
0 → 100644
File moved
compiler/optimizer/cse.py
0 → 100644
compiler/optimizer/dce.py
0 → 100644
compiler/optimizer/fold.py
0 → 100644
compiler/semantics/scope.py
0 → 100644
compiler/semantics/types.py
0 → 100644
compiler/symbols/__init__.py
0 → 100644
compiler/symbols/table.py
0 → 100644
compiler/syntax/__init__.py
0 → 100644
compiler/syntax/nodes.py
0 → 100644
compiler/syntax/parser.py
0 → 100644
Please
register
or
sign in
to comment