Phase 2: enforce statement separators (Rule B)
The parser now requires a newline or ';' between statements (block() in selfhost/parse.ludic); two statements may no longer sit adjacent with only spaces. Also fixed if-without-else swallowing its trailing separator. Migration: tools/ludic-tools/migrate_separators.c inserts ';' at statement boundaries corpus-wide (examples, runtime, 25 self-host fragments, ~1100 boundaries). Verified semantically identical — the migrated compiler compiles itself to IR byte-identical to the pre-migration seed, and every golden game renders identically. Reseeded to the strict compiler; C-free fixpoint holds; test.sh 14/14. Docs: Rule B documented in LANGUAGE.md; BOOTSTRAP.md R1 + stale fences updated; check-docs green across all docs. Fixed a multi-line string literal in emit_expr.ludic (byte-identical \n escape) that the C toolchain lexer mis-lexes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
985f9ad8f2
commit
eac8f8f335
35 changed files with 3861 additions and 3588 deletions
|
|
@ -25,7 +25,7 @@ system Battle phase Update {
|
|||
e.hp = e.hp - d
|
||||
setreg(R_PDMG, d)
|
||||
}
|
||||
1 => { st.guard = 1 setreg(R_PDMG, 0) }
|
||||
1 => { st.guard = 1; setreg(R_PDMG, 0) }
|
||||
2 => {
|
||||
if reg(R_POTION) > 0 {
|
||||
setreg(R_POTION, reg(R_POTION) - 1)
|
||||
|
|
@ -34,7 +34,7 @@ system Battle phase Update {
|
|||
} else { setreg(R_PDMG, 0) }
|
||||
}
|
||||
3 => {
|
||||
if rng_chance(50) { e.hp = 0 setreg(R_MODE, 0) }
|
||||
if rng_chance(50) { e.hp = 0; setreg(R_MODE, 0) }
|
||||
else { setreg(R_PDMG, 0) }
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ system Battle phase Update {
|
|||
if e.hp <= 0 {
|
||||
grant_xp(e.xp)
|
||||
setreg(R_GOLD, reg(R_GOLD) + e.xp)
|
||||
if reg(R_ETYPE) == 2 { setreg(R_BOSS, 1) setreg(R_MODE, 3) setreg(R_ACK, 0) }
|
||||
if reg(R_ETYPE) == 2 { setreg(R_BOSS, 1); setreg(R_MODE, 3); setreg(R_ACK, 0) }
|
||||
else { setreg(R_MODE, 0) }
|
||||
become KnightMenu
|
||||
} else {
|
||||
|
|
@ -85,7 +85,7 @@ system Battle phase Update {
|
|||
setreg(R_PDMG, 16)
|
||||
} else { setreg(R_PDMG, 0) }
|
||||
}
|
||||
2 => { st.guard = 1 setreg(R_PDMG, 0) }
|
||||
2 => { st.guard = 1; setreg(R_PDMG, 0) }
|
||||
}
|
||||
become MageResolve
|
||||
setreg(R_CUR, 0)
|
||||
|
|
@ -100,7 +100,7 @@ system Battle phase Update {
|
|||
if e.hp <= 0 {
|
||||
grant_xp(e.xp)
|
||||
setreg(R_GOLD, reg(R_GOLD) + e.xp)
|
||||
if reg(R_ETYPE) == 2 { setreg(R_BOSS, 1) setreg(R_MODE, 3) setreg(R_ACK, 0) }
|
||||
if reg(R_ETYPE) == 2 { setreg(R_BOSS, 1); setreg(R_MODE, 3); setreg(R_ACK, 0) }
|
||||
else { setreg(R_MODE, 0) }
|
||||
become KnightMenu
|
||||
} else {
|
||||
|
|
@ -116,7 +116,7 @@ system Battle phase Update {
|
|||
if done == 0 {
|
||||
if t3.hp > 0 {
|
||||
let ed = max(1, e.atk - t3.def + rng_range(0, 4))
|
||||
if t3.guard == 1 { ed = ed / 2 t3.guard = 0 }
|
||||
if t3.guard == 1 { ed = ed / 2; t3.guard = 0 }
|
||||
t3.hp = t3.hp - ed
|
||||
setreg(R_EDMG, ed)
|
||||
done = 1
|
||||
|
|
@ -127,7 +127,7 @@ system Battle phase Update {
|
|||
for (t4) in query [Stats, {Party}] {
|
||||
if t4.hp > 0 { alive = alive + 1 }
|
||||
}
|
||||
if alive == 0 { setreg(R_MODE, 2) setreg(R_ACK, 0) }
|
||||
if alive == 0 { setreg(R_MODE, 2); setreg(R_ACK, 0) }
|
||||
else {
|
||||
become KnightMenu
|
||||
setreg(R_CUR, 0)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
game SceneDemo {
|
||||
const R_N: int = 0
|
||||
|
||||
system Boot phase Start { setreg(R_N, 0) print_int(1000) }
|
||||
system Boot phase Start { setreg(R_N, 0); print_int(1000) }
|
||||
|
||||
scene Title start {
|
||||
on enter { print_int(1) }
|
||||
|
|
@ -22,7 +22,7 @@ game SceneDemo {
|
|||
}
|
||||
|
||||
scene Play {
|
||||
on enter { print_int(3) setreg(R_N, 0) }
|
||||
on enter { print_int(3); setreg(R_N, 0) }
|
||||
on exit { print_int(4) }
|
||||
layer World {
|
||||
system Step phase Update {
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ game Snake {
|
|||
|
||||
fn reset(x: int) -> int {
|
||||
for (p, s) in query [Pos, Seg] { despawn self() }
|
||||
spawn S0 { Seg = { order = 0 } Pos = { x = 10, y = 7 } }
|
||||
spawn S1 { Seg = { order = 1 } Pos = { x = 9, y = 7 } }
|
||||
spawn S2 { Seg = { order = 2 } Pos = { x = 8, y = 7 } }
|
||||
spawn S0 { Seg = { order = 0 }; Pos = { x = 10, y = 7 } }
|
||||
spawn S1 { Seg = { order = 1 }; Pos = { x = 9, y = 7 } }
|
||||
spawn S2 { Seg = { order = 2 }; Pos = { x = 8, y = 7 } }
|
||||
setreg(R_DIR, 3)
|
||||
setreg(R_LEN, 3)
|
||||
setreg(R_TICK, 0)
|
||||
|
|
@ -62,7 +62,7 @@ game Snake {
|
|||
setreg(R_TICK, 0)
|
||||
let len = reg(R_LEN)
|
||||
for (pt, stg) in query [Pos, Seg] {
|
||||
if stg.order == len - 1 { setreg(R_TX, pt.x) setreg(R_TY, pt.y) }
|
||||
if stg.order == len - 1 { setreg(R_TX, pt.x); setreg(R_TY, pt.y) }
|
||||
}
|
||||
for step in 0 .. len {
|
||||
let i = len - 1 - step
|
||||
|
|
@ -70,7 +70,7 @@ game Snake {
|
|||
for (pa, sa) in query [Pos, Seg] {
|
||||
if sa.order == i {
|
||||
for (pb, sb) in query [Pos, Seg] {
|
||||
if sb.order == i - 1 { pa.x = pb.x pa.y = pb.y }
|
||||
if sb.order == i - 1 { pa.x = pb.x; pa.y = pb.y }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ game Snake {
|
|||
}
|
||||
if reg(R_ATE) == 1 {
|
||||
setreg(R_SCORE, reg(R_SCORE) + 1)
|
||||
spawn Body { Seg = { order = len } Pos = { x = reg(R_TX), y = reg(R_TY) } }
|
||||
spawn Body { Seg = { order = len }; Pos = { x = reg(R_TX), y = reg(R_TY) } }
|
||||
setreg(R_LEN, len + 1)
|
||||
setreg(R_FX, rng_range(0, GW - 1))
|
||||
setreg(R_FY, rng_range(0, GH - 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue