Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/train/omega-llm/tools/controller/normalize.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / train / omega-llm / tools / controller / normalize.om` 166 lines ยท 3540 bytes Raw Blame History 1 note normalize PROMPT [BODY]. Rewrite the signature or restore a generated body by identifier. 2 global cpwordstart ulong 16 3 global cpwordlen ulong 16 4 global cpwords ulong 1 5 global cpnames ulong 3 6 text nx "x" 7 text ny "y" 8 text na "a" 9 text nb "b" 10 text ni "items" 11 text nc "count" 12 text nd "data" 13 text nn "n" 14 fn cpfile arg ulong buf edit uchar * to ulong 15 wdpclr 16 wdpa arg 17 n = wdload 18 if or lt n 1 ge ulong n len buf 19 exit 72 20 end 21 for i ulong ulong n 22 put buf i get wdsrc i 23 end 24 ret ulong n 25 end 26 fn cpid c uchar to bool 27 ret or eq c 95 or and ge c 48 le c 57 or and ge c 65 le c 90 and ge c 97 le c 122 28 end 29 fn cpwordend buf view uchar * i ulong n ulong to ulong 30 while lt i n bound 8192 31 if not cpid get buf i 32 break 33 end 34 i = add i 1 35 end 36 ret i 37 end 38 fn samebytes a view uchar * b view uchar * to bool 39 if ne len a len b 40 ret false 41 end 42 for i ulong len a 43 if ne get a i get b i 44 ret false 45 end 46 end 47 ret true 48 end 49 global aliaslen ulong 2 50 fn setalias aliases edit uchar * k ulong v view uchar * to void 51 put aliaslen k len v 52 for j ulong len v 53 put aliases add mul k 32 j get v j 54 end 55 end 56 fn parsesig cprompt view uchar * n ulong to void 57 i = ulong 0 58 while lt i n bound 4096 59 if eq get cprompt i 10 60 break 61 end 62 i = add i 1 63 end 64 i = add i 1 65 k = ulong 0 66 while lt i n bound 4096 67 if cpid get cprompt i 68 s = i 69 i = cpwordend cprompt i n 70 if ge k 16 71 exit 72 72 end 73 put cpwordstart k s 74 put cpwordlen k sub i s 75 k = add k 1 76 else 77 i = add i 1 78 end 79 end 80 if and ne k 8 ne k 10 81 exit 72 82 end 83 put cpwords 0 k 84 put cpnames 0 2 85 put cpnames 1 sub k 4 86 end 87 fn choosealiases cprompt view uchar * aliases edit uchar * to void 88 k = get cpwords 0 89 second = false 90 if eq k 10 91 second = and samebytes part cprompt get cpwordstart get cpnames 0 get cpwordlen get cpnames 0 ni samebytes part cprompt get cpwordstart get cpnames 1 get cpwordlen get cpnames 1 nc 92 else 93 second = and samebytes part cprompt get cpwordstart get cpnames 0 get cpwordlen get cpnames 0 nx samebytes part cprompt get cpwordstart get cpnames 1 get cpwordlen get cpnames 1 ny 94 end 95 if eq k 10 96 if second 97 setalias aliases 0 nd 98 setalias aliases 1 nn 99 else 100 setalias aliases 0 ni 101 setalias aliases 1 nc 102 end 103 else 104 if second 105 setalias aliases 0 na 106 setalias aliases 1 nb 107 else 108 setalias aliases 0 nx 109 setalias aliases 1 ny 110 end 111 end 112 end 113 fn restoretoken cprompt view uchar 4096 aliases view uchar 64 v view uchar * to void 114 if samebytes v part aliases mul ulong 32 0 get aliaslen 0 115 wdot part cprompt get cpwordstart get cpnames 0 get cpwordlen get cpnames 0 116 else 117 if samebytes v part aliases mul ulong 32 1 get aliaslen 1 118 wdot part cprompt get cpwordstart get cpnames 1 get cpwordlen get cpnames 1 119 else 120 if or samebytes v part cprompt get cpwordstart get cpnames 0 get cpwordlen get cpnames 0 samebytes v part cprompt get cpwordstart get cpnames 1 get cpwordlen get cpnames 1 121 exit 75 122 end 123 wdot v 124 end 125 end 126 end 127 fn restorebody cprompt view uchar 4096 aliases view uchar 64 a view uchar * to void 128 i = ulong 0 129 while lt i len a bound 8192 130 if cpid get a i 131 s = i 132 i = cpwordend a i len a 133 restoretoken cprompt aliases part a s sub i s 134 else 135 wdoc ulong get a i 136 i = add i 1 137 end 138 end 139 end 140 fn main to int 141 if and ne argcnt 2 ne argcnt 3 142 ret 2 143 end 144 cprompt = new uchar 4096 0 145 aliases = new uchar 64 0 146 a = new uchar 8192 0 147 n = cpfile 1 cprompt 148 parsesig cprompt n 149 choosealiases cprompt aliases 150 if eq argcnt 3 151 an = cpfile 2 a 152 restorebody cprompt aliases part a 0 an 153 else 154 s = ulong 0 155 for j ulong 2 156 k = get cpnames j 157 off = get cpwordstart k 158 wdot part cprompt s sub off s 159 wdot part aliases mul ulong 32 j get aliaslen j 160 s = add off get cpwordlen k 161 end 162 wdot part cprompt s sub n s 163 end 164 wdoflush 1 165 ret 0 166 end