edn_turbo 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +6 -6
- data/bin/build_docker_image.sh +1 -1
- data/ext/edn_turbo/edn_parser.cc +1090 -954
- data/ext/edn_turbo/edn_parser.rl +872 -842
- data/ext/edn_turbo/main.cc +3 -1
- data/ext/edn_turbo/parser.h +1 -0
- data/ext/edn_turbo/util.cc +18 -10
- data/ext/edn_turbo/util.h +2 -0
- data/lib/edn_turbo.rb +6 -0
- data/lib/edn_turbo/version.rb +2 -2
- data/spec/edn_turbo/edn_parser_spec.rb +34 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 695a3c68e9f69b9423a4da07056dfd8f264f62b39896c938938e56d1e28c395f
|
4
|
+
data.tar.gz: a370c5b31f462288fd340771c901d47f27e45e2308ef98728cb6abe59596631a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9b5aeb7c5b62d4add2ff2faa190138cf1baf0e902bdf3a28468c382ef0e94f6c95f93e3e05c48d7deb31e708d92f41607da60183b510593aa741eb68817be5
|
7
|
+
data.tar.gz: 39fb3b6b18cf3593fd537843aa2a08089552cb8900691ca88e3d8a86d05706e5f5ef557c8f3521c0b68b812652d1770f5f3a4621ca30087fa06299266a330352
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
|
3
3
|
|
4
|
+
## 0.6.1 - 2019-05-20
|
5
|
+
### Added
|
6
|
+
- Implement parsing of Ratio literals, represented as a ruby Rational.
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- Parsing of exact precision types.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- Build lists using EDN::list method that was previously broken.
|
13
|
+
|
14
|
+
|
4
15
|
## 0.6.0 - 2019-05-13
|
5
16
|
### Changed
|
6
17
|
- switched from MiniTest to RSpec.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
edn_turbo 0.6.
|
1
|
+
edn_turbo 0.6.1
|
2
2
|
===============
|
3
3
|
|
4
|
-
Fast (
|
4
|
+
Fast [Ragel](http://www.colm.net/open-source/ragel/)-based EDN parser for Ruby.
|
5
5
|
|
6
6
|
`edn_turbo` can be used as a parser plugin for
|
7
7
|
[edn](https://github.com/relevance/edn-ruby). With a few exceptions
|
@@ -66,10 +66,10 @@ the API is the same as the edn gem.
|
|
66
66
|
# also accepts a string
|
67
67
|
pp EDN.read("[ 1 2 3 abc ]")
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
# metadata
|
70
|
+
e = EDN.read('^String ^:foo ^{:foo false :tag Boolean :bar 2} [1 2]')
|
71
|
+
pp e # -> [1, 2]
|
72
|
+
pp e.metadata # -> {:foo=>true, :tag=>#<EDN::Type::Symbol:0x007fdbea8a29b0 @symbol=:String>, :bar=>2}
|
73
73
|
|
74
74
|
```
|
75
75
|
|
data/bin/build_docker_image.sh
CHANGED
data/ext/edn_turbo/edn_parser.cc
CHANGED
@@ -59,14 +59,14 @@ static const int EDN_value_error = 0;
|
|
59
59
|
static const int EDN_value_en_main = 1;
|
60
60
|
|
61
61
|
|
62
|
-
#line
|
62
|
+
#line 202 "edn_parser.rl"
|
63
63
|
|
64
64
|
|
65
65
|
|
66
66
|
const char *edn::Parser::parse_value(const char *p, const char *pe, VALUE& v)
|
67
67
|
{
|
68
|
-
|
69
|
-
|
68
|
+
// std::cerr << __FUNCTION__ << "() p: \"" << p << "\"" << std::endl;
|
69
|
+
int cs;
|
70
70
|
|
71
71
|
|
72
72
|
#line 73 "edn_parser.cc"
|
@@ -74,7 +74,7 @@ const char *edn::Parser::parse_value(const char *p, const char *pe, VALUE& v)
|
|
74
74
|
cs = EDN_value_start;
|
75
75
|
}
|
76
76
|
|
77
|
-
#line
|
77
|
+
#line 211 "edn_parser.rl"
|
78
78
|
|
79
79
|
#line 80 "edn_parser.cc"
|
80
80
|
{
|
@@ -119,116 +119,121 @@ st0:
|
|
119
119
|
cs = 0;
|
120
120
|
goto _out;
|
121
121
|
tr0:
|
122
|
-
#line
|
122
|
+
#line 130 "edn_parser.rl"
|
123
123
|
{
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
// stand-alone operators *, +, -, etc.
|
125
|
+
const char *np = parse_operator(p, pe, v);
|
126
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
127
|
+
}
|
128
128
|
goto st2;
|
129
129
|
tr2:
|
130
130
|
#line 93 "edn_parser.rl"
|
131
131
|
{
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
132
|
+
// string types within double-quotes
|
133
|
+
const char *np = parse_string(p, pe, v);
|
134
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
135
|
+
}
|
136
136
|
goto st2;
|
137
137
|
tr3:
|
138
|
-
#line
|
138
|
+
#line 182 "edn_parser.rl"
|
139
139
|
{
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
// handles tokens w/ leading # ("#_", "#{", and tagged elems)
|
141
|
+
const char *np = parse_dispatch(p + 1, pe, v);
|
142
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
143
|
+
}
|
144
144
|
goto st2;
|
145
145
|
tr4:
|
146
|
-
#line
|
146
|
+
#line 164 "edn_parser.rl"
|
147
147
|
{
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
// (
|
149
|
+
const char *np = parse_list(p, pe, v);
|
150
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
151
|
+
}
|
152
152
|
goto st2;
|
153
153
|
tr5:
|
154
154
|
#line 105 "edn_parser.rl"
|
155
155
|
{
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
// tokens w/ leading digits: non-negative integers & decimals.
|
157
|
+
// try to parse a decimal first
|
158
|
+
const char *np = parse_decimal(p, pe, v);
|
159
|
+
if (np == nullptr) {
|
160
|
+
// if we can't, try to parse it as a ratio
|
161
|
+
np = parse_ratio(p, pe, v);
|
162
|
+
|
163
|
+
// otherwise, an int
|
164
|
+
if (np == nullptr) {
|
161
165
|
np = parse_integer(p, pe, v);
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
if (np) {
|
170
|
+
{p = (( np))-1;}
|
171
|
+
p--;
|
172
|
+
{p++; cs = 2; goto _out;}
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
error(__FUNCTION__, "number format error", *p);
|
176
|
+
{p = (( pe))-1;}
|
177
|
+
}
|
178
|
+
}
|
174
179
|
goto st2;
|
175
180
|
tr6:
|
176
181
|
#line 99 "edn_parser.rl"
|
177
182
|
{
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
183
|
+
// tokens with a leading ':'
|
184
|
+
const char *np = parse_keyword(p, pe, v);
|
185
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
186
|
+
}
|
182
187
|
goto st2;
|
183
188
|
tr7:
|
184
|
-
#line
|
185
|
-
{
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
189
|
+
#line 142 "edn_parser.rl"
|
190
|
+
{
|
191
|
+
// user identifiers and reserved keywords (true, false, nil)
|
192
|
+
VALUE sym = Qnil;
|
193
|
+
const char *np = parse_symbol(p, pe, sym);
|
194
|
+
if (np == nullptr) { {p = (( pe))-1;} } else {
|
195
|
+
// parse_symbol will make 'sym' a ruby string
|
196
|
+
if (std::strcmp(RSTRING_PTR(sym), "true") == 0) { v = Qtrue; }
|
197
|
+
else if (std::strcmp(RSTRING_PTR(sym), "false") == 0) { v = Qfalse; }
|
198
|
+
else if (std::strcmp(RSTRING_PTR(sym), "nil") == 0) { v = Qnil; }
|
199
|
+
else {
|
200
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
201
|
+
}
|
202
|
+
{p = (( np))-1;}
|
203
|
+
}
|
204
|
+
}
|
200
205
|
goto st2;
|
201
206
|
tr8:
|
202
|
-
#line
|
207
|
+
#line 158 "edn_parser.rl"
|
203
208
|
{
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
209
|
+
// [
|
210
|
+
const char *np = parse_vector(p, pe, v);
|
211
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
212
|
+
}
|
208
213
|
goto st2;
|
209
214
|
tr9:
|
210
|
-
#line
|
215
|
+
#line 136 "edn_parser.rl"
|
211
216
|
{
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
217
|
+
// tokens w/ leading \ (escaped characters \newline, \c, etc.)
|
218
|
+
const char *np = parse_esc_char(p, pe, v);
|
219
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
220
|
+
}
|
216
221
|
goto st2;
|
217
222
|
tr10:
|
218
|
-
#line
|
223
|
+
#line 176 "edn_parser.rl"
|
219
224
|
{
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
225
|
+
// ^
|
226
|
+
const char *np = parse_meta(p, pe);
|
227
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
228
|
+
}
|
224
229
|
goto st2;
|
225
230
|
tr11:
|
226
|
-
#line
|
231
|
+
#line 170 "edn_parser.rl"
|
227
232
|
{
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
233
|
+
// {
|
234
|
+
const char *np = parse_map(p, pe, v);
|
235
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
236
|
+
}
|
232
237
|
goto st2;
|
233
238
|
st2:
|
234
239
|
if ( ++p == pe )
|
@@ -236,7 +241,7 @@ st2:
|
|
236
241
|
case 2:
|
237
242
|
#line 80 "edn_parser.rl"
|
238
243
|
{ p--; {p++; cs = 2; goto _out;} }
|
239
|
-
#line
|
244
|
+
#line 245 "edn_parser.cc"
|
240
245
|
goto st0;
|
241
246
|
}
|
242
247
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -245,17 +250,17 @@ case 2:
|
|
245
250
|
_out: {}
|
246
251
|
}
|
247
252
|
|
248
|
-
#line
|
253
|
+
#line 212 "edn_parser.rl"
|
249
254
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
255
|
+
if (cs >= EDN_value_first_final) {
|
256
|
+
return p;
|
257
|
+
}
|
258
|
+
else if (cs == EDN_value_error) {
|
259
|
+
error(__FUNCTION__, "token error", *p);
|
260
|
+
return pe;
|
261
|
+
}
|
262
|
+
else if (cs == EDN_value_en_main) {} // silence ragel warning
|
263
|
+
return nullptr;
|
259
264
|
}
|
260
265
|
|
261
266
|
|
@@ -267,7 +272,7 @@ case 2:
|
|
267
272
|
// ascii range is found.
|
268
273
|
//
|
269
274
|
|
270
|
-
#line
|
275
|
+
#line 276 "edn_parser.cc"
|
271
276
|
static const int EDN_string_start = 1;
|
272
277
|
static const int EDN_string_first_final = 8;
|
273
278
|
static const int EDN_string_error = 0;
|
@@ -275,26 +280,26 @@ static const int EDN_string_error = 0;
|
|
275
280
|
static const int EDN_string_en_main = 1;
|
276
281
|
|
277
282
|
|
278
|
-
#line
|
283
|
+
#line 257 "edn_parser.rl"
|
279
284
|
|
280
285
|
|
281
286
|
|
282
287
|
const char* edn::Parser::parse_string(const char *p, const char *pe, VALUE& v)
|
283
288
|
{
|
284
|
-
|
285
|
-
|
286
|
-
|
289
|
+
static const char* EDN_TYPE = "string";
|
290
|
+
int cs;
|
291
|
+
bool encode = false;
|
287
292
|
|
288
293
|
|
289
|
-
#line
|
294
|
+
#line 295 "edn_parser.cc"
|
290
295
|
{
|
291
296
|
cs = EDN_string_start;
|
292
297
|
}
|
293
298
|
|
294
|
-
#line
|
295
|
-
|
299
|
+
#line 267 "edn_parser.rl"
|
300
|
+
const char* p_save = p;
|
296
301
|
|
297
|
-
#line
|
302
|
+
#line 303 "edn_parser.cc"
|
298
303
|
{
|
299
304
|
if ( p == pe )
|
300
305
|
goto _test_eof;
|
@@ -308,16 +313,16 @@ st0:
|
|
308
313
|
cs = 0;
|
309
314
|
goto _out;
|
310
315
|
tr2:
|
311
|
-
#line
|
316
|
+
#line 246 "edn_parser.rl"
|
312
317
|
{
|
313
|
-
|
314
|
-
|
318
|
+
encode = true;
|
319
|
+
}
|
315
320
|
goto st2;
|
316
321
|
st2:
|
317
322
|
if ( ++p == pe )
|
318
323
|
goto _test_eof2;
|
319
324
|
case 2:
|
320
|
-
#line
|
325
|
+
#line 326 "edn_parser.cc"
|
321
326
|
switch( (*p) ) {
|
322
327
|
case 34: goto tr3;
|
323
328
|
case 92: goto tr4;
|
@@ -326,14 +331,14 @@ case 2:
|
|
326
331
|
goto tr2;
|
327
332
|
goto st2;
|
328
333
|
tr3:
|
329
|
-
#line
|
330
|
-
{
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
334
|
+
#line 238 "edn_parser.rl"
|
335
|
+
{
|
336
|
+
if (edn::util::parse_byte_stream(p_save + 1, p, v, encode)) {
|
337
|
+
{p = (( p + 1))-1;}
|
338
|
+
} else {
|
339
|
+
p--; {p++; cs = 8; goto _out;}
|
340
|
+
}
|
341
|
+
}
|
337
342
|
#line 80 "edn_parser.rl"
|
338
343
|
{ p--; {p++; cs = 8; goto _out;} }
|
339
344
|
goto st8;
|
@@ -341,19 +346,19 @@ st8:
|
|
341
346
|
if ( ++p == pe )
|
342
347
|
goto _test_eof8;
|
343
348
|
case 8:
|
344
|
-
#line
|
349
|
+
#line 350 "edn_parser.cc"
|
345
350
|
goto st0;
|
346
351
|
tr4:
|
347
|
-
#line
|
352
|
+
#line 246 "edn_parser.rl"
|
348
353
|
{
|
349
|
-
|
350
|
-
|
354
|
+
encode = true;
|
355
|
+
}
|
351
356
|
goto st3;
|
352
357
|
st3:
|
353
358
|
if ( ++p == pe )
|
354
359
|
goto _test_eof3;
|
355
360
|
case 3:
|
356
|
-
#line
|
361
|
+
#line 362 "edn_parser.cc"
|
357
362
|
switch( (*p) ) {
|
358
363
|
case 34: goto tr2;
|
359
364
|
case 47: goto tr2;
|
@@ -367,16 +372,16 @@ case 3:
|
|
367
372
|
}
|
368
373
|
goto st2;
|
369
374
|
tr5:
|
370
|
-
#line
|
375
|
+
#line 246 "edn_parser.rl"
|
371
376
|
{
|
372
|
-
|
373
|
-
|
377
|
+
encode = true;
|
378
|
+
}
|
374
379
|
goto st4;
|
375
380
|
st4:
|
376
381
|
if ( ++p == pe )
|
377
382
|
goto _test_eof4;
|
378
383
|
case 4:
|
379
|
-
#line
|
384
|
+
#line 385 "edn_parser.cc"
|
380
385
|
if ( (*p) < 65 ) {
|
381
386
|
if ( 48 <= (*p) && (*p) <= 57 )
|
382
387
|
goto tr6;
|
@@ -387,16 +392,16 @@ case 4:
|
|
387
392
|
goto tr6;
|
388
393
|
goto st0;
|
389
394
|
tr6:
|
390
|
-
#line
|
395
|
+
#line 246 "edn_parser.rl"
|
391
396
|
{
|
392
|
-
|
393
|
-
|
397
|
+
encode = true;
|
398
|
+
}
|
394
399
|
goto st5;
|
395
400
|
st5:
|
396
401
|
if ( ++p == pe )
|
397
402
|
goto _test_eof5;
|
398
403
|
case 5:
|
399
|
-
#line
|
404
|
+
#line 405 "edn_parser.cc"
|
400
405
|
if ( (*p) < 65 ) {
|
401
406
|
if ( 48 <= (*p) && (*p) <= 57 )
|
402
407
|
goto tr7;
|
@@ -407,16 +412,16 @@ case 5:
|
|
407
412
|
goto tr7;
|
408
413
|
goto st0;
|
409
414
|
tr7:
|
410
|
-
#line
|
415
|
+
#line 246 "edn_parser.rl"
|
411
416
|
{
|
412
|
-
|
413
|
-
|
417
|
+
encode = true;
|
418
|
+
}
|
414
419
|
goto st6;
|
415
420
|
st6:
|
416
421
|
if ( ++p == pe )
|
417
422
|
goto _test_eof6;
|
418
423
|
case 6:
|
419
|
-
#line
|
424
|
+
#line 425 "edn_parser.cc"
|
420
425
|
if ( (*p) < 65 ) {
|
421
426
|
if ( 48 <= (*p) && (*p) <= 57 )
|
422
427
|
goto tr8;
|
@@ -427,16 +432,16 @@ case 6:
|
|
427
432
|
goto tr8;
|
428
433
|
goto st0;
|
429
434
|
tr8:
|
430
|
-
#line
|
435
|
+
#line 246 "edn_parser.rl"
|
431
436
|
{
|
432
|
-
|
433
|
-
|
437
|
+
encode = true;
|
438
|
+
}
|
434
439
|
goto st7;
|
435
440
|
st7:
|
436
441
|
if ( ++p == pe )
|
437
442
|
goto _test_eof7;
|
438
443
|
case 7:
|
439
|
-
#line
|
444
|
+
#line 445 "edn_parser.cc"
|
440
445
|
if ( (*p) < 65 ) {
|
441
446
|
if ( 48 <= (*p) && (*p) <= 57 )
|
442
447
|
goto tr2;
|
@@ -462,29 +467,29 @@ case 7:
|
|
462
467
|
case 2:
|
463
468
|
#line 73 "edn_parser.rl"
|
464
469
|
{
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
+
std::stringstream s;
|
471
|
+
s << "unterminated " << EDN_TYPE;
|
472
|
+
error(__FUNCTION__, s.str());
|
473
|
+
p--; {p++; cs = 0; goto _out;}
|
474
|
+
}
|
470
475
|
break;
|
471
|
-
#line
|
476
|
+
#line 477 "edn_parser.cc"
|
472
477
|
}
|
473
478
|
}
|
474
479
|
|
475
480
|
_out: {}
|
476
481
|
}
|
477
482
|
|
478
|
-
#line
|
483
|
+
#line 269 "edn_parser.rl"
|
479
484
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
485
|
+
if (cs >= EDN_string_first_final) {
|
486
|
+
return p + 1;
|
487
|
+
}
|
488
|
+
else if (cs == EDN_string_error) {
|
489
|
+
return pe;
|
490
|
+
}
|
491
|
+
else if (cs == EDN_string_en_main) {} // silence ragel warning
|
492
|
+
return nullptr;
|
488
493
|
}
|
489
494
|
|
490
495
|
|
@@ -493,7 +498,7 @@ case 7:
|
|
493
498
|
// keyword parsing
|
494
499
|
//
|
495
500
|
|
496
|
-
#line
|
501
|
+
#line 502 "edn_parser.cc"
|
497
502
|
static const int EDN_keyword_start = 1;
|
498
503
|
static const int EDN_keyword_first_final = 3;
|
499
504
|
static const int EDN_keyword_error = 0;
|
@@ -501,24 +506,24 @@ static const int EDN_keyword_error = 0;
|
|
501
506
|
static const int EDN_keyword_en_main = 1;
|
502
507
|
|
503
508
|
|
504
|
-
#line
|
509
|
+
#line 299 "edn_parser.rl"
|
505
510
|
|
506
511
|
|
507
512
|
|
508
513
|
const char* edn::Parser::parse_keyword(const char *p, const char *pe, VALUE& v)
|
509
514
|
{
|
510
|
-
|
515
|
+
int cs;
|
511
516
|
|
512
517
|
|
513
|
-
#line
|
518
|
+
#line 519 "edn_parser.cc"
|
514
519
|
{
|
515
520
|
cs = EDN_keyword_start;
|
516
521
|
}
|
517
522
|
|
518
|
-
#line
|
519
|
-
|
523
|
+
#line 307 "edn_parser.rl"
|
524
|
+
const char* p_save = p;
|
520
525
|
|
521
|
-
#line
|
526
|
+
#line 527 "edn_parser.cc"
|
522
527
|
{
|
523
528
|
if ( p == pe )
|
524
529
|
goto _test_eof;
|
@@ -592,7 +597,7 @@ st4:
|
|
592
597
|
if ( ++p == pe )
|
593
598
|
goto _test_eof4;
|
594
599
|
case 4:
|
595
|
-
#line
|
600
|
+
#line 601 "edn_parser.cc"
|
596
601
|
goto st0;
|
597
602
|
st5:
|
598
603
|
if ( ++p == pe )
|
@@ -631,55 +636,54 @@ case 5:
|
|
631
636
|
_out: {}
|
632
637
|
}
|
633
638
|
|
634
|
-
#line
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
639
|
+
#line 309 "edn_parser.rl"
|
640
|
+
|
641
|
+
if (cs >= EDN_keyword_first_final) {
|
642
|
+
std::string buf;
|
643
|
+
uintmax_t len = p - p_save;
|
644
|
+
// don't include leading ':' because the ruby symbol will handle it
|
645
|
+
buf.append(p_save + 1, len - 1);
|
646
|
+
v = ID2SYM(rb_intern(buf.c_str()));
|
647
|
+
return p;
|
648
|
+
}
|
649
|
+
else if (cs == EDN_keyword_error) {
|
650
|
+
error(__FUNCTION__, "invalid keyword", *p);
|
651
|
+
return pe;
|
652
|
+
}
|
653
|
+
else if (cs == EDN_keyword_en_main) {} // silence ragel warning
|
654
|
+
return nullptr;
|
650
655
|
}
|
651
656
|
|
652
657
|
|
653
|
-
|
654
658
|
// ============================================================
|
655
659
|
// decimal parsing machine
|
656
660
|
//
|
657
661
|
|
658
|
-
#line
|
662
|
+
#line 663 "edn_parser.cc"
|
659
663
|
static const int EDN_decimal_start = 1;
|
660
664
|
static const int EDN_decimal_first_final = 9;
|
661
665
|
|
662
666
|
static const int EDN_decimal_en_main = 1;
|
663
667
|
|
664
668
|
|
665
|
-
#line
|
669
|
+
#line 341 "edn_parser.rl"
|
666
670
|
|
667
671
|
|
668
672
|
|
669
673
|
const char* edn::Parser::parse_decimal(const char *p, const char *pe, VALUE& v)
|
670
674
|
{
|
671
|
-
|
675
|
+
int cs;
|
672
676
|
|
673
677
|
|
674
|
-
#line
|
678
|
+
#line 679 "edn_parser.cc"
|
675
679
|
{
|
676
680
|
cs = EDN_decimal_start;
|
677
681
|
}
|
678
682
|
|
679
|
-
#line
|
680
|
-
|
683
|
+
#line 349 "edn_parser.rl"
|
684
|
+
const char* p_save = p;
|
681
685
|
|
682
|
-
#line
|
686
|
+
#line 687 "edn_parser.cc"
|
683
687
|
{
|
684
688
|
if ( p == pe )
|
685
689
|
goto _test_eof;
|
@@ -740,7 +744,7 @@ st10:
|
|
740
744
|
if ( ++p == pe )
|
741
745
|
goto _test_eof10;
|
742
746
|
case 10:
|
743
|
-
#line
|
747
|
+
#line 748 "edn_parser.cc"
|
744
748
|
goto st0;
|
745
749
|
st4:
|
746
750
|
if ( ++p == pe )
|
@@ -856,14 +860,14 @@ case 8:
|
|
856
860
|
_out: {}
|
857
861
|
}
|
858
862
|
|
859
|
-
#line
|
863
|
+
#line 351 "edn_parser.rl"
|
860
864
|
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
865
|
+
if (cs >= EDN_decimal_first_final) {
|
866
|
+
v = edn::util::float_to_ruby(p_save, p - p_save);
|
867
|
+
return p + 1;
|
868
|
+
}
|
869
|
+
else if (cs == EDN_decimal_en_main) {} // silence ragel warning
|
870
|
+
return nullptr;
|
867
871
|
}
|
868
872
|
|
869
873
|
|
@@ -871,30 +875,30 @@ case 8:
|
|
871
875
|
// integer parsing machine - M suffix will return a BigNum
|
872
876
|
//
|
873
877
|
|
874
|
-
#line
|
878
|
+
#line 879 "edn_parser.cc"
|
875
879
|
static const int EDN_integer_start = 1;
|
876
880
|
static const int EDN_integer_first_final = 3;
|
877
881
|
|
878
882
|
static const int EDN_integer_en_main = 1;
|
879
883
|
|
880
884
|
|
881
|
-
#line
|
885
|
+
#line 374 "edn_parser.rl"
|
882
886
|
|
883
887
|
|
884
888
|
const char* edn::Parser::parse_integer(const char *p, const char *pe, VALUE& v)
|
885
889
|
{
|
886
|
-
|
890
|
+
int cs;
|
887
891
|
|
888
892
|
|
889
|
-
#line
|
893
|
+
#line 894 "edn_parser.cc"
|
890
894
|
{
|
891
895
|
cs = EDN_integer_start;
|
892
896
|
}
|
893
897
|
|
894
|
-
#line
|
895
|
-
|
898
|
+
#line 381 "edn_parser.rl"
|
899
|
+
const char* p_save = p;
|
896
900
|
|
897
|
-
#line
|
901
|
+
#line 902 "edn_parser.cc"
|
898
902
|
{
|
899
903
|
if ( p == pe )
|
900
904
|
goto _test_eof;
|
@@ -943,7 +947,7 @@ st4:
|
|
943
947
|
if ( ++p == pe )
|
944
948
|
goto _test_eof4;
|
945
949
|
case 4:
|
946
|
-
#line
|
950
|
+
#line 951 "edn_parser.cc"
|
947
951
|
goto st0;
|
948
952
|
st5:
|
949
953
|
if ( ++p == pe )
|
@@ -984,17 +988,152 @@ case 6:
|
|
984
988
|
_out: {}
|
985
989
|
}
|
986
990
|
|
987
|
-
#line
|
991
|
+
#line 383 "edn_parser.rl"
|
988
992
|
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
993
|
+
if (cs >= EDN_integer_first_final) {
|
994
|
+
v = edn::util::integer_to_ruby(p_save, p - p_save);
|
995
|
+
return p + 1;
|
996
|
+
}
|
997
|
+
else if (cs == EDN_integer_en_main) {} // silence ragel warning
|
998
|
+
return nullptr;
|
995
999
|
}
|
996
1000
|
|
997
1001
|
|
1002
|
+
// ============================================================
|
1003
|
+
// ratio parsing machine
|
1004
|
+
//
|
1005
|
+
|
1006
|
+
#line 1007 "edn_parser.cc"
|
1007
|
+
static const int EDN_ratio_start = 1;
|
1008
|
+
static const int EDN_ratio_first_final = 6;
|
1009
|
+
|
1010
|
+
static const int EDN_ratio_en_main = 1;
|
1011
|
+
|
1012
|
+
|
1013
|
+
#line 406 "edn_parser.rl"
|
1014
|
+
|
1015
|
+
|
1016
|
+
|
1017
|
+
const char* edn::Parser::parse_ratio(const char *p, const char *pe, VALUE& v)
|
1018
|
+
{
|
1019
|
+
int cs;
|
1020
|
+
|
1021
|
+
|
1022
|
+
#line 1023 "edn_parser.cc"
|
1023
|
+
{
|
1024
|
+
cs = EDN_ratio_start;
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
#line 414 "edn_parser.rl"
|
1028
|
+
const char* p_save = p;
|
1029
|
+
|
1030
|
+
#line 1031 "edn_parser.cc"
|
1031
|
+
{
|
1032
|
+
if ( p == pe )
|
1033
|
+
goto _test_eof;
|
1034
|
+
switch ( cs )
|
1035
|
+
{
|
1036
|
+
case 1:
|
1037
|
+
switch( (*p) ) {
|
1038
|
+
case 43: goto st2;
|
1039
|
+
case 45: goto st2;
|
1040
|
+
case 48: goto st3;
|
1041
|
+
}
|
1042
|
+
if ( 49 <= (*p) && (*p) <= 57 )
|
1043
|
+
goto st5;
|
1044
|
+
goto st0;
|
1045
|
+
st0:
|
1046
|
+
cs = 0;
|
1047
|
+
goto _out;
|
1048
|
+
st2:
|
1049
|
+
if ( ++p == pe )
|
1050
|
+
goto _test_eof2;
|
1051
|
+
case 2:
|
1052
|
+
if ( (*p) == 48 )
|
1053
|
+
goto st3;
|
1054
|
+
if ( 49 <= (*p) && (*p) <= 57 )
|
1055
|
+
goto st5;
|
1056
|
+
goto st0;
|
1057
|
+
st3:
|
1058
|
+
if ( ++p == pe )
|
1059
|
+
goto _test_eof3;
|
1060
|
+
case 3:
|
1061
|
+
if ( (*p) == 47 )
|
1062
|
+
goto st4;
|
1063
|
+
goto st0;
|
1064
|
+
st4:
|
1065
|
+
if ( ++p == pe )
|
1066
|
+
goto _test_eof4;
|
1067
|
+
case 4:
|
1068
|
+
if ( (*p) == 48 )
|
1069
|
+
goto st6;
|
1070
|
+
if ( 49 <= (*p) && (*p) <= 57 )
|
1071
|
+
goto st8;
|
1072
|
+
goto st0;
|
1073
|
+
st6:
|
1074
|
+
if ( ++p == pe )
|
1075
|
+
goto _test_eof6;
|
1076
|
+
case 6:
|
1077
|
+
switch( (*p) ) {
|
1078
|
+
case 43: goto st0;
|
1079
|
+
case 45: goto st0;
|
1080
|
+
}
|
1081
|
+
if ( 47 <= (*p) && (*p) <= 57 )
|
1082
|
+
goto st0;
|
1083
|
+
goto tr7;
|
1084
|
+
tr7:
|
1085
|
+
#line 80 "edn_parser.rl"
|
1086
|
+
{ p--; {p++; cs = 7; goto _out;} }
|
1087
|
+
goto st7;
|
1088
|
+
st7:
|
1089
|
+
if ( ++p == pe )
|
1090
|
+
goto _test_eof7;
|
1091
|
+
case 7:
|
1092
|
+
#line 1093 "edn_parser.cc"
|
1093
|
+
goto st0;
|
1094
|
+
st8:
|
1095
|
+
if ( ++p == pe )
|
1096
|
+
goto _test_eof8;
|
1097
|
+
case 8:
|
1098
|
+
switch( (*p) ) {
|
1099
|
+
case 43: goto st0;
|
1100
|
+
case 45: goto st0;
|
1101
|
+
case 47: goto st0;
|
1102
|
+
}
|
1103
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
1104
|
+
goto st8;
|
1105
|
+
goto tr7;
|
1106
|
+
st5:
|
1107
|
+
if ( ++p == pe )
|
1108
|
+
goto _test_eof5;
|
1109
|
+
case 5:
|
1110
|
+
if ( (*p) == 47 )
|
1111
|
+
goto st4;
|
1112
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
1113
|
+
goto st5;
|
1114
|
+
goto st0;
|
1115
|
+
}
|
1116
|
+
_test_eof2: cs = 2; goto _test_eof;
|
1117
|
+
_test_eof3: cs = 3; goto _test_eof;
|
1118
|
+
_test_eof4: cs = 4; goto _test_eof;
|
1119
|
+
_test_eof6: cs = 6; goto _test_eof;
|
1120
|
+
_test_eof7: cs = 7; goto _test_eof;
|
1121
|
+
_test_eof8: cs = 8; goto _test_eof;
|
1122
|
+
_test_eof5: cs = 5; goto _test_eof;
|
1123
|
+
|
1124
|
+
_test_eof: {}
|
1125
|
+
_out: {}
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
#line 416 "edn_parser.rl"
|
1129
|
+
|
1130
|
+
if (cs >= EDN_ratio_first_final) {
|
1131
|
+
v = edn::util::ratio_to_ruby(p_save, p - p_save);
|
1132
|
+
return p + 1;
|
1133
|
+
}
|
1134
|
+
else if (cs == EDN_ratio_en_main) {} // silence ragel warning
|
1135
|
+
return nullptr;
|
1136
|
+
}
|
998
1137
|
|
999
1138
|
// ============================================================
|
1000
1139
|
// operator parsing - handles tokens w/ a leading operator:
|
@@ -1004,7 +1143,7 @@ case 6:
|
|
1004
1143
|
// 3. stand-alone operators: +, -, /, *, etc.
|
1005
1144
|
//
|
1006
1145
|
|
1007
|
-
#line
|
1146
|
+
#line 1147 "edn_parser.cc"
|
1008
1147
|
static const int EDN_operator_start = 1;
|
1009
1148
|
static const int EDN_operator_first_final = 3;
|
1010
1149
|
static const int EDN_operator_error = 0;
|
@@ -1012,24 +1151,24 @@ static const int EDN_operator_error = 0;
|
|
1012
1151
|
static const int EDN_operator_en_main = 1;
|
1013
1152
|
|
1014
1153
|
|
1015
|
-
#line
|
1154
|
+
#line 493 "edn_parser.rl"
|
1016
1155
|
|
1017
1156
|
|
1018
1157
|
|
1019
1158
|
const char* edn::Parser::parse_operator(const char *p, const char *pe, VALUE& v)
|
1020
1159
|
{
|
1021
|
-
|
1160
|
+
int cs;
|
1022
1161
|
|
1023
1162
|
|
1024
|
-
#line
|
1163
|
+
#line 1164 "edn_parser.cc"
|
1025
1164
|
{
|
1026
1165
|
cs = EDN_operator_start;
|
1027
1166
|
}
|
1028
1167
|
|
1029
|
-
#line
|
1030
|
-
|
1168
|
+
#line 501 "edn_parser.rl"
|
1169
|
+
const char* p_save = p;
|
1031
1170
|
|
1032
|
-
#line
|
1171
|
+
#line 1172 "edn_parser.cc"
|
1033
1172
|
{
|
1034
1173
|
if ( p == pe )
|
1035
1174
|
goto _test_eof;
|
@@ -1082,13 +1221,13 @@ case 3:
|
|
1082
1221
|
goto tr9;
|
1083
1222
|
goto tr6;
|
1084
1223
|
tr6:
|
1085
|
-
#line
|
1224
|
+
#line 477 "edn_parser.rl"
|
1086
1225
|
{
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1226
|
+
// stand-alone operators (-, +, /, ... etc)
|
1227
|
+
char op[2] = { *p_save, 0 };
|
1228
|
+
VALUE sym = rb_str_new2(op);
|
1229
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1230
|
+
}
|
1092
1231
|
#line 80 "edn_parser.rl"
|
1093
1232
|
{ p--; {p++; cs = 4; goto _out;} }
|
1094
1233
|
goto st4;
|
@@ -1097,17 +1236,17 @@ tr11:
|
|
1097
1236
|
{ p--; {p++; cs = 4; goto _out;} }
|
1098
1237
|
goto st4;
|
1099
1238
|
tr17:
|
1100
|
-
#line
|
1101
|
-
{
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1239
|
+
#line 438 "edn_parser.rl"
|
1240
|
+
{
|
1241
|
+
// parse a symbol including the leading operator (-, +, .)
|
1242
|
+
VALUE sym = Qnil;
|
1243
|
+
const char *np = parse_symbol(p_save, pe, sym);
|
1244
|
+
if (np == nullptr) { {p = (( pe))-1;} } else {
|
1245
|
+
if (sym != Qnil)
|
1246
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1247
|
+
{p = (( np))-1;}
|
1248
|
+
}
|
1249
|
+
}
|
1111
1250
|
#line 80 "edn_parser.rl"
|
1112
1251
|
{ p--; {p++; cs = 4; goto _out;} }
|
1113
1252
|
goto st4;
|
@@ -1115,31 +1254,31 @@ st4:
|
|
1115
1254
|
if ( ++p == pe )
|
1116
1255
|
goto _test_eof4;
|
1117
1256
|
case 4:
|
1118
|
-
#line
|
1257
|
+
#line 1258 "edn_parser.cc"
|
1119
1258
|
goto st0;
|
1120
1259
|
tr5:
|
1121
1260
|
#line 47 "edn_parser.rl"
|
1122
1261
|
{ line_number++; }
|
1123
1262
|
goto st5;
|
1124
1263
|
tr7:
|
1125
|
-
#line
|
1264
|
+
#line 477 "edn_parser.rl"
|
1126
1265
|
{
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1266
|
+
// stand-alone operators (-, +, /, ... etc)
|
1267
|
+
char op[2] = { *p_save, 0 };
|
1268
|
+
VALUE sym = rb_str_new2(op);
|
1269
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1270
|
+
}
|
1132
1271
|
#line 80 "edn_parser.rl"
|
1133
1272
|
{ p--; {p++; cs = 5; goto _out;} }
|
1134
1273
|
goto st5;
|
1135
1274
|
tr8:
|
1136
|
-
#line
|
1275
|
+
#line 477 "edn_parser.rl"
|
1137
1276
|
{
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1277
|
+
// stand-alone operators (-, +, /, ... etc)
|
1278
|
+
char op[2] = { *p_save, 0 };
|
1279
|
+
VALUE sym = rb_str_new2(op);
|
1280
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1281
|
+
}
|
1143
1282
|
#line 47 "edn_parser.rl"
|
1144
1283
|
{ line_number++; }
|
1145
1284
|
#line 80 "edn_parser.rl"
|
@@ -1159,7 +1298,7 @@ st5:
|
|
1159
1298
|
if ( ++p == pe )
|
1160
1299
|
goto _test_eof5;
|
1161
1300
|
case 5:
|
1162
|
-
#line
|
1301
|
+
#line 1302 "edn_parser.cc"
|
1163
1302
|
switch( (*p) ) {
|
1164
1303
|
case 10: goto tr13;
|
1165
1304
|
case 32: goto tr12;
|
@@ -1184,13 +1323,13 @@ case 5:
|
|
1184
1323
|
goto st0;
|
1185
1324
|
goto tr11;
|
1186
1325
|
tr10:
|
1187
|
-
#line
|
1326
|
+
#line 477 "edn_parser.rl"
|
1188
1327
|
{
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1328
|
+
// stand-alone operators (-, +, /, ... etc)
|
1329
|
+
char op[2] = { *p_save, 0 };
|
1330
|
+
VALUE sym = rb_str_new2(op);
|
1331
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1332
|
+
}
|
1194
1333
|
#line 80 "edn_parser.rl"
|
1195
1334
|
{ p--; {p++; cs = 6; goto _out;} }
|
1196
1335
|
goto st6;
|
@@ -1202,7 +1341,7 @@ st6:
|
|
1202
1341
|
if ( ++p == pe )
|
1203
1342
|
goto _test_eof6;
|
1204
1343
|
case 6:
|
1205
|
-
#line
|
1344
|
+
#line 1345 "edn_parser.cc"
|
1206
1345
|
if ( (*p) == 10 )
|
1207
1346
|
goto tr5;
|
1208
1347
|
goto st2;
|
@@ -1214,48 +1353,53 @@ case 2:
|
|
1214
1353
|
goto tr5;
|
1215
1354
|
goto st2;
|
1216
1355
|
tr9:
|
1217
|
-
#line
|
1218
|
-
{
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1356
|
+
#line 438 "edn_parser.rl"
|
1357
|
+
{
|
1358
|
+
// parse a symbol including the leading operator (-, +, .)
|
1359
|
+
VALUE sym = Qnil;
|
1360
|
+
const char *np = parse_symbol(p_save, pe, sym);
|
1361
|
+
if (np == nullptr) { {p = (( pe))-1;} } else {
|
1362
|
+
if (sym != Qnil)
|
1363
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1364
|
+
{p = (( np))-1;}
|
1365
|
+
}
|
1366
|
+
}
|
1228
1367
|
goto st7;
|
1229
1368
|
tr16:
|
1230
|
-
#line
|
1231
|
-
{
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1369
|
+
#line 449 "edn_parser.rl"
|
1370
|
+
{
|
1371
|
+
// parse a number with the leading symbol - this is slightly
|
1372
|
+
// different than the one within EDN_value since it includes
|
1373
|
+
// the leading - or +
|
1374
|
+
//
|
1375
|
+
// try to parse a decimal first
|
1376
|
+
const char *np = parse_decimal(p_save, pe, v);
|
1377
|
+
if (np == nullptr) {
|
1378
|
+
// if we can't, try to parse it as a ratio
|
1379
|
+
np = parse_ratio(p_save, pe, v);
|
1380
|
+
|
1381
|
+
if (np == nullptr) {
|
1382
|
+
// again, if we can't, try to parse it as an int
|
1240
1383
|
np = parse_integer(p_save, pe, v);
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
if (np) {
|
1388
|
+
{p = (( np))-1;}
|
1389
|
+
p--;
|
1390
|
+
{p++; cs = 7; goto _out;}
|
1391
|
+
}
|
1392
|
+
else {
|
1393
|
+
error(__FUNCTION__, "number format error", *p);
|
1394
|
+
{p = (( pe))-1;}
|
1395
|
+
}
|
1396
|
+
}
|
1253
1397
|
goto st7;
|
1254
1398
|
st7:
|
1255
1399
|
if ( ++p == pe )
|
1256
1400
|
goto _test_eof7;
|
1257
1401
|
case 7:
|
1258
|
-
#line
|
1402
|
+
#line 1403 "edn_parser.cc"
|
1259
1403
|
switch( (*p) ) {
|
1260
1404
|
case 33: goto st0;
|
1261
1405
|
case 95: goto st0;
|
@@ -1338,23 +1482,23 @@ case 9:
|
|
1338
1482
|
goto tr18;
|
1339
1483
|
goto tr17;
|
1340
1484
|
tr18:
|
1341
|
-
#line
|
1342
|
-
{
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1485
|
+
#line 438 "edn_parser.rl"
|
1486
|
+
{
|
1487
|
+
// parse a symbol including the leading operator (-, +, .)
|
1488
|
+
VALUE sym = Qnil;
|
1489
|
+
const char *np = parse_symbol(p_save, pe, sym);
|
1490
|
+
if (np == nullptr) { {p = (( pe))-1;} } else {
|
1491
|
+
if (sym != Qnil)
|
1492
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1493
|
+
{p = (( np))-1;}
|
1494
|
+
}
|
1495
|
+
}
|
1352
1496
|
goto st10;
|
1353
1497
|
st10:
|
1354
1498
|
if ( ++p == pe )
|
1355
1499
|
goto _test_eof10;
|
1356
1500
|
case 10:
|
1357
|
-
#line
|
1501
|
+
#line 1502 "edn_parser.cc"
|
1358
1502
|
switch( (*p) ) {
|
1359
1503
|
case 33: goto st10;
|
1360
1504
|
case 95: goto st10;
|
@@ -1427,47 +1571,47 @@ case 11:
|
|
1427
1571
|
{
|
1428
1572
|
switch ( cs ) {
|
1429
1573
|
case 9:
|
1430
|
-
#line
|
1431
|
-
{
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1574
|
+
#line 438 "edn_parser.rl"
|
1575
|
+
{
|
1576
|
+
// parse a symbol including the leading operator (-, +, .)
|
1577
|
+
VALUE sym = Qnil;
|
1578
|
+
const char *np = parse_symbol(p_save, pe, sym);
|
1579
|
+
if (np == nullptr) { {p = (( pe))-1;} } else {
|
1580
|
+
if (sym != Qnil)
|
1581
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1582
|
+
{p = (( np))-1;}
|
1583
|
+
}
|
1584
|
+
}
|
1441
1585
|
break;
|
1442
1586
|
case 3:
|
1443
1587
|
case 8:
|
1444
1588
|
case 11:
|
1445
|
-
#line
|
1589
|
+
#line 477 "edn_parser.rl"
|
1446
1590
|
{
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1591
|
+
// stand-alone operators (-, +, /, ... etc)
|
1592
|
+
char op[2] = { *p_save, 0 };
|
1593
|
+
VALUE sym = rb_str_new2(op);
|
1594
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SYMBOL_METHOD, sym);
|
1595
|
+
}
|
1452
1596
|
break;
|
1453
|
-
#line
|
1597
|
+
#line 1598 "edn_parser.cc"
|
1454
1598
|
}
|
1455
1599
|
}
|
1456
1600
|
|
1457
1601
|
_out: {}
|
1458
1602
|
}
|
1459
1603
|
|
1460
|
-
#line
|
1604
|
+
#line 503 "edn_parser.rl"
|
1461
1605
|
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1606
|
+
if (cs >= EDN_operator_first_final) {
|
1607
|
+
return p;
|
1608
|
+
}
|
1609
|
+
else if (cs == EDN_operator_error) {
|
1610
|
+
error(__FUNCTION__, "symbol syntax error", *p);
|
1611
|
+
return pe;
|
1612
|
+
}
|
1613
|
+
else if (cs == EDN_operator_en_main) {} // silence ragel warning
|
1614
|
+
return nullptr;
|
1471
1615
|
}
|
1472
1616
|
|
1473
1617
|
|
@@ -1476,7 +1620,7 @@ case 11:
|
|
1476
1620
|
// escaped char parsing - handles \c, \newline, \formfeed, etc.
|
1477
1621
|
//
|
1478
1622
|
|
1479
|
-
#line
|
1623
|
+
#line 1624 "edn_parser.cc"
|
1480
1624
|
static const int EDN_escaped_char_start = 1;
|
1481
1625
|
static const int EDN_escaped_char_first_final = 26;
|
1482
1626
|
static const int EDN_escaped_char_error = 0;
|
@@ -1484,24 +1628,24 @@ static const int EDN_escaped_char_error = 0;
|
|
1484
1628
|
static const int EDN_escaped_char_en_main = 1;
|
1485
1629
|
|
1486
1630
|
|
1487
|
-
#line
|
1631
|
+
#line 533 "edn_parser.rl"
|
1488
1632
|
|
1489
1633
|
|
1490
1634
|
|
1491
1635
|
const char* edn::Parser::parse_esc_char(const char *p, const char *pe, VALUE& v)
|
1492
1636
|
{
|
1493
|
-
|
1637
|
+
int cs;
|
1494
1638
|
|
1495
1639
|
|
1496
|
-
#line
|
1640
|
+
#line 1641 "edn_parser.cc"
|
1497
1641
|
{
|
1498
1642
|
cs = EDN_escaped_char_start;
|
1499
1643
|
}
|
1500
1644
|
|
1501
|
-
#line
|
1502
|
-
|
1645
|
+
#line 541 "edn_parser.rl"
|
1646
|
+
const char* p_save = p;
|
1503
1647
|
|
1504
|
-
#line
|
1648
|
+
#line 1649 "edn_parser.cc"
|
1505
1649
|
{
|
1506
1650
|
if ( p == pe )
|
1507
1651
|
goto _test_eof;
|
@@ -1559,7 +1703,7 @@ st27:
|
|
1559
1703
|
if ( ++p == pe )
|
1560
1704
|
goto _test_eof27;
|
1561
1705
|
case 27:
|
1562
|
-
#line
|
1706
|
+
#line 1707 "edn_parser.cc"
|
1563
1707
|
switch( (*p) ) {
|
1564
1708
|
case 10: goto tr10;
|
1565
1709
|
case 32: goto tr28;
|
@@ -1584,7 +1728,7 @@ st28:
|
|
1584
1728
|
if ( ++p == pe )
|
1585
1729
|
goto _test_eof28;
|
1586
1730
|
case 28:
|
1587
|
-
#line
|
1731
|
+
#line 1732 "edn_parser.cc"
|
1588
1732
|
goto st0;
|
1589
1733
|
st29:
|
1590
1734
|
if ( ++p == pe )
|
@@ -1893,26 +2037,25 @@ case 25:
|
|
1893
2037
|
_out: {}
|
1894
2038
|
}
|
1895
2039
|
|
1896
|
-
#line
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
2040
|
+
#line 543 "edn_parser.rl"
|
2041
|
+
|
2042
|
+
if (cs >= EDN_escaped_char_first_final) {
|
2043
|
+
// convert the escaped value to a character
|
2044
|
+
if (!edn::util::parse_escaped_char(p_save + 1, p, v)) {
|
2045
|
+
return pe;
|
2046
|
+
}
|
2047
|
+
return p;
|
2048
|
+
}
|
2049
|
+
else if (cs == EDN_escaped_char_error) {
|
2050
|
+
error(__FUNCTION__, "unexpected value", *p);
|
2051
|
+
return pe;
|
2052
|
+
}
|
2053
|
+
else if (cs == EDN_escaped_char_en_main) {} // silence ragel warning
|
2054
|
+
return nullptr;
|
1911
2055
|
}
|
1912
2056
|
|
1913
2057
|
|
1914
2058
|
|
1915
|
-
|
1916
2059
|
// ============================================================
|
1917
2060
|
// symbol parsing - handles identifiers that begin with an alpha
|
1918
2061
|
// character and an optional leading operator (name, -today,
|
@@ -1920,7 +2063,7 @@ case 25:
|
|
1920
2063
|
//
|
1921
2064
|
//
|
1922
2065
|
|
1923
|
-
#line
|
2066
|
+
#line 2067 "edn_parser.cc"
|
1924
2067
|
static const int EDN_symbol_start = 1;
|
1925
2068
|
static const int EDN_symbol_first_final = 4;
|
1926
2069
|
static const int EDN_symbol_error = 0;
|
@@ -1928,24 +2071,24 @@ static const int EDN_symbol_error = 0;
|
|
1928
2071
|
static const int EDN_symbol_en_main = 1;
|
1929
2072
|
|
1930
2073
|
|
1931
|
-
#line
|
2074
|
+
#line 593 "edn_parser.rl"
|
1932
2075
|
|
1933
2076
|
|
1934
2077
|
|
1935
2078
|
const char* edn::Parser::parse_symbol(const char *p, const char *pe, VALUE& s)
|
1936
2079
|
{
|
1937
|
-
|
2080
|
+
int cs;
|
1938
2081
|
|
1939
2082
|
|
1940
|
-
#line
|
2083
|
+
#line 2084 "edn_parser.cc"
|
1941
2084
|
{
|
1942
2085
|
cs = EDN_symbol_start;
|
1943
2086
|
}
|
1944
2087
|
|
1945
|
-
#line
|
1946
|
-
|
2088
|
+
#line 601 "edn_parser.rl"
|
2089
|
+
const char* p_save = p;
|
1947
2090
|
|
1948
|
-
#line
|
2091
|
+
#line 2092 "edn_parser.cc"
|
1949
2092
|
{
|
1950
2093
|
if ( p == pe )
|
1951
2094
|
goto _test_eof;
|
@@ -2014,7 +2157,7 @@ st5:
|
|
2014
2157
|
if ( ++p == pe )
|
2015
2158
|
goto _test_eof5;
|
2016
2159
|
case 5:
|
2017
|
-
#line
|
2160
|
+
#line 2161 "edn_parser.cc"
|
2018
2161
|
goto st0;
|
2019
2162
|
tr4:
|
2020
2163
|
#line 47 "edn_parser.rl"
|
@@ -2034,7 +2177,7 @@ st6:
|
|
2034
2177
|
if ( ++p == pe )
|
2035
2178
|
goto _test_eof6;
|
2036
2179
|
case 6:
|
2037
|
-
#line
|
2180
|
+
#line 2181 "edn_parser.cc"
|
2038
2181
|
switch( (*p) ) {
|
2039
2182
|
case 10: goto tr9;
|
2040
2183
|
case 32: goto tr8;
|
@@ -2066,7 +2209,7 @@ st7:
|
|
2066
2209
|
if ( ++p == pe )
|
2067
2210
|
goto _test_eof7;
|
2068
2211
|
case 7:
|
2069
|
-
#line
|
2212
|
+
#line 2213 "edn_parser.cc"
|
2070
2213
|
if ( (*p) == 10 )
|
2071
2214
|
goto tr4;
|
2072
2215
|
goto st2;
|
@@ -2174,24 +2317,23 @@ case 9:
|
|
2174
2317
|
_out: {}
|
2175
2318
|
}
|
2176
2319
|
|
2177
|
-
#line
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2320
|
+
#line 603 "edn_parser.rl"
|
2321
|
+
|
2322
|
+
if (cs >= EDN_symbol_first_final) {
|
2323
|
+
// copy the symbol text
|
2324
|
+
if (s == Qnil)
|
2325
|
+
s = rb_str_new2("");
|
2326
|
+
rb_str_cat(s, p_save, p - p_save);
|
2327
|
+
return p;
|
2328
|
+
}
|
2329
|
+
else if (cs == EDN_symbol_error) {
|
2330
|
+
error(__FUNCTION__, "invalid symbol sequence", *p);
|
2331
|
+
}
|
2332
|
+
else if (cs == EDN_symbol_en_main) {} // silence ragel warning
|
2333
|
+
return nullptr;
|
2191
2334
|
}
|
2192
2335
|
|
2193
2336
|
|
2194
|
-
|
2195
2337
|
// ============================================================
|
2196
2338
|
// EDN_sequence_common is used to parse EDN containers - elements are
|
2197
2339
|
// initially stored in an array and then the final corresponding
|
@@ -2199,13 +2341,13 @@ case 9:
|
|
2199
2341
|
// sets the same array is used)
|
2200
2342
|
//
|
2201
2343
|
|
2202
|
-
#line
|
2344
|
+
#line 680 "edn_parser.rl"
|
2203
2345
|
|
2204
2346
|
|
2205
2347
|
//
|
2206
2348
|
// vector-specific machine
|
2207
2349
|
|
2208
|
-
#line
|
2350
|
+
#line 2351 "edn_parser.cc"
|
2209
2351
|
static const int EDN_vector_start = 1;
|
2210
2352
|
static const int EDN_vector_first_final = 4;
|
2211
2353
|
static const int EDN_vector_error = 0;
|
@@ -2213,7 +2355,7 @@ static const int EDN_vector_error = 0;
|
|
2213
2355
|
static const int EDN_vector_en_main = 1;
|
2214
2356
|
|
2215
2357
|
|
2216
|
-
#line
|
2358
|
+
#line 695 "edn_parser.rl"
|
2217
2359
|
|
2218
2360
|
|
2219
2361
|
|
@@ -2222,20 +2364,20 @@ static const int EDN_vector_en_main = 1;
|
|
2222
2364
|
//
|
2223
2365
|
const char* edn::Parser::parse_vector(const char *p, const char *pe, VALUE& v)
|
2224
2366
|
{
|
2225
|
-
|
2367
|
+
static const char* EDN_TYPE = "vector";
|
2226
2368
|
|
2227
|
-
|
2228
|
-
|
2369
|
+
int cs;
|
2370
|
+
VALUE elems; // will store the vector's elements - allocated in @open_seq
|
2229
2371
|
|
2230
2372
|
|
2231
|
-
#line
|
2373
|
+
#line 2374 "edn_parser.cc"
|
2232
2374
|
{
|
2233
2375
|
cs = EDN_vector_start;
|
2234
2376
|
}
|
2235
2377
|
|
2236
|
-
#line
|
2378
|
+
#line 709 "edn_parser.rl"
|
2237
2379
|
|
2238
|
-
#line
|
2380
|
+
#line 2381 "edn_parser.cc"
|
2239
2381
|
{
|
2240
2382
|
if ( p == pe )
|
2241
2383
|
goto _test_eof;
|
@@ -2248,72 +2390,72 @@ case 1:
|
|
2248
2390
|
tr2:
|
2249
2391
|
#line 73 "edn_parser.rl"
|
2250
2392
|
{
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2393
|
+
std::stringstream s;
|
2394
|
+
s << "unterminated " << EDN_TYPE;
|
2395
|
+
error(__FUNCTION__, s.str());
|
2396
|
+
p--; {p++; cs = 0; goto _out;}
|
2397
|
+
}
|
2256
2398
|
goto st0;
|
2257
|
-
#line
|
2399
|
+
#line 2400 "edn_parser.cc"
|
2258
2400
|
st0:
|
2259
2401
|
cs = 0;
|
2260
2402
|
goto _out;
|
2261
2403
|
tr0:
|
2262
|
-
#line
|
2263
|
-
{
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2404
|
+
#line 629 "edn_parser.rl"
|
2405
|
+
{
|
2406
|
+
// sequences store elements in an array, then process it to
|
2407
|
+
// convert it to a list, set, or map as needed once the
|
2408
|
+
// sequence end is reached
|
2409
|
+
elems = rb_ary_new();
|
2410
|
+
// additionally, metadata for elements in the sequence may be
|
2411
|
+
// carried so we must push a new level in the metadata stack
|
2412
|
+
new_meta_list();
|
2413
|
+
}
|
2272
2414
|
goto st2;
|
2273
2415
|
tr4:
|
2274
2416
|
#line 47 "edn_parser.rl"
|
2275
2417
|
{ line_number++; }
|
2276
2418
|
goto st2;
|
2277
2419
|
tr5:
|
2278
|
-
#line
|
2279
|
-
{
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2420
|
+
#line 644 "edn_parser.rl"
|
2421
|
+
{
|
2422
|
+
// reads an item within a sequence (vector, list, map, or
|
2423
|
+
// set). Regardless of the sequence type, an array of the
|
2424
|
+
// items is built. Once done, the sequence parser will convert
|
2425
|
+
// if needed
|
2426
|
+
VALUE e;
|
2427
|
+
std::size_t meta_sz = meta_size();
|
2428
|
+
const char *np = parse_value(p, pe, e);
|
2429
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {
|
2430
|
+
// if there's an entry in the discard list, the current
|
2431
|
+
// object is not meant to be kept due to a #_ so don't
|
2432
|
+
// push it into the list of elements
|
2433
|
+
if (!discard.empty()) {
|
2434
|
+
discard.pop_back();
|
2435
|
+
}
|
2436
|
+
else if (!meta_empty()) {
|
2437
|
+
// check if parse_value added metadata
|
2438
|
+
if (meta_size() == meta_sz) {
|
2439
|
+
// there's metadata and it didn't increase so
|
2440
|
+
// parse_value() read an element we care
|
2441
|
+
// about. Bind the metadata to it and add it to
|
2442
|
+
// the sequence
|
2443
|
+
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
2444
|
+
rb_ary_push(elems, e);
|
2293
2445
|
}
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
2302
|
-
rb_ary_push(elems, e);
|
2303
|
-
}
|
2304
|
-
} else {
|
2305
|
-
// no metadata.. just push it
|
2306
|
-
rb_ary_push(elems, e);
|
2307
|
-
}
|
2308
|
-
{p = (( np))-1;}
|
2309
|
-
}
|
2310
|
-
}
|
2446
|
+
} else {
|
2447
|
+
// no metadata.. just push it
|
2448
|
+
rb_ary_push(elems, e);
|
2449
|
+
}
|
2450
|
+
{p = (( np))-1;}
|
2451
|
+
}
|
2452
|
+
}
|
2311
2453
|
goto st2;
|
2312
2454
|
st2:
|
2313
2455
|
if ( ++p == pe )
|
2314
2456
|
goto _test_eof2;
|
2315
2457
|
case 2:
|
2316
|
-
#line
|
2458
|
+
#line 2459 "edn_parser.cc"
|
2317
2459
|
switch( (*p) ) {
|
2318
2460
|
case 10: goto tr4;
|
2319
2461
|
case 32: goto st2;
|
@@ -2344,11 +2486,11 @@ case 3:
|
|
2344
2486
|
goto tr4;
|
2345
2487
|
goto st3;
|
2346
2488
|
tr7:
|
2347
|
-
#line
|
2489
|
+
#line 639 "edn_parser.rl"
|
2348
2490
|
{
|
2349
|
-
|
2350
|
-
|
2351
|
-
|
2491
|
+
// remove the current metadata level
|
2492
|
+
del_top_meta_list();
|
2493
|
+
}
|
2352
2494
|
#line 80 "edn_parser.rl"
|
2353
2495
|
{ p--; {p++; cs = 4; goto _out;} }
|
2354
2496
|
goto st4;
|
@@ -2356,7 +2498,7 @@ st4:
|
|
2356
2498
|
if ( ++p == pe )
|
2357
2499
|
goto _test_eof4;
|
2358
2500
|
case 4:
|
2359
|
-
#line
|
2501
|
+
#line 2502 "edn_parser.cc"
|
2360
2502
|
goto st0;
|
2361
2503
|
}
|
2362
2504
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -2371,31 +2513,31 @@ case 4:
|
|
2371
2513
|
case 3:
|
2372
2514
|
#line 73 "edn_parser.rl"
|
2373
2515
|
{
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
2516
|
+
std::stringstream s;
|
2517
|
+
s << "unterminated " << EDN_TYPE;
|
2518
|
+
error(__FUNCTION__, s.str());
|
2519
|
+
p--; {p++; cs = 0; goto _out;}
|
2520
|
+
}
|
2379
2521
|
break;
|
2380
|
-
#line
|
2522
|
+
#line 2523 "edn_parser.cc"
|
2381
2523
|
}
|
2382
2524
|
}
|
2383
2525
|
|
2384
2526
|
_out: {}
|
2385
2527
|
}
|
2386
2528
|
|
2387
|
-
#line
|
2529
|
+
#line 710 "edn_parser.rl"
|
2388
2530
|
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2392
|
-
|
2393
|
-
|
2394
|
-
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
|
2531
|
+
if (cs >= EDN_vector_first_final) {
|
2532
|
+
v = elems;
|
2533
|
+
return p + 1;
|
2534
|
+
}
|
2535
|
+
else if (cs == EDN_vector_error) {
|
2536
|
+
error(__FUNCTION__, "vector format error", *p);
|
2537
|
+
return pe;
|
2538
|
+
}
|
2539
|
+
else if (cs == EDN_vector_en_main) {} // silence ragel warning
|
2540
|
+
return nullptr;
|
2399
2541
|
}
|
2400
2542
|
|
2401
2543
|
|
@@ -2404,7 +2546,7 @@ case 4:
|
|
2404
2546
|
// list parsing machine
|
2405
2547
|
//
|
2406
2548
|
|
2407
|
-
#line
|
2549
|
+
#line 2550 "edn_parser.cc"
|
2408
2550
|
static const int EDN_list_start = 1;
|
2409
2551
|
static const int EDN_list_first_final = 4;
|
2410
2552
|
static const int EDN_list_error = 0;
|
@@ -2412,7 +2554,7 @@ static const int EDN_list_error = 0;
|
|
2412
2554
|
static const int EDN_list_en_main = 1;
|
2413
2555
|
|
2414
2556
|
|
2415
|
-
#line
|
2557
|
+
#line 739 "edn_parser.rl"
|
2416
2558
|
|
2417
2559
|
|
2418
2560
|
//
|
@@ -2420,20 +2562,20 @@ static const int EDN_list_en_main = 1;
|
|
2420
2562
|
//
|
2421
2563
|
const char* edn::Parser::parse_list(const char *p, const char *pe, VALUE& v)
|
2422
2564
|
{
|
2423
|
-
|
2565
|
+
static const char* EDN_TYPE = "list";
|
2424
2566
|
|
2425
|
-
|
2426
|
-
|
2567
|
+
int cs;
|
2568
|
+
VALUE elems; // stores the list's elements - allocated in @open_seq
|
2427
2569
|
|
2428
2570
|
|
2429
|
-
#line
|
2571
|
+
#line 2572 "edn_parser.cc"
|
2430
2572
|
{
|
2431
2573
|
cs = EDN_list_start;
|
2432
2574
|
}
|
2433
2575
|
|
2434
|
-
#line
|
2576
|
+
#line 752 "edn_parser.rl"
|
2435
2577
|
|
2436
|
-
#line
|
2578
|
+
#line 2579 "edn_parser.cc"
|
2437
2579
|
{
|
2438
2580
|
if ( p == pe )
|
2439
2581
|
goto _test_eof;
|
@@ -2446,72 +2588,72 @@ case 1:
|
|
2446
2588
|
tr2:
|
2447
2589
|
#line 73 "edn_parser.rl"
|
2448
2590
|
{
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2591
|
+
std::stringstream s;
|
2592
|
+
s << "unterminated " << EDN_TYPE;
|
2593
|
+
error(__FUNCTION__, s.str());
|
2594
|
+
p--; {p++; cs = 0; goto _out;}
|
2595
|
+
}
|
2454
2596
|
goto st0;
|
2455
|
-
#line
|
2597
|
+
#line 2598 "edn_parser.cc"
|
2456
2598
|
st0:
|
2457
2599
|
cs = 0;
|
2458
2600
|
goto _out;
|
2459
2601
|
tr0:
|
2460
|
-
#line
|
2461
|
-
{
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
|
2467
|
-
|
2468
|
-
|
2469
|
-
|
2602
|
+
#line 629 "edn_parser.rl"
|
2603
|
+
{
|
2604
|
+
// sequences store elements in an array, then process it to
|
2605
|
+
// convert it to a list, set, or map as needed once the
|
2606
|
+
// sequence end is reached
|
2607
|
+
elems = rb_ary_new();
|
2608
|
+
// additionally, metadata for elements in the sequence may be
|
2609
|
+
// carried so we must push a new level in the metadata stack
|
2610
|
+
new_meta_list();
|
2611
|
+
}
|
2470
2612
|
goto st2;
|
2471
2613
|
tr4:
|
2472
2614
|
#line 47 "edn_parser.rl"
|
2473
2615
|
{ line_number++; }
|
2474
2616
|
goto st2;
|
2475
2617
|
tr5:
|
2476
|
-
#line
|
2477
|
-
{
|
2478
|
-
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2488
|
-
|
2489
|
-
|
2490
|
-
|
2491
|
-
|
2492
|
-
|
2493
|
-
|
2494
|
-
|
2495
|
-
|
2496
|
-
|
2497
|
-
|
2498
|
-
|
2499
|
-
|
2500
|
-
|
2501
|
-
}
|
2502
|
-
} else {
|
2503
|
-
// no metadata.. just push it
|
2504
|
-
rb_ary_push(elems, e);
|
2618
|
+
#line 644 "edn_parser.rl"
|
2619
|
+
{
|
2620
|
+
// reads an item within a sequence (vector, list, map, or
|
2621
|
+
// set). Regardless of the sequence type, an array of the
|
2622
|
+
// items is built. Once done, the sequence parser will convert
|
2623
|
+
// if needed
|
2624
|
+
VALUE e;
|
2625
|
+
std::size_t meta_sz = meta_size();
|
2626
|
+
const char *np = parse_value(p, pe, e);
|
2627
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {
|
2628
|
+
// if there's an entry in the discard list, the current
|
2629
|
+
// object is not meant to be kept due to a #_ so don't
|
2630
|
+
// push it into the list of elements
|
2631
|
+
if (!discard.empty()) {
|
2632
|
+
discard.pop_back();
|
2633
|
+
}
|
2634
|
+
else if (!meta_empty()) {
|
2635
|
+
// check if parse_value added metadata
|
2636
|
+
if (meta_size() == meta_sz) {
|
2637
|
+
// there's metadata and it didn't increase so
|
2638
|
+
// parse_value() read an element we care
|
2639
|
+
// about. Bind the metadata to it and add it to
|
2640
|
+
// the sequence
|
2641
|
+
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
2642
|
+
rb_ary_push(elems, e);
|
2505
2643
|
}
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2644
|
+
} else {
|
2645
|
+
// no metadata.. just push it
|
2646
|
+
rb_ary_push(elems, e);
|
2647
|
+
}
|
2648
|
+
{p = (( np))-1;}
|
2649
|
+
}
|
2650
|
+
}
|
2509
2651
|
goto st2;
|
2510
2652
|
st2:
|
2511
2653
|
if ( ++p == pe )
|
2512
2654
|
goto _test_eof2;
|
2513
2655
|
case 2:
|
2514
|
-
#line
|
2656
|
+
#line 2657 "edn_parser.cc"
|
2515
2657
|
switch( (*p) ) {
|
2516
2658
|
case 10: goto tr4;
|
2517
2659
|
case 32: goto st2;
|
@@ -2535,11 +2677,11 @@ case 2:
|
|
2535
2677
|
goto tr5;
|
2536
2678
|
goto tr2;
|
2537
2679
|
tr6:
|
2538
|
-
#line
|
2680
|
+
#line 639 "edn_parser.rl"
|
2539
2681
|
{
|
2540
|
-
|
2541
|
-
|
2542
|
-
|
2682
|
+
// remove the current metadata level
|
2683
|
+
del_top_meta_list();
|
2684
|
+
}
|
2543
2685
|
#line 80 "edn_parser.rl"
|
2544
2686
|
{ p--; {p++; cs = 4; goto _out;} }
|
2545
2687
|
goto st4;
|
@@ -2547,7 +2689,7 @@ st4:
|
|
2547
2689
|
if ( ++p == pe )
|
2548
2690
|
goto _test_eof4;
|
2549
2691
|
case 4:
|
2550
|
-
#line
|
2692
|
+
#line 2693 "edn_parser.cc"
|
2551
2693
|
goto st0;
|
2552
2694
|
st3:
|
2553
2695
|
if ( ++p == pe )
|
@@ -2569,33 +2711,33 @@ case 3:
|
|
2569
2711
|
case 3:
|
2570
2712
|
#line 73 "edn_parser.rl"
|
2571
2713
|
{
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
|
2576
|
-
|
2714
|
+
std::stringstream s;
|
2715
|
+
s << "unterminated " << EDN_TYPE;
|
2716
|
+
error(__FUNCTION__, s.str());
|
2717
|
+
p--; {p++; cs = 0; goto _out;}
|
2718
|
+
}
|
2577
2719
|
break;
|
2578
|
-
#line
|
2720
|
+
#line 2721 "edn_parser.cc"
|
2579
2721
|
}
|
2580
2722
|
}
|
2581
2723
|
|
2582
2724
|
_out: {}
|
2583
2725
|
}
|
2584
2726
|
|
2585
|
-
#line
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
2595
|
-
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2727
|
+
#line 753 "edn_parser.rl"
|
2728
|
+
|
2729
|
+
if (cs >= EDN_list_first_final) {
|
2730
|
+
//v = elems;
|
2731
|
+
// TODO: replace with this but first figure out why array is not unrolled by EDN::list()
|
2732
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_LIST_METHOD, elems);
|
2733
|
+
return p + 1;
|
2734
|
+
}
|
2735
|
+
else if (cs == EDN_list_error) {
|
2736
|
+
error(__FUNCTION__, *p);
|
2737
|
+
return pe;
|
2738
|
+
}
|
2739
|
+
else if (cs == EDN_list_en_main) {} // silence ragel warning
|
2740
|
+
return nullptr;
|
2599
2741
|
}
|
2600
2742
|
|
2601
2743
|
|
@@ -2604,7 +2746,7 @@ case 3:
|
|
2604
2746
|
// hash parsing
|
2605
2747
|
//
|
2606
2748
|
|
2607
|
-
#line
|
2749
|
+
#line 2750 "edn_parser.cc"
|
2608
2750
|
static const int EDN_map_start = 1;
|
2609
2751
|
static const int EDN_map_first_final = 4;
|
2610
2752
|
static const int EDN_map_error = 0;
|
@@ -2612,28 +2754,28 @@ static const int EDN_map_error = 0;
|
|
2612
2754
|
static const int EDN_map_en_main = 1;
|
2613
2755
|
|
2614
2756
|
|
2615
|
-
#line
|
2757
|
+
#line 785 "edn_parser.rl"
|
2616
2758
|
|
2617
2759
|
|
2618
2760
|
|
2619
2761
|
const char* edn::Parser::parse_map(const char *p, const char *pe, VALUE& v)
|
2620
2762
|
{
|
2621
|
-
|
2763
|
+
static const char* EDN_TYPE = "map";
|
2622
2764
|
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2765
|
+
int cs;
|
2766
|
+
// since we don't know whether we're looking at a key or value,
|
2767
|
+
// initially store all elements in an array (allocated in @open_seq)
|
2768
|
+
VALUE elems;
|
2627
2769
|
|
2628
2770
|
|
2629
|
-
#line
|
2771
|
+
#line 2772 "edn_parser.cc"
|
2630
2772
|
{
|
2631
2773
|
cs = EDN_map_start;
|
2632
2774
|
}
|
2633
2775
|
|
2634
|
-
#line
|
2776
|
+
#line 798 "edn_parser.rl"
|
2635
2777
|
|
2636
|
-
#line
|
2778
|
+
#line 2779 "edn_parser.cc"
|
2637
2779
|
{
|
2638
2780
|
if ( p == pe )
|
2639
2781
|
goto _test_eof;
|
@@ -2646,72 +2788,72 @@ case 1:
|
|
2646
2788
|
tr2:
|
2647
2789
|
#line 73 "edn_parser.rl"
|
2648
2790
|
{
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2791
|
+
std::stringstream s;
|
2792
|
+
s << "unterminated " << EDN_TYPE;
|
2793
|
+
error(__FUNCTION__, s.str());
|
2794
|
+
p--; {p++; cs = 0; goto _out;}
|
2795
|
+
}
|
2654
2796
|
goto st0;
|
2655
|
-
#line
|
2797
|
+
#line 2798 "edn_parser.cc"
|
2656
2798
|
st0:
|
2657
2799
|
cs = 0;
|
2658
2800
|
goto _out;
|
2659
2801
|
tr0:
|
2660
|
-
#line
|
2661
|
-
{
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2802
|
+
#line 629 "edn_parser.rl"
|
2803
|
+
{
|
2804
|
+
// sequences store elements in an array, then process it to
|
2805
|
+
// convert it to a list, set, or map as needed once the
|
2806
|
+
// sequence end is reached
|
2807
|
+
elems = rb_ary_new();
|
2808
|
+
// additionally, metadata for elements in the sequence may be
|
2809
|
+
// carried so we must push a new level in the metadata stack
|
2810
|
+
new_meta_list();
|
2811
|
+
}
|
2670
2812
|
goto st2;
|
2671
2813
|
tr4:
|
2672
2814
|
#line 47 "edn_parser.rl"
|
2673
2815
|
{ line_number++; }
|
2674
2816
|
goto st2;
|
2675
2817
|
tr5:
|
2676
|
-
#line
|
2677
|
-
{
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2818
|
+
#line 644 "edn_parser.rl"
|
2819
|
+
{
|
2820
|
+
// reads an item within a sequence (vector, list, map, or
|
2821
|
+
// set). Regardless of the sequence type, an array of the
|
2822
|
+
// items is built. Once done, the sequence parser will convert
|
2823
|
+
// if needed
|
2824
|
+
VALUE e;
|
2825
|
+
std::size_t meta_sz = meta_size();
|
2826
|
+
const char *np = parse_value(p, pe, e);
|
2827
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {
|
2828
|
+
// if there's an entry in the discard list, the current
|
2829
|
+
// object is not meant to be kept due to a #_ so don't
|
2830
|
+
// push it into the list of elements
|
2831
|
+
if (!discard.empty()) {
|
2832
|
+
discard.pop_back();
|
2833
|
+
}
|
2834
|
+
else if (!meta_empty()) {
|
2835
|
+
// check if parse_value added metadata
|
2836
|
+
if (meta_size() == meta_sz) {
|
2837
|
+
// there's metadata and it didn't increase so
|
2838
|
+
// parse_value() read an element we care
|
2839
|
+
// about. Bind the metadata to it and add it to
|
2840
|
+
// the sequence
|
2841
|
+
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
2842
|
+
rb_ary_push(elems, e);
|
2691
2843
|
}
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
|
2699
|
-
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
2700
|
-
rb_ary_push(elems, e);
|
2701
|
-
}
|
2702
|
-
} else {
|
2703
|
-
// no metadata.. just push it
|
2704
|
-
rb_ary_push(elems, e);
|
2705
|
-
}
|
2706
|
-
{p = (( np))-1;}
|
2707
|
-
}
|
2708
|
-
}
|
2844
|
+
} else {
|
2845
|
+
// no metadata.. just push it
|
2846
|
+
rb_ary_push(elems, e);
|
2847
|
+
}
|
2848
|
+
{p = (( np))-1;}
|
2849
|
+
}
|
2850
|
+
}
|
2709
2851
|
goto st2;
|
2710
2852
|
st2:
|
2711
2853
|
if ( ++p == pe )
|
2712
2854
|
goto _test_eof2;
|
2713
2855
|
case 2:
|
2714
|
-
#line
|
2856
|
+
#line 2857 "edn_parser.cc"
|
2715
2857
|
switch( (*p) ) {
|
2716
2858
|
case 10: goto tr4;
|
2717
2859
|
case 32: goto st2;
|
@@ -2745,11 +2887,11 @@ case 3:
|
|
2745
2887
|
goto tr4;
|
2746
2888
|
goto st3;
|
2747
2889
|
tr7:
|
2748
|
-
#line
|
2890
|
+
#line 639 "edn_parser.rl"
|
2749
2891
|
{
|
2750
|
-
|
2751
|
-
|
2752
|
-
|
2892
|
+
// remove the current metadata level
|
2893
|
+
del_top_meta_list();
|
2894
|
+
}
|
2753
2895
|
#line 80 "edn_parser.rl"
|
2754
2896
|
{ p--; {p++; cs = 4; goto _out;} }
|
2755
2897
|
goto st4;
|
@@ -2757,7 +2899,7 @@ st4:
|
|
2757
2899
|
if ( ++p == pe )
|
2758
2900
|
goto _test_eof4;
|
2759
2901
|
case 4:
|
2760
|
-
#line
|
2902
|
+
#line 2903 "edn_parser.cc"
|
2761
2903
|
goto st0;
|
2762
2904
|
}
|
2763
2905
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -2772,45 +2914,44 @@ case 4:
|
|
2772
2914
|
case 3:
|
2773
2915
|
#line 73 "edn_parser.rl"
|
2774
2916
|
{
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2917
|
+
std::stringstream s;
|
2918
|
+
s << "unterminated " << EDN_TYPE;
|
2919
|
+
error(__FUNCTION__, s.str());
|
2920
|
+
p--; {p++; cs = 0; goto _out;}
|
2921
|
+
}
|
2780
2922
|
break;
|
2781
|
-
#line
|
2923
|
+
#line 2924 "edn_parser.cc"
|
2782
2924
|
}
|
2783
2925
|
}
|
2784
2926
|
|
2785
2927
|
_out: {}
|
2786
2928
|
}
|
2787
2929
|
|
2788
|
-
#line
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
return nullptr;
|
2930
|
+
#line 799 "edn_parser.rl"
|
2931
|
+
|
2932
|
+
if (cs >= EDN_map_first_final) {
|
2933
|
+
// hash parsing is done. Make sure we have an even count
|
2934
|
+
if ((RARRAY_LEN(elems) % 2) != 0) {
|
2935
|
+
error(__FUNCTION__, "odd number of elements in map");
|
2936
|
+
return pe;
|
2937
|
+
}
|
2938
|
+
|
2939
|
+
// now convert the sequence to a hash
|
2940
|
+
VALUE rslt = rb_hash_new();
|
2941
|
+
while (RARRAY_LEN(elems) > 0)
|
2942
|
+
{
|
2943
|
+
VALUE k = rb_ary_shift(elems);
|
2944
|
+
rb_hash_aset(rslt, k, rb_ary_shift(elems));
|
2945
|
+
}
|
2946
|
+
|
2947
|
+
v = rslt;
|
2948
|
+
return p + 1;
|
2949
|
+
}
|
2950
|
+
else if (cs == EDN_map_error) {
|
2951
|
+
return pe;
|
2952
|
+
}
|
2953
|
+
else if (cs == EDN_map_en_main) {} // silence ragel warning
|
2954
|
+
return nullptr;
|
2814
2955
|
}
|
2815
2956
|
|
2816
2957
|
|
@@ -2821,7 +2962,7 @@ case 4:
|
|
2821
2962
|
// the remaining data to the correct parser
|
2822
2963
|
//
|
2823
2964
|
|
2824
|
-
#line
|
2965
|
+
#line 2966 "edn_parser.cc"
|
2825
2966
|
static const int EDN_dispatch_start = 1;
|
2826
2967
|
static const int EDN_dispatch_first_final = 2;
|
2827
2968
|
static const int EDN_dispatch_error = 0;
|
@@ -2829,23 +2970,23 @@ static const int EDN_dispatch_error = 0;
|
|
2829
2970
|
static const int EDN_dispatch_en_main = 1;
|
2830
2971
|
|
2831
2972
|
|
2832
|
-
#line
|
2973
|
+
#line 862 "edn_parser.rl"
|
2833
2974
|
|
2834
2975
|
|
2835
2976
|
|
2836
2977
|
const char* edn::Parser::parse_dispatch(const char *p, const char *pe, VALUE& v)
|
2837
2978
|
{
|
2838
|
-
|
2979
|
+
int cs;
|
2839
2980
|
|
2840
2981
|
|
2841
|
-
#line
|
2982
|
+
#line 2983 "edn_parser.cc"
|
2842
2983
|
{
|
2843
2984
|
cs = EDN_dispatch_start;
|
2844
2985
|
}
|
2845
2986
|
|
2846
|
-
#line
|
2987
|
+
#line 870 "edn_parser.rl"
|
2847
2988
|
|
2848
|
-
#line
|
2989
|
+
#line 2990 "edn_parser.cc"
|
2849
2990
|
{
|
2850
2991
|
if ( p == pe )
|
2851
2992
|
goto _test_eof;
|
@@ -2866,32 +3007,32 @@ st0:
|
|
2866
3007
|
cs = 0;
|
2867
3008
|
goto _out;
|
2868
3009
|
tr0:
|
2869
|
-
#line
|
3010
|
+
#line 850 "edn_parser.rl"
|
2870
3011
|
{
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
3012
|
+
// #inst, #uuid, or #user/tag
|
3013
|
+
const char *np = parse_tagged(p, pe, v);
|
3014
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
3015
|
+
}
|
2875
3016
|
#line 80 "edn_parser.rl"
|
2876
3017
|
{ p--; {p++; cs = 2; goto _out;} }
|
2877
3018
|
goto st2;
|
2878
3019
|
tr2:
|
2879
|
-
#line
|
3020
|
+
#line 844 "edn_parser.rl"
|
2880
3021
|
{
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
|
3022
|
+
// discard token #_
|
3023
|
+
const char *np = parse_discard(p, pe);
|
3024
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
3025
|
+
}
|
2885
3026
|
#line 80 "edn_parser.rl"
|
2886
3027
|
{ p--; {p++; cs = 2; goto _out;} }
|
2887
3028
|
goto st2;
|
2888
3029
|
tr3:
|
2889
|
-
#line
|
3030
|
+
#line 838 "edn_parser.rl"
|
2890
3031
|
{
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
3032
|
+
// #{ }
|
3033
|
+
const char *np = parse_set(p, pe, v);
|
3034
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {p = (( np))-1;}
|
3035
|
+
}
|
2895
3036
|
#line 80 "edn_parser.rl"
|
2896
3037
|
{ p--; {p++; cs = 2; goto _out;} }
|
2897
3038
|
goto st2;
|
@@ -2899,7 +3040,7 @@ st2:
|
|
2899
3040
|
if ( ++p == pe )
|
2900
3041
|
goto _test_eof2;
|
2901
3042
|
case 2:
|
2902
|
-
#line
|
3043
|
+
#line 3044 "edn_parser.cc"
|
2903
3044
|
goto st0;
|
2904
3045
|
}
|
2905
3046
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -2908,18 +3049,17 @@ case 2:
|
|
2908
3049
|
_out: {}
|
2909
3050
|
}
|
2910
3051
|
|
2911
|
-
#line
|
2912
|
-
|
2913
|
-
if (cs >= EDN_dispatch_first_final) {
|
2914
|
-
return p + 1;
|
2915
|
-
}
|
2916
|
-
else if (cs == EDN_dispatch_error) {
|
2917
|
-
error(__FUNCTION__, "dispatch extend error", *p);
|
2918
|
-
return pe;
|
2919
|
-
}
|
2920
|
-
else if (cs == EDN_dispatch_en_main) {} // silence ragel warning
|
3052
|
+
#line 871 "edn_parser.rl"
|
2921
3053
|
|
2922
|
-
|
3054
|
+
if (cs >= EDN_dispatch_first_final) {
|
3055
|
+
return p + 1;
|
3056
|
+
}
|
3057
|
+
else if (cs == EDN_dispatch_error) {
|
3058
|
+
error(__FUNCTION__, "dispatch extend error", *p);
|
3059
|
+
return pe;
|
3060
|
+
}
|
3061
|
+
else if (cs == EDN_dispatch_en_main) {} // silence ragel warning
|
3062
|
+
return nullptr;
|
2923
3063
|
}
|
2924
3064
|
|
2925
3065
|
|
@@ -2927,7 +3067,7 @@ case 2:
|
|
2927
3067
|
// set parsing machine
|
2928
3068
|
//
|
2929
3069
|
|
2930
|
-
#line
|
3070
|
+
#line 3071 "edn_parser.cc"
|
2931
3071
|
static const int EDN_set_start = 1;
|
2932
3072
|
static const int EDN_set_first_final = 4;
|
2933
3073
|
static const int EDN_set_error = 0;
|
@@ -2935,7 +3075,7 @@ static const int EDN_set_error = 0;
|
|
2935
3075
|
static const int EDN_set_en_main = 1;
|
2936
3076
|
|
2937
3077
|
|
2938
|
-
#line
|
3078
|
+
#line 899 "edn_parser.rl"
|
2939
3079
|
|
2940
3080
|
|
2941
3081
|
//
|
@@ -2943,20 +3083,20 @@ static const int EDN_set_en_main = 1;
|
|
2943
3083
|
//
|
2944
3084
|
const char* edn::Parser::parse_set(const char *p, const char *pe, VALUE& v)
|
2945
3085
|
{
|
2946
|
-
|
3086
|
+
static const char* EDN_TYPE = "set";
|
2947
3087
|
|
2948
|
-
|
2949
|
-
|
3088
|
+
int cs;
|
3089
|
+
VALUE elems; // holds the set's elements as an array allocated in @open_seq
|
2950
3090
|
|
2951
3091
|
|
2952
|
-
#line
|
3092
|
+
#line 3093 "edn_parser.cc"
|
2953
3093
|
{
|
2954
3094
|
cs = EDN_set_start;
|
2955
3095
|
}
|
2956
3096
|
|
2957
|
-
#line
|
3097
|
+
#line 912 "edn_parser.rl"
|
2958
3098
|
|
2959
|
-
#line
|
3099
|
+
#line 3100 "edn_parser.cc"
|
2960
3100
|
{
|
2961
3101
|
if ( p == pe )
|
2962
3102
|
goto _test_eof;
|
@@ -2969,72 +3109,72 @@ case 1:
|
|
2969
3109
|
tr2:
|
2970
3110
|
#line 73 "edn_parser.rl"
|
2971
3111
|
{
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
3112
|
+
std::stringstream s;
|
3113
|
+
s << "unterminated " << EDN_TYPE;
|
3114
|
+
error(__FUNCTION__, s.str());
|
3115
|
+
p--; {p++; cs = 0; goto _out;}
|
3116
|
+
}
|
2977
3117
|
goto st0;
|
2978
|
-
#line
|
3118
|
+
#line 3119 "edn_parser.cc"
|
2979
3119
|
st0:
|
2980
3120
|
cs = 0;
|
2981
3121
|
goto _out;
|
2982
3122
|
tr0:
|
2983
|
-
#line
|
2984
|
-
{
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
3123
|
+
#line 629 "edn_parser.rl"
|
3124
|
+
{
|
3125
|
+
// sequences store elements in an array, then process it to
|
3126
|
+
// convert it to a list, set, or map as needed once the
|
3127
|
+
// sequence end is reached
|
3128
|
+
elems = rb_ary_new();
|
3129
|
+
// additionally, metadata for elements in the sequence may be
|
3130
|
+
// carried so we must push a new level in the metadata stack
|
3131
|
+
new_meta_list();
|
3132
|
+
}
|
2993
3133
|
goto st2;
|
2994
3134
|
tr4:
|
2995
3135
|
#line 47 "edn_parser.rl"
|
2996
3136
|
{ line_number++; }
|
2997
3137
|
goto st2;
|
2998
3138
|
tr5:
|
2999
|
-
#line
|
3000
|
-
{
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3139
|
+
#line 644 "edn_parser.rl"
|
3140
|
+
{
|
3141
|
+
// reads an item within a sequence (vector, list, map, or
|
3142
|
+
// set). Regardless of the sequence type, an array of the
|
3143
|
+
// items is built. Once done, the sequence parser will convert
|
3144
|
+
// if needed
|
3145
|
+
VALUE e;
|
3146
|
+
std::size_t meta_sz = meta_size();
|
3147
|
+
const char *np = parse_value(p, pe, e);
|
3148
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {
|
3149
|
+
// if there's an entry in the discard list, the current
|
3150
|
+
// object is not meant to be kept due to a #_ so don't
|
3151
|
+
// push it into the list of elements
|
3152
|
+
if (!discard.empty()) {
|
3153
|
+
discard.pop_back();
|
3154
|
+
}
|
3155
|
+
else if (!meta_empty()) {
|
3156
|
+
// check if parse_value added metadata
|
3157
|
+
if (meta_size() == meta_sz) {
|
3158
|
+
// there's metadata and it didn't increase so
|
3159
|
+
// parse_value() read an element we care
|
3160
|
+
// about. Bind the metadata to it and add it to
|
3161
|
+
// the sequence
|
3162
|
+
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
3163
|
+
rb_ary_push(elems, e);
|
3014
3164
|
}
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
e = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, e, ruby_meta());
|
3023
|
-
rb_ary_push(elems, e);
|
3024
|
-
}
|
3025
|
-
} else {
|
3026
|
-
// no metadata.. just push it
|
3027
|
-
rb_ary_push(elems, e);
|
3028
|
-
}
|
3029
|
-
{p = (( np))-1;}
|
3030
|
-
}
|
3031
|
-
}
|
3165
|
+
} else {
|
3166
|
+
// no metadata.. just push it
|
3167
|
+
rb_ary_push(elems, e);
|
3168
|
+
}
|
3169
|
+
{p = (( np))-1;}
|
3170
|
+
}
|
3171
|
+
}
|
3032
3172
|
goto st2;
|
3033
3173
|
st2:
|
3034
3174
|
if ( ++p == pe )
|
3035
3175
|
goto _test_eof2;
|
3036
3176
|
case 2:
|
3037
|
-
#line
|
3177
|
+
#line 3178 "edn_parser.cc"
|
3038
3178
|
switch( (*p) ) {
|
3039
3179
|
case 10: goto tr4;
|
3040
3180
|
case 32: goto st2;
|
@@ -3068,11 +3208,11 @@ case 3:
|
|
3068
3208
|
goto tr4;
|
3069
3209
|
goto st3;
|
3070
3210
|
tr7:
|
3071
|
-
#line
|
3211
|
+
#line 639 "edn_parser.rl"
|
3072
3212
|
{
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3213
|
+
// remove the current metadata level
|
3214
|
+
del_top_meta_list();
|
3215
|
+
}
|
3076
3216
|
#line 80 "edn_parser.rl"
|
3077
3217
|
{ p--; {p++; cs = 4; goto _out;} }
|
3078
3218
|
goto st4;
|
@@ -3080,7 +3220,7 @@ st4:
|
|
3080
3220
|
if ( ++p == pe )
|
3081
3221
|
goto _test_eof4;
|
3082
3222
|
case 4:
|
3083
|
-
#line
|
3223
|
+
#line 3224 "edn_parser.cc"
|
3084
3224
|
goto st0;
|
3085
3225
|
}
|
3086
3226
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -3095,32 +3235,32 @@ case 4:
|
|
3095
3235
|
case 3:
|
3096
3236
|
#line 73 "edn_parser.rl"
|
3097
3237
|
{
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3238
|
+
std::stringstream s;
|
3239
|
+
s << "unterminated " << EDN_TYPE;
|
3240
|
+
error(__FUNCTION__, s.str());
|
3241
|
+
p--; {p++; cs = 0; goto _out;}
|
3242
|
+
}
|
3103
3243
|
break;
|
3104
|
-
#line
|
3244
|
+
#line 3245 "edn_parser.cc"
|
3105
3245
|
}
|
3106
3246
|
}
|
3107
3247
|
|
3108
3248
|
_out: {}
|
3109
3249
|
}
|
3110
3250
|
|
3111
|
-
#line
|
3251
|
+
#line 913 "edn_parser.rl"
|
3112
3252
|
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3253
|
+
if (cs >= EDN_set_first_final) {
|
3254
|
+
// all elements collected; now convert to a set
|
3255
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_MAKE_SET_METHOD, elems);
|
3256
|
+
return p + 1;
|
3257
|
+
}
|
3258
|
+
else if (cs == EDN_set_error) {
|
3259
|
+
error(__FUNCTION__, *p);
|
3260
|
+
return pe;
|
3261
|
+
}
|
3262
|
+
else if (cs == EDN_set_en_main) {} // silence ragel warning
|
3263
|
+
return nullptr;
|
3124
3264
|
}
|
3125
3265
|
|
3126
3266
|
|
@@ -3131,7 +3271,7 @@ case 4:
|
|
3131
3271
|
// defining a machine to consume items within container delimiters
|
3132
3272
|
//
|
3133
3273
|
|
3134
|
-
#line
|
3274
|
+
#line 3275 "edn_parser.cc"
|
3135
3275
|
static const int EDN_discard_start = 1;
|
3136
3276
|
static const int EDN_discard_first_final = 4;
|
3137
3277
|
static const int EDN_discard_error = 0;
|
@@ -3139,24 +3279,24 @@ static const int EDN_discard_error = 0;
|
|
3139
3279
|
static const int EDN_discard_en_main = 1;
|
3140
3280
|
|
3141
3281
|
|
3142
|
-
#line
|
3282
|
+
#line 963 "edn_parser.rl"
|
3143
3283
|
|
3144
3284
|
|
3145
3285
|
|
3146
3286
|
const char* edn::Parser::parse_discard(const char *p, const char *pe)
|
3147
3287
|
{
|
3148
|
-
|
3149
|
-
|
3288
|
+
int cs;
|
3289
|
+
VALUE v;
|
3150
3290
|
|
3151
3291
|
|
3152
|
-
#line
|
3292
|
+
#line 3293 "edn_parser.cc"
|
3153
3293
|
{
|
3154
3294
|
cs = EDN_discard_start;
|
3155
3295
|
}
|
3156
3296
|
|
3157
|
-
#line
|
3297
|
+
#line 972 "edn_parser.rl"
|
3158
3298
|
|
3159
|
-
#line
|
3299
|
+
#line 3300 "edn_parser.cc"
|
3160
3300
|
{
|
3161
3301
|
if ( p == pe )
|
3162
3302
|
goto _test_eof;
|
@@ -3167,15 +3307,15 @@ case 1:
|
|
3167
3307
|
goto st2;
|
3168
3308
|
goto st0;
|
3169
3309
|
tr2:
|
3170
|
-
#line
|
3310
|
+
#line 953 "edn_parser.rl"
|
3171
3311
|
{
|
3172
|
-
|
3173
|
-
|
3174
|
-
|
3175
|
-
|
3176
|
-
|
3312
|
+
std::stringstream s;
|
3313
|
+
s << "discard sequence without element to discard";
|
3314
|
+
error(__FUNCTION__, s.str());
|
3315
|
+
p--; {p++; cs = 0; goto _out;}
|
3316
|
+
}
|
3177
3317
|
goto st0;
|
3178
|
-
#line
|
3318
|
+
#line 3319 "edn_parser.cc"
|
3179
3319
|
st0:
|
3180
3320
|
cs = 0;
|
3181
3321
|
goto _out;
|
@@ -3187,7 +3327,7 @@ st2:
|
|
3187
3327
|
if ( ++p == pe )
|
3188
3328
|
goto _test_eof2;
|
3189
3329
|
case 2:
|
3190
|
-
#line
|
3330
|
+
#line 3331 "edn_parser.cc"
|
3191
3331
|
switch( (*p) ) {
|
3192
3332
|
case 10: goto tr3;
|
3193
3333
|
case 32: goto st2;
|
@@ -3213,17 +3353,17 @@ case 2:
|
|
3213
3353
|
goto tr4;
|
3214
3354
|
goto tr2;
|
3215
3355
|
tr4:
|
3216
|
-
#line
|
3217
|
-
{
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
|
3226
|
-
|
3356
|
+
#line 942 "edn_parser.rl"
|
3357
|
+
{
|
3358
|
+
const char *np = parse_value(p, pe, v);
|
3359
|
+
if (np == nullptr) { p--; {p++; cs = 4; goto _out;} } else {
|
3360
|
+
// this token is to be discarded so store it in the
|
3361
|
+
// discard stack - we really don't need to save it so this
|
3362
|
+
// could be simplified
|
3363
|
+
discard.push_back(v);
|
3364
|
+
{p = (( np))-1;}
|
3365
|
+
}
|
3366
|
+
}
|
3227
3367
|
#line 80 "edn_parser.rl"
|
3228
3368
|
{ p--; {p++; cs = 4; goto _out;} }
|
3229
3369
|
goto st4;
|
@@ -3231,7 +3371,7 @@ st4:
|
|
3231
3371
|
if ( ++p == pe )
|
3232
3372
|
goto _test_eof4;
|
3233
3373
|
case 4:
|
3234
|
-
#line
|
3374
|
+
#line 3375 "edn_parser.cc"
|
3235
3375
|
goto st0;
|
3236
3376
|
st3:
|
3237
3377
|
if ( ++p == pe )
|
@@ -3250,33 +3390,32 @@ case 3:
|
|
3250
3390
|
{
|
3251
3391
|
switch ( cs ) {
|
3252
3392
|
case 2:
|
3253
|
-
#line
|
3393
|
+
#line 953 "edn_parser.rl"
|
3254
3394
|
{
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3395
|
+
std::stringstream s;
|
3396
|
+
s << "discard sequence without element to discard";
|
3397
|
+
error(__FUNCTION__, s.str());
|
3398
|
+
p--; {p++; cs = 0; goto _out;}
|
3399
|
+
}
|
3260
3400
|
break;
|
3261
|
-
#line
|
3401
|
+
#line 3402 "edn_parser.cc"
|
3262
3402
|
}
|
3263
3403
|
}
|
3264
3404
|
|
3265
3405
|
_out: {}
|
3266
3406
|
}
|
3267
3407
|
|
3268
|
-
#line
|
3408
|
+
#line 973 "edn_parser.rl"
|
3269
3409
|
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
return nullptr;
|
3410
|
+
if (cs >= EDN_discard_first_final) {
|
3411
|
+
return p + 1;
|
3412
|
+
}
|
3413
|
+
else if (cs == EDN_discard_error) {
|
3414
|
+
error(__FUNCTION__, *p);
|
3415
|
+
return pe;
|
3416
|
+
}
|
3417
|
+
else if (cs == EDN_discard_en_main) {} // silence ragel warning
|
3418
|
+
return nullptr;
|
3280
3419
|
}
|
3281
3420
|
|
3282
3421
|
|
@@ -3296,7 +3435,7 @@ case 3:
|
|
3296
3435
|
// 2. add parse checks for uuid and inst for better error reporting
|
3297
3436
|
//
|
3298
3437
|
|
3299
|
-
#line
|
3438
|
+
#line 3439 "edn_parser.cc"
|
3300
3439
|
static const int EDN_tagged_start = 1;
|
3301
3440
|
static const int EDN_tagged_first_final = 7;
|
3302
3441
|
static const int EDN_tagged_error = 0;
|
@@ -3304,28 +3443,28 @@ static const int EDN_tagged_error = 0;
|
|
3304
3443
|
static const int EDN_tagged_en_main = 1;
|
3305
3444
|
|
3306
3445
|
|
3307
|
-
#line
|
3446
|
+
#line 1040 "edn_parser.rl"
|
3308
3447
|
|
3309
3448
|
|
3310
3449
|
|
3311
3450
|
const char* edn::Parser::parse_tagged(const char *p, const char *pe, VALUE& v)
|
3312
3451
|
{
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3452
|
+
VALUE sym_name = Qnil;
|
3453
|
+
VALUE data = Qnil;
|
3454
|
+
bool sym_ok = false;
|
3455
|
+
bool data_ok = false;
|
3317
3456
|
|
3318
|
-
|
3457
|
+
int cs;
|
3319
3458
|
|
3320
3459
|
|
3321
|
-
#line
|
3460
|
+
#line 3461 "edn_parser.cc"
|
3322
3461
|
{
|
3323
3462
|
cs = EDN_tagged_start;
|
3324
3463
|
}
|
3325
3464
|
|
3326
|
-
#line
|
3465
|
+
#line 1053 "edn_parser.rl"
|
3327
3466
|
|
3328
|
-
#line
|
3467
|
+
#line 3468 "edn_parser.cc"
|
3329
3468
|
{
|
3330
3469
|
if ( p == pe )
|
3331
3470
|
goto _test_eof;
|
@@ -3342,21 +3481,21 @@ st0:
|
|
3342
3481
|
cs = 0;
|
3343
3482
|
goto _out;
|
3344
3483
|
tr0:
|
3345
|
-
#line
|
3346
|
-
{
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3484
|
+
#line 1019 "edn_parser.rl"
|
3485
|
+
{
|
3486
|
+
// parses the symbol portion of the pair
|
3487
|
+
const char *np = parse_symbol(p, pe, sym_name);
|
3488
|
+
if (np == nullptr) { p--; {p++; cs = 2; goto _out;} } else {
|
3489
|
+
sym_ok = true;
|
3490
|
+
{p = (( np))-1;}
|
3491
|
+
}
|
3492
|
+
}
|
3354
3493
|
goto st2;
|
3355
3494
|
st2:
|
3356
3495
|
if ( ++p == pe )
|
3357
3496
|
goto _test_eof2;
|
3358
3497
|
case 2:
|
3359
|
-
#line
|
3498
|
+
#line 3499 "edn_parser.cc"
|
3360
3499
|
switch( (*p) ) {
|
3361
3500
|
case 10: goto tr3;
|
3362
3501
|
case 32: goto st3;
|
@@ -3389,7 +3528,7 @@ st3:
|
|
3389
3528
|
if ( ++p == pe )
|
3390
3529
|
goto _test_eof3;
|
3391
3530
|
case 3:
|
3392
|
-
#line
|
3531
|
+
#line 3532 "edn_parser.cc"
|
3393
3532
|
switch( (*p) ) {
|
3394
3533
|
case 10: goto tr3;
|
3395
3534
|
case 32: goto st3;
|
@@ -3415,15 +3554,15 @@ case 3:
|
|
3415
3554
|
goto tr7;
|
3416
3555
|
goto st0;
|
3417
3556
|
tr7:
|
3418
|
-
#line
|
3419
|
-
{
|
3420
|
-
|
3421
|
-
|
3422
|
-
|
3423
|
-
|
3424
|
-
|
3425
|
-
|
3426
|
-
|
3557
|
+
#line 1027 "edn_parser.rl"
|
3558
|
+
{
|
3559
|
+
// parses the value portion
|
3560
|
+
const char *np = parse_value(p, pe, data);
|
3561
|
+
if (np == nullptr) { p--; {p++; cs = 7; goto _out;} } else {
|
3562
|
+
data_ok = true;
|
3563
|
+
{p = (( np))-1;}
|
3564
|
+
}
|
3565
|
+
}
|
3427
3566
|
#line 80 "edn_parser.rl"
|
3428
3567
|
{ p--; {p++; cs = 7; goto _out;} }
|
3429
3568
|
goto st7;
|
@@ -3431,7 +3570,7 @@ st7:
|
|
3431
3570
|
if ( ++p == pe )
|
3432
3571
|
goto _test_eof7;
|
3433
3572
|
case 7:
|
3434
|
-
#line
|
3573
|
+
#line 3574 "edn_parser.cc"
|
3435
3574
|
goto st0;
|
3436
3575
|
st4:
|
3437
3576
|
if ( ++p == pe )
|
@@ -3509,45 +3648,43 @@ case 6:
|
|
3509
3648
|
_out: {}
|
3510
3649
|
}
|
3511
3650
|
|
3512
|
-
#line
|
3651
|
+
#line 1054 "edn_parser.rl"
|
3513
3652
|
|
3514
|
-
|
3653
|
+
if (cs >= EDN_tagged_first_final) {
|
3515
3654
|
//std::cerr << __FUNCTION__ << " parse symbol name as '" << sym_name << "', value is: " << data << std::endl;
|
3516
3655
|
|
3517
|
-
|
3518
|
-
|
3519
|
-
|
3520
|
-
|
3521
|
-
|
3522
|
-
|
3523
|
-
|
3524
|
-
|
3525
|
-
|
3526
|
-
|
3527
|
-
|
3528
|
-
|
3529
|
-
|
3530
|
-
|
3531
|
-
|
3532
|
-
|
3533
|
-
|
3534
|
-
|
3535
|
-
|
3536
|
-
|
3537
|
-
|
3538
|
-
|
3656
|
+
if (!sym_ok || !data_ok) {
|
3657
|
+
error(__FUNCTION__, "tagged element symbol error", *p);
|
3658
|
+
v = EDN_EOF_CONST;
|
3659
|
+
return nullptr;
|
3660
|
+
}
|
3661
|
+
|
3662
|
+
try {
|
3663
|
+
// tagged_element makes a call to ruby which may throw an
|
3664
|
+
// exception when parsing the data
|
3665
|
+
v = edn::util::call_module_fn(rb_mEDN, EDN_TAGGED_ELEM_METHOD, sym_name, data);
|
3666
|
+
return p + 1;
|
3667
|
+
} catch (std::exception& e) {
|
3668
|
+
error(__FUNCTION__, e.what());
|
3669
|
+
return pe;
|
3670
|
+
}
|
3671
|
+
}
|
3672
|
+
else if (cs == EDN_tagged_error) {
|
3673
|
+
error(__FUNCTION__, "tagged element symbol error", *p);
|
3674
|
+
}
|
3675
|
+
else if (cs == EDN_tagged_en_main) {} // silence ragel warning
|
3676
|
+
v = EDN_EOF_CONST;
|
3677
|
+
return nullptr;
|
3539
3678
|
}
|
3540
3679
|
|
3541
3680
|
|
3542
|
-
|
3543
|
-
|
3544
3681
|
// ============================================================
|
3545
3682
|
// metadata - looks like ruby just discards this but we'll track it
|
3546
3683
|
// and provide a means to retrive after each parse op - might be
|
3547
3684
|
// useful?
|
3548
3685
|
//
|
3549
3686
|
|
3550
|
-
#line
|
3687
|
+
#line 3688 "edn_parser.cc"
|
3551
3688
|
static const int EDN_meta_start = 1;
|
3552
3689
|
static const int EDN_meta_first_final = 3;
|
3553
3690
|
static const int EDN_meta_error = 0;
|
@@ -3555,24 +3692,24 @@ static const int EDN_meta_error = 0;
|
|
3555
3692
|
static const int EDN_meta_en_main = 1;
|
3556
3693
|
|
3557
3694
|
|
3558
|
-
#line
|
3695
|
+
#line 1102 "edn_parser.rl"
|
3559
3696
|
|
3560
3697
|
|
3561
3698
|
|
3562
3699
|
const char* edn::Parser::parse_meta(const char *p, const char *pe)
|
3563
3700
|
{
|
3564
|
-
|
3565
|
-
|
3701
|
+
int cs;
|
3702
|
+
VALUE v;
|
3566
3703
|
|
3567
3704
|
|
3568
|
-
#line
|
3705
|
+
#line 3706 "edn_parser.cc"
|
3569
3706
|
{
|
3570
3707
|
cs = EDN_meta_start;
|
3571
3708
|
}
|
3572
3709
|
|
3573
|
-
#line
|
3710
|
+
#line 1111 "edn_parser.rl"
|
3574
3711
|
|
3575
|
-
#line
|
3712
|
+
#line 3713 "edn_parser.cc"
|
3576
3713
|
{
|
3577
3714
|
if ( p == pe )
|
3578
3715
|
goto _test_eof;
|
@@ -3611,11 +3748,11 @@ case 2:
|
|
3611
3748
|
goto tr2;
|
3612
3749
|
goto st0;
|
3613
3750
|
tr2:
|
3614
|
-
#line
|
3751
|
+
#line 1094 "edn_parser.rl"
|
3615
3752
|
{
|
3616
|
-
|
3617
|
-
|
3618
|
-
|
3753
|
+
const char *np = parse_value(p, pe, v);
|
3754
|
+
if (np == nullptr) { p--; {p++; cs = 3; goto _out;} } else { {p = (( np))-1;} }
|
3755
|
+
}
|
3619
3756
|
#line 80 "edn_parser.rl"
|
3620
3757
|
{ p--; {p++; cs = 3; goto _out;} }
|
3621
3758
|
goto st3;
|
@@ -3623,7 +3760,7 @@ st3:
|
|
3623
3760
|
if ( ++p == pe )
|
3624
3761
|
goto _test_eof3;
|
3625
3762
|
case 3:
|
3626
|
-
#line
|
3763
|
+
#line 3764 "edn_parser.cc"
|
3627
3764
|
goto st0;
|
3628
3765
|
}
|
3629
3766
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -3633,19 +3770,18 @@ case 3:
|
|
3633
3770
|
_out: {}
|
3634
3771
|
}
|
3635
3772
|
|
3636
|
-
#line
|
3773
|
+
#line 1112 "edn_parser.rl"
|
3637
3774
|
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
return nullptr;
|
3775
|
+
if (cs >= EDN_meta_first_final) {
|
3776
|
+
append_to_meta(v);
|
3777
|
+
return p + 1;
|
3778
|
+
}
|
3779
|
+
else if (cs == EDN_meta_error) {
|
3780
|
+
error(__FUNCTION__, *p);
|
3781
|
+
return pe;
|
3782
|
+
}
|
3783
|
+
else if (cs == EDN_meta_en_main) {} // silence ragel warning
|
3784
|
+
return nullptr;
|
3649
3785
|
}
|
3650
3786
|
|
3651
3787
|
|
@@ -3655,7 +3791,7 @@ case 3:
|
|
3655
3791
|
// top-level, therefore, does not tokenize source stream
|
3656
3792
|
//
|
3657
3793
|
|
3658
|
-
#line
|
3794
|
+
#line 3795 "edn_parser.cc"
|
3659
3795
|
static const int EDN_parser_start = 2;
|
3660
3796
|
static const int EDN_parser_first_final = 2;
|
3661
3797
|
static const int EDN_parser_error = 0;
|
@@ -3663,25 +3799,25 @@ static const int EDN_parser_error = 0;
|
|
3663
3799
|
static const int EDN_parser_en_main = 2;
|
3664
3800
|
|
3665
3801
|
|
3666
|
-
#line
|
3802
|
+
#line 1160 "edn_parser.rl"
|
3667
3803
|
|
3668
3804
|
|
3669
3805
|
|
3670
3806
|
VALUE edn::Parser::parse(const char* src, std::size_t len)
|
3671
3807
|
{
|
3672
|
-
|
3673
|
-
|
3808
|
+
int cs;
|
3809
|
+
VALUE result = EDN_EOF_CONST;
|
3674
3810
|
|
3675
3811
|
|
3676
|
-
#line
|
3812
|
+
#line 3813 "edn_parser.cc"
|
3677
3813
|
{
|
3678
3814
|
cs = EDN_parser_start;
|
3679
3815
|
}
|
3680
3816
|
|
3681
|
-
#line
|
3682
|
-
|
3817
|
+
#line 1169 "edn_parser.rl"
|
3818
|
+
set_source(src, len);
|
3683
3819
|
|
3684
|
-
#line
|
3820
|
+
#line 3821 "edn_parser.cc"
|
3685
3821
|
{
|
3686
3822
|
if ( p == pe )
|
3687
3823
|
goto _test_eof;
|
@@ -3692,30 +3828,30 @@ tr1:
|
|
3692
3828
|
{ line_number++; }
|
3693
3829
|
goto st2;
|
3694
3830
|
tr4:
|
3695
|
-
#line
|
3696
|
-
{
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3831
|
+
#line 1137 "edn_parser.rl"
|
3832
|
+
{
|
3833
|
+
// save the count of metadata items before we parse this value
|
3834
|
+
// so we can determine if we've read another metadata value or
|
3835
|
+
// an actual data item
|
3836
|
+
std::size_t meta_sz = meta_size();
|
3837
|
+
const char* np = parse_value(p, pe, result);
|
3838
|
+
if (np == nullptr) { {p = (( pe))-1;} {p++; cs = 2; goto _out;} } else {
|
3839
|
+
// if we have metadata saved and it matches the count we
|
3840
|
+
// saved before we parsed a value, then we must bind the
|
3841
|
+
// metadata sequence to it
|
3842
|
+
if (!meta_empty() && meta_size() == meta_sz) {
|
3843
|
+
// this will empty the metadata sequence too
|
3844
|
+
result = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, result, ruby_meta());
|
3845
|
+
}
|
3846
|
+
{p = (( np))-1;}
|
3847
|
+
}
|
3848
|
+
}
|
3713
3849
|
goto st2;
|
3714
3850
|
st2:
|
3715
3851
|
if ( ++p == pe )
|
3716
3852
|
goto _test_eof2;
|
3717
3853
|
case 2:
|
3718
|
-
#line
|
3854
|
+
#line 3855 "edn_parser.cc"
|
3719
3855
|
switch( (*p) ) {
|
3720
3856
|
case 10: goto tr1;
|
3721
3857
|
case 32: goto st2;
|
@@ -3758,17 +3894,17 @@ case 1:
|
|
3758
3894
|
_out: {}
|
3759
3895
|
}
|
3760
3896
|
|
3761
|
-
#line
|
3897
|
+
#line 1171 "edn_parser.rl"
|
3762
3898
|
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3768
|
-
|
3769
|
-
|
3770
|
-
|
3771
|
-
|
3899
|
+
if (cs == EDN_parser_error) {
|
3900
|
+
error(__FUNCTION__, *p);
|
3901
|
+
return EDN_EOF_CONST;
|
3902
|
+
}
|
3903
|
+
else if (cs == EDN_parser_first_final) {
|
3904
|
+
p = pe = eof = nullptr;
|
3905
|
+
}
|
3906
|
+
else if (cs == EDN_parser_en_main) {} // silence ragel warning
|
3907
|
+
return result;
|
3772
3908
|
}
|
3773
3909
|
|
3774
3910
|
|
@@ -3776,13 +3912,13 @@ case 1:
|
|
3776
3912
|
// token-by-token machine
|
3777
3913
|
//
|
3778
3914
|
|
3779
|
-
#line
|
3915
|
+
#line 3916 "edn_parser.cc"
|
3780
3916
|
static const int EDN_tokens_start = 1;
|
3781
3917
|
|
3782
3918
|
static const int EDN_tokens_en_main = 1;
|
3783
3919
|
|
3784
3920
|
|
3785
|
-
#line
|
3921
|
+
#line 1225 "edn_parser.rl"
|
3786
3922
|
|
3787
3923
|
|
3788
3924
|
|
@@ -3790,25 +3926,25 @@ static const int EDN_tokens_en_main = 1;
|
|
3790
3926
|
//
|
3791
3927
|
edn::Parser::eTokenState edn::Parser::parse_next(VALUE& value)
|
3792
3928
|
{
|
3793
|
-
|
3794
|
-
|
3795
|
-
|
3796
|
-
|
3797
|
-
|
3929
|
+
int cs;
|
3930
|
+
eTokenState state = TOKEN_ERROR;
|
3931
|
+
// need to track metadada read and bind it to the next value read
|
3932
|
+
// - but must account for sequences of metadata values
|
3933
|
+
std::size_t meta_sz;
|
3798
3934
|
|
3799
|
-
|
3800
|
-
|
3801
|
-
|
3935
|
+
// clear any previously saved discards; only track if read during
|
3936
|
+
// this op
|
3937
|
+
discard.clear();
|
3802
3938
|
|
3803
3939
|
|
3804
|
-
#line
|
3940
|
+
#line 3941 "edn_parser.cc"
|
3805
3941
|
{
|
3806
3942
|
cs = EDN_tokens_start;
|
3807
3943
|
}
|
3808
3944
|
|
3809
|
-
#line
|
3945
|
+
#line 1243 "edn_parser.rl"
|
3810
3946
|
|
3811
|
-
#line
|
3947
|
+
#line 3948 "edn_parser.cc"
|
3812
3948
|
{
|
3813
3949
|
if ( p == pe )
|
3814
3950
|
goto _test_eof;
|
@@ -3822,7 +3958,7 @@ st1:
|
|
3822
3958
|
if ( ++p == pe )
|
3823
3959
|
goto _test_eof1;
|
3824
3960
|
case 1:
|
3825
|
-
#line
|
3961
|
+
#line 3962 "edn_parser.cc"
|
3826
3962
|
switch( (*p) ) {
|
3827
3963
|
case 10: goto tr2;
|
3828
3964
|
case 32: goto st1;
|
@@ -3855,43 +3991,43 @@ tr6:
|
|
3855
3991
|
{ line_number++; }
|
3856
3992
|
goto st4;
|
3857
3993
|
tr3:
|
3858
|
-
#line
|
3859
|
-
{
|
3860
|
-
|
3861
|
-
|
3862
|
-
|
3863
|
-
|
3864
|
-
|
3865
|
-
|
3866
|
-
|
3867
|
-
|
3868
|
-
|
3869
|
-
|
3870
|
-
|
3871
|
-
|
3872
|
-
|
3873
|
-
|
3874
|
-
|
3875
|
-
|
3876
|
-
|
3877
|
-
|
3878
|
-
|
3879
|
-
}
|
3880
|
-
} else if (!discard.empty()) {
|
3881
|
-
// a discard read. Don't return a value
|
3882
|
-
state = TOKEN_IS_DISCARD;
|
3883
|
-
} else {
|
3884
|
-
state = TOKEN_OK;
|
3994
|
+
#line 1193 "edn_parser.rl"
|
3995
|
+
{
|
3996
|
+
// we won't know if we've parsed a discard or a metadata until
|
3997
|
+
// after parse_value() is done. Save the current number of
|
3998
|
+
// elements in the metadata sequence; then we can check if it
|
3999
|
+
// grew or if the discard sequence grew
|
4000
|
+
meta_sz = meta_size();
|
4001
|
+
|
4002
|
+
const char* np = parse_value(p, pe, value);
|
4003
|
+
if (np == nullptr) { p--; {p++; cs = 4; goto _out;} } else {
|
4004
|
+
if (!meta_empty()) {
|
4005
|
+
// was an additional metadata entry read? if so, don't
|
4006
|
+
// return a value
|
4007
|
+
if (meta_size() > meta_sz) {
|
4008
|
+
state = TOKEN_IS_META;
|
4009
|
+
}
|
4010
|
+
else {
|
4011
|
+
// a value was read and there's a pending metadata
|
4012
|
+
// sequence. Bind them.
|
4013
|
+
value = edn::util::call_module_fn(rb_mEDNT, EDNT_EXTENDED_VALUE_METHOD, value, ruby_meta());
|
4014
|
+
state = TOKEN_OK;
|
3885
4015
|
}
|
3886
|
-
|
3887
|
-
|
3888
|
-
|
4016
|
+
} else if (!discard.empty()) {
|
4017
|
+
// a discard read. Don't return a value
|
4018
|
+
state = TOKEN_IS_DISCARD;
|
4019
|
+
} else {
|
4020
|
+
state = TOKEN_OK;
|
4021
|
+
}
|
4022
|
+
{p = (( np))-1;}
|
4023
|
+
}
|
4024
|
+
}
|
3889
4025
|
goto st4;
|
3890
4026
|
st4:
|
3891
4027
|
if ( ++p == pe )
|
3892
4028
|
goto _test_eof4;
|
3893
4029
|
case 4:
|
3894
|
-
#line
|
4030
|
+
#line 4031 "edn_parser.cc"
|
3895
4031
|
switch( (*p) ) {
|
3896
4032
|
case 10: goto tr6;
|
3897
4033
|
case 32: goto st4;
|
@@ -3925,10 +4061,10 @@ case 3:
|
|
3925
4061
|
_out: {}
|
3926
4062
|
}
|
3927
4063
|
|
3928
|
-
#line
|
4064
|
+
#line 1244 "edn_parser.rl"
|
3929
4065
|
|
3930
|
-
|
3931
|
-
|
4066
|
+
if (cs == EDN_tokens_en_main) {} // silence ragel warning
|
4067
|
+
return state;
|
3932
4068
|
}
|
3933
4069
|
|
3934
4070
|
/*
|