trenni 3.8.0 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -52,7 +52,7 @@
52
52
  has_entities = 1;
53
53
 
54
54
  Trenni_append(&pcdata, encoding,
55
- rb_funcall(entities, id_key_get, 1, Trenni_token(entity, encoding))
55
+ rb_funcall(entities, id_key_get, 1, Trenni_Token_string(entity, encoding))
56
56
  );
57
57
  }
58
58
 
@@ -83,7 +83,7 @@
83
83
  action doctype_end {
84
84
  doctype.end = p;
85
85
 
86
- rb_funcall(delegate, id_doctype, 1, Trenni_token(doctype, encoding));
86
+ rb_funcall(delegate, id_doctype, 1, Trenni_Token_string(doctype, encoding));
87
87
  }
88
88
 
89
89
  action doctype_error {
@@ -97,7 +97,7 @@
97
97
  action comment_end {
98
98
  comment.end = p;
99
99
 
100
- rb_funcall(delegate, id_comment, 1, Trenni_token(comment, encoding));
100
+ rb_funcall(delegate, id_comment, 1, Trenni_Token_string(comment, encoding));
101
101
  }
102
102
 
103
103
  action comment_error {
@@ -117,7 +117,7 @@
117
117
  action instruction_end {
118
118
  instruction.end = p;
119
119
 
120
- rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
120
+ rb_funcall(delegate, id_instruction, 1, Trenni_Token_string(instruction, encoding));
121
121
  }
122
122
 
123
123
  action instruction_error {
@@ -128,7 +128,7 @@
128
128
  // Reset self-closing state - we don't know yet.
129
129
  self_closing = 0;
130
130
 
131
- rb_funcall(delegate, id_open_tag_begin, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
131
+ rb_funcall(delegate, id_open_tag_begin, 2, Trenni_Token_string(identifier, encoding), ULONG2NUM(identifier.begin-s));
132
132
  }
133
133
 
134
134
  action tag_opening_begin {
@@ -152,11 +152,11 @@
152
152
 
153
153
  action attribute {
154
154
  if (has_value == 1) {
155
- rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Trenni_markup_safe(pcdata, has_entities));
155
+ rb_funcall(delegate, id_attribute, 2, Trenni_Token_string(identifier, encoding), Trenni_markup_safe(pcdata, has_entities));
156
156
  } else if (has_value == 2) {
157
- rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
157
+ rb_funcall(delegate, id_attribute, 2, Trenni_Token_string(identifier, encoding), empty_string);
158
158
  } else {
159
- rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
159
+ rb_funcall(delegate, id_attribute, 2, Trenni_Token_string(identifier, encoding), Qtrue);
160
160
  }
161
161
  }
162
162
 
@@ -168,7 +168,7 @@
168
168
  }
169
169
 
170
170
  action tag_closing_end {
171
- rb_funcall(delegate, id_close_tag, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
171
+ rb_funcall(delegate, id_close_tag, 2, Trenni_Token_string(identifier, encoding), ULONG2NUM(identifier.begin-s));
172
172
  }
173
173
 
174
174
  action tag_error {
@@ -182,7 +182,7 @@
182
182
  action cdata_end {
183
183
  cdata.end = p;
184
184
 
185
- rb_funcall(delegate, id_cdata, 1, Trenni_token(cdata, encoding));
185
+ rb_funcall(delegate, id_cdata, 1, Trenni_Token_string(cdata, encoding));
186
186
  }
187
187
 
188
188
  action cdata_error {
@@ -207,7 +207,7 @@ VALUE Trenni_Native_parse_markup(VALUE self, VALUE buffer, VALUE delegate, VALUE
207
207
  unsigned long cs, top = 0, stack[2] = {0};
208
208
  unsigned long codepoint = 0;
209
209
 
210
- Token identifier = {0}, cdata = {0}, characters = {0}, entity = {0}, doctype = {0}, comment = {0}, instruction = {0};
210
+ Trenni_Token identifier = {0}, cdata = {0}, characters = {0}, entity = {0}, doctype = {0}, comment = {0}, instruction = {0};
211
211
  unsigned self_closing = 0, has_value = 0, has_entities = 0;
212
212
 
213
213
  s = p = RSTRING_PTR(string);
@@ -0,0 +1,619 @@
1
+
2
+ #line 1 "query.rl"
3
+
4
+ #include "query.h"
5
+
6
+
7
+ #line 8 "query.c"
8
+ static const int Trenni_query_parser_start = 12;
9
+ static const int Trenni_query_parser_first_final = 12;
10
+ static const int Trenni_query_parser_error = 0;
11
+
12
+ static const int Trenni_query_parser_en_main = 12;
13
+
14
+
15
+ #line 56 "query.rl"
16
+
17
+
18
+ VALUE Trenni_Native_parse_query(VALUE self, VALUE buffer, VALUE delegate) {
19
+ VALUE string = rb_funcall(buffer, id_read, 0);
20
+
21
+ rb_encoding *encoding = rb_enc_get(string);
22
+
23
+ const char *s, *p, *pe, *eof;
24
+ unsigned long cs;
25
+
26
+ Trenni_Token string_token = {0}, integer_token = {0}, value_token = {0};
27
+ unsigned encoded = 0;
28
+
29
+ s = p = RSTRING_PTR(string);
30
+ eof = pe = p + RSTRING_LEN(string);
31
+
32
+
33
+ #line 34 "query.c"
34
+ {
35
+ cs = Trenni_query_parser_start;
36
+ }
37
+
38
+ #line 39 "query.c"
39
+ {
40
+ if ( p == pe )
41
+ goto _test_eof;
42
+ switch ( cs )
43
+ {
44
+ case 12:
45
+ switch( (*p) ) {
46
+ case 37: goto tr4;
47
+ case 38: goto st0;
48
+ case 43: goto tr5;
49
+ case 61: goto st0;
50
+ case 91: goto st0;
51
+ case 93: goto st0;
52
+ }
53
+ if ( 48 <= (*p) && (*p) <= 57 )
54
+ goto tr6;
55
+ goto tr3;
56
+ tr3:
57
+ #line 7 "query.rl"
58
+ {
59
+ string_token.begin = p;
60
+ }
61
+ goto st13;
62
+ tr5:
63
+ #line 7 "query.rl"
64
+ {
65
+ string_token.begin = p;
66
+ }
67
+ #line 49 "query.rl"
68
+ {
69
+ encoded = 1;
70
+ }
71
+ goto st13;
72
+ tr8:
73
+ #line 49 "query.rl"
74
+ {
75
+ encoded = 1;
76
+ }
77
+ goto st13;
78
+ st13:
79
+ if ( ++p == pe )
80
+ goto _test_eof13;
81
+ case 13:
82
+ #line 83 "query.c"
83
+ switch( (*p) ) {
84
+ case 37: goto tr7;
85
+ case 38: goto tr24;
86
+ case 43: goto tr8;
87
+ case 61: goto tr25;
88
+ case 91: goto tr26;
89
+ case 93: goto st0;
90
+ }
91
+ goto st13;
92
+ tr4:
93
+ #line 7 "query.rl"
94
+ {
95
+ string_token.begin = p;
96
+ }
97
+ #line 49 "query.rl"
98
+ {
99
+ encoded = 1;
100
+ }
101
+ goto st1;
102
+ tr7:
103
+ #line 49 "query.rl"
104
+ {
105
+ encoded = 1;
106
+ }
107
+ goto st1;
108
+ st1:
109
+ if ( ++p == pe )
110
+ goto _test_eof1;
111
+ case 1:
112
+ #line 113 "query.c"
113
+ if ( (*p) < 65 ) {
114
+ if ( 48 <= (*p) && (*p) <= 57 )
115
+ goto st2;
116
+ } else if ( (*p) > 70 ) {
117
+ if ( 97 <= (*p) && (*p) <= 102 )
118
+ goto st2;
119
+ } else
120
+ goto st2;
121
+ goto st0;
122
+ st0:
123
+ cs = 0;
124
+ goto _out;
125
+ st2:
126
+ if ( ++p == pe )
127
+ goto _test_eof2;
128
+ case 2:
129
+ if ( (*p) < 65 ) {
130
+ if ( 48 <= (*p) && (*p) <= 57 )
131
+ goto st13;
132
+ } else if ( (*p) > 70 ) {
133
+ if ( 97 <= (*p) && (*p) <= 102 )
134
+ goto st13;
135
+ } else
136
+ goto st13;
137
+ goto st0;
138
+ tr24:
139
+ #line 11 "query.rl"
140
+ {
141
+ string_token.end = p;
142
+
143
+ rb_funcall(delegate, id_string, 2, Trenni_Token_string(string_token, encoding), encoded ? Qtrue : Qfalse);
144
+
145
+ encoded = 0;
146
+ }
147
+ #line 45 "query.rl"
148
+ {
149
+ rb_funcall(delegate, id_pair, 0);
150
+ }
151
+ goto st3;
152
+ tr29:
153
+ #line 33 "query.rl"
154
+ {
155
+ value_token.begin = p;
156
+ }
157
+ #line 37 "query.rl"
158
+ {
159
+ value_token.end = p;
160
+
161
+ rb_funcall(delegate, id_assign, 2, Trenni_Token_string(value_token, encoding), encoded ? Qtrue : Qfalse);
162
+
163
+ encoded = 0;
164
+ }
165
+ #line 45 "query.rl"
166
+ {
167
+ rb_funcall(delegate, id_pair, 0);
168
+ }
169
+ goto st3;
170
+ tr32:
171
+ #line 37 "query.rl"
172
+ {
173
+ value_token.end = p;
174
+
175
+ rb_funcall(delegate, id_assign, 2, Trenni_Token_string(value_token, encoding), encoded ? Qtrue : Qfalse);
176
+
177
+ encoded = 0;
178
+ }
179
+ #line 45 "query.rl"
180
+ {
181
+ rb_funcall(delegate, id_pair, 0);
182
+ }
183
+ goto st3;
184
+ tr34:
185
+ #line 45 "query.rl"
186
+ {
187
+ rb_funcall(delegate, id_pair, 0);
188
+ }
189
+ goto st3;
190
+ tr37:
191
+ #line 29 "query.rl"
192
+ {
193
+ rb_funcall(delegate, id_append, 0);
194
+ }
195
+ #line 45 "query.rl"
196
+ {
197
+ rb_funcall(delegate, id_pair, 0);
198
+ }
199
+ goto st3;
200
+ st3:
201
+ if ( ++p == pe )
202
+ goto _test_eof3;
203
+ case 3:
204
+ #line 205 "query.c"
205
+ switch( (*p) ) {
206
+ case 37: goto tr4;
207
+ case 38: goto st0;
208
+ case 43: goto tr5;
209
+ case 61: goto st0;
210
+ case 91: goto st0;
211
+ case 93: goto st0;
212
+ }
213
+ if ( 48 <= (*p) && (*p) <= 57 )
214
+ goto tr6;
215
+ goto tr3;
216
+ tr6:
217
+ #line 7 "query.rl"
218
+ {
219
+ string_token.begin = p;
220
+ }
221
+ #line 19 "query.rl"
222
+ {
223
+ integer_token.begin = p;
224
+ }
225
+ goto st4;
226
+ st4:
227
+ if ( ++p == pe )
228
+ goto _test_eof4;
229
+ case 4:
230
+ #line 231 "query.c"
231
+ switch( (*p) ) {
232
+ case 37: goto tr7;
233
+ case 38: goto st0;
234
+ case 43: goto tr8;
235
+ case 61: goto st0;
236
+ case 91: goto st0;
237
+ case 93: goto st0;
238
+ }
239
+ if ( 48 <= (*p) && (*p) <= 57 )
240
+ goto st4;
241
+ goto st13;
242
+ tr25:
243
+ #line 11 "query.rl"
244
+ {
245
+ string_token.end = p;
246
+
247
+ rb_funcall(delegate, id_string, 2, Trenni_Token_string(string_token, encoding), encoded ? Qtrue : Qfalse);
248
+
249
+ encoded = 0;
250
+ }
251
+ goto st14;
252
+ tr38:
253
+ #line 29 "query.rl"
254
+ {
255
+ rb_funcall(delegate, id_append, 0);
256
+ }
257
+ goto st14;
258
+ st14:
259
+ if ( ++p == pe )
260
+ goto _test_eof14;
261
+ case 14:
262
+ #line 263 "query.c"
263
+ switch( (*p) ) {
264
+ case 37: goto tr28;
265
+ case 38: goto tr29;
266
+ case 43: goto tr30;
267
+ case 61: goto st0;
268
+ case 91: goto st0;
269
+ case 93: goto st0;
270
+ }
271
+ goto tr27;
272
+ tr33:
273
+ #line 49 "query.rl"
274
+ {
275
+ encoded = 1;
276
+ }
277
+ goto st15;
278
+ tr27:
279
+ #line 33 "query.rl"
280
+ {
281
+ value_token.begin = p;
282
+ }
283
+ goto st15;
284
+ tr30:
285
+ #line 33 "query.rl"
286
+ {
287
+ value_token.begin = p;
288
+ }
289
+ #line 49 "query.rl"
290
+ {
291
+ encoded = 1;
292
+ }
293
+ goto st15;
294
+ st15:
295
+ if ( ++p == pe )
296
+ goto _test_eof15;
297
+ case 15:
298
+ #line 299 "query.c"
299
+ switch( (*p) ) {
300
+ case 37: goto tr31;
301
+ case 38: goto tr32;
302
+ case 43: goto tr33;
303
+ case 61: goto st0;
304
+ case 91: goto st0;
305
+ case 93: goto st0;
306
+ }
307
+ goto st15;
308
+ tr31:
309
+ #line 49 "query.rl"
310
+ {
311
+ encoded = 1;
312
+ }
313
+ goto st5;
314
+ tr28:
315
+ #line 33 "query.rl"
316
+ {
317
+ value_token.begin = p;
318
+ }
319
+ #line 49 "query.rl"
320
+ {
321
+ encoded = 1;
322
+ }
323
+ goto st5;
324
+ st5:
325
+ if ( ++p == pe )
326
+ goto _test_eof5;
327
+ case 5:
328
+ #line 329 "query.c"
329
+ if ( (*p) < 65 ) {
330
+ if ( 48 <= (*p) && (*p) <= 57 )
331
+ goto st6;
332
+ } else if ( (*p) > 70 ) {
333
+ if ( 97 <= (*p) && (*p) <= 102 )
334
+ goto st6;
335
+ } else
336
+ goto st6;
337
+ goto st0;
338
+ st6:
339
+ if ( ++p == pe )
340
+ goto _test_eof6;
341
+ case 6:
342
+ if ( (*p) < 65 ) {
343
+ if ( 48 <= (*p) && (*p) <= 57 )
344
+ goto st15;
345
+ } else if ( (*p) > 70 ) {
346
+ if ( 97 <= (*p) && (*p) <= 102 )
347
+ goto st15;
348
+ } else
349
+ goto st15;
350
+ goto st0;
351
+ tr26:
352
+ #line 11 "query.rl"
353
+ {
354
+ string_token.end = p;
355
+
356
+ rb_funcall(delegate, id_string, 2, Trenni_Token_string(string_token, encoding), encoded ? Qtrue : Qfalse);
357
+
358
+ encoded = 0;
359
+ }
360
+ goto st7;
361
+ st7:
362
+ if ( ++p == pe )
363
+ goto _test_eof7;
364
+ case 7:
365
+ #line 366 "query.c"
366
+ switch( (*p) ) {
367
+ case 37: goto tr13;
368
+ case 38: goto st0;
369
+ case 43: goto tr14;
370
+ case 61: goto st0;
371
+ case 91: goto st0;
372
+ case 93: goto st17;
373
+ }
374
+ if ( 48 <= (*p) && (*p) <= 57 )
375
+ goto tr15;
376
+ goto tr12;
377
+ tr12:
378
+ #line 7 "query.rl"
379
+ {
380
+ string_token.begin = p;
381
+ }
382
+ goto st8;
383
+ tr14:
384
+ #line 7 "query.rl"
385
+ {
386
+ string_token.begin = p;
387
+ }
388
+ #line 49 "query.rl"
389
+ {
390
+ encoded = 1;
391
+ }
392
+ goto st8;
393
+ tr19:
394
+ #line 49 "query.rl"
395
+ {
396
+ encoded = 1;
397
+ }
398
+ goto st8;
399
+ st8:
400
+ if ( ++p == pe )
401
+ goto _test_eof8;
402
+ case 8:
403
+ #line 404 "query.c"
404
+ switch( (*p) ) {
405
+ case 37: goto tr18;
406
+ case 38: goto st0;
407
+ case 43: goto tr19;
408
+ case 61: goto st0;
409
+ case 91: goto st0;
410
+ case 93: goto tr20;
411
+ }
412
+ goto st8;
413
+ tr13:
414
+ #line 7 "query.rl"
415
+ {
416
+ string_token.begin = p;
417
+ }
418
+ #line 49 "query.rl"
419
+ {
420
+ encoded = 1;
421
+ }
422
+ goto st9;
423
+ tr18:
424
+ #line 49 "query.rl"
425
+ {
426
+ encoded = 1;
427
+ }
428
+ goto st9;
429
+ st9:
430
+ if ( ++p == pe )
431
+ goto _test_eof9;
432
+ case 9:
433
+ #line 434 "query.c"
434
+ if ( (*p) < 65 ) {
435
+ if ( 48 <= (*p) && (*p) <= 57 )
436
+ goto st10;
437
+ } else if ( (*p) > 70 ) {
438
+ if ( 97 <= (*p) && (*p) <= 102 )
439
+ goto st10;
440
+ } else
441
+ goto st10;
442
+ goto st0;
443
+ st10:
444
+ if ( ++p == pe )
445
+ goto _test_eof10;
446
+ case 10:
447
+ if ( (*p) < 65 ) {
448
+ if ( 48 <= (*p) && (*p) <= 57 )
449
+ goto st8;
450
+ } else if ( (*p) > 70 ) {
451
+ if ( 97 <= (*p) && (*p) <= 102 )
452
+ goto st8;
453
+ } else
454
+ goto st8;
455
+ goto st0;
456
+ tr20:
457
+ #line 11 "query.rl"
458
+ {
459
+ string_token.end = p;
460
+
461
+ rb_funcall(delegate, id_string, 2, Trenni_Token_string(string_token, encoding), encoded ? Qtrue : Qfalse);
462
+
463
+ encoded = 0;
464
+ }
465
+ goto st16;
466
+ tr23:
467
+ #line 23 "query.rl"
468
+ {
469
+ integer_token.end = p;
470
+
471
+ rb_funcall(delegate, id_integer, 1, Trenni_Token_string(integer_token, encoding));
472
+ }
473
+ goto st16;
474
+ st16:
475
+ if ( ++p == pe )
476
+ goto _test_eof16;
477
+ case 16:
478
+ #line 479 "query.c"
479
+ switch( (*p) ) {
480
+ case 38: goto tr34;
481
+ case 61: goto st14;
482
+ case 91: goto st7;
483
+ }
484
+ goto st0;
485
+ tr15:
486
+ #line 19 "query.rl"
487
+ {
488
+ integer_token.begin = p;
489
+ }
490
+ #line 7 "query.rl"
491
+ {
492
+ string_token.begin = p;
493
+ }
494
+ goto st11;
495
+ st11:
496
+ if ( ++p == pe )
497
+ goto _test_eof11;
498
+ case 11:
499
+ #line 500 "query.c"
500
+ switch( (*p) ) {
501
+ case 37: goto tr18;
502
+ case 38: goto st0;
503
+ case 43: goto tr19;
504
+ case 61: goto st0;
505
+ case 91: goto st0;
506
+ case 93: goto tr23;
507
+ }
508
+ if ( 48 <= (*p) && (*p) <= 57 )
509
+ goto st11;
510
+ goto st8;
511
+ st17:
512
+ if ( ++p == pe )
513
+ goto _test_eof17;
514
+ case 17:
515
+ switch( (*p) ) {
516
+ case 38: goto tr37;
517
+ case 61: goto tr38;
518
+ }
519
+ goto st0;
520
+ }
521
+ _test_eof13: cs = 13; goto _test_eof;
522
+ _test_eof1: cs = 1; goto _test_eof;
523
+ _test_eof2: cs = 2; goto _test_eof;
524
+ _test_eof3: cs = 3; goto _test_eof;
525
+ _test_eof4: cs = 4; goto _test_eof;
526
+ _test_eof14: cs = 14; goto _test_eof;
527
+ _test_eof15: cs = 15; goto _test_eof;
528
+ _test_eof5: cs = 5; goto _test_eof;
529
+ _test_eof6: cs = 6; goto _test_eof;
530
+ _test_eof7: cs = 7; goto _test_eof;
531
+ _test_eof8: cs = 8; goto _test_eof;
532
+ _test_eof9: cs = 9; goto _test_eof;
533
+ _test_eof10: cs = 10; goto _test_eof;
534
+ _test_eof16: cs = 16; goto _test_eof;
535
+ _test_eof11: cs = 11; goto _test_eof;
536
+ _test_eof17: cs = 17; goto _test_eof;
537
+
538
+ _test_eof: {}
539
+ if ( p == eof )
540
+ {
541
+ switch ( cs ) {
542
+ case 16:
543
+ #line 45 "query.rl"
544
+ {
545
+ rb_funcall(delegate, id_pair, 0);
546
+ }
547
+ break;
548
+ case 13:
549
+ #line 11 "query.rl"
550
+ {
551
+ string_token.end = p;
552
+
553
+ rb_funcall(delegate, id_string, 2, Trenni_Token_string(string_token, encoding), encoded ? Qtrue : Qfalse);
554
+
555
+ encoded = 0;
556
+ }
557
+ #line 45 "query.rl"
558
+ {
559
+ rb_funcall(delegate, id_pair, 0);
560
+ }
561
+ break;
562
+ case 17:
563
+ #line 29 "query.rl"
564
+ {
565
+ rb_funcall(delegate, id_append, 0);
566
+ }
567
+ #line 45 "query.rl"
568
+ {
569
+ rb_funcall(delegate, id_pair, 0);
570
+ }
571
+ break;
572
+ case 15:
573
+ #line 37 "query.rl"
574
+ {
575
+ value_token.end = p;
576
+
577
+ rb_funcall(delegate, id_assign, 2, Trenni_Token_string(value_token, encoding), encoded ? Qtrue : Qfalse);
578
+
579
+ encoded = 0;
580
+ }
581
+ #line 45 "query.rl"
582
+ {
583
+ rb_funcall(delegate, id_pair, 0);
584
+ }
585
+ break;
586
+ case 14:
587
+ #line 33 "query.rl"
588
+ {
589
+ value_token.begin = p;
590
+ }
591
+ #line 37 "query.rl"
592
+ {
593
+ value_token.end = p;
594
+
595
+ rb_funcall(delegate, id_assign, 2, Trenni_Token_string(value_token, encoding), encoded ? Qtrue : Qfalse);
596
+
597
+ encoded = 0;
598
+ }
599
+ #line 45 "query.rl"
600
+ {
601
+ rb_funcall(delegate, id_pair, 0);
602
+ }
603
+ break;
604
+ #line 605 "query.c"
605
+ }
606
+ }
607
+
608
+ _out: {}
609
+ }
610
+
611
+ #line 75 "query.rl"
612
+
613
+
614
+ if (p != eof) {
615
+ Trenni_raise_error("could not parse all input", buffer, p-s);
616
+ }
617
+
618
+ return Qnil;
619
+ }