yeptris 0.6.64.0-riscv64-linux-gnu

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.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/README.adoc +150 -0
  3. data/ext/build_windows_native.rb +60 -0
  4. data/ext/libyeptris/extconf.rb +57 -0
  5. data/ext/yeptris_native/cbor_ruby.c +198 -0
  6. data/ext/yeptris_native/extconf.rb +99 -0
  7. data/ext/yeptris_native/json_ruby.c +414 -0
  8. data/ext/yeptris_native/version.h +29 -0
  9. data/ext/yeptris_native/yeptris_native.c +507 -0
  10. data/lib/yeptris/3.3/native.so +0 -0
  11. data/lib/yeptris/cbor.rb +169 -0
  12. data/lib/yeptris/document.rb +319 -0
  13. data/lib/yeptris/ffi.rb +572 -0
  14. data/lib/yeptris/json/descriptor.rb +266 -0
  15. data/lib/yeptris/json.rb +502 -0
  16. data/lib/yeptris/materializer.rb +389 -0
  17. data/lib/yeptris/node.rb +482 -0
  18. data/lib/yeptris/psych/class_loader.rb +24 -0
  19. data/lib/yeptris/psych/coder_shim.rb +55 -0
  20. data/lib/yeptris/psych/drop_in.rb +63 -0
  21. data/lib/yeptris/psych/encodable.rb +14 -0
  22. data/lib/yeptris/psych/handler.rb +95 -0
  23. data/lib/yeptris/psych/parser.rb +114 -0
  24. data/lib/yeptris/psych/scalar_scanner.rb +149 -0
  25. data/lib/yeptris/psych/tree_builder.rb +119 -0
  26. data/lib/yeptris/psych/visitors.rb +670 -0
  27. data/lib/yeptris/psych.rb +796 -0
  28. data/lib/yeptris/schema.rb +253 -0
  29. data/lib/yeptris/validation.rb +320 -0
  30. data/lib/yeptris/valueml.rb +477 -0
  31. data/lib/yeptris/yaml/descriptor.rb +56 -0
  32. data/lib/yeptris/yaml.rb +668 -0
  33. data/lib/yeptris.rb +130 -0
  34. data/libyeptris.so +0 -0
  35. data/vendor/libyeptris/CMakeLists.txt +280 -0
  36. data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
  37. data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
  38. data/vendor/libyeptris/src/CMakeLists.txt +183 -0
  39. data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
  40. data/vendor/libyeptris/src/include/yeptris/cbor.h +174 -0
  41. data/vendor/libyeptris/src/include/yeptris/dom.h +196 -0
  42. data/vendor/libyeptris/src/include/yeptris/emit.h +128 -0
  43. data/vendor/libyeptris/src/include/yeptris/error.h +42 -0
  44. data/vendor/libyeptris/src/include/yeptris/events.h +171 -0
  45. data/vendor/libyeptris/src/include/yeptris/json.h +57 -0
  46. data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
  47. data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
  48. data/vendor/libyeptris/src/include/yeptris/marshal.h +75 -0
  49. data/vendor/libyeptris/src/include/yeptris/parse.h +121 -0
  50. data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
  51. data/vendor/libyeptris/src/include/yeptris/resolve.h +81 -0
  52. data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
  53. data/vendor/libyeptris/src/include/yeptris/tape.h +128 -0
  54. data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
  55. data/vendor/libyeptris/src/include/yeptris/validate.h +401 -0
  56. data/vendor/libyeptris/src/include/yeptris/values.h +108 -0
  57. data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
  58. data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
  59. data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
  60. data/vendor/libyeptris/src/include/yeptris.h +24 -0
  61. data/vendor/libyeptris/src/yeptris/build.c +393 -0
  62. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +35 -0
  63. data/vendor/libyeptris/src/yeptris/cbor/decode.c +1054 -0
  64. data/vendor/libyeptris/src/yeptris/cbor/encode.c +836 -0
  65. data/vendor/libyeptris/src/yeptris/cbor/encode_priv.h +32 -0
  66. data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +982 -0
  67. data/vendor/libyeptris/src/yeptris/cbor/sink.h +36 -0
  68. data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
  69. data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
  70. data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
  71. data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
  72. data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
  73. data/vendor/libyeptris/src/yeptris/common/error.h +81 -0
  74. data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
  75. data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
  76. data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
  77. data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
  78. data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
  79. data/vendor/libyeptris/src/yeptris/common/simd_text.h +342 -0
  80. data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +672 -0
  81. data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +793 -0
  82. data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +324 -0
  83. data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
  84. data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
  85. data/vendor/libyeptris/src/yeptris/doc.h +86 -0
  86. data/vendor/libyeptris/src/yeptris/dom/dom.c +1312 -0
  87. data/vendor/libyeptris/src/yeptris/dom/dom.h +332 -0
  88. data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
  89. data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
  90. data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
  91. data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
  92. data/vendor/libyeptris/src/yeptris/dom/ytape.c +2323 -0
  93. data/vendor/libyeptris/src/yeptris/dom/ytape.h +96 -0
  94. data/vendor/libyeptris/src/yeptris/emit/emit.c +670 -0
  95. data/vendor/libyeptris/src/yeptris/emit/float/api.h +43 -0
  96. data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
  97. data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
  98. data/vendor/libyeptris/src/yeptris/emit/float/fpconv.c +428 -0
  99. data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
  100. data/vendor/libyeptris/src/yeptris/emit/style.c +21 -0
  101. data/vendor/libyeptris/src/yeptris/emit/style.h +32 -0
  102. data/vendor/libyeptris/src/yeptris/emit/writer.c +1951 -0
  103. data/vendor/libyeptris/src/yeptris/emit/writer.h +111 -0
  104. data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
  105. data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
  106. data/vendor/libyeptris/src/yeptris/encoding/transcode.c +157 -0
  107. data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
  108. data/vendor/libyeptris/src/yeptris/events/capture.c +166 -0
  109. data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
  110. data/vendor/libyeptris/src/yeptris/events/iterparse.c +298 -0
  111. data/vendor/libyeptris/src/yeptris/events/pull.c +117 -0
  112. data/vendor/libyeptris/src/yeptris/events/push.c +151 -0
  113. data/vendor/libyeptris/src/yeptris/events/recorder.c +144 -0
  114. data/vendor/libyeptris/src/yeptris/events/values.c +630 -0
  115. data/vendor/libyeptris/src/yeptris/events/values_priv.h +53 -0
  116. data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
  117. data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
  118. data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
  119. data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
  120. data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
  121. data/vendor/libyeptris/src/yeptris/marshal.c +988 -0
  122. data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
  123. data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
  124. data/vendor/libyeptris/src/yeptris/memory/arena.c +150 -0
  125. data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
  126. data/vendor/libyeptris/src/yeptris/memory/pool.c +133 -0
  127. data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
  128. data/vendor/libyeptris/src/yeptris/parse/engine.c +6528 -0
  129. data/vendor/libyeptris/src/yeptris/parse/engine.h +96 -0
  130. data/vendor/libyeptris/src/yeptris/parse/events.h +137 -0
  131. data/vendor/libyeptris/src/yeptris/parse/numbers.c +374 -0
  132. data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
  133. data/vendor/libyeptris/src/yeptris/parse/scalars.c +435 -0
  134. data/vendor/libyeptris/src/yeptris/parse/scalars.h +87 -0
  135. data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +358 -0
  136. data/vendor/libyeptris/src/yeptris/parse.c +1074 -0
  137. data/vendor/libyeptris/src/yeptris/plan.c +824 -0
  138. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +339 -0
  139. data/vendor/libyeptris/src/yeptris/resolve/core12.c +153 -0
  140. data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
  141. data/vendor/libyeptris/src/yeptris/resolve/json12.c +109 -0
  142. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +103 -0
  143. data/vendor/libyeptris/src/yeptris/resolve/tags.c +250 -0
  144. data/vendor/libyeptris/src/yeptris/scan/json.c +839 -0
  145. data/vendor/libyeptris/src/yeptris/scan/json.h +116 -0
  146. data/vendor/libyeptris/src/yeptris/scan/scan.c +862 -0
  147. data/vendor/libyeptris/src/yeptris/scan/scan.h +177 -0
  148. data/vendor/libyeptris/src/yeptris/schema.c +309 -0
  149. data/vendor/libyeptris/src/yeptris/tape.c +2375 -0
  150. data/vendor/libyeptris/src/yeptris/tape_in.h +39 -0
  151. data/vendor/libyeptris/src/yeptris/validate/compile.c +306 -0
  152. data/vendor/libyeptris/src/yeptris/validate/internal.h +347 -0
  153. data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1922 -0
  154. data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
  155. data/vendor/libyeptris/src/yeptris/validate/regexp.c +1600 -0
  156. data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
  157. data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
  158. data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
  159. data/vendor/libyeptris/src/yeptris/validate/validate.c +1043 -0
  160. data/vendor/libyeptris/src/yeptris/version.c +7 -0
  161. data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
  162. data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
  163. data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
  164. metadata +221 -0
@@ -0,0 +1,339 @@
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 (yep_tag_bool_value(p, n) >= 0) {
69
+ return 3; /* the one bool table (tags.c): true/false sets ci */
70
+ }
71
+ if (eq(p, n, "=")) {
72
+ return 10; /* value */
73
+ }
74
+ if (eq(p, n, "<<")) {
75
+ return 9; /* merge */
76
+ }
77
+ uint32_t i = 0;
78
+ if (p[0] == '-' || p[0] == '+') {
79
+ i = 1;
80
+ }
81
+ if (i >= n) {
82
+ return 0;
83
+ }
84
+ /* timestamps: full production first (psych TIME), then plain dates */
85
+ {
86
+ /* -?dddd-dd-dd([Tt ]dd:dd:dd(.d*)?(Z|+dd(:dd)?|+d)?)? — the
87
+ * date-only form handled after; conservative core check */
88
+ uint32_t k = i;
89
+ int digs = 0;
90
+ while (k < n && p[k] >= '0' && p[k] <= '9' && digs < 4) {
91
+ k++;
92
+ digs++;
93
+ }
94
+ if (digs == 4 && k + 1 < n && p[k] == '-') {
95
+ k++;
96
+ int m1 = 0;
97
+ while (k < n && p[k] >= '0' && p[k] <= '9' && m1 < 2) {
98
+ k++;
99
+ m1++;
100
+ }
101
+ if (m1 >= 1 && k + 1 < n && p[k] == '-') {
102
+ k++;
103
+ int m2 = 0;
104
+ while (k < n && p[k] >= '0' && p[k] <= '9' && m2 < 2) {
105
+ k++;
106
+ m2++;
107
+ }
108
+ if (m2 >= 1) {
109
+ if (k == n) {
110
+ return 5; /* date */
111
+ }
112
+ if (p[k] == 'T' || p[k] == 't' || p[k] == ' ') {
113
+ /* time part: dd:dd:dd required */
114
+ k++; /* consume the separator */
115
+ int ok = 1;
116
+ int f[3] = {0, 0, 0};
117
+ int fi = 0;
118
+ int seen_colon = 0;
119
+ while (k < n) {
120
+ char c = p[k];
121
+ if (c == ':') {
122
+ if (f[fi] < 1 || f[fi] > 2 || fi >= 2) {
123
+ ok = 0;
124
+ break;
125
+ }
126
+ seen_colon = 1;
127
+ fi++;
128
+ k++;
129
+ continue;
130
+ }
131
+ if (c >= '0' && c <= '9' && fi <= 2) {
132
+ f[fi]++;
133
+ if (f[fi] > 2) {
134
+ ok = 0;
135
+ break;
136
+ }
137
+ k++;
138
+ continue;
139
+ }
140
+ break;
141
+ }
142
+ if (ok && seen_colon && fi == 2 && f[2] == 2) {
143
+ /* optional .frac, Z or offset */
144
+ if (k < n && p[k] == '.') {
145
+ k++;
146
+ int fd = 0;
147
+ while (k < n && p[k] >= '0' && p[k] <= '9') {
148
+ k++;
149
+ fd++;
150
+ }
151
+ if (fd == 0) {
152
+ ok = 0;
153
+ }
154
+ }
155
+ while (ok && k < n && p[k] == ' ') {
156
+ k++; /* psych: \s* before the zone */
157
+ }
158
+ if (ok && k < n) {
159
+ if (p[k] == 'Z') {
160
+ k++;
161
+ } else if (p[k] == '+' || p[k] == '-') {
162
+ k++;
163
+ int od = 0;
164
+ while (k < n && ((p[k] >= '0' && p[k] <= '9') ||
165
+ (od == 2 && p[k] == ':'))) {
166
+ if (p[k] == ':') {
167
+ if (od != 2) {
168
+ ok = 0;
169
+ break;
170
+ }
171
+ } else {
172
+ od++;
173
+ }
174
+ k++;
175
+ }
176
+ if (od < 1 || od > 4) {
177
+ ok = 0;
178
+ }
179
+ } else {
180
+ ok = 0;
181
+ }
182
+ }
183
+ if (ok && k == n) {
184
+ return 5; /* timestamp */
185
+ }
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ }
192
+ /* .inf/.nan (psych, with sign on inf) */
193
+ {
194
+ const char* r = p + i;
195
+ uint32_t rn = n - i;
196
+ if (rn > 1 && r[0] == '.') {
197
+ if (ci_eq3(r, rn, ".inf") || ci_eq3(r, rn, ".nan")) {
198
+ return 2;
199
+ }
200
+ }
201
+ }
202
+ /* sexagesimal: [-+]?d[d_]*(:[0-5]?d){1,2}(.d*)? */
203
+ {
204
+ uint32_t k = i;
205
+ if (k < n && p[k] >= '0' && p[k] <= '9') {
206
+ k++;
207
+ while (k < n && ((p[k] >= '0' && p[k] <= '9') || p[k] == '_')) {
208
+ k++;
209
+ }
210
+ if (k < n && p[k] == ':') {
211
+ int groups = 0;
212
+ int ok = 1;
213
+ int is_float = 0;
214
+ while (k < n && p[k] == ':') {
215
+ k++;
216
+ groups++;
217
+ int d = 0;
218
+ while (k < n && p[k] >= '0' && p[k] <= '9') {
219
+ k++;
220
+ d++;
221
+ }
222
+ if (d < 1 || d > 2 || groups > 2) {
223
+ ok = 0;
224
+ break;
225
+ }
226
+ if (d == 2 && p[k - 2] > '5') {
227
+ ok = 0; /* [0-5]?d */
228
+ break;
229
+ }
230
+ }
231
+ if (ok && k < n && p[k] == '.') {
232
+ is_float = 1;
233
+ k++;
234
+ while (k < n && ((p[k] >= '0' && p[k] <= '9') || p[k] == '_')) {
235
+ k++;
236
+ }
237
+ }
238
+ if (ok && k == n && groups >= 1) {
239
+ return is_float ? 2 : 1;
240
+ }
241
+ }
242
+ }
243
+ }
244
+ /* 0b / 0x / leading-0 octal / decimal int with underscores */
245
+ if (n - i > 2 && p[i] == '0' && (p[i + 1] == 'b' || p[i + 1] == 'B')) {
246
+ return is_digits_us(p + i + 2, n - i - 2) ? 1 : 0;
247
+ }
248
+ if (n - i > 2 && p[i] == '0' &&
249
+ p[i + 1] == 'x') { /* lowercase only — psych keeps "0X1A" a String */
250
+ uint32_t k = i + 2;
251
+ if (p[k] == '_') {
252
+ k++;
253
+ }
254
+ int d = 0;
255
+ for (; k < n; k++) {
256
+ char c = p[k];
257
+ if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ||
258
+ c == '_') {
259
+ if (c != '_') {
260
+ d++;
261
+ }
262
+ continue;
263
+ }
264
+ return 0;
265
+ }
266
+ return d ? 1 : 0;
267
+ }
268
+ if (n - i >= 2 && p[i] == '0') {
269
+ /* leading-0 octal (psych: 0[_]*[0-7][0-7_]*) */
270
+ uint32_t k = i + 1;
271
+ while (k < n && p[k] == '_') {
272
+ k++;
273
+ }
274
+ int d = 0;
275
+ for (; k < n; k++) {
276
+ if (p[k] >= '0' && p[k] <= '7') {
277
+ d++;
278
+ } else if (p[k] == '_') {
279
+ continue;
280
+ } else {
281
+ break;
282
+ }
283
+ }
284
+ if (d && k == n) {
285
+ return 1;
286
+ }
287
+ if (d == 0 && k == n && p[n - 1] == '0') {
288
+ return 1; /* plain 0 */
289
+ }
290
+ }
291
+ /* decimal int / float with underscores and commas (psych legacy).
292
+ * The float law is psych's scanner (and libyaml's 1.1 resolver): a
293
+ * DOT is required, and an exponent only counts when SIGNED —
294
+ * "1e0" and "1.5e2" stay strings (psych tokenize; libyaml's 1.1
295
+ * float regex agrees), "1.5" / ".5" / "1.5e+2" are floats. The
296
+ * unqualified-exponent float leaked host strings into number
297
+ * typing (yeptris-ruby #293's CBOR dump). */
298
+ {
299
+ int digits = 0, dot = 0, e = 0, ed = 0, esigned = 0;
300
+ for (uint32_t k = i; k < n; k++) {
301
+ char c = p[k];
302
+ if (c >= '0' && c <= '9') {
303
+ if (e) {
304
+ ed = 1;
305
+ } else {
306
+ digits = 1;
307
+ }
308
+ } else if ((c == '_' || c == ',') && !e) {
309
+ /* separators */
310
+ } else if (c == '.' && !e) {
311
+ if (dot) {
312
+ return 0;
313
+ }
314
+ dot = 1;
315
+ } else if ((c == 'e' || c == 'E') && digits && !e) {
316
+ e = 1;
317
+ if (k + 1 < n && (p[k + 1] == '-' || p[k + 1] == '+')) {
318
+ esigned = 1;
319
+ k++;
320
+ }
321
+ } else {
322
+ return 0;
323
+ }
324
+ }
325
+ if (digits && dot && (!e || (ed && esigned))) {
326
+ return 2;
327
+ }
328
+ if (digits && !dot && !e) {
329
+ return 1;
330
+ }
331
+ }
332
+ return 0; /* str */
333
+ }
334
+
335
+ static const yep_resolver k_compat11 = {compat11, NULL, NULL, 0};
336
+
337
+ const yep_resolver* yep_resolver_compat11(void) {
338
+ return &k_compat11;
339
+ }
@@ -0,0 +1,153 @@
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
+ * yep_core12_plain is the ONE classifier (the yep_json12_plain
16
+ * precedent): the resolver wraps it, and the full-1.2 family composes
17
+ * it (full12.c's timestamp lane rides the same truth table).
18
+ */
19
+
20
+ #include <stdint.h>
21
+ #include <string.h>
22
+
23
+ #include "resolver.h"
24
+
25
+ yep_tag_id yep_core12_plain(const char* p, uint32_t n) {
26
+ if (n == 0) {
27
+ return 4; /* null */
28
+ }
29
+ unsigned char c0 = (unsigned char)p[0];
30
+ unsigned l0 = c0 | 0x20u;
31
+
32
+ /* The gate (profile: 6.5% of deep-nesting was the reject chain):
33
+ * a first byte that can begin no core production is a string. */
34
+ if (!((c0 >= '0' && c0 <= '9') || c0 == '-' || c0 == '+' || c0 == '.' || l0 == 'n' ||
35
+ l0 == 't' || l0 == 'f' || l0 == 'y' || c0 == '~')) {
36
+ return 0;
37
+ }
38
+
39
+ /* Word leads: the exact casings only; every other spelling (and
40
+ * every y-word — compat owns those) is a string, no walk. */
41
+ if (l0 == 'n' || l0 == 't' || l0 == 'f' || l0 == 'y') {
42
+ if (n == 4 && l0 == 'n') {
43
+ return (memcmp(p, "null", 4) == 0 || memcmp(p, "Null", 4) == 0 ||
44
+ memcmp(p, "NULL", 4) == 0)
45
+ ? 4
46
+ : 0;
47
+ }
48
+ if (n == 4 && l0 == 't') {
49
+ return (memcmp(p, "true", 4) == 0 || memcmp(p, "True", 4) == 0 ||
50
+ memcmp(p, "TRUE", 4) == 0)
51
+ ? 3
52
+ : 0;
53
+ }
54
+ if (n == 5 && l0 == 'f') {
55
+ return (memcmp(p, "false", 5) == 0 || memcmp(p, "False", 5) == 0 ||
56
+ memcmp(p, "FALSE", 5) == 0)
57
+ ? 3
58
+ : 0;
59
+ }
60
+ return 0;
61
+ }
62
+ if (c0 == '~') {
63
+ return n == 1 ? 4 : 0;
64
+ }
65
+
66
+ /* Number path: optional sign, then the productions in frequency
67
+ * order (.inf/.nan, hex, octal, decimal int/float). */
68
+ uint32_t i = (c0 == '-' || c0 == '+') ? 1 : 0;
69
+ if (i >= n) {
70
+ return 0; /* lone sign */
71
+ }
72
+ {
73
+ const char* r = p + i;
74
+ uint32_t rn = n - i;
75
+ if (rn == 4 && r[0] == '.') {
76
+ if (memcmp(r, ".inf", 4) == 0 || memcmp(r, ".Inf", 4) == 0 ||
77
+ memcmp(r, ".INF", 4) == 0 ||
78
+ (i == 0 && (memcmp(r, ".nan", 4) == 0 || memcmp(r, ".NaN", 4) == 0 ||
79
+ memcmp(r, ".NAN", 4) == 0))) {
80
+ return 2; /* float; NaN carries no sign */
81
+ }
82
+ }
83
+ }
84
+ if (n - i > 2 && p[i] == '0' &&
85
+ p[i + 1] == 'x') { /* lowercase only: the core schema's int regexp; "0X1A" rides a string
86
+ (psych agrees) */
87
+ for (uint32_t k = i + 2; k < n; k++) {
88
+ char c = p[k];
89
+ if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
90
+ return 0;
91
+ }
92
+ }
93
+ return 1; /* int */
94
+ }
95
+ if (n - i > 2 && p[i] == '0' && p[i + 1] == 'o') {
96
+ for (uint32_t k = i + 2; k < n; k++) {
97
+ if (p[k] < '0' || p[k] > '7') {
98
+ return 0;
99
+ }
100
+ }
101
+ return 1; /* int */
102
+ }
103
+ int digits = 0, dot = 0, e = 0, edigits = 0;
104
+ for (uint32_t k = i; k < n; k++) {
105
+ char c = p[k];
106
+ if (c >= '0' && c <= '9') {
107
+ if (e) {
108
+ edigits = 1;
109
+ } else {
110
+ digits = 1;
111
+ }
112
+ continue;
113
+ }
114
+ if (c == '.' && !e) {
115
+ if (dot) {
116
+ return 0;
117
+ }
118
+ dot = 1;
119
+ continue;
120
+ }
121
+ if ((c == 'e' || c == 'E') && digits && !e) {
122
+ e = 1;
123
+ if (k + 1 < n && (p[k + 1] == '-' || p[k + 1] == '+')) {
124
+ k++;
125
+ }
126
+ continue;
127
+ }
128
+ return 0;
129
+ }
130
+ if (digits && (dot || e) && (!e || edigits)) {
131
+ return 2; /* float */
132
+ }
133
+ if (digits && !dot && !e) {
134
+ return 1; /* int */
135
+ }
136
+ return 0;
137
+ }
138
+
139
+ static yep_tag_id core12(void* ctx, const char* p, uint32_t n) {
140
+ (void)ctx;
141
+ return yep_core12_plain(p, n);
142
+ }
143
+
144
+ static yep_tag_id core12_number(void* ctx, int is_float) {
145
+ (void)ctx;
146
+ return is_float ? 2 : 1;
147
+ }
148
+
149
+ static const yep_resolver k_core12 = {core12, core12_number, NULL, 0};
150
+
151
+ const yep_resolver* yep_resolver_core12(void) {
152
+ return &k_core12;
153
+ }
@@ -0,0 +1,201 @@
1
+ /* full12.c — the FULL YAML 1.2 family resolver (#906 slice 3).
2
+ *
3
+ * The spec's schema chapter names two families (10.2 JSON, 10.3 core)
4
+ * and leaves the rest to 10.4 "Other Schemas": interoperable schemas
5
+ * "make use of global tags", may add their own resolution regexes, and
6
+ * are "strongly recommended ... based on the core schema". The
7
+ * historical full schema is the yaml.org type repository carried
8
+ * forward in practice — libyaml implements nothing of it; PyYAML's
9
+ * SafeLoader resolves timestamps, and that is the de-facto full
10
+ * behavior the ecosystem knows. This resolver is that family:
11
+ *
12
+ * core12's productions verbatim (the spec-refereed base — NOT
13
+ * psych's numeric quirks: underscores, sexagesimal, leading-0
14
+ * octal and y/n booleans stay in compat11, which is the 1.1
15
+ * practice lane, not a 1.2 family);
16
+ * + timestamps on untagged plains: spec example 2.22's four shapes —
17
+ * canonical (2001-12-15T02:59:43.1Z), iso8601
18
+ * (2001-12-14t21:59:43.10-05:00), spaced (2001-12-14 21:59:43.10
19
+ * -5), date (2002-12-14) — classified by PyYAML 6.0.2's
20
+ * timestamp regex, the practice oracle (see pyyaml_timestamp
21
+ * below for the production-by-production account);
22
+ * + the merge/value words ('<<' / '='), the 1.1 full schema's
23
+ * grammar-adjacent tags PyYAML also resolves implicitly;
24
+ * - binary: NEVER implicit (nowhere, in any edition) — the explicit
25
+ * !!binary tag rides as consumer-defined passthrough (PyYAML's
26
+ * base64 shaping is a CONSTRUCTION step; keeping shaping out of
27
+ * resolution is the documented passthrough policy).
28
+ *
29
+ * The validator family-checks explicit !!timestamp content through the
30
+ * same classifier (the resolver's `timestamped` capability), so a
31
+ * resolution change lands once and both move together.
32
+ */
33
+
34
+ #include <stdint.h>
35
+
36
+ #include "resolver.h"
37
+
38
+ /* PyYAML 6.0.2 resolver.py's timestamp_regexp, production by
39
+ * production (re.X whitespace stripped):
40
+ *
41
+ * [0-9]{4}-[0-9]{2}-[0-9]{2} date-only: month
42
+ * and day are EXACTLY
43
+ * two digits
44
+ * | [0-9]{4}-[0-9]{1,2}-[0-9]{1,2} with a time part:
45
+ * month/day/hour are
46
+ * 1-2 digits, the
47
+ * (?:[Tt]|[ \t]+)[0-9]{1,2} separator T/t/space-
48
+ * run, minutes and
49
+ * :[0-9]{2}:[0-9]{2}(?:\.[0-9]*)? seconds EXACTLY two,
50
+ * fraction zero+ digits
51
+ * (?:[ \t]*(?:Z|[-+][0-9]{1,2}(?::[0-9]{2})?))? tz OPTIONAL: Z or a
52
+ * signed 1-2-digit
53
+ * offset, minutes
54
+ * optional
55
+ *
56
+ * The two-oracle divergences this keeps (PyYAML's resolver is the
57
+ * oracle, deliberately): NO sign on the year (psych allows -?); NO
58
+ * calendar range checks (2001-13-14 resolves timestamp — PyYAML's own
59
+ * resolver agrees, only its constructor raises; resolution is not
60
+ * calendar validation, the consumer's date type owns ranges). The
61
+ * spec's plain-scalar colon law is what keeps the spaced forms
62
+ * unquoted ("a:1" is a plain scalar; "a: 1" is a pair — 5.3.2's note
63
+ * cites timestamps as the canonical case).
64
+ */
65
+ static int pyyaml_timestamp(const char* p, uint32_t n) {
66
+ uint32_t k = 0;
67
+ for (int d = 0; d < 4; d++) { /* year: exactly four digits, no sign */
68
+ if (k >= n || p[k] < '0' || p[k] > '9') {
69
+ return 0;
70
+ }
71
+ k++;
72
+ }
73
+ if (k >= n || p[k] != '-') {
74
+ return 0;
75
+ }
76
+ k++;
77
+ uint32_t mdig = 0, ddig = 0;
78
+ for (int seg = 0; seg < 2; seg++) {
79
+ const uint32_t start = k;
80
+ while (k < n && k - start < 2 && p[k] >= '0' && p[k] <= '9') {
81
+ k++;
82
+ }
83
+ if (seg == 0) {
84
+ mdig = k - start;
85
+ if (mdig == 0 || k >= n || p[k] != '-') {
86
+ return 0;
87
+ }
88
+ k++;
89
+ } else {
90
+ ddig = k - start;
91
+ if (ddig == 0) {
92
+ return 0;
93
+ }
94
+ }
95
+ }
96
+ if (k == n) {
97
+ /* date-only: the branch demands EXACTLY two-digit month/day
98
+ * ("2001-1-1" is a string — PyYAML's own verdict) */
99
+ return mdig == 2 && ddig == 2;
100
+ }
101
+ /* the time part is MANDATORY on the second branch */
102
+ if (p[k] == 'T' || p[k] == 't') {
103
+ k++;
104
+ } else if (p[k] == ' ' || p[k] == '\t') {
105
+ while (k < n && (p[k] == ' ' || p[k] == '\t')) {
106
+ k++;
107
+ }
108
+ } else {
109
+ return 0;
110
+ }
111
+ const uint32_t hstart = k; /* hour: 1-2 digits */
112
+ while (k < n && k - hstart < 2 && p[k] >= '0' && p[k] <= '9') {
113
+ k++;
114
+ }
115
+ if (k == hstart) {
116
+ return 0;
117
+ }
118
+ for (int seg = 0; seg < 2; seg++) { /* :dd:dd — exactly two each */
119
+ if (k >= n || p[k] != ':') {
120
+ return 0;
121
+ }
122
+ k++;
123
+ const uint32_t start = k;
124
+ while (k < n && k - start < 2 && p[k] >= '0' && p[k] <= '9') {
125
+ k++;
126
+ }
127
+ if (k - start != 2) {
128
+ return 0;
129
+ }
130
+ }
131
+ if (k < n && p[k] == '.') { /* fraction: dot then zero+ digits */
132
+ k++;
133
+ while (k < n && p[k] >= '0' && p[k] <= '9') {
134
+ k++;
135
+ }
136
+ }
137
+ /* tz: greedy, OPTIONAL — a malformed tail backtracks to empty and
138
+ * the overall match then fails at the tail byte (regex semantics) */
139
+ const uint32_t save = k;
140
+ while (k < n && (p[k] == ' ' || p[k] == '\t')) {
141
+ k++;
142
+ }
143
+ if (k < n && p[k] == 'Z') {
144
+ k++;
145
+ } else if (k < n && (p[k] == '+' || p[k] == '-')) {
146
+ k++;
147
+ const uint32_t ostart = k; /* offset hour: 1-2 digits */
148
+ while (k < n && k - ostart < 2 && p[k] >= '0' && p[k] <= '9') {
149
+ k++;
150
+ }
151
+ int ok = k - ostart > 0;
152
+ if (ok && k < n && p[k] == ':') { /* optional :mm — exactly two */
153
+ const uint32_t mstart = k + 1;
154
+ ok = mstart + 1 < n && p[mstart] >= '0' && p[mstart] <= '9' && p[mstart + 1] >= '0' &&
155
+ p[mstart + 1] <= '9';
156
+ if (ok) {
157
+ k = mstart + 2;
158
+ }
159
+ }
160
+ if (!ok) {
161
+ k = save;
162
+ }
163
+ } else {
164
+ k = save;
165
+ }
166
+ return k == n;
167
+ }
168
+
169
+ static yep_tag_id full12(void* ctx, const char* p, uint32_t n) {
170
+ (void)ctx;
171
+ /* the merge/value words: exact compares, ahead of everything (the
172
+ * 1.1 full schema's grammar-adjacent tags, PyYAML-resolved) */
173
+ if (n == 1 && p[0] == '=') {
174
+ return 10; /* value */
175
+ }
176
+ if (n == 2 && p[0] == '<' && p[1] == '<') {
177
+ return 9; /* merge */
178
+ }
179
+ /* the core base, verbatim */
180
+ yep_tag_id core = yep_core12_plain(p, n);
181
+ if (core != 0) {
182
+ return core;
183
+ }
184
+ /* timestamps: gate on the shape (four digits, '-', >= 10 bytes) —
185
+ * every accepted form starts with four digits */
186
+ if (n >= 10 && p[0] >= '0' && p[0] <= '9' && pyyaml_timestamp(p, n)) {
187
+ return 5;
188
+ }
189
+ return 0;
190
+ }
191
+
192
+ static yep_tag_id full12_number(void* ctx, int is_float) {
193
+ (void)ctx;
194
+ return is_float ? 2 : 1; /* full numbers are core numbers */
195
+ }
196
+
197
+ static const yep_resolver k_full12 = {full12, full12_number, NULL, 1};
198
+
199
+ const yep_resolver* yep_resolver_full12(void) {
200
+ return &k_full12;
201
+ }