yeptris 0.6.18.2-arm-linux-eabihf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.adoc +141 -0
- data/ext/build_windows_native.rb +41 -0
- data/ext/libyeptris/extconf.rb +57 -0
- data/ext/yeptris_native/cbor_ruby.c +193 -0
- data/ext/yeptris_native/extconf.rb +47 -0
- data/ext/yeptris_native/json_ruby.c +354 -0
- data/ext/yeptris_native/yeptris_native.c +497 -0
- data/lib/yeptris/cbor.rb +130 -0
- data/lib/yeptris/document.rb +255 -0
- data/lib/yeptris/ffi.rb +426 -0
- data/lib/yeptris/json/descriptor.rb +266 -0
- data/lib/yeptris/json.rb +394 -0
- data/lib/yeptris/materializer.rb +354 -0
- data/lib/yeptris/native-3.4.so +0 -0
- data/lib/yeptris/node.rb +453 -0
- data/lib/yeptris/psych/class_loader.rb +24 -0
- data/lib/yeptris/psych/coder_shim.rb +55 -0
- data/lib/yeptris/psych/drop_in.rb +63 -0
- data/lib/yeptris/psych/encodable.rb +14 -0
- data/lib/yeptris/psych/handler.rb +90 -0
- data/lib/yeptris/psych/parser.rb +105 -0
- data/lib/yeptris/psych/scalar_scanner.rb +149 -0
- data/lib/yeptris/psych/visitors.rb +545 -0
- data/lib/yeptris/psych.rb +622 -0
- data/lib/yeptris/schema.rb +253 -0
- data/lib/yeptris/valueml.rb +455 -0
- data/lib/yeptris/yaml/descriptor.rb +56 -0
- data/lib/yeptris/yaml.rb +422 -0
- data/lib/yeptris.rb +113 -0
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +254 -0
- data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
- data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
- data/vendor/libyeptris/src/CMakeLists.txt +167 -0
- data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
- data/vendor/libyeptris/src/include/yeptris/cbor.h +101 -0
- data/vendor/libyeptris/src/include/yeptris/dom.h +190 -0
- data/vendor/libyeptris/src/include/yeptris/emit.h +81 -0
- data/vendor/libyeptris/src/include/yeptris/error.h +41 -0
- data/vendor/libyeptris/src/include/yeptris/events.h +157 -0
- data/vendor/libyeptris/src/include/yeptris/json.h +45 -0
- data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
- data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
- data/vendor/libyeptris/src/include/yeptris/marshal.h +52 -0
- data/vendor/libyeptris/src/include/yeptris/parse.h +48 -0
- data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +71 -0
- data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
- data/vendor/libyeptris/src/include/yeptris/tape.h +123 -0
- data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
- data/vendor/libyeptris/src/include/yeptris/values.h +102 -0
- data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
- data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
- data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
- data/vendor/libyeptris/src/include/yeptris.h +23 -0
- data/vendor/libyeptris/src/yeptris/build.c +376 -0
- data/vendor/libyeptris/src/yeptris/cbor/cbor.h +25 -0
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +981 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +835 -0
- data/vendor/libyeptris/src/yeptris/cbor/sink.h +58 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
- data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
- data/vendor/libyeptris/src/yeptris/common/error.h +79 -0
- data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
- data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.h +295 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +534 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +662 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +298 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
- data/vendor/libyeptris/src/yeptris/doc.h +56 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +1192 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +312 -0
- data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
- data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
- data/vendor/libyeptris/src/yeptris/emit/emit.c +434 -0
- data/vendor/libyeptris/src/yeptris/emit/float/api.h +38 -0
- data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
- data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
- data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
- data/vendor/libyeptris/src/yeptris/emit/style.c +81 -0
- data/vendor/libyeptris/src/yeptris/emit/style.h +24 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +816 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.h +76 -0
- data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
- data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
- data/vendor/libyeptris/src/yeptris/encoding/transcode.c +148 -0
- data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
- data/vendor/libyeptris/src/yeptris/events/capture.c +150 -0
- data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
- data/vendor/libyeptris/src/yeptris/events/iterparse.c +208 -0
- data/vendor/libyeptris/src/yeptris/events/pull.c +97 -0
- data/vendor/libyeptris/src/yeptris/events/push.c +104 -0
- data/vendor/libyeptris/src/yeptris/events/recorder.c +107 -0
- data/vendor/libyeptris/src/yeptris/events/values.c +527 -0
- data/vendor/libyeptris/src/yeptris/events/values_priv.h +51 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
- data/vendor/libyeptris/src/yeptris/marshal.c +782 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.c +134 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.c +122 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +3698 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.h +65 -0
- data/vendor/libyeptris/src/yeptris/parse/events.h +124 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.c +349 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.c +416 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.h +75 -0
- data/vendor/libyeptris/src/yeptris/parse.c +737 -0
- data/vendor/libyeptris/src/yeptris/plan.c +824 -0
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +334 -0
- data/vendor/libyeptris/src/yeptris/resolve/core12.c +143 -0
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +56 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +58 -0
- data/vendor/libyeptris/src/yeptris/scan/json.c +792 -0
- data/vendor/libyeptris/src/yeptris/scan/json.h +109 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +463 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.h +150 -0
- data/vendor/libyeptris/src/yeptris/schema.c +308 -0
- data/vendor/libyeptris/src/yeptris/tape.c +1308 -0
- data/vendor/libyeptris/src/yeptris/tape_in.h +19 -0
- data/vendor/libyeptris/src/yeptris/version.c +7 -0
- data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
- data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
- data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
- metadata +199 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/* compat11.c — libyaml/Psych 1.1 implicit semantics (TODO.impl/10).
|
|
2
|
+
*
|
|
3
|
+
* The oracle is psych's scalar_scanner.rb; every divergence is a
|
|
4
|
+
* compat bug (15's ported tests enforce it):
|
|
5
|
+
* bool: y/Y/yes/on/true/n/N/no/off/false, any case pattern psych
|
|
6
|
+
* matches (/^(yes|true|on)$/i family)
|
|
7
|
+
* int: decimal with _, 0b binary, leading-0 octal, 0x hex
|
|
8
|
+
* float: psych FLOAT + sexagesimal ints/floats + .inf/.nan
|
|
9
|
+
* timestamp: the yaml.org timestamp production (plus plain dates)
|
|
10
|
+
* '=' is the value tag; '<<' is merge (grammar-level anyway)
|
|
11
|
+
* else str.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#include <stdint.h>
|
|
15
|
+
#include <string.h>
|
|
16
|
+
|
|
17
|
+
#include "resolver.h"
|
|
18
|
+
|
|
19
|
+
static int eq(const char* p, uint32_t n, const char* s) {
|
|
20
|
+
uint32_t m = 0;
|
|
21
|
+
while (s[m] != '\0') {
|
|
22
|
+
m++;
|
|
23
|
+
}
|
|
24
|
+
return n == m && (n == 0 || memcmp(p, s, n) == 0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static int ci_eq3(const char* p, uint32_t n, const char* s) {
|
|
28
|
+
/* case-insensitive match (psych's /i booleans) */
|
|
29
|
+
uint32_t m = 0;
|
|
30
|
+
while (s[m] != '\0') {
|
|
31
|
+
m++;
|
|
32
|
+
}
|
|
33
|
+
if (n != m) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
for (uint32_t k = 0; k < n; k++) {
|
|
37
|
+
char a = p[k], b = s[k];
|
|
38
|
+
if (a >= 'A' && a <= 'Z') {
|
|
39
|
+
a = (char)(a - 'A' + 'a');
|
|
40
|
+
}
|
|
41
|
+
if (b >= 'A' && b <= 'Z') {
|
|
42
|
+
b = (char)(b - 'A' + 'a');
|
|
43
|
+
}
|
|
44
|
+
if (a != b) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static int is_digits_us(const char* p, uint32_t n) {
|
|
52
|
+
if (n == 0) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
for (uint32_t k = 0; k < n; k++) {
|
|
56
|
+
if (!((p[k] >= '0' && p[k] <= '9') || p[k] == '_')) {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return p[0] != '_';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static yep_tag_id compat11(void* ctx, const char* p, uint32_t n) {
|
|
64
|
+
(void)ctx;
|
|
65
|
+
if (n == 0 || eq(p, n, "~") || ci_eq3(p, n, "null")) {
|
|
66
|
+
return 4; /* null: psych nil for ""/"~"/null (any case) */
|
|
67
|
+
}
|
|
68
|
+
if (ci_eq3(p, n, "yes") || ci_eq3(p, n, "true") || ci_eq3(p, n, "on") || ci_eq3(p, n, "y")) {
|
|
69
|
+
return 3;
|
|
70
|
+
}
|
|
71
|
+
if (ci_eq3(p, n, "no") || ci_eq3(p, n, "false") || ci_eq3(p, n, "off") || ci_eq3(p, n, "n")) {
|
|
72
|
+
return 3;
|
|
73
|
+
}
|
|
74
|
+
if (eq(p, n, "=")) {
|
|
75
|
+
return 10; /* value */
|
|
76
|
+
}
|
|
77
|
+
if (eq(p, n, "<<")) {
|
|
78
|
+
return 9; /* merge */
|
|
79
|
+
}
|
|
80
|
+
uint32_t i = 0;
|
|
81
|
+
if (p[0] == '-' || p[0] == '+') {
|
|
82
|
+
i = 1;
|
|
83
|
+
}
|
|
84
|
+
if (i >= n) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
/* timestamps: full production first (psych TIME), then plain dates */
|
|
88
|
+
{
|
|
89
|
+
/* -?dddd-dd-dd([Tt ]dd:dd:dd(.d*)?(Z|+dd(:dd)?|+d)?)? — the
|
|
90
|
+
* date-only form handled after; conservative core check */
|
|
91
|
+
uint32_t k = i;
|
|
92
|
+
int digs = 0;
|
|
93
|
+
while (k < n && p[k] >= '0' && p[k] <= '9' && digs < 4) {
|
|
94
|
+
k++;
|
|
95
|
+
digs++;
|
|
96
|
+
}
|
|
97
|
+
if (digs == 4 && k + 1 < n && p[k] == '-') {
|
|
98
|
+
k++;
|
|
99
|
+
int m1 = 0;
|
|
100
|
+
while (k < n && p[k] >= '0' && p[k] <= '9' && m1 < 2) {
|
|
101
|
+
k++;
|
|
102
|
+
m1++;
|
|
103
|
+
}
|
|
104
|
+
if (m1 >= 1 && k + 1 < n && p[k] == '-') {
|
|
105
|
+
k++;
|
|
106
|
+
int m2 = 0;
|
|
107
|
+
while (k < n && p[k] >= '0' && p[k] <= '9' && m2 < 2) {
|
|
108
|
+
k++;
|
|
109
|
+
m2++;
|
|
110
|
+
}
|
|
111
|
+
if (m2 >= 1) {
|
|
112
|
+
if (k == n) {
|
|
113
|
+
return 5; /* date */
|
|
114
|
+
}
|
|
115
|
+
if (p[k] == 'T' || p[k] == 't' || p[k] == ' ') {
|
|
116
|
+
/* time part: dd:dd:dd required */
|
|
117
|
+
k++; /* consume the separator */
|
|
118
|
+
int ok = 1;
|
|
119
|
+
int f[3] = {0, 0, 0};
|
|
120
|
+
int fi = 0;
|
|
121
|
+
int seen_colon = 0;
|
|
122
|
+
while (k < n) {
|
|
123
|
+
char c = p[k];
|
|
124
|
+
if (c == ':') {
|
|
125
|
+
if (f[fi] < 1 || f[fi] > 2 || fi >= 2) {
|
|
126
|
+
ok = 0;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
seen_colon = 1;
|
|
130
|
+
fi++;
|
|
131
|
+
k++;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (c >= '0' && c <= '9' && fi <= 2) {
|
|
135
|
+
f[fi]++;
|
|
136
|
+
if (f[fi] > 2) {
|
|
137
|
+
ok = 0;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
k++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (ok && seen_colon && fi == 2 && f[2] == 2) {
|
|
146
|
+
/* optional .frac, Z or offset */
|
|
147
|
+
if (k < n && p[k] == '.') {
|
|
148
|
+
k++;
|
|
149
|
+
int fd = 0;
|
|
150
|
+
while (k < n && p[k] >= '0' && p[k] <= '9') {
|
|
151
|
+
k++;
|
|
152
|
+
fd++;
|
|
153
|
+
}
|
|
154
|
+
if (fd == 0) {
|
|
155
|
+
ok = 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
while (ok && k < n && p[k] == ' ') {
|
|
159
|
+
k++; /* psych: \s* before the zone */
|
|
160
|
+
}
|
|
161
|
+
if (ok && k < n) {
|
|
162
|
+
if (p[k] == 'Z') {
|
|
163
|
+
k++;
|
|
164
|
+
} else if (p[k] == '+' || p[k] == '-') {
|
|
165
|
+
k++;
|
|
166
|
+
int od = 0;
|
|
167
|
+
while (k < n && ((p[k] >= '0' && p[k] <= '9') ||
|
|
168
|
+
(od == 2 && p[k] == ':'))) {
|
|
169
|
+
if (p[k] == ':') {
|
|
170
|
+
if (od != 2) {
|
|
171
|
+
ok = 0;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
od++;
|
|
176
|
+
}
|
|
177
|
+
k++;
|
|
178
|
+
}
|
|
179
|
+
if (od < 1 || od > 4) {
|
|
180
|
+
ok = 0;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
ok = 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (ok && k == n) {
|
|
187
|
+
return 5; /* timestamp */
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/* .inf/.nan (psych, with sign on inf) */
|
|
196
|
+
{
|
|
197
|
+
const char* r = p + i;
|
|
198
|
+
uint32_t rn = n - i;
|
|
199
|
+
if (rn > 1 && r[0] == '.') {
|
|
200
|
+
if (ci_eq3(r, rn, ".inf") || ci_eq3(r, rn, ".nan")) {
|
|
201
|
+
return 2;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/* sexagesimal: [-+]?d[d_]*(:[0-5]?d){1,2}(.d*)? */
|
|
206
|
+
{
|
|
207
|
+
uint32_t k = i;
|
|
208
|
+
if (k < n && p[k] >= '0' && p[k] <= '9') {
|
|
209
|
+
k++;
|
|
210
|
+
while (k < n && ((p[k] >= '0' && p[k] <= '9') || p[k] == '_')) {
|
|
211
|
+
k++;
|
|
212
|
+
}
|
|
213
|
+
if (k < n && p[k] == ':') {
|
|
214
|
+
int groups = 0;
|
|
215
|
+
int ok = 1;
|
|
216
|
+
int is_float = 0;
|
|
217
|
+
while (k < n && p[k] == ':') {
|
|
218
|
+
k++;
|
|
219
|
+
groups++;
|
|
220
|
+
int d = 0;
|
|
221
|
+
while (k < n && p[k] >= '0' && p[k] <= '9') {
|
|
222
|
+
k++;
|
|
223
|
+
d++;
|
|
224
|
+
}
|
|
225
|
+
if (d < 1 || d > 2 || groups > 2) {
|
|
226
|
+
ok = 0;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
if (d == 2 && p[k - 2] > '5') {
|
|
230
|
+
ok = 0; /* [0-5]?d */
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (ok && k < n && p[k] == '.') {
|
|
235
|
+
is_float = 1;
|
|
236
|
+
k++;
|
|
237
|
+
while (k < n && ((p[k] >= '0' && p[k] <= '9') || p[k] == '_')) {
|
|
238
|
+
k++;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (ok && k == n && groups >= 1) {
|
|
242
|
+
return is_float ? 2 : 1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/* 0b / 0x / leading-0 octal / decimal int with underscores */
|
|
248
|
+
if (n - i > 2 && p[i] == '0' && (p[i + 1] == 'b' || p[i + 1] == 'B')) {
|
|
249
|
+
return is_digits_us(p + i + 2, n - i - 2) ? 1 : 0;
|
|
250
|
+
}
|
|
251
|
+
if (n - i > 2 && p[i] == '0' && (p[i + 1] == 'x' || p[i + 1] == 'X')) {
|
|
252
|
+
uint32_t k = i + 2;
|
|
253
|
+
if (p[k] == '_') {
|
|
254
|
+
k++;
|
|
255
|
+
}
|
|
256
|
+
int d = 0;
|
|
257
|
+
for (; k < n; k++) {
|
|
258
|
+
char c = p[k];
|
|
259
|
+
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ||
|
|
260
|
+
c == '_') {
|
|
261
|
+
if (c != '_') {
|
|
262
|
+
d++;
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
return 0;
|
|
267
|
+
}
|
|
268
|
+
return d ? 1 : 0;
|
|
269
|
+
}
|
|
270
|
+
if (n - i >= 2 && p[i] == '0') {
|
|
271
|
+
/* leading-0 octal (psych: 0[_]*[0-7][0-7_]*) */
|
|
272
|
+
uint32_t k = i + 1;
|
|
273
|
+
while (k < n && p[k] == '_') {
|
|
274
|
+
k++;
|
|
275
|
+
}
|
|
276
|
+
int d = 0;
|
|
277
|
+
for (; k < n; k++) {
|
|
278
|
+
if (p[k] >= '0' && p[k] <= '7') {
|
|
279
|
+
d++;
|
|
280
|
+
} else if (p[k] == '_') {
|
|
281
|
+
continue;
|
|
282
|
+
} else {
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (d && k == n) {
|
|
287
|
+
return 1;
|
|
288
|
+
}
|
|
289
|
+
if (d == 0 && k == n && p[n - 1] == '0') {
|
|
290
|
+
return 1; /* plain 0 */
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/* decimal int / float with underscores and commas (psych legacy) */
|
|
294
|
+
{
|
|
295
|
+
int digits = 0, dot = 0, e = 0, ed = 0;
|
|
296
|
+
for (uint32_t k = i; k < n; k++) {
|
|
297
|
+
char c = p[k];
|
|
298
|
+
if (c >= '0' && c <= '9') {
|
|
299
|
+
if (e) {
|
|
300
|
+
ed = 1;
|
|
301
|
+
} else {
|
|
302
|
+
digits = 1;
|
|
303
|
+
}
|
|
304
|
+
} else if ((c == '_' || c == ',') && !e) {
|
|
305
|
+
/* separators */
|
|
306
|
+
} else if (c == '.' && !e) {
|
|
307
|
+
if (dot) {
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
dot = 1;
|
|
311
|
+
} else if ((c == 'e' || c == 'E') && digits && !e) {
|
|
312
|
+
e = 1;
|
|
313
|
+
if (k + 1 < n && (p[k + 1] == '-' || p[k + 1] == '+')) {
|
|
314
|
+
k++;
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (digits && (dot || e) && (!e || ed)) {
|
|
321
|
+
return 2;
|
|
322
|
+
}
|
|
323
|
+
if (digits && !dot && !e) {
|
|
324
|
+
return 1;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return 0; /* str */
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
static const yep_resolver k_compat11 = {compat11, NULL, NULL};
|
|
331
|
+
|
|
332
|
+
const yep_resolver* yep_resolver_compat11(void) {
|
|
333
|
+
return &k_compat11;
|
|
334
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* core12.c — the YAML 1.2 core schema (TODO.impl/10).
|
|
2
|
+
*
|
|
3
|
+
* null: "", "~", "null", "Null", "NULL"
|
|
4
|
+
* bool: true/True/TRUE, false/False/FALSE
|
|
5
|
+
* int: [-+]?[0-9]+ | [-+]?0o[0-7]+ | [-+]?0x[0-9a-fA-F]+
|
|
6
|
+
* float: core float production, [-+]?(\.inf|\.Inf|\.INF), \.nan/\.NaN/\.NAN
|
|
7
|
+
* else str
|
|
8
|
+
*
|
|
9
|
+
* Shape (TODO.restructure/71): the first-byte gate, then ONE branch —
|
|
10
|
+
* word lead letters do the null/true/false compares and return, digits
|
|
11
|
+
* and signs take the number walk. The old chain tried the word memcmps
|
|
12
|
+
* for every length-4/5 scalar before ruling (anchor-heavy: 42 cycles
|
|
13
|
+
* per call on gate-passing strings).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
#include <string.h>
|
|
18
|
+
|
|
19
|
+
#include "resolver.h"
|
|
20
|
+
|
|
21
|
+
static yep_tag_id core12(void* ctx, const char* p, uint32_t n) {
|
|
22
|
+
(void)ctx;
|
|
23
|
+
if (n == 0) {
|
|
24
|
+
return 4; /* null */
|
|
25
|
+
}
|
|
26
|
+
unsigned char c0 = (unsigned char)p[0];
|
|
27
|
+
unsigned l0 = c0 | 0x20u;
|
|
28
|
+
|
|
29
|
+
/* The gate (profile: 6.5% of deep-nesting was the reject chain):
|
|
30
|
+
* a first byte that can begin no core production is a string. */
|
|
31
|
+
if (!((c0 >= '0' && c0 <= '9') || c0 == '-' || c0 == '+' || c0 == '.' || l0 == 'n' ||
|
|
32
|
+
l0 == 't' || l0 == 'f' || l0 == 'y' || c0 == '~')) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Word leads: the exact casings only; every other spelling (and
|
|
37
|
+
* every y-word — compat owns those) is a string, no walk. */
|
|
38
|
+
if (l0 == 'n' || l0 == 't' || l0 == 'f' || l0 == 'y') {
|
|
39
|
+
if (n == 4 && l0 == 'n') {
|
|
40
|
+
return (memcmp(p, "null", 4) == 0 || memcmp(p, "Null", 4) == 0 ||
|
|
41
|
+
memcmp(p, "NULL", 4) == 0)
|
|
42
|
+
? 4
|
|
43
|
+
: 0;
|
|
44
|
+
}
|
|
45
|
+
if (n == 4 && l0 == 't') {
|
|
46
|
+
return (memcmp(p, "true", 4) == 0 || memcmp(p, "True", 4) == 0 ||
|
|
47
|
+
memcmp(p, "TRUE", 4) == 0)
|
|
48
|
+
? 3
|
|
49
|
+
: 0;
|
|
50
|
+
}
|
|
51
|
+
if (n == 5 && l0 == 'f') {
|
|
52
|
+
return (memcmp(p, "false", 5) == 0 || memcmp(p, "False", 5) == 0 ||
|
|
53
|
+
memcmp(p, "FALSE", 5) == 0)
|
|
54
|
+
? 3
|
|
55
|
+
: 0;
|
|
56
|
+
}
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
if (c0 == '~') {
|
|
60
|
+
return n == 1 ? 4 : 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Number path: optional sign, then the productions in frequency
|
|
64
|
+
* order (.inf/.nan, hex, octal, decimal int/float). */
|
|
65
|
+
uint32_t i = (c0 == '-' || c0 == '+') ? 1 : 0;
|
|
66
|
+
if (i >= n) {
|
|
67
|
+
return 0; /* lone sign */
|
|
68
|
+
}
|
|
69
|
+
{
|
|
70
|
+
const char* r = p + i;
|
|
71
|
+
uint32_t rn = n - i;
|
|
72
|
+
if (rn == 4 && r[0] == '.') {
|
|
73
|
+
if (memcmp(r, ".inf", 4) == 0 || memcmp(r, ".Inf", 4) == 0 ||
|
|
74
|
+
memcmp(r, ".INF", 4) == 0 ||
|
|
75
|
+
(i == 0 && (memcmp(r, ".nan", 4) == 0 || memcmp(r, ".NaN", 4) == 0 ||
|
|
76
|
+
memcmp(r, ".NAN", 4) == 0))) {
|
|
77
|
+
return 2; /* float; NaN carries no sign */
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (n - i > 2 && p[i] == '0' && (p[i + 1] == 'x' || p[i + 1] == 'X')) {
|
|
82
|
+
for (uint32_t k = i + 2; k < n; k++) {
|
|
83
|
+
char c = p[k];
|
|
84
|
+
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return 1; /* int */
|
|
89
|
+
}
|
|
90
|
+
if (n - i > 2 && p[i] == '0' && p[i + 1] == 'o') {
|
|
91
|
+
for (uint32_t k = i + 2; k < n; k++) {
|
|
92
|
+
if (p[k] < '0' || p[k] > '7') {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return 1; /* int */
|
|
97
|
+
}
|
|
98
|
+
int digits = 0, dot = 0, e = 0, edigits = 0;
|
|
99
|
+
for (uint32_t k = i; k < n; k++) {
|
|
100
|
+
char c = p[k];
|
|
101
|
+
if (c >= '0' && c <= '9') {
|
|
102
|
+
if (e) {
|
|
103
|
+
edigits = 1;
|
|
104
|
+
} else {
|
|
105
|
+
digits = 1;
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (c == '.' && !e) {
|
|
110
|
+
if (dot) {
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
dot = 1;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if ((c == 'e' || c == 'E') && digits && !e) {
|
|
117
|
+
e = 1;
|
|
118
|
+
if (k + 1 < n && (p[k + 1] == '-' || p[k + 1] == '+')) {
|
|
119
|
+
k++;
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
if (digits && (dot || e) && (!e || edigits)) {
|
|
126
|
+
return 2; /* float */
|
|
127
|
+
}
|
|
128
|
+
if (digits && !dot && !e) {
|
|
129
|
+
return 1; /* int */
|
|
130
|
+
}
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static yep_tag_id core12_number(void* ctx, int is_float) {
|
|
135
|
+
(void)ctx;
|
|
136
|
+
return is_float ? 2 : 1;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static const yep_resolver k_core12 = {core12, core12_number, NULL};
|
|
140
|
+
|
|
141
|
+
const yep_resolver* yep_resolver_core12(void) {
|
|
142
|
+
return &k_core12;
|
|
143
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* resolver.h — the internal resolver interface (TODO.impl/10).
|
|
2
|
+
*
|
|
3
|
+
* MECE: scan produces facts, the engine parses, the RESOLVER alone
|
|
4
|
+
* decides implicit typing. OCP: a new schema is a new resolver
|
|
5
|
+
* instance; no schema branches exist anywhere else.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef YEP_RESOLVER_H
|
|
8
|
+
#define YEP_RESOLVER_H
|
|
9
|
+
|
|
10
|
+
#include <stdint.h>
|
|
11
|
+
|
|
12
|
+
#include "common/string_view.h"
|
|
13
|
+
|
|
14
|
+
/* yep_view: bytes + length, the one string representation (SSOT). */
|
|
15
|
+
|
|
16
|
+
/* The tag-id space is the public YeptrisTagId (resolve.h); internal
|
|
17
|
+
* re-export for the table SSOT. */
|
|
18
|
+
typedef uint8_t yep_tag_id;
|
|
19
|
+
|
|
20
|
+
typedef struct yep_resolver {
|
|
21
|
+
/* Returns the implicit tag for a PLAIN, untagged scalar. */
|
|
22
|
+
yep_tag_id (*resolve)(void* ctx, const char* p, uint32_t len);
|
|
23
|
+
/* Optional fast path for spans a validator already classified as
|
|
24
|
+
* strict numbers (is_float: the text contains '.' or an exponent):
|
|
25
|
+
* skips the digit re-walk resolve() would pay. NULL = resolve(). */
|
|
26
|
+
yep_tag_id (*resolve_number)(void* ctx, int is_float);
|
|
27
|
+
void* ctx;
|
|
28
|
+
} yep_resolver;
|
|
29
|
+
|
|
30
|
+
/* Typing for a validated number span, through whichever hook the
|
|
31
|
+
* schema provides (the typing SSOT either way). */
|
|
32
|
+
static inline yep_tag_id yep_resolve_number(const yep_resolver* r, int is_float) {
|
|
33
|
+
if (r->resolve_number != NULL) {
|
|
34
|
+
return r->resolve_number(NULL, is_float);
|
|
35
|
+
}
|
|
36
|
+
return is_float ? 2 /* float */ : 1 /* int */;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* The two built-in resolvers (no ctx). */
|
|
40
|
+
const yep_resolver* yep_resolver_core12(void);
|
|
41
|
+
const yep_resolver* yep_resolver_compat11(void);
|
|
42
|
+
|
|
43
|
+
/* core tag id <-> canonical URI (tags.c is the identity SSOT). */
|
|
44
|
+
const char* yep_tag_uri(yep_tag_id id);
|
|
45
|
+
|
|
46
|
+
/* Explicit-tag resolution: the tag URI a node carried maps to a core
|
|
47
|
+
* id when it matches one, else YEPTRIS_TAG_CUSTOM. */
|
|
48
|
+
yep_tag_id yep_tag_from_uri(const char* p, uint32_t len);
|
|
49
|
+
|
|
50
|
+
/* Canonical word for a resolved float view: ".inf" / "-.inf" / ".nan"
|
|
51
|
+
* or NULL when the view is not an infinity/nan word (the canonical
|
|
52
|
+
* emitter re-prints these words; libc strtod does not accept them
|
|
53
|
+
* portably). */
|
|
54
|
+
const char* yep_tag_float_word(const char* p, uint32_t len);
|
|
55
|
+
|
|
56
|
+
#endif /* YEP_RESOLVER_H */
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* tags.c — the tag identity SSOT (TODO.impl/10).
|
|
2
|
+
*
|
|
3
|
+
* Dense ids for the core set; canonical URIs live here once. Custom
|
|
4
|
+
* tags keep their string (the DOM already stores the view) and use
|
|
5
|
+
* YEPTRIS_TAG_CUSTOM.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "resolver.h"
|
|
9
|
+
|
|
10
|
+
#include <string.h>
|
|
11
|
+
|
|
12
|
+
typedef struct {
|
|
13
|
+
yep_tag_id id;
|
|
14
|
+
const char* uri;
|
|
15
|
+
} yep_tag_entry;
|
|
16
|
+
|
|
17
|
+
static const yep_tag_entry k_core[] = {
|
|
18
|
+
{0, "tag:yaml.org,2002:str"}, {1, "tag:yaml.org,2002:int"},
|
|
19
|
+
{2, "tag:yaml.org,2002:float"}, {3, "tag:yaml.org,2002:bool"},
|
|
20
|
+
{4, "tag:yaml.org,2002:null"}, {5, "tag:yaml.org,2002:timestamp"},
|
|
21
|
+
{6, "tag:yaml.org,2002:seq"}, {7, "tag:yaml.org,2002:map"},
|
|
22
|
+
{8, "tag:yaml.org,2002:binary"}, {9, "tag:yaml.org,2002:merge"},
|
|
23
|
+
{10, "tag:yaml.org,2002:value"},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const char* yep_tag_uri(yep_tag_id id) {
|
|
27
|
+
if (id < sizeof(k_core) / sizeof(k_core[0])) {
|
|
28
|
+
return k_core[id].uri;
|
|
29
|
+
}
|
|
30
|
+
return NULL;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
yep_tag_id yep_tag_from_uri(const char* p, uint32_t len) {
|
|
34
|
+
for (size_t i = 0; i < sizeof(k_core) / sizeof(k_core[0]); i++) {
|
|
35
|
+
if (strlen(k_core[i].uri) == len && memcmp(k_core[i].uri, p, len) == 0) {
|
|
36
|
+
return k_core[i].id;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return 11; /* YEPTRIS_TAG_CUSTOM */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const char* yep_tag_float_word(const char* p, uint32_t len) {
|
|
43
|
+
static const struct {
|
|
44
|
+
const char* word;
|
|
45
|
+
const char* canon;
|
|
46
|
+
} words[] = {
|
|
47
|
+
{".inf", ".inf"}, {".Inf", ".inf"}, {".INF", ".inf"}, {"-.inf", "-.inf"},
|
|
48
|
+
{"-.Inf", "-.inf"}, {"-.INF", "-.inf"}, {"+.inf", ".inf"}, {"+.Inf", ".inf"},
|
|
49
|
+
{"+.INF", ".inf"}, {".nan", ".nan"}, {".NaN", ".nan"}, {".NAN", ".nan"},
|
|
50
|
+
};
|
|
51
|
+
for (size_t i = 0; i < sizeof(words) / sizeof(words[0]); i++) {
|
|
52
|
+
uint32_t wl = (uint32_t)strlen(words[i].word);
|
|
53
|
+
if (len == wl && memcmp(p, words[i].word, wl) == 0) {
|
|
54
|
+
return words[i].canon;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return NULL;
|
|
58
|
+
}
|