edn_turbo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -12
- data/ext/edn_turbo/edn_parser.cc +504 -576
- data/ext/edn_turbo/edn_parser.h +12 -14
- data/ext/edn_turbo/edn_parser.rl +103 -175
- data/ext/edn_turbo/edn_parser_def.cc +22 -24
- data/ext/edn_turbo/edn_parser_unicode.cc +29 -0
- data/ext/edn_turbo/extconf.rb +23 -0
- data/ext/edn_turbo/main.cc +0 -1
- data/lib/edn_turbo/version.rb +1 -1
- data/test/test_output_diff.rb +9 -0
- metadata +2 -1
data/ext/edn_turbo/edn_parser.cc
CHANGED
@@ -3,9 +3,6 @@
|
|
3
3
|
#include <iostream>
|
4
4
|
#include <string>
|
5
5
|
|
6
|
-
#include <ruby/ruby.h>
|
7
|
-
#include <ruby/encoding.h>
|
8
|
-
|
9
6
|
#include <rice/Hash.hpp>
|
10
7
|
#include <rice/Array.hpp>
|
11
8
|
#include <rice/to_from_ruby.hpp>
|
@@ -15,9 +12,13 @@
|
|
15
12
|
//
|
16
13
|
// EDN spec at: https://github.com/edn-format/edn
|
17
14
|
//
|
15
|
+
//
|
16
|
+
// many thanks to Florian Frank for json-ruby which was essential in
|
17
|
+
// helping me learn about ragel
|
18
|
+
//
|
18
19
|
|
19
20
|
|
20
|
-
#line
|
21
|
+
#line 48 "edn_parser.rl"
|
21
22
|
|
22
23
|
|
23
24
|
// ============================================================
|
@@ -25,7 +26,7 @@
|
|
25
26
|
//
|
26
27
|
|
27
28
|
|
28
|
-
#line
|
29
|
+
#line 30 "edn_parser.cc"
|
29
30
|
static const int EDN_value_start = 1;
|
30
31
|
static const int EDN_value_first_final = 11;
|
31
32
|
static const int EDN_value_error = 0;
|
@@ -33,23 +34,23 @@ static const int EDN_value_error = 0;
|
|
33
34
|
static const int EDN_value_en_main = 1;
|
34
35
|
|
35
36
|
|
36
|
-
#line
|
37
|
+
#line 127 "edn_parser.rl"
|
37
38
|
|
38
39
|
|
39
40
|
|
40
|
-
const char *edn::Parser::
|
41
|
+
const char *edn::Parser::parse_value(const char *p, const char *pe, Rice::Object& o)
|
41
42
|
{
|
42
43
|
int cs;
|
43
44
|
|
44
45
|
|
45
|
-
#line
|
46
|
+
#line 47 "edn_parser.cc"
|
46
47
|
{
|
47
48
|
cs = EDN_value_start;
|
48
49
|
}
|
49
50
|
|
50
|
-
#line
|
51
|
+
#line 135 "edn_parser.rl"
|
51
52
|
|
52
|
-
#line
|
53
|
+
#line 54 "edn_parser.cc"
|
53
54
|
{
|
54
55
|
if ( p == pe )
|
55
56
|
goto _test_eof;
|
@@ -74,27 +75,27 @@ st0:
|
|
74
75
|
cs = 0;
|
75
76
|
goto _out;
|
76
77
|
tr0:
|
77
|
-
#line
|
78
|
+
#line 75 "edn_parser.rl"
|
78
79
|
{
|
79
|
-
const char *np =
|
80
|
+
const char *np = parse_string(p, pe, o);
|
80
81
|
if (np == NULL) { p--; {p++; cs = 11; goto _out;} } else {p = (( np))-1;}
|
81
82
|
}
|
82
83
|
goto st11;
|
83
84
|
tr2:
|
84
|
-
#line
|
85
|
+
#line 104 "edn_parser.rl"
|
85
86
|
{
|
86
|
-
const char *np =
|
87
|
+
const char *np = parse_list(p, pe, o);
|
87
88
|
if (np == NULL) { p--; {p++; cs = 11; goto _out;} } else {p = (( np))-1;}
|
88
89
|
}
|
89
90
|
goto st11;
|
90
91
|
tr3:
|
91
|
-
#line
|
92
|
+
#line 80 "edn_parser.rl"
|
92
93
|
{
|
93
94
|
// try to parse a decimal first
|
94
|
-
const char *np =
|
95
|
+
const char *np = parse_decimal(p, pe, o);
|
95
96
|
if (np == NULL) {
|
96
97
|
// if we can't, try to parse it as an int
|
97
|
-
np =
|
98
|
+
np = parse_integer(p, pe, o);
|
98
99
|
}
|
99
100
|
|
100
101
|
if (np) {
|
@@ -109,40 +110,40 @@ tr3:
|
|
109
110
|
}
|
110
111
|
goto st11;
|
111
112
|
tr4:
|
112
|
-
#line
|
113
|
+
#line 70 "edn_parser.rl"
|
113
114
|
{
|
114
|
-
const char *np =
|
115
|
+
const char *np = parse_keyword(p, pe, o);
|
115
116
|
if (np == NULL) { p--; {p++; cs = 11; goto _out;} } else {p = (( np))-1;}
|
116
117
|
}
|
117
118
|
goto st11;
|
118
119
|
tr5:
|
119
|
-
#line
|
120
|
+
#line 99 "edn_parser.rl"
|
120
121
|
{
|
121
|
-
const char *np =
|
122
|
+
const char *np = parse_vector(p, pe, o);
|
122
123
|
if (np == NULL) { p--; {p++; cs = 11; goto _out;} } else {p = (( np))-1;}
|
123
124
|
}
|
124
125
|
goto st11;
|
125
126
|
tr9:
|
126
|
-
#line
|
127
|
+
#line 109 "edn_parser.rl"
|
127
128
|
{
|
128
|
-
const char *np =
|
129
|
+
const char *np = parse_map(p, pe, o);
|
129
130
|
if (np == NULL) { p--; {p++; cs = 11; goto _out;} } else {p = (( np))-1;}
|
130
131
|
}
|
131
132
|
goto st11;
|
132
133
|
tr13:
|
133
|
-
#line
|
134
|
+
#line 63 "edn_parser.rl"
|
134
135
|
{
|
135
136
|
o = Qfalse;
|
136
137
|
}
|
137
138
|
goto st11;
|
138
139
|
tr15:
|
139
|
-
#line
|
140
|
+
#line 60 "edn_parser.rl"
|
140
141
|
{
|
141
142
|
o = Qnil;
|
142
143
|
}
|
143
144
|
goto st11;
|
144
145
|
tr18:
|
145
|
-
#line
|
146
|
+
#line 66 "edn_parser.rl"
|
146
147
|
{
|
147
148
|
o = Qtrue;
|
148
149
|
}
|
@@ -151,9 +152,9 @@ st11:
|
|
151
152
|
if ( ++p == pe )
|
152
153
|
goto _test_eof11;
|
153
154
|
case 11:
|
154
|
-
#line
|
155
|
+
#line 114 "edn_parser.rl"
|
155
156
|
{ p--; {p++; cs = 11; goto _out;} }
|
156
|
-
#line
|
157
|
+
#line 158 "edn_parser.cc"
|
157
158
|
goto st0;
|
158
159
|
st2:
|
159
160
|
if ( ++p == pe )
|
@@ -234,7 +235,7 @@ case 10:
|
|
234
235
|
_out: {}
|
235
236
|
}
|
236
237
|
|
237
|
-
#line
|
238
|
+
#line 136 "edn_parser.rl"
|
238
239
|
|
239
240
|
if (cs >= EDN_value_first_final) {
|
240
241
|
return p;
|
@@ -248,35 +249,34 @@ case 10:
|
|
248
249
|
}
|
249
250
|
|
250
251
|
|
252
|
+
|
251
253
|
// ============================================================
|
252
|
-
//
|
253
|
-
// discard (#_ <ident>) is handled by the top-level machine
|
254
|
+
// keyword parsing
|
254
255
|
//
|
255
256
|
|
256
|
-
#line
|
257
|
-
static const int
|
258
|
-
static const int
|
259
|
-
static const int
|
257
|
+
#line 258 "edn_parser.cc"
|
258
|
+
static const int EDN_keyword_start = 1;
|
259
|
+
static const int EDN_keyword_first_final = 4;
|
260
|
+
static const int EDN_keyword_error = 0;
|
260
261
|
|
261
|
-
static const int
|
262
|
+
static const int EDN_keyword_en_main = 1;
|
262
263
|
|
263
264
|
|
264
|
-
#line
|
265
|
+
#line 164 "edn_parser.rl"
|
265
266
|
|
266
267
|
|
267
268
|
|
268
|
-
const char* edn::Parser::
|
269
|
+
const char* edn::Parser::parse_keyword(const char *p, const char *pe, Rice::Object& o)
|
269
270
|
{
|
270
271
|
int cs;
|
271
|
-
Rice::String str;
|
272
272
|
|
273
273
|
|
274
274
|
#line 275 "edn_parser.cc"
|
275
275
|
{
|
276
|
-
cs =
|
276
|
+
cs = EDN_keyword_start;
|
277
277
|
}
|
278
278
|
|
279
|
-
#line
|
279
|
+
#line 172 "edn_parser.rl"
|
280
280
|
p_save = p;
|
281
281
|
|
282
282
|
#line 283 "edn_parser.cc"
|
@@ -286,7 +286,7 @@ const char* edn::Parser::EDN_parse_tagged(const char *p, const char *pe, Rice::O
|
|
286
286
|
switch ( cs )
|
287
287
|
{
|
288
288
|
case 1:
|
289
|
-
if ( (*p) ==
|
289
|
+
if ( (*p) == 58 )
|
290
290
|
goto st2;
|
291
291
|
goto st0;
|
292
292
|
st0:
|
@@ -296,381 +296,89 @@ st2:
|
|
296
296
|
if ( ++p == pe )
|
297
297
|
goto _test_eof2;
|
298
298
|
case 2:
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
st15:
|
306
|
-
if ( ++p == pe )
|
307
|
-
goto _test_eof15;
|
308
|
-
case 15:
|
309
|
-
switch( (*p) ) {
|
310
|
-
case 32: goto st17;
|
311
|
-
case 43: goto st0;
|
312
|
-
case 58: goto st0;
|
313
|
-
}
|
314
|
-
if ( (*p) < 48 ) {
|
315
|
-
if ( (*p) > 13 ) {
|
316
|
-
if ( 45 <= (*p) && (*p) <= 46 )
|
317
|
-
goto st17;
|
318
|
-
} else if ( (*p) >= 9 )
|
319
|
-
goto tr17;
|
320
|
-
} else if ( (*p) > 57 ) {
|
321
|
-
if ( (*p) > 90 ) {
|
322
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
323
|
-
goto st17;
|
324
|
-
} else if ( (*p) >= 65 )
|
325
|
-
goto st17;
|
326
|
-
} else
|
327
|
-
goto st17;
|
328
|
-
goto tr16;
|
329
|
-
tr16:
|
330
|
-
#line 162 "edn_parser.rl"
|
331
|
-
{ p--; {p++; cs = 16; goto _out;} }
|
332
|
-
goto st16;
|
333
|
-
st16:
|
334
|
-
if ( ++p == pe )
|
335
|
-
goto _test_eof16;
|
336
|
-
case 16:
|
337
|
-
#line 338 "edn_parser.cc"
|
338
|
-
switch( (*p) ) {
|
339
|
-
case 32: goto st0;
|
340
|
-
case 43: goto st0;
|
341
|
-
}
|
342
|
-
if ( (*p) < 48 ) {
|
343
|
-
if ( 45 <= (*p) && (*p) <= 46 )
|
344
|
-
goto st0;
|
345
|
-
} else if ( (*p) > 58 ) {
|
346
|
-
if ( (*p) > 90 ) {
|
347
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
348
|
-
goto st0;
|
349
|
-
} else if ( (*p) >= 65 )
|
350
|
-
goto st0;
|
351
|
-
} else
|
352
|
-
goto st0;
|
353
|
-
goto tr16;
|
354
|
-
tr17:
|
355
|
-
#line 162 "edn_parser.rl"
|
356
|
-
{ p--; {p++; cs = 17; goto _out;} }
|
357
|
-
goto st17;
|
358
|
-
st17:
|
359
|
-
if ( ++p == pe )
|
360
|
-
goto _test_eof17;
|
361
|
-
case 17:
|
362
|
-
#line 363 "edn_parser.cc"
|
363
|
-
switch( (*p) ) {
|
364
|
-
case 32: goto st0;
|
365
|
-
case 43: goto st0;
|
366
|
-
case 58: goto st0;
|
367
|
-
}
|
368
|
-
if ( (*p) < 48 ) {
|
369
|
-
if ( 45 <= (*p) && (*p) <= 46 )
|
370
|
-
goto st17;
|
371
|
-
} else if ( (*p) > 57 ) {
|
372
|
-
if ( (*p) > 90 ) {
|
373
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
374
|
-
goto st17;
|
375
|
-
} else if ( (*p) >= 65 )
|
376
|
-
goto st17;
|
377
|
-
} else
|
378
|
-
goto st17;
|
379
|
-
goto tr16;
|
380
|
-
st3:
|
381
|
-
if ( ++p == pe )
|
382
|
-
goto _test_eof3;
|
383
|
-
case 3:
|
384
|
-
if ( (*p) == 110 )
|
299
|
+
if ( (*p) == 95 )
|
300
|
+
goto st4;
|
301
|
+
if ( (*p) > 90 ) {
|
302
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
303
|
+
goto st4;
|
304
|
+
} else if ( (*p) >= 65 )
|
385
305
|
goto st4;
|
386
306
|
goto st0;
|
387
307
|
st4:
|
388
308
|
if ( ++p == pe )
|
389
309
|
goto _test_eof4;
|
390
310
|
case 4:
|
391
|
-
|
392
|
-
goto
|
393
|
-
|
311
|
+
switch( (*p) ) {
|
312
|
+
case 39: goto st0;
|
313
|
+
case 45: goto st4;
|
314
|
+
case 47: goto st3;
|
315
|
+
case 95: goto st4;
|
316
|
+
}
|
317
|
+
if ( (*p) < 65 ) {
|
318
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
319
|
+
goto st4;
|
320
|
+
} else if ( (*p) > 90 ) {
|
321
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
322
|
+
goto st4;
|
323
|
+
} else
|
324
|
+
goto st4;
|
325
|
+
goto tr4;
|
326
|
+
tr4:
|
327
|
+
#line 159 "edn_parser.rl"
|
328
|
+
{ p--; {p++; cs = 5; goto _out;} }
|
329
|
+
goto st5;
|
394
330
|
st5:
|
395
331
|
if ( ++p == pe )
|
396
332
|
goto _test_eof5;
|
397
333
|
case 5:
|
398
|
-
|
334
|
+
#line 335 "edn_parser.cc"
|
335
|
+
goto st0;
|
336
|
+
st3:
|
337
|
+
if ( ++p == pe )
|
338
|
+
goto _test_eof3;
|
339
|
+
case 3:
|
340
|
+
if ( (*p) == 95 )
|
341
|
+
goto st6;
|
342
|
+
if ( (*p) > 90 ) {
|
343
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
344
|
+
goto st6;
|
345
|
+
} else if ( (*p) >= 65 )
|
399
346
|
goto st6;
|
400
347
|
goto st0;
|
401
348
|
st6:
|
402
349
|
if ( ++p == pe )
|
403
350
|
goto _test_eof6;
|
404
351
|
case 6:
|
405
|
-
if ( (*p) == 32 )
|
406
|
-
goto st7;
|
407
|
-
goto st0;
|
408
|
-
st7:
|
409
|
-
if ( ++p == pe )
|
410
|
-
goto _test_eof7;
|
411
|
-
case 7:
|
412
|
-
if ( (*p) == 34 )
|
413
|
-
goto st8;
|
414
|
-
goto st0;
|
415
|
-
st8:
|
416
|
-
if ( ++p == pe )
|
417
|
-
goto _test_eof8;
|
418
|
-
case 8:
|
419
|
-
switch( (*p) ) {
|
420
|
-
case 34: goto st16;
|
421
|
-
case 43: goto st8;
|
422
|
-
case 84: goto st8;
|
423
|
-
case 90: goto st8;
|
424
|
-
}
|
425
|
-
if ( (*p) > 46 ) {
|
426
|
-
if ( 48 <= (*p) && (*p) <= 58 )
|
427
|
-
goto st8;
|
428
|
-
} else if ( (*p) >= 45 )
|
429
|
-
goto st8;
|
430
|
-
goto st0;
|
431
|
-
st9:
|
432
|
-
if ( ++p == pe )
|
433
|
-
goto _test_eof9;
|
434
|
-
case 9:
|
435
|
-
if ( (*p) == 117 )
|
436
|
-
goto st10;
|
437
|
-
goto st0;
|
438
|
-
st10:
|
439
|
-
if ( ++p == pe )
|
440
|
-
goto _test_eof10;
|
441
|
-
case 10:
|
442
|
-
if ( (*p) == 105 )
|
443
|
-
goto st11;
|
444
|
-
goto st0;
|
445
|
-
st11:
|
446
|
-
if ( ++p == pe )
|
447
|
-
goto _test_eof11;
|
448
|
-
case 11:
|
449
|
-
if ( (*p) == 100 )
|
450
|
-
goto st12;
|
451
|
-
goto st0;
|
452
|
-
st12:
|
453
|
-
if ( ++p == pe )
|
454
|
-
goto _test_eof12;
|
455
|
-
case 12:
|
456
|
-
if ( (*p) == 32 )
|
457
|
-
goto st13;
|
458
|
-
goto st0;
|
459
|
-
st13:
|
460
|
-
if ( ++p == pe )
|
461
|
-
goto _test_eof13;
|
462
|
-
case 13:
|
463
|
-
if ( (*p) == 34 )
|
464
|
-
goto st14;
|
465
|
-
goto st0;
|
466
|
-
st14:
|
467
|
-
if ( ++p == pe )
|
468
|
-
goto _test_eof14;
|
469
|
-
case 14:
|
470
352
|
switch( (*p) ) {
|
471
|
-
case
|
472
|
-
case 45: goto
|
353
|
+
case 39: goto st0;
|
354
|
+
case 45: goto st6;
|
355
|
+
case 47: goto st0;
|
356
|
+
case 95: goto st6;
|
473
357
|
}
|
474
|
-
if ( (*p)
|
475
|
-
if (
|
476
|
-
goto
|
477
|
-
} else if ( (*p)
|
478
|
-
|
479
|
-
|
358
|
+
if ( (*p) < 65 ) {
|
359
|
+
if ( 48 <= (*p) && (*p) <= 57 )
|
360
|
+
goto st6;
|
361
|
+
} else if ( (*p) > 90 ) {
|
362
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
363
|
+
goto st6;
|
364
|
+
} else
|
365
|
+
goto st6;
|
366
|
+
goto tr4;
|
480
367
|
}
|
481
368
|
_test_eof2: cs = 2; goto _test_eof;
|
482
|
-
_test_eof15: cs = 15; goto _test_eof;
|
483
|
-
_test_eof16: cs = 16; goto _test_eof;
|
484
|
-
_test_eof17: cs = 17; goto _test_eof;
|
485
|
-
_test_eof3: cs = 3; goto _test_eof;
|
486
369
|
_test_eof4: cs = 4; goto _test_eof;
|
487
370
|
_test_eof5: cs = 5; goto _test_eof;
|
371
|
+
_test_eof3: cs = 3; goto _test_eof;
|
488
372
|
_test_eof6: cs = 6; goto _test_eof;
|
489
|
-
_test_eof7: cs = 7; goto _test_eof;
|
490
|
-
_test_eof8: cs = 8; goto _test_eof;
|
491
|
-
_test_eof9: cs = 9; goto _test_eof;
|
492
|
-
_test_eof10: cs = 10; goto _test_eof;
|
493
|
-
_test_eof11: cs = 11; goto _test_eof;
|
494
|
-
_test_eof12: cs = 12; goto _test_eof;
|
495
|
-
_test_eof13: cs = 13; goto _test_eof;
|
496
|
-
_test_eof14: cs = 14; goto _test_eof;
|
497
373
|
|
498
374
|
_test_eof: {}
|
499
375
|
_out: {}
|
500
376
|
}
|
501
377
|
|
502
|
-
#line
|
503
|
-
|
504
|
-
if (cs >= EDN_dispatch_first_final) {
|
505
|
-
|
506
|
-
//is it a discard? if so, just drop the following token
|
507
|
-
if (*(p_save + 1) == '_')
|
508
|
-
{
|
509
|
-
discard = true;
|
510
|
-
return p + 1;
|
511
|
-
}
|
378
|
+
#line 174 "edn_parser.rl"
|
512
379
|
|
513
|
-
|
514
|
-
|
515
|
-
buf.reserve(len);
|
516
|
-
|
517
|
-
if (len > 10)
|
518
|
-
{
|
519
|
-
// there's enough room to be #inst or #uuid, copy the
|
520
|
-
// string portion
|
521
|
-
if (std::strncmp(p_save + 1, "inst", 4) == 0) {
|
522
|
-
buf.append(p_save + 7, len - 8);
|
523
|
-
} else if (std::strncmp(p_save + 1, "uuid", 4) == 0) {
|
524
|
-
buf.append(p_save + 7, len - 8);
|
525
|
-
}
|
526
|
-
|
527
|
-
o = Rice::String(buf);
|
528
|
-
return p;
|
529
|
-
}
|
530
|
-
|
531
|
-
// tagged element
|
532
|
-
o = Rice::String(buf);
|
533
|
-
return p;
|
534
|
-
}
|
535
|
-
else if (cs == EDN_dispatch_error) {
|
536
|
-
error(*p);
|
537
|
-
return pe;
|
538
|
-
}
|
539
|
-
else if (cs == EDN_dispatch_en_main) {} // silence ragel warning
|
540
|
-
return NULL;
|
541
|
-
}
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
// ============================================================
|
546
|
-
// keyword parsing
|
547
|
-
//
|
548
|
-
|
549
|
-
#line 550 "edn_parser.cc"
|
550
|
-
static const int EDN_keyword_start = 1;
|
551
|
-
static const int EDN_keyword_first_final = 4;
|
552
|
-
static const int EDN_keyword_error = 0;
|
553
|
-
|
554
|
-
static const int EDN_keyword_en_main = 1;
|
555
|
-
|
556
|
-
|
557
|
-
#line 237 "edn_parser.rl"
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
const char* edn::Parser::EDN_parse_keyword(const char *p, const char *pe, Rice::Object& o)
|
562
|
-
{
|
563
|
-
int cs;
|
564
|
-
|
565
|
-
|
566
|
-
#line 567 "edn_parser.cc"
|
567
|
-
{
|
568
|
-
cs = EDN_keyword_start;
|
569
|
-
}
|
570
|
-
|
571
|
-
#line 245 "edn_parser.rl"
|
572
|
-
p_save = p;
|
573
|
-
|
574
|
-
#line 575 "edn_parser.cc"
|
575
|
-
{
|
576
|
-
if ( p == pe )
|
577
|
-
goto _test_eof;
|
578
|
-
switch ( cs )
|
579
|
-
{
|
580
|
-
case 1:
|
581
|
-
if ( (*p) == 58 )
|
582
|
-
goto st2;
|
583
|
-
goto st0;
|
584
|
-
st0:
|
585
|
-
cs = 0;
|
586
|
-
goto _out;
|
587
|
-
st2:
|
588
|
-
if ( ++p == pe )
|
589
|
-
goto _test_eof2;
|
590
|
-
case 2:
|
591
|
-
if ( (*p) == 95 )
|
592
|
-
goto st4;
|
593
|
-
if ( (*p) > 90 ) {
|
594
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
595
|
-
goto st4;
|
596
|
-
} else if ( (*p) >= 65 )
|
597
|
-
goto st4;
|
598
|
-
goto st0;
|
599
|
-
st4:
|
600
|
-
if ( ++p == pe )
|
601
|
-
goto _test_eof4;
|
602
|
-
case 4:
|
603
|
-
switch( (*p) ) {
|
604
|
-
case 39: goto st0;
|
605
|
-
case 45: goto st4;
|
606
|
-
case 47: goto st3;
|
607
|
-
case 95: goto st4;
|
608
|
-
}
|
609
|
-
if ( (*p) < 65 ) {
|
610
|
-
if ( 48 <= (*p) && (*p) <= 57 )
|
611
|
-
goto st4;
|
612
|
-
} else if ( (*p) > 90 ) {
|
613
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
614
|
-
goto st4;
|
615
|
-
} else
|
616
|
-
goto st4;
|
617
|
-
goto tr4;
|
618
|
-
tr4:
|
619
|
-
#line 232 "edn_parser.rl"
|
620
|
-
{ p--; {p++; cs = 5; goto _out;} }
|
621
|
-
goto st5;
|
622
|
-
st5:
|
623
|
-
if ( ++p == pe )
|
624
|
-
goto _test_eof5;
|
625
|
-
case 5:
|
626
|
-
#line 627 "edn_parser.cc"
|
627
|
-
goto st0;
|
628
|
-
st3:
|
629
|
-
if ( ++p == pe )
|
630
|
-
goto _test_eof3;
|
631
|
-
case 3:
|
632
|
-
if ( (*p) == 95 )
|
633
|
-
goto st6;
|
634
|
-
if ( (*p) > 90 ) {
|
635
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
636
|
-
goto st6;
|
637
|
-
} else if ( (*p) >= 65 )
|
638
|
-
goto st6;
|
639
|
-
goto st0;
|
640
|
-
st6:
|
641
|
-
if ( ++p == pe )
|
642
|
-
goto _test_eof6;
|
643
|
-
case 6:
|
644
|
-
switch( (*p) ) {
|
645
|
-
case 39: goto st0;
|
646
|
-
case 45: goto st6;
|
647
|
-
case 47: goto st0;
|
648
|
-
case 95: goto st6;
|
649
|
-
}
|
650
|
-
if ( (*p) < 65 ) {
|
651
|
-
if ( 48 <= (*p) && (*p) <= 57 )
|
652
|
-
goto st6;
|
653
|
-
} else if ( (*p) > 90 ) {
|
654
|
-
if ( 97 <= (*p) && (*p) <= 122 )
|
655
|
-
goto st6;
|
656
|
-
} else
|
657
|
-
goto st6;
|
658
|
-
goto tr4;
|
659
|
-
}
|
660
|
-
_test_eof2: cs = 2; goto _test_eof;
|
661
|
-
_test_eof4: cs = 4; goto _test_eof;
|
662
|
-
_test_eof5: cs = 5; goto _test_eof;
|
663
|
-
_test_eof3: cs = 3; goto _test_eof;
|
664
|
-
_test_eof6: cs = 6; goto _test_eof;
|
665
|
-
|
666
|
-
_test_eof: {}
|
667
|
-
_out: {}
|
668
|
-
}
|
669
|
-
|
670
|
-
#line 247 "edn_parser.rl"
|
671
|
-
|
672
|
-
if (cs >= EDN_keyword_first_final) {
|
673
|
-
uint32_t len = p - p_save - 1; // don't include leading ':' because Rice::Symbol will handle it
|
380
|
+
if (cs >= EDN_keyword_first_final) {
|
381
|
+
uint32_t len = p - p_save - 1; // don't include leading ':' because Rice::Symbol will handle it
|
674
382
|
std::string buf;
|
675
383
|
buf.append(p_save + 1, len);
|
676
384
|
o = Rice::Symbol(buf);
|
@@ -690,7 +398,7 @@ case 6:
|
|
690
398
|
// string parsing
|
691
399
|
//
|
692
400
|
|
693
|
-
#line
|
401
|
+
#line 402 "edn_parser.cc"
|
694
402
|
static const int EDN_string_start = 1;
|
695
403
|
static const int EDN_string_first_final = 8;
|
696
404
|
static const int EDN_string_error = 0;
|
@@ -698,86 +406,11 @@ static const int EDN_string_error = 0;
|
|
698
406
|
static const int EDN_string_en_main = 1;
|
699
407
|
|
700
408
|
|
701
|
-
#line
|
409
|
+
#line 219 "edn_parser.rl"
|
702
410
|
|
703
411
|
|
704
412
|
|
705
|
-
|
706
|
-
// copies the string data, unescaping any present values that need to be replaced
|
707
|
-
//
|
708
|
-
bool edn::Parser::EDN_parse_byte_stream(const char *p, const char *pe, Rice::String& s)
|
709
|
-
{
|
710
|
-
if (pe > p) {
|
711
|
-
std::string buf;
|
712
|
-
std::size_t len = pe - p;
|
713
|
-
|
714
|
-
// pre-allocate storage needed
|
715
|
-
buf.reserve(len);
|
716
|
-
|
717
|
-
const char* cp = p;
|
718
|
-
std::size_t pos = 0;
|
719
|
-
char c, replacement;
|
720
|
-
|
721
|
-
while (cp < pe)
|
722
|
-
{
|
723
|
-
// append any other character that is not the escaping slash
|
724
|
-
if (*cp != '\\') {
|
725
|
-
buf.replace(pos++, 1, 1, *cp++);
|
726
|
-
continue;
|
727
|
-
}
|
728
|
-
|
729
|
-
// looking at a '\' - check what it escapes if there's a
|
730
|
-
// following character
|
731
|
-
if (++cp == pe)
|
732
|
-
break;
|
733
|
-
|
734
|
-
c = *cp++;
|
735
|
-
replacement = '?';
|
736
|
-
|
737
|
-
switch (c)
|
738
|
-
{
|
739
|
-
case 't':
|
740
|
-
replacement = '\t';
|
741
|
-
break;
|
742
|
-
case 'n':
|
743
|
-
replacement = '\n';
|
744
|
-
break;
|
745
|
-
case 'r':
|
746
|
-
replacement = '\r';
|
747
|
-
break;
|
748
|
-
case '\"':
|
749
|
-
replacement = '\"';
|
750
|
-
break;
|
751
|
-
case '\\':
|
752
|
-
replacement = '\\';
|
753
|
-
break;
|
754
|
-
/* TODO: add support for this!
|
755
|
-
case 'u':
|
756
|
-
replacement = '\u';
|
757
|
-
break;
|
758
|
-
*/
|
759
|
-
default:
|
760
|
-
std::cerr << "value must be unescaped but case is unhandled: '" << c << "'" << std::endl;
|
761
|
-
break;
|
762
|
-
}
|
763
|
-
|
764
|
-
// substitute the escaped walue
|
765
|
-
if (replacement != '?')
|
766
|
-
buf.replace(pos++, 1, 1, replacement);
|
767
|
-
}
|
768
|
-
|
769
|
-
// utf-8 encode
|
770
|
-
VALUE vs = Rice::protect( rb_str_new2, buf.c_str() );
|
771
|
-
VALUE s_utf8 = Rice::protect( rb_enc_associate, vs, rb_utf8_encoding() );
|
772
|
-
s = Rice::String(s_utf8);
|
773
|
-
return true;
|
774
|
-
}
|
775
|
-
|
776
|
-
return false;
|
777
|
-
}
|
778
|
-
|
779
|
-
|
780
|
-
const char* edn::Parser::EDN_parse_string(const char *p, const char *pe, Rice::Object& o)
|
413
|
+
const char* edn::Parser::parse_string(const char *p, const char *pe, Rice::Object& o)
|
781
414
|
{
|
782
415
|
static const char* EDN_TYPE = "string";
|
783
416
|
int cs;
|
@@ -785,15 +418,15 @@ const char* edn::Parser::EDN_parse_string(const char *p, const char *pe, Rice::O
|
|
785
418
|
|
786
419
|
Rice::String s;
|
787
420
|
|
788
|
-
#line
|
421
|
+
#line 422 "edn_parser.cc"
|
789
422
|
{
|
790
423
|
cs = EDN_string_start;
|
791
424
|
}
|
792
425
|
|
793
|
-
#line
|
426
|
+
#line 230 "edn_parser.rl"
|
794
427
|
p_save = p;
|
795
428
|
|
796
|
-
#line
|
429
|
+
#line 430 "edn_parser.cc"
|
797
430
|
{
|
798
431
|
if ( p == pe )
|
799
432
|
goto _test_eof;
|
@@ -804,7 +437,7 @@ case 1:
|
|
804
437
|
goto st2;
|
805
438
|
goto st0;
|
806
439
|
tr2:
|
807
|
-
#line
|
440
|
+
#line 42 "edn_parser.rl"
|
808
441
|
{
|
809
442
|
std::stringstream s;
|
810
443
|
s << "unterminated " << EDN_TYPE;
|
@@ -812,7 +445,7 @@ tr2:
|
|
812
445
|
{p = (( pe))-1;}
|
813
446
|
}
|
814
447
|
goto st0;
|
815
|
-
#line
|
448
|
+
#line 449 "edn_parser.cc"
|
816
449
|
st0:
|
817
450
|
cs = 0;
|
818
451
|
goto _out;
|
@@ -828,23 +461,23 @@ case 2:
|
|
828
461
|
goto tr2;
|
829
462
|
goto st2;
|
830
463
|
tr3:
|
831
|
-
#line
|
464
|
+
#line 201 "edn_parser.rl"
|
832
465
|
{
|
833
|
-
if (!
|
466
|
+
if (!parse_byte_stream(p_save + 1, p, s)) {
|
834
467
|
p--;
|
835
468
|
{p++; cs = 8; goto _out;}
|
836
469
|
} else {
|
837
470
|
{p = (( p + 1))-1;}
|
838
471
|
}
|
839
472
|
}
|
840
|
-
#line
|
473
|
+
#line 210 "edn_parser.rl"
|
841
474
|
{ p--; {p++; cs = 8; goto _out;} }
|
842
475
|
goto st8;
|
843
476
|
st8:
|
844
477
|
if ( ++p == pe )
|
845
478
|
goto _test_eof8;
|
846
479
|
case 8:
|
847
|
-
#line
|
480
|
+
#line 481 "edn_parser.cc"
|
848
481
|
goto st0;
|
849
482
|
st3:
|
850
483
|
if ( ++p == pe )
|
@@ -921,7 +554,7 @@ case 7:
|
|
921
554
|
{
|
922
555
|
switch ( cs ) {
|
923
556
|
case 2:
|
924
|
-
#line
|
557
|
+
#line 42 "edn_parser.rl"
|
925
558
|
{
|
926
559
|
std::stringstream s;
|
927
560
|
s << "unterminated " << EDN_TYPE;
|
@@ -929,14 +562,14 @@ case 7:
|
|
929
562
|
{p = (( pe))-1;}
|
930
563
|
}
|
931
564
|
break;
|
932
|
-
#line
|
565
|
+
#line 566 "edn_parser.cc"
|
933
566
|
}
|
934
567
|
}
|
935
568
|
|
936
569
|
_out: {}
|
937
570
|
}
|
938
571
|
|
939
|
-
#line
|
572
|
+
#line 232 "edn_parser.rl"
|
940
573
|
|
941
574
|
if (cs >= EDN_string_first_final) {
|
942
575
|
o = s;
|
@@ -953,31 +586,31 @@ case 7:
|
|
953
586
|
// decimal parsing grammar
|
954
587
|
//
|
955
588
|
|
956
|
-
#line
|
589
|
+
#line 590 "edn_parser.cc"
|
957
590
|
static const int EDN_decimal_start = 1;
|
958
591
|
static const int EDN_decimal_first_final = 8;
|
959
592
|
|
960
593
|
static const int EDN_decimal_en_main = 1;
|
961
594
|
|
962
595
|
|
963
|
-
#line
|
596
|
+
#line 262 "edn_parser.rl"
|
964
597
|
|
965
598
|
|
966
599
|
|
967
|
-
const char* edn::Parser::
|
600
|
+
const char* edn::Parser::parse_decimal(const char *p, const char *pe, Rice::Object& o)
|
968
601
|
{
|
969
602
|
int cs;
|
970
603
|
|
971
604
|
|
972
|
-
#line
|
605
|
+
#line 606 "edn_parser.cc"
|
973
606
|
{
|
974
607
|
cs = EDN_decimal_start;
|
975
608
|
}
|
976
609
|
|
977
|
-
#line
|
610
|
+
#line 270 "edn_parser.rl"
|
978
611
|
p_save = p;
|
979
612
|
|
980
|
-
#line
|
613
|
+
#line 614 "edn_parser.cc"
|
981
614
|
{
|
982
615
|
if ( p == pe )
|
983
616
|
goto _test_eof;
|
@@ -1036,14 +669,14 @@ case 8:
|
|
1036
669
|
goto st0;
|
1037
670
|
goto tr9;
|
1038
671
|
tr9:
|
1039
|
-
#line
|
672
|
+
#line 253 "edn_parser.rl"
|
1040
673
|
{ p--; {p++; cs = 9; goto _out;} }
|
1041
674
|
goto st9;
|
1042
675
|
st9:
|
1043
676
|
if ( ++p == pe )
|
1044
677
|
goto _test_eof9;
|
1045
678
|
case 9:
|
1046
|
-
#line
|
679
|
+
#line 680 "edn_parser.cc"
|
1047
680
|
goto st0;
|
1048
681
|
st5:
|
1049
682
|
if ( ++p == pe )
|
@@ -1121,7 +754,7 @@ case 7:
|
|
1121
754
|
_out: {}
|
1122
755
|
}
|
1123
756
|
|
1124
|
-
#line
|
757
|
+
#line 272 "edn_parser.rl"
|
1125
758
|
|
1126
759
|
if (cs >= EDN_decimal_first_final) {
|
1127
760
|
double value;
|
@@ -1137,30 +770,30 @@ case 7:
|
|
1137
770
|
// integer parsing grammar
|
1138
771
|
//
|
1139
772
|
|
1140
|
-
#line
|
773
|
+
#line 774 "edn_parser.cc"
|
1141
774
|
static const int EDN_integer_start = 1;
|
1142
775
|
static const int EDN_integer_first_final = 3;
|
1143
776
|
|
1144
777
|
static const int EDN_integer_en_main = 1;
|
1145
778
|
|
1146
779
|
|
1147
|
-
#line
|
780
|
+
#line 294 "edn_parser.rl"
|
1148
781
|
|
1149
782
|
|
1150
|
-
const char* edn::Parser::
|
783
|
+
const char* edn::Parser::parse_integer(const char *p, const char *pe, Rice::Object& o)
|
1151
784
|
{
|
1152
785
|
int cs;
|
1153
786
|
|
1154
787
|
|
1155
|
-
#line
|
788
|
+
#line 789 "edn_parser.cc"
|
1156
789
|
{
|
1157
790
|
cs = EDN_integer_start;
|
1158
791
|
}
|
1159
792
|
|
1160
|
-
#line
|
793
|
+
#line 301 "edn_parser.rl"
|
1161
794
|
p_save = p;
|
1162
795
|
|
1163
|
-
#line
|
796
|
+
#line 797 "edn_parser.cc"
|
1164
797
|
{
|
1165
798
|
if ( p == pe )
|
1166
799
|
goto _test_eof;
|
@@ -1196,14 +829,14 @@ case 3:
|
|
1196
829
|
goto st0;
|
1197
830
|
goto tr4;
|
1198
831
|
tr4:
|
1199
|
-
#line
|
832
|
+
#line 291 "edn_parser.rl"
|
1200
833
|
{ p--; {p++; cs = 4; goto _out;} }
|
1201
834
|
goto st4;
|
1202
835
|
st4:
|
1203
836
|
if ( ++p == pe )
|
1204
837
|
goto _test_eof4;
|
1205
838
|
case 4:
|
1206
|
-
#line
|
839
|
+
#line 840 "edn_parser.cc"
|
1207
840
|
goto st0;
|
1208
841
|
st5:
|
1209
842
|
if ( ++p == pe )
|
@@ -1224,7 +857,7 @@ case 5:
|
|
1224
857
|
_out: {}
|
1225
858
|
}
|
1226
859
|
|
1227
|
-
#line
|
860
|
+
#line 303 "edn_parser.rl"
|
1228
861
|
|
1229
862
|
if (cs >= EDN_integer_first_final) {
|
1230
863
|
int value;
|
@@ -1241,13 +874,13 @@ case 5:
|
|
1241
874
|
// vectors and lists since they're both represented as vectors in ruby
|
1242
875
|
//
|
1243
876
|
|
1244
|
-
#line
|
877
|
+
#line 355 "edn_parser.rl"
|
1245
878
|
|
1246
879
|
|
1247
880
|
//
|
1248
881
|
// vector-specific machine
|
1249
882
|
|
1250
|
-
#line
|
883
|
+
#line 884 "edn_parser.cc"
|
1251
884
|
static const int EDN_vector_start = 1;
|
1252
885
|
static const int EDN_vector_first_final = 4;
|
1253
886
|
static const int EDN_vector_error = 0;
|
@@ -1255,14 +888,14 @@ static const int EDN_vector_error = 0;
|
|
1255
888
|
static const int EDN_vector_en_main = 1;
|
1256
889
|
|
1257
890
|
|
1258
|
-
#line
|
891
|
+
#line 369 "edn_parser.rl"
|
1259
892
|
|
1260
893
|
|
1261
894
|
|
1262
895
|
//
|
1263
896
|
// vector parsing
|
1264
897
|
//
|
1265
|
-
const char* edn::Parser::
|
898
|
+
const char* edn::Parser::parse_vector(const char *p, const char *pe, Rice::Object& o)
|
1266
899
|
{
|
1267
900
|
static const char* EDN_TYPE = "vector";
|
1268
901
|
|
@@ -1270,14 +903,14 @@ const char* edn::Parser::EDN_parse_vector(const char *p, const char *pe, Rice::O
|
|
1270
903
|
Rice::Array arr;
|
1271
904
|
|
1272
905
|
|
1273
|
-
#line
|
906
|
+
#line 907 "edn_parser.cc"
|
1274
907
|
{
|
1275
908
|
cs = EDN_vector_start;
|
1276
909
|
}
|
1277
910
|
|
1278
|
-
#line
|
911
|
+
#line 383 "edn_parser.rl"
|
1279
912
|
|
1280
|
-
#line
|
913
|
+
#line 914 "edn_parser.cc"
|
1281
914
|
{
|
1282
915
|
if ( p == pe )
|
1283
916
|
goto _test_eof;
|
@@ -1288,7 +921,7 @@ case 1:
|
|
1288
921
|
goto st2;
|
1289
922
|
goto st0;
|
1290
923
|
tr2:
|
1291
|
-
#line
|
924
|
+
#line 42 "edn_parser.rl"
|
1292
925
|
{
|
1293
926
|
std::stringstream s;
|
1294
927
|
s << "unterminated " << EDN_TYPE;
|
@@ -1296,19 +929,19 @@ tr2:
|
|
1296
929
|
{p = (( pe))-1;}
|
1297
930
|
}
|
1298
931
|
goto st0;
|
1299
|
-
#line
|
932
|
+
#line 933 "edn_parser.cc"
|
1300
933
|
st0:
|
1301
934
|
cs = 0;
|
1302
935
|
goto _out;
|
1303
936
|
tr3:
|
1304
|
-
#line
|
937
|
+
#line 22 "edn_parser.rl"
|
1305
938
|
{ line_number++; }
|
1306
939
|
goto st2;
|
1307
940
|
tr4:
|
1308
|
-
#line
|
941
|
+
#line 322 "edn_parser.rl"
|
1309
942
|
{
|
1310
943
|
Rice::Object v;
|
1311
|
-
const char *np =
|
944
|
+
const char *np = parse_value(p, pe, v);
|
1312
945
|
if (np == NULL) {
|
1313
946
|
p--; {p++; cs = 2; goto _out;}
|
1314
947
|
} else {
|
@@ -1318,11 +951,11 @@ tr4:
|
|
1318
951
|
}
|
1319
952
|
goto st2;
|
1320
953
|
tr5:
|
1321
|
-
#line
|
954
|
+
#line 333 "edn_parser.rl"
|
1322
955
|
{
|
1323
956
|
bool discard = false;
|
1324
957
|
Rice::Object v;
|
1325
|
-
const char *np =
|
958
|
+
const char *np = parse_tagged(p, pe, v, discard);
|
1326
959
|
if (np == NULL) {
|
1327
960
|
p--; {p++; cs = 2; goto _out;}
|
1328
961
|
} else {
|
@@ -1337,7 +970,7 @@ st2:
|
|
1337
970
|
if ( ++p == pe )
|
1338
971
|
goto _test_eof2;
|
1339
972
|
case 2:
|
1340
|
-
#line
|
973
|
+
#line 974 "edn_parser.cc"
|
1341
974
|
switch( (*p) ) {
|
1342
975
|
case 10: goto tr3;
|
1343
976
|
case 32: goto st2;
|
@@ -1370,14 +1003,14 @@ case 3:
|
|
1370
1003
|
goto tr3;
|
1371
1004
|
goto st3;
|
1372
1005
|
tr7:
|
1373
|
-
#line
|
1006
|
+
#line 347 "edn_parser.rl"
|
1374
1007
|
{ p--; {p++; cs = 4; goto _out;} }
|
1375
1008
|
goto st4;
|
1376
1009
|
st4:
|
1377
1010
|
if ( ++p == pe )
|
1378
1011
|
goto _test_eof4;
|
1379
1012
|
case 4:
|
1380
|
-
#line
|
1013
|
+
#line 1014 "edn_parser.cc"
|
1381
1014
|
goto st0;
|
1382
1015
|
}
|
1383
1016
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -1389,7 +1022,7 @@ case 4:
|
|
1389
1022
|
{
|
1390
1023
|
switch ( cs ) {
|
1391
1024
|
case 2:
|
1392
|
-
#line
|
1025
|
+
#line 42 "edn_parser.rl"
|
1393
1026
|
{
|
1394
1027
|
std::stringstream s;
|
1395
1028
|
s << "unterminated " << EDN_TYPE;
|
@@ -1397,14 +1030,14 @@ case 4:
|
|
1397
1030
|
{p = (( pe))-1;}
|
1398
1031
|
}
|
1399
1032
|
break;
|
1400
|
-
#line
|
1033
|
+
#line 1034 "edn_parser.cc"
|
1401
1034
|
}
|
1402
1035
|
}
|
1403
1036
|
|
1404
1037
|
_out: {}
|
1405
1038
|
}
|
1406
1039
|
|
1407
|
-
#line
|
1040
|
+
#line 384 "edn_parser.rl"
|
1408
1041
|
|
1409
1042
|
if (cs >= EDN_vector_first_final) {
|
1410
1043
|
o = arr;
|
@@ -1424,7 +1057,7 @@ case 4:
|
|
1424
1057
|
// list parsing machine
|
1425
1058
|
//
|
1426
1059
|
|
1427
|
-
#line
|
1060
|
+
#line 1061 "edn_parser.cc"
|
1428
1061
|
static const int EDN_list_start = 1;
|
1429
1062
|
static const int EDN_list_first_final = 6;
|
1430
1063
|
static const int EDN_list_error = 0;
|
@@ -1432,13 +1065,13 @@ static const int EDN_list_error = 0;
|
|
1432
1065
|
static const int EDN_list_en_main = 1;
|
1433
1066
|
|
1434
1067
|
|
1435
|
-
#line
|
1068
|
+
#line 413 "edn_parser.rl"
|
1436
1069
|
|
1437
1070
|
|
1438
1071
|
//
|
1439
1072
|
// list parsing
|
1440
1073
|
//
|
1441
|
-
const char* edn::Parser::
|
1074
|
+
const char* edn::Parser::parse_list(const char *p, const char *pe, Rice::Object& o)
|
1442
1075
|
{
|
1443
1076
|
static const char* EDN_TYPE = "list";
|
1444
1077
|
|
@@ -1446,14 +1079,14 @@ const char* edn::Parser::EDN_parse_list(const char *p, const char *pe, Rice::Obj
|
|
1446
1079
|
Rice::Array arr;
|
1447
1080
|
|
1448
1081
|
|
1449
|
-
#line
|
1082
|
+
#line 1083 "edn_parser.cc"
|
1450
1083
|
{
|
1451
1084
|
cs = EDN_list_start;
|
1452
1085
|
}
|
1453
1086
|
|
1454
|
-
#line
|
1087
|
+
#line 426 "edn_parser.rl"
|
1455
1088
|
|
1456
|
-
#line
|
1089
|
+
#line 1090 "edn_parser.cc"
|
1457
1090
|
{
|
1458
1091
|
if ( p == pe )
|
1459
1092
|
goto _test_eof;
|
@@ -1464,7 +1097,7 @@ case 1:
|
|
1464
1097
|
goto st2;
|
1465
1098
|
goto st0;
|
1466
1099
|
tr2:
|
1467
|
-
#line
|
1100
|
+
#line 42 "edn_parser.rl"
|
1468
1101
|
{
|
1469
1102
|
std::stringstream s;
|
1470
1103
|
s << "unterminated " << EDN_TYPE;
|
@@ -1472,19 +1105,19 @@ tr2:
|
|
1472
1105
|
{p = (( pe))-1;}
|
1473
1106
|
}
|
1474
1107
|
goto st0;
|
1475
|
-
#line
|
1108
|
+
#line 1109 "edn_parser.cc"
|
1476
1109
|
st0:
|
1477
1110
|
cs = 0;
|
1478
1111
|
goto _out;
|
1479
1112
|
tr3:
|
1480
|
-
#line
|
1113
|
+
#line 22 "edn_parser.rl"
|
1481
1114
|
{ line_number++; }
|
1482
1115
|
goto st2;
|
1483
1116
|
st2:
|
1484
1117
|
if ( ++p == pe )
|
1485
1118
|
goto _test_eof2;
|
1486
1119
|
case 2:
|
1487
|
-
#line
|
1120
|
+
#line 1121 "edn_parser.cc"
|
1488
1121
|
switch( (*p) ) {
|
1489
1122
|
case 10: goto tr3;
|
1490
1123
|
case 32: goto st2;
|
@@ -1509,14 +1142,14 @@ case 2:
|
|
1509
1142
|
goto tr4;
|
1510
1143
|
goto tr2;
|
1511
1144
|
tr8:
|
1512
|
-
#line
|
1145
|
+
#line 22 "edn_parser.rl"
|
1513
1146
|
{ line_number++; }
|
1514
1147
|
goto st3;
|
1515
1148
|
tr4:
|
1516
|
-
#line
|
1149
|
+
#line 322 "edn_parser.rl"
|
1517
1150
|
{
|
1518
1151
|
Rice::Object v;
|
1519
|
-
const char *np =
|
1152
|
+
const char *np = parse_value(p, pe, v);
|
1520
1153
|
if (np == NULL) {
|
1521
1154
|
p--; {p++; cs = 3; goto _out;}
|
1522
1155
|
} else {
|
@@ -1526,11 +1159,11 @@ tr4:
|
|
1526
1159
|
}
|
1527
1160
|
goto st3;
|
1528
1161
|
tr9:
|
1529
|
-
#line
|
1162
|
+
#line 333 "edn_parser.rl"
|
1530
1163
|
{
|
1531
1164
|
bool discard = false;
|
1532
1165
|
Rice::Object v;
|
1533
|
-
const char *np =
|
1166
|
+
const char *np = parse_tagged(p, pe, v, discard);
|
1534
1167
|
if (np == NULL) {
|
1535
1168
|
p--; {p++; cs = 3; goto _out;}
|
1536
1169
|
} else {
|
@@ -1545,7 +1178,7 @@ st3:
|
|
1545
1178
|
if ( ++p == pe )
|
1546
1179
|
goto _test_eof3;
|
1547
1180
|
case 3:
|
1548
|
-
#line
|
1181
|
+
#line 1182 "edn_parser.cc"
|
1549
1182
|
switch( (*p) ) {
|
1550
1183
|
case 10: goto tr8;
|
1551
1184
|
case 32: goto st3;
|
@@ -1571,14 +1204,14 @@ case 3:
|
|
1571
1204
|
goto tr4;
|
1572
1205
|
goto tr2;
|
1573
1206
|
tr5:
|
1574
|
-
#line
|
1207
|
+
#line 347 "edn_parser.rl"
|
1575
1208
|
{ p--; {p++; cs = 6; goto _out;} }
|
1576
1209
|
goto st6;
|
1577
1210
|
st6:
|
1578
1211
|
if ( ++p == pe )
|
1579
1212
|
goto _test_eof6;
|
1580
1213
|
case 6:
|
1581
|
-
#line
|
1214
|
+
#line 1215 "edn_parser.cc"
|
1582
1215
|
goto st0;
|
1583
1216
|
st4:
|
1584
1217
|
if ( ++p == pe )
|
@@ -1607,7 +1240,7 @@ case 5:
|
|
1607
1240
|
switch ( cs ) {
|
1608
1241
|
case 2:
|
1609
1242
|
case 3:
|
1610
|
-
#line
|
1243
|
+
#line 42 "edn_parser.rl"
|
1611
1244
|
{
|
1612
1245
|
std::stringstream s;
|
1613
1246
|
s << "unterminated " << EDN_TYPE;
|
@@ -1615,14 +1248,14 @@ case 5:
|
|
1615
1248
|
{p = (( pe))-1;}
|
1616
1249
|
}
|
1617
1250
|
break;
|
1618
|
-
#line
|
1251
|
+
#line 1252 "edn_parser.cc"
|
1619
1252
|
}
|
1620
1253
|
}
|
1621
1254
|
|
1622
1255
|
_out: {}
|
1623
1256
|
}
|
1624
1257
|
|
1625
|
-
#line
|
1258
|
+
#line 427 "edn_parser.rl"
|
1626
1259
|
|
1627
1260
|
if (cs >= EDN_list_first_final) {
|
1628
1261
|
o = arr;
|
@@ -1642,7 +1275,7 @@ case 5:
|
|
1642
1275
|
// hash parsing
|
1643
1276
|
//
|
1644
1277
|
|
1645
|
-
#line
|
1278
|
+
#line 1279 "edn_parser.cc"
|
1646
1279
|
static const int EDN_map_start = 1;
|
1647
1280
|
static const int EDN_map_first_final = 6;
|
1648
1281
|
static const int EDN_map_error = 0;
|
@@ -1650,11 +1283,11 @@ static const int EDN_map_error = 0;
|
|
1650
1283
|
static const int EDN_map_en_main = 1;
|
1651
1284
|
|
1652
1285
|
|
1653
|
-
#line
|
1286
|
+
#line 486 "edn_parser.rl"
|
1654
1287
|
|
1655
1288
|
|
1656
1289
|
|
1657
|
-
const char* edn::Parser::
|
1290
|
+
const char* edn::Parser::parse_map(const char *p, const char *pe, Rice::Object& o)
|
1658
1291
|
{
|
1659
1292
|
static const char* EDN_TYPE = "map";
|
1660
1293
|
|
@@ -1663,15 +1296,15 @@ const char* edn::Parser::EDN_parse_map(const char *p, const char *pe, Rice::Obje
|
|
1663
1296
|
Rice::Object k, v;
|
1664
1297
|
|
1665
1298
|
|
1666
|
-
#line
|
1299
|
+
#line 1300 "edn_parser.cc"
|
1667
1300
|
{
|
1668
1301
|
cs = EDN_map_start;
|
1669
1302
|
}
|
1670
1303
|
|
1671
|
-
#line
|
1304
|
+
#line 498 "edn_parser.rl"
|
1672
1305
|
p_save = p;
|
1673
1306
|
|
1674
|
-
#line
|
1307
|
+
#line 1308 "edn_parser.cc"
|
1675
1308
|
{
|
1676
1309
|
if ( p == pe )
|
1677
1310
|
goto _test_eof;
|
@@ -1682,7 +1315,7 @@ case 1:
|
|
1682
1315
|
goto st2;
|
1683
1316
|
goto st0;
|
1684
1317
|
tr2:
|
1685
|
-
#line
|
1318
|
+
#line 42 "edn_parser.rl"
|
1686
1319
|
{
|
1687
1320
|
std::stringstream s;
|
1688
1321
|
s << "unterminated " << EDN_TYPE;
|
@@ -1691,24 +1324,24 @@ tr2:
|
|
1691
1324
|
}
|
1692
1325
|
goto st0;
|
1693
1326
|
tr7:
|
1694
|
-
#line
|
1327
|
+
#line 471 "edn_parser.rl"
|
1695
1328
|
{
|
1696
1329
|
error("map pair not found");
|
1697
1330
|
{p = (( pe))-1;}
|
1698
1331
|
}
|
1699
1332
|
goto st0;
|
1700
|
-
#line
|
1333
|
+
#line 1334 "edn_parser.cc"
|
1701
1334
|
st0:
|
1702
1335
|
cs = 0;
|
1703
1336
|
goto _out;
|
1704
1337
|
tr3:
|
1705
|
-
#line
|
1338
|
+
#line 22 "edn_parser.rl"
|
1706
1339
|
{ line_number++; }
|
1707
1340
|
goto st2;
|
1708
1341
|
tr10:
|
1709
|
-
#line
|
1342
|
+
#line 460 "edn_parser.rl"
|
1710
1343
|
{
|
1711
|
-
const char *np =
|
1344
|
+
const char *np = parse_value(p, pe, v);
|
1712
1345
|
if (np == NULL) {
|
1713
1346
|
p--; {p++; cs = 2; goto _out;}
|
1714
1347
|
} else {
|
@@ -1721,7 +1354,7 @@ st2:
|
|
1721
1354
|
if ( ++p == pe )
|
1722
1355
|
goto _test_eof2;
|
1723
1356
|
case 2:
|
1724
|
-
#line
|
1357
|
+
#line 1358 "edn_parser.cc"
|
1725
1358
|
switch( (*p) ) {
|
1726
1359
|
case 10: goto tr3;
|
1727
1360
|
case 32: goto st2;
|
@@ -1746,13 +1379,13 @@ case 2:
|
|
1746
1379
|
goto tr4;
|
1747
1380
|
goto tr2;
|
1748
1381
|
tr9:
|
1749
|
-
#line
|
1382
|
+
#line 22 "edn_parser.rl"
|
1750
1383
|
{ line_number++; }
|
1751
1384
|
goto st3;
|
1752
1385
|
tr4:
|
1753
|
-
#line
|
1386
|
+
#line 451 "edn_parser.rl"
|
1754
1387
|
{
|
1755
|
-
const char *np =
|
1388
|
+
const char *np = parse_value(p, pe, k);
|
1756
1389
|
if (np == NULL) {
|
1757
1390
|
p--; {p++; cs = 3; goto _out;}
|
1758
1391
|
} else {
|
@@ -1764,7 +1397,7 @@ st3:
|
|
1764
1397
|
if ( ++p == pe )
|
1765
1398
|
goto _test_eof3;
|
1766
1399
|
case 3:
|
1767
|
-
#line
|
1400
|
+
#line 1401 "edn_parser.cc"
|
1768
1401
|
switch( (*p) ) {
|
1769
1402
|
case 10: goto tr9;
|
1770
1403
|
case 32: goto st3;
|
@@ -1802,14 +1435,14 @@ case 5:
|
|
1802
1435
|
goto tr3;
|
1803
1436
|
goto st5;
|
1804
1437
|
tr6:
|
1805
|
-
#line
|
1438
|
+
#line 476 "edn_parser.rl"
|
1806
1439
|
{ p--; {p++; cs = 6; goto _out;} }
|
1807
1440
|
goto st6;
|
1808
1441
|
st6:
|
1809
1442
|
if ( ++p == pe )
|
1810
1443
|
goto _test_eof6;
|
1811
1444
|
case 6:
|
1812
|
-
#line
|
1445
|
+
#line 1446 "edn_parser.cc"
|
1813
1446
|
goto st0;
|
1814
1447
|
}
|
1815
1448
|
_test_eof2: cs = 2; goto _test_eof;
|
@@ -1823,7 +1456,7 @@ case 6:
|
|
1823
1456
|
{
|
1824
1457
|
switch ( cs ) {
|
1825
1458
|
case 2:
|
1826
|
-
#line
|
1459
|
+
#line 42 "edn_parser.rl"
|
1827
1460
|
{
|
1828
1461
|
std::stringstream s;
|
1829
1462
|
s << "unterminated " << EDN_TYPE;
|
@@ -1832,20 +1465,20 @@ case 6:
|
|
1832
1465
|
}
|
1833
1466
|
break;
|
1834
1467
|
case 3:
|
1835
|
-
#line
|
1468
|
+
#line 471 "edn_parser.rl"
|
1836
1469
|
{
|
1837
1470
|
error("map pair not found");
|
1838
1471
|
{p = (( pe))-1;}
|
1839
1472
|
}
|
1840
1473
|
break;
|
1841
|
-
#line
|
1474
|
+
#line 1475 "edn_parser.cc"
|
1842
1475
|
}
|
1843
1476
|
}
|
1844
1477
|
|
1845
1478
|
_out: {}
|
1846
1479
|
}
|
1847
1480
|
|
1848
|
-
#line
|
1481
|
+
#line 500 "edn_parser.rl"
|
1849
1482
|
|
1850
1483
|
if (cs >= EDN_map_first_final) {
|
1851
1484
|
o = map;
|
@@ -1860,18 +1493,313 @@ case 6:
|
|
1860
1493
|
|
1861
1494
|
|
1862
1495
|
|
1496
|
+
// ============================================================
|
1497
|
+
// tagged element parsing - any of #uuid, #inst, #{, #(some symbol)
|
1498
|
+
// discard (#_ <ident>) is handled by the top-level machine
|
1499
|
+
//
|
1500
|
+
// NOTE: this is not fully implemented yet
|
1501
|
+
//
|
1502
|
+
|
1503
|
+
#line 1504 "edn_parser.cc"
|
1504
|
+
static const int EDN_dispatch_start = 1;
|
1505
|
+
static const int EDN_dispatch_first_final = 15;
|
1506
|
+
static const int EDN_dispatch_error = 0;
|
1507
|
+
|
1508
|
+
static const int EDN_dispatch_en_main = 1;
|
1509
|
+
|
1510
|
+
|
1511
|
+
#line 538 "edn_parser.rl"
|
1512
|
+
|
1513
|
+
|
1514
|
+
|
1515
|
+
const char* edn::Parser::parse_tagged(const char *p, const char *pe, Rice::Object& o, bool& discard)
|
1516
|
+
{
|
1517
|
+
int cs;
|
1518
|
+
Rice::String str;
|
1519
|
+
|
1520
|
+
|
1521
|
+
#line 1522 "edn_parser.cc"
|
1522
|
+
{
|
1523
|
+
cs = EDN_dispatch_start;
|
1524
|
+
}
|
1525
|
+
|
1526
|
+
#line 547 "edn_parser.rl"
|
1527
|
+
p_save = p;
|
1528
|
+
|
1529
|
+
#line 1530 "edn_parser.cc"
|
1530
|
+
{
|
1531
|
+
if ( p == pe )
|
1532
|
+
goto _test_eof;
|
1533
|
+
switch ( cs )
|
1534
|
+
{
|
1535
|
+
case 1:
|
1536
|
+
if ( (*p) == 35 )
|
1537
|
+
goto st2;
|
1538
|
+
goto st0;
|
1539
|
+
st0:
|
1540
|
+
cs = 0;
|
1541
|
+
goto _out;
|
1542
|
+
st2:
|
1543
|
+
if ( ++p == pe )
|
1544
|
+
goto _test_eof2;
|
1545
|
+
case 2:
|
1546
|
+
switch( (*p) ) {
|
1547
|
+
case 95: goto st15;
|
1548
|
+
case 105: goto st3;
|
1549
|
+
case 117: goto st9;
|
1550
|
+
}
|
1551
|
+
goto st0;
|
1552
|
+
st15:
|
1553
|
+
if ( ++p == pe )
|
1554
|
+
goto _test_eof15;
|
1555
|
+
case 15:
|
1556
|
+
switch( (*p) ) {
|
1557
|
+
case 32: goto st17;
|
1558
|
+
case 43: goto st0;
|
1559
|
+
case 58: goto st0;
|
1560
|
+
}
|
1561
|
+
if ( (*p) < 48 ) {
|
1562
|
+
if ( (*p) > 13 ) {
|
1563
|
+
if ( 45 <= (*p) && (*p) <= 46 )
|
1564
|
+
goto st17;
|
1565
|
+
} else if ( (*p) >= 9 )
|
1566
|
+
goto tr17;
|
1567
|
+
} else if ( (*p) > 57 ) {
|
1568
|
+
if ( (*p) > 90 ) {
|
1569
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
1570
|
+
goto st17;
|
1571
|
+
} else if ( (*p) >= 65 )
|
1572
|
+
goto st17;
|
1573
|
+
} else
|
1574
|
+
goto st17;
|
1575
|
+
goto tr16;
|
1576
|
+
tr16:
|
1577
|
+
#line 530 "edn_parser.rl"
|
1578
|
+
{ p--; {p++; cs = 16; goto _out;} }
|
1579
|
+
goto st16;
|
1580
|
+
st16:
|
1581
|
+
if ( ++p == pe )
|
1582
|
+
goto _test_eof16;
|
1583
|
+
case 16:
|
1584
|
+
#line 1585 "edn_parser.cc"
|
1585
|
+
switch( (*p) ) {
|
1586
|
+
case 32: goto st0;
|
1587
|
+
case 43: goto st0;
|
1588
|
+
}
|
1589
|
+
if ( (*p) < 48 ) {
|
1590
|
+
if ( 45 <= (*p) && (*p) <= 46 )
|
1591
|
+
goto st0;
|
1592
|
+
} else if ( (*p) > 58 ) {
|
1593
|
+
if ( (*p) > 90 ) {
|
1594
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
1595
|
+
goto st0;
|
1596
|
+
} else if ( (*p) >= 65 )
|
1597
|
+
goto st0;
|
1598
|
+
} else
|
1599
|
+
goto st0;
|
1600
|
+
goto tr16;
|
1601
|
+
tr17:
|
1602
|
+
#line 530 "edn_parser.rl"
|
1603
|
+
{ p--; {p++; cs = 17; goto _out;} }
|
1604
|
+
goto st17;
|
1605
|
+
st17:
|
1606
|
+
if ( ++p == pe )
|
1607
|
+
goto _test_eof17;
|
1608
|
+
case 17:
|
1609
|
+
#line 1610 "edn_parser.cc"
|
1610
|
+
switch( (*p) ) {
|
1611
|
+
case 32: goto st0;
|
1612
|
+
case 43: goto st0;
|
1613
|
+
case 58: goto st0;
|
1614
|
+
}
|
1615
|
+
if ( (*p) < 48 ) {
|
1616
|
+
if ( 45 <= (*p) && (*p) <= 46 )
|
1617
|
+
goto st17;
|
1618
|
+
} else if ( (*p) > 57 ) {
|
1619
|
+
if ( (*p) > 90 ) {
|
1620
|
+
if ( 97 <= (*p) && (*p) <= 122 )
|
1621
|
+
goto st17;
|
1622
|
+
} else if ( (*p) >= 65 )
|
1623
|
+
goto st17;
|
1624
|
+
} else
|
1625
|
+
goto st17;
|
1626
|
+
goto tr16;
|
1627
|
+
st3:
|
1628
|
+
if ( ++p == pe )
|
1629
|
+
goto _test_eof3;
|
1630
|
+
case 3:
|
1631
|
+
if ( (*p) == 110 )
|
1632
|
+
goto st4;
|
1633
|
+
goto st0;
|
1634
|
+
st4:
|
1635
|
+
if ( ++p == pe )
|
1636
|
+
goto _test_eof4;
|
1637
|
+
case 4:
|
1638
|
+
if ( (*p) == 115 )
|
1639
|
+
goto st5;
|
1640
|
+
goto st0;
|
1641
|
+
st5:
|
1642
|
+
if ( ++p == pe )
|
1643
|
+
goto _test_eof5;
|
1644
|
+
case 5:
|
1645
|
+
if ( (*p) == 116 )
|
1646
|
+
goto st6;
|
1647
|
+
goto st0;
|
1648
|
+
st6:
|
1649
|
+
if ( ++p == pe )
|
1650
|
+
goto _test_eof6;
|
1651
|
+
case 6:
|
1652
|
+
if ( (*p) == 32 )
|
1653
|
+
goto st7;
|
1654
|
+
goto st0;
|
1655
|
+
st7:
|
1656
|
+
if ( ++p == pe )
|
1657
|
+
goto _test_eof7;
|
1658
|
+
case 7:
|
1659
|
+
if ( (*p) == 34 )
|
1660
|
+
goto st8;
|
1661
|
+
goto st0;
|
1662
|
+
st8:
|
1663
|
+
if ( ++p == pe )
|
1664
|
+
goto _test_eof8;
|
1665
|
+
case 8:
|
1666
|
+
switch( (*p) ) {
|
1667
|
+
case 34: goto st16;
|
1668
|
+
case 43: goto st8;
|
1669
|
+
case 84: goto st8;
|
1670
|
+
case 90: goto st8;
|
1671
|
+
}
|
1672
|
+
if ( (*p) > 46 ) {
|
1673
|
+
if ( 48 <= (*p) && (*p) <= 58 )
|
1674
|
+
goto st8;
|
1675
|
+
} else if ( (*p) >= 45 )
|
1676
|
+
goto st8;
|
1677
|
+
goto st0;
|
1678
|
+
st9:
|
1679
|
+
if ( ++p == pe )
|
1680
|
+
goto _test_eof9;
|
1681
|
+
case 9:
|
1682
|
+
if ( (*p) == 117 )
|
1683
|
+
goto st10;
|
1684
|
+
goto st0;
|
1685
|
+
st10:
|
1686
|
+
if ( ++p == pe )
|
1687
|
+
goto _test_eof10;
|
1688
|
+
case 10:
|
1689
|
+
if ( (*p) == 105 )
|
1690
|
+
goto st11;
|
1691
|
+
goto st0;
|
1692
|
+
st11:
|
1693
|
+
if ( ++p == pe )
|
1694
|
+
goto _test_eof11;
|
1695
|
+
case 11:
|
1696
|
+
if ( (*p) == 100 )
|
1697
|
+
goto st12;
|
1698
|
+
goto st0;
|
1699
|
+
st12:
|
1700
|
+
if ( ++p == pe )
|
1701
|
+
goto _test_eof12;
|
1702
|
+
case 12:
|
1703
|
+
if ( (*p) == 32 )
|
1704
|
+
goto st13;
|
1705
|
+
goto st0;
|
1706
|
+
st13:
|
1707
|
+
if ( ++p == pe )
|
1708
|
+
goto _test_eof13;
|
1709
|
+
case 13:
|
1710
|
+
if ( (*p) == 34 )
|
1711
|
+
goto st14;
|
1712
|
+
goto st0;
|
1713
|
+
st14:
|
1714
|
+
if ( ++p == pe )
|
1715
|
+
goto _test_eof14;
|
1716
|
+
case 14:
|
1717
|
+
switch( (*p) ) {
|
1718
|
+
case 34: goto st16;
|
1719
|
+
case 45: goto st14;
|
1720
|
+
}
|
1721
|
+
if ( (*p) > 57 ) {
|
1722
|
+
if ( 97 <= (*p) && (*p) <= 102 )
|
1723
|
+
goto st14;
|
1724
|
+
} else if ( (*p) >= 48 )
|
1725
|
+
goto st14;
|
1726
|
+
goto st0;
|
1727
|
+
}
|
1728
|
+
_test_eof2: cs = 2; goto _test_eof;
|
1729
|
+
_test_eof15: cs = 15; goto _test_eof;
|
1730
|
+
_test_eof16: cs = 16; goto _test_eof;
|
1731
|
+
_test_eof17: cs = 17; goto _test_eof;
|
1732
|
+
_test_eof3: cs = 3; goto _test_eof;
|
1733
|
+
_test_eof4: cs = 4; goto _test_eof;
|
1734
|
+
_test_eof5: cs = 5; goto _test_eof;
|
1735
|
+
_test_eof6: cs = 6; goto _test_eof;
|
1736
|
+
_test_eof7: cs = 7; goto _test_eof;
|
1737
|
+
_test_eof8: cs = 8; goto _test_eof;
|
1738
|
+
_test_eof9: cs = 9; goto _test_eof;
|
1739
|
+
_test_eof10: cs = 10; goto _test_eof;
|
1740
|
+
_test_eof11: cs = 11; goto _test_eof;
|
1741
|
+
_test_eof12: cs = 12; goto _test_eof;
|
1742
|
+
_test_eof13: cs = 13; goto _test_eof;
|
1743
|
+
_test_eof14: cs = 14; goto _test_eof;
|
1744
|
+
|
1745
|
+
_test_eof: {}
|
1746
|
+
_out: {}
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
#line 549 "edn_parser.rl"
|
1750
|
+
|
1751
|
+
if (cs >= EDN_dispatch_first_final) {
|
1752
|
+
|
1753
|
+
//is it a discard? if so, just drop the following token
|
1754
|
+
if (*(p_save + 1) == '_')
|
1755
|
+
{
|
1756
|
+
discard = true;
|
1757
|
+
return p + 1;
|
1758
|
+
}
|
1759
|
+
|
1760
|
+
std::size_t len = p - p_save;
|
1761
|
+
std::string buf;
|
1762
|
+
buf.reserve(len);
|
1763
|
+
|
1764
|
+
if (len > 10)
|
1765
|
+
{
|
1766
|
+
// there's enough room to be #inst or #uuid, copy the
|
1767
|
+
// string portion
|
1768
|
+
if (std::strncmp(p_save + 1, "inst", 4) == 0) {
|
1769
|
+
buf.append(p_save + 7, len - 8);
|
1770
|
+
} else if (std::strncmp(p_save + 1, "uuid", 4) == 0) {
|
1771
|
+
buf.append(p_save + 7, len - 8);
|
1772
|
+
}
|
1773
|
+
|
1774
|
+
o = Rice::String(buf);
|
1775
|
+
return p;
|
1776
|
+
}
|
1777
|
+
|
1778
|
+
// tagged element
|
1779
|
+
o = Rice::String(buf);
|
1780
|
+
return p;
|
1781
|
+
}
|
1782
|
+
else if (cs == EDN_dispatch_error) {
|
1783
|
+
error(*p);
|
1784
|
+
return pe;
|
1785
|
+
}
|
1786
|
+
else if (cs == EDN_dispatch_en_main) {} // silence ragel warning
|
1787
|
+
return NULL;
|
1788
|
+
}
|
1789
|
+
|
1790
|
+
|
1863
1791
|
// ============================================================
|
1864
1792
|
// main parsing machine
|
1865
1793
|
//
|
1866
1794
|
|
1867
|
-
#line
|
1795
|
+
#line 1796 "edn_parser.cc"
|
1868
1796
|
static const int EDN_start = 1;
|
1869
1797
|
static const int EDN_error = 0;
|
1870
1798
|
|
1871
1799
|
static const int EDN_en_main = 1;
|
1872
1800
|
|
1873
1801
|
|
1874
|
-
#line
|
1802
|
+
#line 619 "edn_parser.rl"
|
1875
1803
|
|
1876
1804
|
|
1877
1805
|
//
|
@@ -1887,31 +1815,31 @@ Rice::Object edn::Parser::parse(const char* buf, std::size_t len)
|
|
1887
1815
|
line_number = 1;
|
1888
1816
|
|
1889
1817
|
|
1890
|
-
#line
|
1818
|
+
#line 1819 "edn_parser.cc"
|
1891
1819
|
{
|
1892
1820
|
cs = EDN_start;
|
1893
1821
|
}
|
1894
1822
|
|
1895
|
-
#line
|
1823
|
+
#line 634 "edn_parser.rl"
|
1896
1824
|
p = &buf[0];
|
1897
1825
|
pe = p + len;
|
1898
1826
|
eof = pe; // eof defined in Parser class
|
1899
1827
|
|
1900
|
-
#line
|
1828
|
+
#line 1829 "edn_parser.cc"
|
1901
1829
|
{
|
1902
1830
|
if ( p == pe )
|
1903
1831
|
goto _test_eof;
|
1904
1832
|
switch ( cs )
|
1905
1833
|
{
|
1906
1834
|
tr2:
|
1907
|
-
#line
|
1835
|
+
#line 22 "edn_parser.rl"
|
1908
1836
|
{ line_number++; }
|
1909
1837
|
goto st1;
|
1910
1838
|
st1:
|
1911
1839
|
if ( ++p == pe )
|
1912
1840
|
goto _test_eof1;
|
1913
1841
|
case 1:
|
1914
|
-
#line
|
1842
|
+
#line 1843 "edn_parser.cc"
|
1915
1843
|
switch( (*p) ) {
|
1916
1844
|
case 10: goto tr2;
|
1917
1845
|
case 32: goto st1;
|
@@ -1928,27 +1856,27 @@ st0:
|
|
1928
1856
|
cs = 0;
|
1929
1857
|
goto _out;
|
1930
1858
|
tr8:
|
1931
|
-
#line
|
1859
|
+
#line 22 "edn_parser.rl"
|
1932
1860
|
{ line_number++; }
|
1933
1861
|
goto st4;
|
1934
1862
|
tr3:
|
1935
|
-
#line
|
1863
|
+
#line 609 "edn_parser.rl"
|
1936
1864
|
{
|
1937
|
-
const char *np =
|
1865
|
+
const char *np = parse_list(p, pe, result);
|
1938
1866
|
if (np == NULL) { p--; {p++; cs = 4; goto _out;} } else {p = (( np))-1;}
|
1939
1867
|
}
|
1940
1868
|
goto st4;
|
1941
1869
|
tr5:
|
1942
|
-
#line
|
1870
|
+
#line 599 "edn_parser.rl"
|
1943
1871
|
{
|
1944
|
-
const char* np =
|
1872
|
+
const char* np = parse_vector(p, pe, result);
|
1945
1873
|
if (np == NULL) { p--; {p++; cs = 4; goto _out;} } else {p = (( np))-1;}
|
1946
1874
|
}
|
1947
1875
|
goto st4;
|
1948
1876
|
tr6:
|
1949
|
-
#line
|
1877
|
+
#line 604 "edn_parser.rl"
|
1950
1878
|
{
|
1951
|
-
const char *np =
|
1879
|
+
const char *np = parse_map(p, pe, result);
|
1952
1880
|
if (np == NULL) { p--; {p++; cs = 4; goto _out;} } else {p = (( np))-1;}
|
1953
1881
|
}
|
1954
1882
|
goto st4;
|
@@ -1956,7 +1884,7 @@ st4:
|
|
1956
1884
|
if ( ++p == pe )
|
1957
1885
|
goto _test_eof4;
|
1958
1886
|
case 4:
|
1959
|
-
#line
|
1887
|
+
#line 1888 "edn_parser.cc"
|
1960
1888
|
switch( (*p) ) {
|
1961
1889
|
case 10: goto tr8;
|
1962
1890
|
case 32: goto st4;
|
@@ -1990,7 +1918,7 @@ case 3:
|
|
1990
1918
|
_out: {}
|
1991
1919
|
}
|
1992
1920
|
|
1993
|
-
#line
|
1921
|
+
#line 638 "edn_parser.rl"
|
1994
1922
|
|
1995
1923
|
if (cs == EDN_error) {
|
1996
1924
|
error(*p);
|