game/module -> program, main -> entry, component -> property, archetype -> model, system -> handler. Done via a transitional self-hosting bootstrap: parser accepts both -> reseed -> compiler source moved to new keywords + parser tightened to new-only -> reseed (fixpoint holds). Old keywords now rejected. Token-safe corpus migration (tools/ludic-tools/rename_kw.c) leaves the LLVM @main/entry: labels in emit strings untouched; goldens byte-identical. Editor vocab (header/JetBrains/TextMate/emacs), check-docs wrapper, and doc fences updated; error string 'unknown component' -> 'unknown property'. test.sh 14/14, test-tools 28/0, check-vocabulary green. (Doc prose pass to follow.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.1 KiB
Text
37 lines
1.1 KiB
Text
# ============================================================================
|
|
# qdecl.ludic — a system whose query lives in its signature.
|
|
#
|
|
# system CleanBattle phase LateUpdate
|
|
# query (b, p) [Battle, Pos, {Foe}] where b.hp <= 0
|
|
# { … }
|
|
#
|
|
# is the same thing as writing `for (b, p) in query [...] where ... { … }` around
|
|
# the whole body — the loop header just moves into the declaration. The body runs
|
|
# once per matching entity, and self() is that entity.
|
|
# ============================================================================
|
|
program QueryDecl {
|
|
property Battle { hp: int = 0, side: int = 0 }
|
|
property Pos { x: int = 0, y: int = 0 }
|
|
model Foe { Battle, Pos }
|
|
|
|
handler Seed phase Start {
|
|
spawn Foe { Battle { hp: 3, side: 1 } }
|
|
spawn Foe { Battle { hp: 0, side: 1 } }
|
|
spawn Foe { Battle { hp: -2, side: 0 } }
|
|
}
|
|
|
|
handler CleanBattle phase LateUpdate
|
|
query (b, p) [Battle, Pos, {Foe}] where b.hp <= 0 and b.side == 1
|
|
{
|
|
print_int(p.x)
|
|
despawn self()
|
|
}
|
|
|
|
handler Census phase Render
|
|
query (b) [Battle]
|
|
{
|
|
print_int(b.hp)
|
|
}
|
|
|
|
handler Bye phase Render { quit() }
|
|
}
|