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 / seed / omc / sites / found-stmt-1.om
| 1 | note sites: found by a one-token change of a tracked program (41 to 120 lines); reaches the omc error site in stmt (code 7) |
| 2 | note Read unsigned decimal numbers separated by spaces or newlines from stdin; print their sum. |
| 3 | global inb uchar 65536 |
| 4 | global outb uchar 32 |
| 5 | fn readall to ulong |
| 6 | n = ulong 0 |
| 7 | while lt n 65536 bound 65537 |
| 8 | k = read 0 inb n sub 65536 n |
| 9 | if lt k 0 |
| 10 | exit 2 |
| 11 | end |
| 12 | if eq k 0 |
| 13 | break |
| 14 | end |
| 15 | n = add n ulong k |
| 16 | end |
| 17 | ret n |
| 18 | end |
| 19 | fn printu v ulong to void |
| 20 | i = ulong 31 |
| 21 | put outb i 10 |
| 22 | x = v |
| 23 | while true bound 21 |
| 24 | i = sub i 1 |
| 25 | put outb i uchar add rem x 10 48 |
| 26 | x = div x 10 |
| 27 | if eq x 0 |
| 28 | break |
| 29 | end |
| 30 | end |
| 31 | off = i |
| 32 | k = write 1 outb off sub 32 off |
| 33 | if ne k long sub 32 off |
| 34 | exit true |
| 35 | end |
| 36 | end |
| 37 | text yes "yes\n" |
| 38 | text no "no\n" |
| 39 | fn main to int |
| 40 | n = readall |
| 41 | d = long 0 |
| 42 | ok = true |
| 43 | for i ulong n |
| 44 | c = get inb i |
| 45 | if eq c 40 |
| 46 | d = add d 1 |
| 47 | end |
| 48 | if eq c 41 |
| 49 | d = sub d 1 |
| 50 | if lt d 0 |
| 51 | ok = false |
| 52 | end |
| 53 | end |
| 54 | end |
| 55 | if ok |
| 56 | k = write 1 yes 0 len yes |
| 57 | else |
| 58 | k = write 1 no 0 len no |
| 59 | end |
| 60 | ret 0 |
| 61 | end |