GSET
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

  1. Imports are IR items and are mandatory to consume. In Go, ast.Program.Imports was written by the parser and read by nothing — so no language ever emitted an import. In Rust, Import is an Item, and emit_module is required to consume it. This is why Module has no separate imports field.
  2. A capability matrix replaces silent return nil. Backends declare Native | Desugared | Unsupported via capability() 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.
  3. CodeWriter owns indentation. Go hardcoded indentUnit = " " for all five languages, which guaranteed every generated .go file failed gofmt.

Adding a frontend

  1. Add the tree-sitter grammar as a dependency behind a Cargo feature.
  2. Implement lowering from the concrete syntax tree to the IR via the validating builder.
  3. Register the Frontend in the registry keyed by language id and extension.
  4. Add corpus inputs under tests/corpus/<lang>/ — every corpus file is asserted to contain no ExprKind::Error.

Adding a backend

  1. Implement Backend: id(), capability(), emit_module().
  2. Emit through CodeWriter.
  3. Clear the target-syntax gate (the target's own checker, e.g. go vet).
  4. Add golden files under tests/golden/.

On this page