interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / om / components / artifact_parse.om

94 lines · 1366 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Byte-at-a-time memory-shell parser. 0 continue, 1 end accepted, 2 reject, 3 component.
3note Modes 0 field text, 1 lowercase digest, 2 decimal comma list, 3 semantic version.
4note State: digits, accumulator, component, expected components, emitted value, total bytes.
5fn artifact_parse mode ulong ch ulong s edit ulong 8 to ulong
6if eq mode 4
7hi = shr ch 4
8lo = and ch 15
9if lt hi 10
10hi = add hi 48
11else
12hi = add hi 87
13end
14if lt lo 10
15lo = add lo 48
16else
17lo = add lo 87
18end
19ret or hi shl lo 8
20end
21if eq mode 0
22if eq ch 0
23ret 1
24end
25if or lt ch 32 eq ch 127
26ret 2
27end
28ret 0
29end
30if eq mode 1
31if eq ch 0
32if eq get s 0 64
33ret 1
34end
35ret 2
36end
37if ge get s 0 64
38ret 2
39end
40valid = and ge ch 48 le ch 57
41if and ge ch 97 le ch 102
42valid = true
43end
44if not valid
45ret 2
46end
47put s 0 add get s 0 1
48ret 0
49end
50if and ne mode 2 ne mode 3
51ret 2
52end
53if eq mode 2
54if ge get s 5 63
55if ne ch 0
56ret 2
57end
58end
59end
60put s 5 add get s 5 1
61if and ge ch 48 le ch 57
62if ge get s 0 9
63ret 2
64end
65put s 0 add get s 0 1
66put s 1 add mul get s 1 10 sub ch 48
67ret 0
68end
69if eq get s 0 0
70ret 2
71end
72if eq ch 0
73if ne add get s 2 1 get s 3
74ret 2
75end
76put s 4 get s 1
77ret 1
78end
79sep = ulong 44
80if eq mode 3
81sep = 46
82end
83if ne ch sep
84ret 2
85end
86if ge add get s 2 1 get s 3
87ret 2
88end
89put s 4 get s 1
90put s 0 0
91put s 1 0
92put s 2 add get s 2 1
93ret 3
94end