os

An operating system
git clone https://erai.gay/code/os/
Log | Files | Refs | README | LICENSE

commit 2e5fdc2bd1ac20831c9f22b1c48ff68796d4c2a4
parent 45bbbb593e7c2aa83a8bf9b40728cf441afb1ca6
Author: erai <erai@omiltem.net>
Date:   Sun, 13 Apr 2025 14:23:31 -0400

generate correct lalr sets

Diffstat:
Mcc0.c | 73++++++++++++++++++++++++++++++++++++++-----------------------------------
Mlalr.om | 9++-------
2 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/cc0.c b/cc0.c @@ -26430,11 +26430,11 @@ b23: if (!v26) goto b20; v44 = *(u*)(vi + 48UL); v45 = ((u(*)())v43)(v44); vsym = v45; -b45: if (!vsym) goto b51; +b42: if (!vsym) goto b48; v46 = 0UL; -b52: if (!v46) goto b49; +b49: if (!v46) goto b46; return 0UL; -b49: v47 = (u)zlalr_memoset; +b46: v47 = (u)zlalr_memoset; v48 = vlc; v49 = *(u*)(vsym + 56UL); v50 = ((u(*)())v47)(v48, v49); @@ -26443,9 +26443,9 @@ b49: v47 = (u)zlalr_memoset; v52 = vsym + 0UL; v53 = ((u(*)())v51)(v52); vsym = v53; - goto b45; -b51: v46 = 1UL; - goto b52; + goto b42; +b48: v46 = 1UL; + goto b49; b20: vqueue = *(u*)(vt + 32UL); valt = *(u*)(*(u*)(*(u*)(*(u*)(vlc + 32UL) + *(u*)(vt + 40UL) * 8UL) + 48UL) + *(u*)(vt + 48UL) * 8UL); if (*(u*)(vt + 56UL) != *(u*)(valt + 8UL)) goto b26; @@ -26459,24 +26459,21 @@ b26: vsym = *(u*)(valt + 0UL) + *(u*)(vt + 56UL) * 64UL; v29 = vseen; v30 = (u)vr; v31 = ((u(*)())v27)(v28, v29, v30); - va = v31; - if (!va) goto b30; - *(u*)(va + 32UL) = vqueue; - vqueue = va; -b28: v32 = (u)zlalr_linkout; + v31; + v32 = (u)zlalr_linkout; v33 = vlc; v34 = vi + 48UL; v35 = vsym; v36 = (u)vr; v37 = ((u(*)())v32)(v33, v34, v35, v36); v37; - if (!*(u*)(vsym + 32UL)) goto b34; + if (!*(u*)(vsym + 32UL)) goto b31; goto b16; -b34: vprod = *(u*)(*(u*)(vlc + 32UL) + *(u*)(vsym + 40UL) * 8UL); +b31: vprod = *(u*)(*(u*)(vlc + 32UL) + *(u*)(vsym + 40UL) * 8UL); vj = 0UL; -b35: if (vj != *(u*)(vprod + 56UL)) goto b39; +b32: if (vj != *(u*)(vprod + 56UL)) goto b36; goto b16; -b39: *(u*)((u)vr + 40UL) = *(u*)(vsym + 40UL); +b36: *(u*)((u)vr + 40UL) = *(u*)(vsym + 40UL); *(u*)((u)vr + 48UL) = vj; *(u*)((u)vr + 56UL) = 0UL; v38 = (u)zlalr_assoc; @@ -26485,13 +26482,12 @@ b39: *(u*)((u)vr + 40UL) = *(u*)(vsym + 40UL); v41 = (u)vr; v42 = ((u(*)())v38)(v39, v40, v41); va = v42; - if (!va) goto b43; + if (!va) goto b40; *(u*)(va + 32UL) = vqueue; vqueue = va; -b41: vj = vj + 1UL; - goto b35; -b43: goto b41; -b30: goto b28; +b38: vj = vj + 1UL; + goto b32; +b40: goto b38; b22: v26 = 1UL; goto b23; b7: v18 = (u)zlalr_assoc; @@ -26543,6 +26539,10 @@ u zlalr_items(u vlc) { u v13 = 0; u v14 = 0; u v15 = 0; + u v16 = 0; + u v17 = 0; + u v18 = 0; + u v19 = 0; v3 = (u)zlalr_mkitemset; v4 = vlc; v5 = ((u(*)())v3)(v4); @@ -26553,22 +26553,25 @@ u zlalr_items(u vlc) { v9 = (u)vinit_state; v10 = ((u(*)())v6)(v7, v8, v9); v10; - *(u*)(vlc + 64UL) = vi; - *(u*)(vlc + 72UL) = vi; -b3: vi = *(u*)(vlc + 72UL); - if (!vi) goto b9; - v11 = 0UL; -b10: if (!v11) goto b7; + v11 = (u)zlalr_memoset; + v12 = vlc; + v13 = vi; + v14 = ((u(*)())v11)(v12, v13); + *(u*)(vlc + 64UL) = v14; +b4: vi = *(u*)(vlc + 72UL); + if (!vi) goto b10; + v15 = 0UL; +b11: if (!v15) goto b8; return 0UL; -b7: *(u*)(vlc + 72UL) = *(u*)(vi + 40UL); - v12 = (u)zlalr_goto; - v13 = vlc; - v14 = vi; - v15 = ((u(*)())v12)(v13, v14); - v15; - goto b3; -b9: v11 = 1UL; - goto b10; +b8: *(u*)(vlc + 72UL) = *(u*)(vi + 40UL); + v16 = (u)zlalr_goto; + v17 = vlc; + v18 = vi; + v19 = ((u(*)())v16)(v17, v18); + v19; + goto b4; +b10: v15 = 1UL; + goto b11; } u zlalr_itemsetcmp(u va, u vb) { u vx = 0; diff --git a/lalr.om b/lalr.om @@ -446,8 +446,7 @@ func lalr_items(lc: *lalr_compiler) { i = lalr_mkitemset(lc); lalr_assoc(lc, i, &init_state); - lc.root = i; - lc.goto_queue = i; + lc.root = lalr_memoset(lc, i); loop { i = lc.goto_queue; @@ -505,11 +504,7 @@ func lalr_goto(lc: *lalr_compiler, i: *lalr_itemset) { r.alt = t.alt; r.point = t.point + 1; - a = lalr_assoc(lc, seen, &r); - if a { - a.queue_next = queue; - queue = a; - } + lalr_assoc(lc, seen, &r); lalr_linkout(lc, &i.goto_out, sym, &r); if sym.term {