interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / tilelab / parser_mutant.om

90 lines · 1493 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Host-only negative control: remove exactly one parser guard from source on stdin.
3note Mode 1 removes overflow refusal; mode 2 removes malformed-REGS propagation.
4om2
5text over "if gt v div sub ulong 0xffffffffffffffff digit 10"
6text status "if ne get argbad 0 0"
7text repl "if false"
8global source uchar 65536
9global arg uchar 1
10fn matches pos ulong mode uchar to bool
11if eq mode 49
12if gt add pos len over len source
13ret false
14end
15for j ulong len over
16if ne get source add pos j get over j
17ret false
18end
19end
20ret true
21end
22if gt add pos len status len source
23ret false
24end
25for j ulong len status
26if ne get source add pos j get status j
27ret false
28end
29end
30ret true
31end
32fn emit off ulong n ulong to void
33pos = ulong 0
34while lt pos n bound 65536
35r = write 1 source add off pos sub n pos
36if le r 0
37exit 4
38end
39pos = add pos ulong r
40end
41end
42fn main to int
43if ne argcnt 2
44ret 2
45end
46r = argread 1 arg 0 1
47if ne r 1
48ret 2
49end
50mode = get arg 0
51if and ne mode 49 ne mode 50
52ret 2
53end
54n = ulong 0
55while lt n len source bound 65536
56r = read 0 source n sub len source n
57if lt r 0
58ret 3
59end
60if eq r 0
61break
62end
63n = add n ulong r
64end
65if eq n len source
66ret 3
67end
68found = ulong 0
69where = ulong 0
70for i ulong n
71if matches i mode
72found = add found 1
73where = i
74end
75end
76if ne found 1
77ret 5
78end
79size = len status
80if eq mode 49
81size = len over
82end
83emit 0 where
84r = write 1 repl 0 len repl
85if ne r long len repl
86ret 4
87end
88emit add where size sub n add where size
89ret 0
90end