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
omega-mv / aienux / allen / reply.om
| 1 | note SAY/WAIT parser, staged folded bytes. Native CODE receive remains separate. |
| 2 | global Say uchar 160 |
| 3 | global S ulong 5 |
| 4 | fn sayhead to bool |
| 5 | put P 0 0 |
| 6 | put P 2 0 |
| 7 | if ineq 0 87 |
| 8 | expect 87 |
| 9 | expect 65 |
| 10 | expect 73 |
| 11 | expect 84 |
| 12 | expect 32 |
| 13 | number |
| 14 | put S 0 get P 1 |
| 15 | put S 1 0 |
| 16 | put S 2 0 |
| 17 | if ne get P 0 get Inlen 0 |
| 18 | ret false |
| 19 | end |
| 20 | ret eq get P 2 0 |
| 21 | end |
| 22 | expect 83 |
| 23 | expect 65 |
| 24 | expect 89 |
| 25 | expect 32 |
| 26 | number |
| 27 | put S 0 get P 1 |
| 28 | expect 32 |
| 29 | if ne get P 2 0 |
| 30 | ret false |
| 31 | end |
| 32 | put S 1 1 |
| 33 | put S 2 1 |
| 34 | save = get P 0 |
| 35 | number |
| 36 | part = get P 1 |
| 37 | if ineq get P 0 47 |
| 38 | expect 47 |
| 39 | number |
| 40 | put S 2 get P 1 |
| 41 | expect 32 |
| 42 | if or ne get P 2 0 eq part 0 |
| 43 | ret false |
| 44 | end |
| 45 | put S 1 part |
| 46 | else |
| 47 | put P 0 save |
| 48 | put P 2 0 |
| 49 | end |
| 50 | put S 3 get P 0 |
| 51 | ret eq get P 2 0 |
| 52 | end |
| 53 | fn sayfold to bool |
| 54 | n = ulong 0 |
| 55 | p = get S 3 |
| 56 | space = true |
| 57 | while lt p get Inlen 0 |
| 58 | c = get In p |
| 59 | p = add p 1 |
| 60 | if eq c 92 |
| 61 | if or ineq p 110 ineq p 116 |
| 62 | c = 32 |
| 63 | p = add p 1 |
| 64 | end |
| 65 | end |
| 66 | if or lt c 32 ge c 127 |
| 67 | c = 32 |
| 68 | end |
| 69 | if eq c 32 |
| 70 | if not space |
| 71 | if ge n 159 |
| 72 | ret false |
| 73 | end |
| 74 | put Say n c |
| 75 | n = add n 1 |
| 76 | end |
| 77 | space = true |
| 78 | else |
| 79 | if ge n 159 |
| 80 | ret false |
| 81 | end |
| 82 | put Say n c |
| 83 | n = add n 1 |
| 84 | space = false |
| 85 | end |
| 86 | end |
| 87 | if gt n 0 |
| 88 | if eq get Say sub n 1 32 |
| 89 | n = sub n 1 |
| 90 | end |
| 91 | end |
| 92 | put S 4 n |
| 93 | ret true |
| 94 | end |
| 95 | note Return1 accepted,2 request AGAIN,3 give up after retry;0 rejected. |
| 96 | fn saytake now ulong to ulong |
| 97 | if or eq get R 1 0 gt get Inlen 0 319 |
| 98 | ret 0 |
| 99 | end |
| 100 | if not sayhead |
| 101 | ret 0 |
| 102 | end |
| 103 | if or ne get S 0 get R 0 lt now get R 4 |
| 104 | ret 0 |
| 105 | end |
| 106 | if eq get S 1 0 |
| 107 | b = heard get S 0 now |
| 108 | ret 1 |
| 109 | end |
| 110 | if not sayfold |
| 111 | ret 0 |
| 112 | end |
| 113 | if gt get R 2 1 |
| 114 | if eq get S 2 0 |
| 115 | ret 0 |
| 116 | end |
| 117 | if ne get C 0 get R 0 |
| 118 | ret 0 |
| 119 | end |
| 120 | if ne codestat 2 |
| 121 | if eq get R 13 0 |
| 122 | put R 13 1 |
| 123 | outreset |
| 124 | emitb 65 |
| 125 | emitb 71 |
| 126 | emitb 65 |
| 127 | emitb 73 |
| 128 | emitb 78 |
| 129 | emitb 32 |
| 130 | emitn get R 0 |
| 131 | ret 2 |
| 132 | end |
| 133 | cancel |
| 134 | ret 3 |
| 135 | end |
| 136 | else |
| 137 | if ne get S 1 add get R 11 1 |
| 138 | ret 0 |
| 139 | end |
| 140 | if and ne get S 2 0 ne get S 2 get S 1 |
| 141 | ret 0 |
| 142 | end |
| 143 | end |
| 144 | n = get R 8 |
| 145 | if or eq get S 1 1 gt get R 2 1 |
| 146 | n = 0 |
| 147 | end |
| 148 | join = ulong 0 |
| 149 | if and gt n 0 gt get S 4 0 |
| 150 | join = 1 |
| 151 | end |
| 152 | if gt add add n join get S 4 159 |
| 153 | ret 0 |
| 154 | end |
| 155 | if gt get R 2 1 |
| 156 | if not codeshow get R 0 |
| 157 | ret 0 |
| 158 | end |
| 159 | end |
| 160 | if eq join 1 |
| 161 | put Answer n uchar 32 |
| 162 | n = add n 1 |
| 163 | end |
| 164 | for i ulong get S 4 |
| 165 | put Answer add n i get Say i |
| 166 | end |
| 167 | put R 8 add n get S 4 |
| 168 | put R 11 get S 1 |
| 169 | put R 4 now |
| 170 | if ne get S 2 0 |
| 171 | put R 1 0 |
| 172 | histadd 1 |
| 173 | end |
| 174 | ret 1 |
| 175 | end |