writeonce/compiler/test/golden/tokens/representative.wo
shoney.arickathil f57844110d feat(compiler): Tasks 1-4 — scaffold, diagnostics, lexer, declaration parser
- Task 1: OCaml/dune scaffold with woc CLI (exit codes 0/1/2), just woc-build/woc-test
- Task 2: Diagnostics module — WO-E coded diagnostics with excerpts, related sites, ordered dedup collector, exit-code decision
- Task 3: Newline-significant lexer mirroring rt conventions (self/me/subscribe/insert stay idents), --dump-tokens, golden test framework with bless mode
- Task 4: Declaration parser — class/type/interface/fn signatures, @gc/@table annotations, brace-depth skip-on-block (service/policy/on), decl-level recovery, --dump-ast goldens
- 13 golden fixtures (tokens + AST) with WOC_BLESS=1 support
- just woc-test green (14 diag + 93 runner checks)
2026-08-10 09:00:08 +02:00

33 lines
651 B
Text

-- representative token fixture: comments, newlines, literals, annotations, punctuation
@table(name: "products", index: [name])
class Product {
let name: Text = "widget"
let price: Int = 42
let tags: [Text] = []
let in_stock: Bool = true
fn discounted(pct: Int) -> Int {
let cut = self.price * pct / 100
if cut >= self.price {
return 0
} else {
return self.price - cut
}
}
fn total(counts: [Int]) -> Int {
let sum = 0
for n in counts {
sum = sum + n
}
return sum
}
fn clearance() -> Bool {
let ok = self.price <= 50
while ok {
return false
}
return ok
}
}