Development
Architecture
Crate layout, the IR design decisions that kill bug classes, and how to add a frontend or backend.
Workspace layout
GSETLang/
├── Cargo.toml # workspace; lto="fat", panic="abort"
├── rust-toolchain.toml # pinned (currently 1.98.1)
├── crates/
│ ├── gset-ir/ # typed IR, spans, diagnostics, lowering traits
│ ├── gset-frontend/ # Frontend trait + registry
│ │ └── python/ # (js/ts, go, java, ruby, rust, c planned)
│ ├── gset-backend/ # Backend trait + CodeWriter + capability matrix
│ │ └── go/ # (python, javascript, java, ruby planned)
│ ├── gset-semantic/ # symbols, scope, type inference
│ ├── gset-deps/ # manifests, lockfiles, resolution (planned)
│ └── gset-cli/ # bin "gset": transpile/run/version/help
├── grammars/ # tree-sitter grammar sources
├── tests/
│ ├── corpus/py/ # real-language input sources
│ └── golden/ # expected output per frontend × backend
├── docs/ # engineering plans (this site is separate)
└── packages/ manifests/ .github/workflows/Grammar crates are Cargo features rather than separate workspace members: same "don't compile what you don't use" isolation, without multiplying release plumbing.
IR design decisions that kill bug classes
- Imports are IR items and are mandatory to consume. In Go,
ast.Program.Importswas written by the parser and read by nothing — so no language ever emitted an import. In Rust,Importis anItem, andemit_moduleis required to consume it. This is whyModulehas no separateimportsfield. - A capability matrix replaces silent
return nil. Backends declareNative | Desugared | Unsupportedviacapability()before emission. The Go transpiler let six statement types (enum,struct,trait,interface, type alias,export) vanish from output with no warning. Unsupported now becomes a typed error or an explicit// gset(unsupported):marker. CodeWriterowns indentation. Go hardcodedindentUnit = " "for all five languages, which guaranteed every generated.gofile failedgofmt.
Adding a frontend
- Add the tree-sitter grammar as a dependency behind a Cargo feature.
- Implement lowering from the concrete syntax tree to the IR via the validating builder.
- Register the
Frontendin the registry keyed by language id and extension. - Add corpus inputs under
tests/corpus/<lang>/— every corpus file is asserted to contain noExprKind::Error.
Adding a backend
- Implement
Backend:id(),capability(),emit_module(). - Emit through
CodeWriter. - Clear the target-syntax gate (the target's own checker, e.g.
go vet). - Add golden files under
tests/golden/.