trenni 1.7.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +7 -3
  4. data/Gemfile +4 -0
  5. data/README.md +72 -10
  6. data/Rakefile +85 -0
  7. data/benchmark/call_vs_yield.rb +51 -0
  8. data/benchmark/interpolation_vs_concat.rb +29 -0
  9. data/benchmark/io_vs_string.rb +14 -4
  10. data/entities.json +2233 -0
  11. data/ext/trenni/extconf.rb +13 -0
  12. data/ext/trenni/markup.c +1981 -0
  13. data/ext/trenni/markup.h +6 -0
  14. data/ext/trenni/markup.rl +223 -0
  15. data/ext/trenni/template.c +1113 -0
  16. data/ext/trenni/template.h +6 -0
  17. data/ext/trenni/template.rl +77 -0
  18. data/ext/trenni/trenni.c +64 -0
  19. data/ext/trenni/trenni.h +28 -0
  20. data/lib/trenni.rb +1 -0
  21. data/lib/trenni/buffer.rb +13 -2
  22. data/lib/trenni/builder.rb +54 -47
  23. data/lib/trenni/entities.rb +2154 -0
  24. data/lib/trenni/entities.trenni +34 -0
  25. data/lib/trenni/fallback/markup.rb +1648 -0
  26. data/lib/trenni/fallback/markup.rl +236 -0
  27. data/lib/trenni/fallback/template.rb +843 -0
  28. data/lib/trenni/fallback/template.rl +97 -0
  29. data/lib/trenni/markup.rb +76 -0
  30. data/lib/trenni/native.rb +28 -0
  31. data/lib/trenni/parse_delegate.rb +34 -0
  32. data/lib/trenni/{scanner.rb → parse_error.rb} +9 -54
  33. data/lib/trenni/parsers.rb +12 -0
  34. data/lib/trenni/substitutions.rb +45 -0
  35. data/lib/trenni/template.rb +52 -135
  36. data/lib/trenni/version.rb +1 -1
  37. data/parsers/trenni/entities.rl +11 -0
  38. data/parsers/trenni/markup.rl +43 -0
  39. data/parsers/trenni/template.rl +60 -0
  40. data/spec/trenni/builder_spec.rb +37 -62
  41. data/spec/trenni/corpus/large.rb +4605 -0
  42. data/spec/trenni/corpus/large.xhtml +726 -0
  43. data/spec/trenni/markup_parser_spec.rb +233 -0
  44. data/spec/trenni/markup_spec.rb +48 -0
  45. data/spec/trenni/parsers_performance_spec.rb +44 -0
  46. data/spec/trenni/template_error_spec.rb +36 -0
  47. data/spec/trenni/template_performance_spec.rb +102 -0
  48. data/spec/trenni/template_spec.rb +90 -64
  49. data/spec/trenni/template_spec/basic.trenni +1 -0
  50. data/spec/trenni/template_spec/capture.trenni +2 -2
  51. data/spec/trenni/template_spec/error.trenni +4 -0
  52. data/trenni.gemspec +9 -6
  53. metadata +57 -15
  54. data/lib/trenni/parser.rb +0 -153
  55. data/spec/trenni/parser_spec.rb +0 -144
@@ -0,0 +1,13 @@
1
+ # Loads mkmf which is used to make makefiles for Ruby extensions
2
+ require 'mkmf'
3
+
4
+ $CFLAGS << " -O3 -std=c99"
5
+
6
+ gem_name = File.basename(__dir__)
7
+ extension_name = 'trenni'
8
+
9
+ # The destination
10
+ dir_config(extension_name)
11
+
12
+ # Generate the makefile to compile the native binary into `lib`:
13
+ create_makefile(File.join(gem_name, extension_name))
@@ -0,0 +1,1981 @@
1
+
2
+ #line 1 "markup.rl"
3
+
4
+ #include "markup.h"
5
+
6
+ #include <ruby/encoding.h>
7
+
8
+
9
+ #line 10 "markup.c"
10
+ static const int Trenni_markup_parser_start = 48;
11
+ static const int Trenni_markup_parser_first_final = 48;
12
+ static const int Trenni_markup_parser_error = 0;
13
+
14
+ static const int Trenni_markup_parser_en_parse_entity = 42;
15
+ static const int Trenni_markup_parser_en_main = 48;
16
+
17
+
18
+ #line 192 "markup.rl"
19
+
20
+
21
+ VALUE Trenni_Native_parse_markup(VALUE self, VALUE buffer, VALUE delegate, VALUE entities) {
22
+ VALUE string = rb_funcall(buffer, id_read, 0);
23
+
24
+ rb_encoding *encoding = rb_enc_get(string);
25
+
26
+ VALUE pcdata = Qnil;
27
+
28
+ VALUE empty_string = rb_obj_freeze(rb_enc_str_new("", 0, encoding));
29
+
30
+ const char *s, *p, *pe, *eof;
31
+ unsigned long cs, top = 0, stack[2] = {0};
32
+ unsigned long codepoint = 0;
33
+
34
+ Token identifier = {0}, cdata = {0}, characters = {0}, entity = {0}, doctype = {0}, comment = {0}, instruction = {0};
35
+ unsigned self_closing = 0, has_value = 0;
36
+
37
+ s = p = RSTRING_PTR(string);
38
+ eof = pe = p + RSTRING_LEN(string);
39
+
40
+
41
+ #line 42 "markup.c"
42
+ {
43
+ cs = Trenni_markup_parser_start;
44
+ top = 0;
45
+ }
46
+
47
+ #line 48 "markup.c"
48
+ {
49
+ if ( p == pe )
50
+ goto _test_eof;
51
+ goto _resume;
52
+
53
+ _again:
54
+ switch ( cs ) {
55
+ case 48: goto st48;
56
+ case 49: goto st49;
57
+ case 50: goto st50;
58
+ case 1: goto st1;
59
+ case 2: goto st2;
60
+ case 0: goto st0;
61
+ case 3: goto st3;
62
+ case 4: goto st4;
63
+ case 5: goto st5;
64
+ case 51: goto st51;
65
+ case 6: goto st6;
66
+ case 7: goto st7;
67
+ case 8: goto st8;
68
+ case 9: goto st9;
69
+ case 10: goto st10;
70
+ case 11: goto st11;
71
+ case 12: goto st12;
72
+ case 13: goto st13;
73
+ case 14: goto st14;
74
+ case 15: goto st15;
75
+ case 16: goto st16;
76
+ case 17: goto st17;
77
+ case 18: goto st18;
78
+ case 19: goto st19;
79
+ case 52: goto st52;
80
+ case 20: goto st20;
81
+ case 21: goto st21;
82
+ case 22: goto st22;
83
+ case 23: goto st23;
84
+ case 24: goto st24;
85
+ case 25: goto st25;
86
+ case 26: goto st26;
87
+ case 53: goto st53;
88
+ case 27: goto st27;
89
+ case 28: goto st28;
90
+ case 29: goto st29;
91
+ case 30: goto st30;
92
+ case 31: goto st31;
93
+ case 32: goto st32;
94
+ case 33: goto st33;
95
+ case 34: goto st34;
96
+ case 35: goto st35;
97
+ case 54: goto st54;
98
+ case 36: goto st36;
99
+ case 37: goto st37;
100
+ case 55: goto st55;
101
+ case 38: goto st38;
102
+ case 39: goto st39;
103
+ case 40: goto st40;
104
+ case 41: goto st41;
105
+ case 56: goto st56;
106
+ case 42: goto st42;
107
+ case 43: goto st43;
108
+ case 44: goto st44;
109
+ case 57: goto st57;
110
+ case 45: goto st45;
111
+ case 46: goto st46;
112
+ case 47: goto st47;
113
+ default: break;
114
+ }
115
+
116
+ if ( ++p == pe )
117
+ goto _test_eof;
118
+ _resume:
119
+ switch ( cs )
120
+ {
121
+ st48:
122
+ if ( ++p == pe )
123
+ goto _test_eof48;
124
+ case 48:
125
+ switch( (*p) ) {
126
+ case 38: goto tr88;
127
+ case 60: goto tr89;
128
+ }
129
+ goto tr87;
130
+ tr90:
131
+ #line 29 "markup.rl"
132
+ {
133
+ characters.end = p;
134
+
135
+ Trenni_append_token(&pcdata, encoding, characters);
136
+ }
137
+ #line 25 "markup.rl"
138
+ {
139
+ characters.begin = p;
140
+ }
141
+ goto st49;
142
+ tr93:
143
+ #line 25 "markup.rl"
144
+ {
145
+ characters.begin = p;
146
+ }
147
+ goto st49;
148
+ tr87:
149
+ #line 180 "markup.rl"
150
+ {
151
+
152
+ }
153
+ #line 18 "markup.rl"
154
+ {
155
+ pcdata = Qnil;
156
+ }
157
+ #line 25 "markup.rl"
158
+ {
159
+ characters.begin = p;
160
+ }
161
+ goto st49;
162
+ tr96:
163
+ #line 151 "markup.rl"
164
+ {
165
+ rb_funcall(delegate, id_open_tag_end, 1, self_closing == 1 ? Qtrue : Qfalse);
166
+ }
167
+ #line 180 "markup.rl"
168
+ {
169
+
170
+ }
171
+ #line 18 "markup.rl"
172
+ {
173
+ pcdata = Qnil;
174
+ }
175
+ #line 25 "markup.rl"
176
+ {
177
+ characters.begin = p;
178
+ }
179
+ goto st49;
180
+ tr99:
181
+ #line 85 "markup.rl"
182
+ {
183
+ comment.end = p;
184
+
185
+ rb_funcall(delegate, id_comment, 1, Trenni_token(comment, encoding));
186
+ }
187
+ #line 180 "markup.rl"
188
+ {
189
+
190
+ }
191
+ #line 18 "markup.rl"
192
+ {
193
+ pcdata = Qnil;
194
+ }
195
+ #line 25 "markup.rl"
196
+ {
197
+ characters.begin = p;
198
+ }
199
+ goto st49;
200
+ tr102:
201
+ #line 71 "markup.rl"
202
+ {
203
+ doctype.end = p;
204
+
205
+ rb_funcall(delegate, id_doctype, 1, Trenni_token(doctype, encoding));
206
+ }
207
+ #line 180 "markup.rl"
208
+ {
209
+
210
+ }
211
+ #line 18 "markup.rl"
212
+ {
213
+ pcdata = Qnil;
214
+ }
215
+ #line 25 "markup.rl"
216
+ {
217
+ characters.begin = p;
218
+ }
219
+ goto st49;
220
+ tr105:
221
+ #line 170 "markup.rl"
222
+ {
223
+ cdata.end = p;
224
+
225
+ rb_funcall(delegate, id_cdata, 1, Trenni_token(cdata, encoding));
226
+ }
227
+ #line 180 "markup.rl"
228
+ {
229
+
230
+ }
231
+ #line 18 "markup.rl"
232
+ {
233
+ pcdata = Qnil;
234
+ }
235
+ #line 25 "markup.rl"
236
+ {
237
+ characters.begin = p;
238
+ }
239
+ goto st49;
240
+ tr108:
241
+ #line 158 "markup.rl"
242
+ {
243
+ rb_funcall(delegate, id_close_tag, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
244
+ }
245
+ #line 180 "markup.rl"
246
+ {
247
+
248
+ }
249
+ #line 18 "markup.rl"
250
+ {
251
+ pcdata = Qnil;
252
+ }
253
+ #line 25 "markup.rl"
254
+ {
255
+ characters.begin = p;
256
+ }
257
+ goto st49;
258
+ tr111:
259
+ #line 105 "markup.rl"
260
+ {
261
+ instruction.end = p;
262
+
263
+ rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
264
+ }
265
+ #line 180 "markup.rl"
266
+ {
267
+
268
+ }
269
+ #line 18 "markup.rl"
270
+ {
271
+ pcdata = Qnil;
272
+ }
273
+ #line 25 "markup.rl"
274
+ {
275
+ characters.begin = p;
276
+ }
277
+ goto st49;
278
+ st49:
279
+ if ( ++p == pe )
280
+ goto _test_eof49;
281
+ case 49:
282
+ #line 283 "markup.c"
283
+ switch( (*p) ) {
284
+ case 38: goto tr91;
285
+ case 60: goto tr92;
286
+ }
287
+ goto tr90;
288
+ tr91:
289
+ #line 29 "markup.rl"
290
+ {
291
+ characters.end = p;
292
+
293
+ Trenni_append_token(&pcdata, encoding, characters);
294
+ }
295
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
296
+ {{stack[top++] = 50; goto st42;}}
297
+ goto st50;
298
+ tr94:
299
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
300
+ {{stack[top++] = 50; goto st42;}}
301
+ goto st50;
302
+ tr88:
303
+ #line 180 "markup.rl"
304
+ {
305
+
306
+ }
307
+ #line 18 "markup.rl"
308
+ {
309
+ pcdata = Qnil;
310
+ }
311
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
312
+ {{stack[top++] = 50; goto st42;}}
313
+ goto st50;
314
+ tr97:
315
+ #line 151 "markup.rl"
316
+ {
317
+ rb_funcall(delegate, id_open_tag_end, 1, self_closing == 1 ? Qtrue : Qfalse);
318
+ }
319
+ #line 180 "markup.rl"
320
+ {
321
+
322
+ }
323
+ #line 18 "markup.rl"
324
+ {
325
+ pcdata = Qnil;
326
+ }
327
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
328
+ {{stack[top++] = 50; goto st42;}}
329
+ goto st50;
330
+ tr100:
331
+ #line 85 "markup.rl"
332
+ {
333
+ comment.end = p;
334
+
335
+ rb_funcall(delegate, id_comment, 1, Trenni_token(comment, encoding));
336
+ }
337
+ #line 180 "markup.rl"
338
+ {
339
+
340
+ }
341
+ #line 18 "markup.rl"
342
+ {
343
+ pcdata = Qnil;
344
+ }
345
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
346
+ {{stack[top++] = 50; goto st42;}}
347
+ goto st50;
348
+ tr103:
349
+ #line 71 "markup.rl"
350
+ {
351
+ doctype.end = p;
352
+
353
+ rb_funcall(delegate, id_doctype, 1, Trenni_token(doctype, encoding));
354
+ }
355
+ #line 180 "markup.rl"
356
+ {
357
+
358
+ }
359
+ #line 18 "markup.rl"
360
+ {
361
+ pcdata = Qnil;
362
+ }
363
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
364
+ {{stack[top++] = 50; goto st42;}}
365
+ goto st50;
366
+ tr106:
367
+ #line 170 "markup.rl"
368
+ {
369
+ cdata.end = p;
370
+
371
+ rb_funcall(delegate, id_cdata, 1, Trenni_token(cdata, encoding));
372
+ }
373
+ #line 180 "markup.rl"
374
+ {
375
+
376
+ }
377
+ #line 18 "markup.rl"
378
+ {
379
+ pcdata = Qnil;
380
+ }
381
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
382
+ {{stack[top++] = 50; goto st42;}}
383
+ goto st50;
384
+ tr109:
385
+ #line 158 "markup.rl"
386
+ {
387
+ rb_funcall(delegate, id_close_tag, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
388
+ }
389
+ #line 180 "markup.rl"
390
+ {
391
+
392
+ }
393
+ #line 18 "markup.rl"
394
+ {
395
+ pcdata = Qnil;
396
+ }
397
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
398
+ {{stack[top++] = 50; goto st42;}}
399
+ goto st50;
400
+ tr112:
401
+ #line 105 "markup.rl"
402
+ {
403
+ instruction.end = p;
404
+
405
+ rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
406
+ }
407
+ #line 180 "markup.rl"
408
+ {
409
+
410
+ }
411
+ #line 18 "markup.rl"
412
+ {
413
+ pcdata = Qnil;
414
+ }
415
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
416
+ {{stack[top++] = 50; goto st42;}}
417
+ goto st50;
418
+ st50:
419
+ if ( ++p == pe )
420
+ goto _test_eof50;
421
+ case 50:
422
+ #line 423 "markup.c"
423
+ switch( (*p) ) {
424
+ case 38: goto tr94;
425
+ case 60: goto tr95;
426
+ }
427
+ goto tr93;
428
+ tr89:
429
+ #line 122 "markup.rl"
430
+ {
431
+ }
432
+ #line 155 "markup.rl"
433
+ {
434
+ }
435
+ #line 95 "markup.rl"
436
+ {
437
+ instruction.begin = p;
438
+ }
439
+ #line 81 "markup.rl"
440
+ {
441
+ comment.begin = p;
442
+ }
443
+ #line 67 "markup.rl"
444
+ {
445
+ doctype.begin = p;
446
+ }
447
+ #line 166 "markup.rl"
448
+ {
449
+ cdata.begin = p;
450
+ }
451
+ goto st1;
452
+ tr92:
453
+ #line 29 "markup.rl"
454
+ {
455
+ characters.end = p;
456
+
457
+ Trenni_append_token(&pcdata, encoding, characters);
458
+ }
459
+ #line 22 "markup.rl"
460
+ {
461
+ }
462
+ #line 184 "markup.rl"
463
+ {
464
+ // Entities are handled separately:
465
+ rb_funcall(delegate, id_text, 1, pcdata);
466
+ }
467
+ #line 122 "markup.rl"
468
+ {
469
+ }
470
+ #line 155 "markup.rl"
471
+ {
472
+ }
473
+ #line 95 "markup.rl"
474
+ {
475
+ instruction.begin = p;
476
+ }
477
+ #line 81 "markup.rl"
478
+ {
479
+ comment.begin = p;
480
+ }
481
+ #line 67 "markup.rl"
482
+ {
483
+ doctype.begin = p;
484
+ }
485
+ #line 166 "markup.rl"
486
+ {
487
+ cdata.begin = p;
488
+ }
489
+ goto st1;
490
+ tr95:
491
+ #line 22 "markup.rl"
492
+ {
493
+ }
494
+ #line 184 "markup.rl"
495
+ {
496
+ // Entities are handled separately:
497
+ rb_funcall(delegate, id_text, 1, pcdata);
498
+ }
499
+ #line 122 "markup.rl"
500
+ {
501
+ }
502
+ #line 155 "markup.rl"
503
+ {
504
+ }
505
+ #line 95 "markup.rl"
506
+ {
507
+ instruction.begin = p;
508
+ }
509
+ #line 81 "markup.rl"
510
+ {
511
+ comment.begin = p;
512
+ }
513
+ #line 67 "markup.rl"
514
+ {
515
+ doctype.begin = p;
516
+ }
517
+ #line 166 "markup.rl"
518
+ {
519
+ cdata.begin = p;
520
+ }
521
+ goto st1;
522
+ tr98:
523
+ #line 151 "markup.rl"
524
+ {
525
+ rb_funcall(delegate, id_open_tag_end, 1, self_closing == 1 ? Qtrue : Qfalse);
526
+ }
527
+ #line 122 "markup.rl"
528
+ {
529
+ }
530
+ #line 155 "markup.rl"
531
+ {
532
+ }
533
+ #line 95 "markup.rl"
534
+ {
535
+ instruction.begin = p;
536
+ }
537
+ #line 81 "markup.rl"
538
+ {
539
+ comment.begin = p;
540
+ }
541
+ #line 67 "markup.rl"
542
+ {
543
+ doctype.begin = p;
544
+ }
545
+ #line 166 "markup.rl"
546
+ {
547
+ cdata.begin = p;
548
+ }
549
+ goto st1;
550
+ tr101:
551
+ #line 85 "markup.rl"
552
+ {
553
+ comment.end = p;
554
+
555
+ rb_funcall(delegate, id_comment, 1, Trenni_token(comment, encoding));
556
+ }
557
+ #line 122 "markup.rl"
558
+ {
559
+ }
560
+ #line 155 "markup.rl"
561
+ {
562
+ }
563
+ #line 95 "markup.rl"
564
+ {
565
+ instruction.begin = p;
566
+ }
567
+ #line 81 "markup.rl"
568
+ {
569
+ comment.begin = p;
570
+ }
571
+ #line 67 "markup.rl"
572
+ {
573
+ doctype.begin = p;
574
+ }
575
+ #line 166 "markup.rl"
576
+ {
577
+ cdata.begin = p;
578
+ }
579
+ goto st1;
580
+ tr104:
581
+ #line 71 "markup.rl"
582
+ {
583
+ doctype.end = p;
584
+
585
+ rb_funcall(delegate, id_doctype, 1, Trenni_token(doctype, encoding));
586
+ }
587
+ #line 122 "markup.rl"
588
+ {
589
+ }
590
+ #line 155 "markup.rl"
591
+ {
592
+ }
593
+ #line 95 "markup.rl"
594
+ {
595
+ instruction.begin = p;
596
+ }
597
+ #line 81 "markup.rl"
598
+ {
599
+ comment.begin = p;
600
+ }
601
+ #line 67 "markup.rl"
602
+ {
603
+ doctype.begin = p;
604
+ }
605
+ #line 166 "markup.rl"
606
+ {
607
+ cdata.begin = p;
608
+ }
609
+ goto st1;
610
+ tr107:
611
+ #line 170 "markup.rl"
612
+ {
613
+ cdata.end = p;
614
+
615
+ rb_funcall(delegate, id_cdata, 1, Trenni_token(cdata, encoding));
616
+ }
617
+ #line 122 "markup.rl"
618
+ {
619
+ }
620
+ #line 155 "markup.rl"
621
+ {
622
+ }
623
+ #line 95 "markup.rl"
624
+ {
625
+ instruction.begin = p;
626
+ }
627
+ #line 81 "markup.rl"
628
+ {
629
+ comment.begin = p;
630
+ }
631
+ #line 67 "markup.rl"
632
+ {
633
+ doctype.begin = p;
634
+ }
635
+ #line 166 "markup.rl"
636
+ {
637
+ cdata.begin = p;
638
+ }
639
+ goto st1;
640
+ tr110:
641
+ #line 158 "markup.rl"
642
+ {
643
+ rb_funcall(delegate, id_close_tag, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
644
+ }
645
+ #line 122 "markup.rl"
646
+ {
647
+ }
648
+ #line 155 "markup.rl"
649
+ {
650
+ }
651
+ #line 95 "markup.rl"
652
+ {
653
+ instruction.begin = p;
654
+ }
655
+ #line 81 "markup.rl"
656
+ {
657
+ comment.begin = p;
658
+ }
659
+ #line 67 "markup.rl"
660
+ {
661
+ doctype.begin = p;
662
+ }
663
+ #line 166 "markup.rl"
664
+ {
665
+ cdata.begin = p;
666
+ }
667
+ goto st1;
668
+ tr113:
669
+ #line 105 "markup.rl"
670
+ {
671
+ instruction.end = p;
672
+
673
+ rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
674
+ }
675
+ #line 122 "markup.rl"
676
+ {
677
+ }
678
+ #line 155 "markup.rl"
679
+ {
680
+ }
681
+ #line 95 "markup.rl"
682
+ {
683
+ instruction.begin = p;
684
+ }
685
+ #line 81 "markup.rl"
686
+ {
687
+ comment.begin = p;
688
+ }
689
+ #line 67 "markup.rl"
690
+ {
691
+ doctype.begin = p;
692
+ }
693
+ #line 166 "markup.rl"
694
+ {
695
+ cdata.begin = p;
696
+ }
697
+ goto st1;
698
+ st1:
699
+ if ( ++p == pe )
700
+ goto _test_eof1;
701
+ case 1:
702
+ #line 703 "markup.c"
703
+ switch( (*p) ) {
704
+ case 33: goto st15;
705
+ case 47: goto st36;
706
+ case 63: goto st38;
707
+ case 96: goto tr1;
708
+ }
709
+ if ( (*p) < 59 ) {
710
+ if ( 0 <= (*p) && (*p) <= 44 )
711
+ goto tr1;
712
+ } else if ( (*p) > 64 ) {
713
+ if ( (*p) > 94 ) {
714
+ if ( 123 <= (*p) )
715
+ goto tr1;
716
+ } else if ( (*p) >= 91 )
717
+ goto tr1;
718
+ } else
719
+ goto tr1;
720
+ goto tr0;
721
+ tr0:
722
+ #line 10 "markup.rl"
723
+ {
724
+ identifier.begin = p;
725
+ }
726
+ goto st2;
727
+ st2:
728
+ if ( ++p == pe )
729
+ goto _test_eof2;
730
+ case 2:
731
+ #line 732 "markup.c"
732
+ switch( (*p) ) {
733
+ case 32: goto tr6;
734
+ case 47: goto tr7;
735
+ case 62: goto tr8;
736
+ case 96: goto tr1;
737
+ }
738
+ if ( (*p) < 14 ) {
739
+ if ( (*p) > 8 ) {
740
+ if ( 9 <= (*p) && (*p) <= 13 )
741
+ goto tr6;
742
+ } else if ( (*p) >= 0 )
743
+ goto tr1;
744
+ } else if ( (*p) > 44 ) {
745
+ if ( (*p) < 91 ) {
746
+ if ( 59 <= (*p) && (*p) <= 64 )
747
+ goto tr1;
748
+ } else if ( (*p) > 94 ) {
749
+ if ( 123 <= (*p) )
750
+ goto tr1;
751
+ } else
752
+ goto tr1;
753
+ } else
754
+ goto tr1;
755
+ goto st2;
756
+ tr1:
757
+ #line 162 "markup.rl"
758
+ {
759
+ Trenni_raise_error("could not parse tag", buffer, p-s);
760
+ }
761
+ goto st0;
762
+ tr69:
763
+ #line 111 "markup.rl"
764
+ {
765
+ Trenni_raise_error("could not parse instruction", buffer, p-s);
766
+ }
767
+ goto st0;
768
+ tr75:
769
+ #line 35 "markup.rl"
770
+ {
771
+ Trenni_raise_error("could not parse entity", buffer, p-s);
772
+ }
773
+ goto st0;
774
+ #line 775 "markup.c"
775
+ st0:
776
+ cs = 0;
777
+ goto _out;
778
+ tr6:
779
+ #line 14 "markup.rl"
780
+ {
781
+ identifier.end = p;
782
+ }
783
+ #line 115 "markup.rl"
784
+ {
785
+ // Reset self-closing state - we don't know yet.
786
+ self_closing = 0;
787
+
788
+ rb_funcall(delegate, id_open_tag_begin, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
789
+ }
790
+ goto st3;
791
+ tr14:
792
+ #line 14 "markup.rl"
793
+ {
794
+ identifier.end = p;
795
+ }
796
+ #line 141 "markup.rl"
797
+ {
798
+ if (has_value == 1) {
799
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
800
+ } else if (has_value == 2) {
801
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
802
+ } else {
803
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
804
+ }
805
+ }
806
+ goto st3;
807
+ tr26:
808
+ #line 133 "markup.rl"
809
+ {
810
+ has_value = 1;
811
+ }
812
+ #line 141 "markup.rl"
813
+ {
814
+ if (has_value == 1) {
815
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
816
+ } else if (has_value == 2) {
817
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
818
+ } else {
819
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
820
+ }
821
+ }
822
+ goto st3;
823
+ tr32:
824
+ #line 137 "markup.rl"
825
+ {
826
+ has_value = 2;
827
+ }
828
+ #line 141 "markup.rl"
829
+ {
830
+ if (has_value == 1) {
831
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
832
+ } else if (has_value == 2) {
833
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
834
+ } else {
835
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
836
+ }
837
+ }
838
+ goto st3;
839
+ st3:
840
+ if ( ++p == pe )
841
+ goto _test_eof3;
842
+ case 3:
843
+ #line 844 "markup.c"
844
+ switch( (*p) ) {
845
+ case 32: goto st3;
846
+ case 47: goto tr11;
847
+ case 62: goto st51;
848
+ case 96: goto tr1;
849
+ }
850
+ if ( (*p) < 14 ) {
851
+ if ( (*p) > 8 ) {
852
+ if ( 9 <= (*p) && (*p) <= 13 )
853
+ goto st3;
854
+ } else if ( (*p) >= 0 )
855
+ goto tr1;
856
+ } else if ( (*p) > 44 ) {
857
+ if ( (*p) < 91 ) {
858
+ if ( 59 <= (*p) && (*p) <= 64 )
859
+ goto tr1;
860
+ } else if ( (*p) > 94 ) {
861
+ if ( 123 <= (*p) )
862
+ goto tr1;
863
+ } else
864
+ goto tr1;
865
+ } else
866
+ goto tr1;
867
+ goto tr9;
868
+ tr9:
869
+ #line 129 "markup.rl"
870
+ {
871
+ has_value = 0;
872
+ }
873
+ #line 10 "markup.rl"
874
+ {
875
+ identifier.begin = p;
876
+ }
877
+ goto st4;
878
+ st4:
879
+ if ( ++p == pe )
880
+ goto _test_eof4;
881
+ case 4:
882
+ #line 883 "markup.c"
883
+ switch( (*p) ) {
884
+ case 32: goto tr14;
885
+ case 47: goto tr15;
886
+ case 61: goto tr16;
887
+ case 62: goto tr17;
888
+ case 96: goto tr1;
889
+ }
890
+ if ( (*p) < 14 ) {
891
+ if ( (*p) > 8 ) {
892
+ if ( 9 <= (*p) && (*p) <= 13 )
893
+ goto tr14;
894
+ } else if ( (*p) >= 0 )
895
+ goto tr1;
896
+ } else if ( (*p) > 44 ) {
897
+ if ( (*p) < 91 ) {
898
+ if ( 59 <= (*p) && (*p) <= 64 )
899
+ goto tr1;
900
+ } else if ( (*p) > 94 ) {
901
+ if ( 123 <= (*p) )
902
+ goto tr1;
903
+ } else
904
+ goto tr1;
905
+ } else
906
+ goto tr1;
907
+ goto st4;
908
+ tr7:
909
+ #line 14 "markup.rl"
910
+ {
911
+ identifier.end = p;
912
+ }
913
+ #line 115 "markup.rl"
914
+ {
915
+ // Reset self-closing state - we don't know yet.
916
+ self_closing = 0;
917
+
918
+ rb_funcall(delegate, id_open_tag_begin, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
919
+ }
920
+ #line 125 "markup.rl"
921
+ {
922
+ self_closing = 1;
923
+ }
924
+ goto st5;
925
+ tr11:
926
+ #line 125 "markup.rl"
927
+ {
928
+ self_closing = 1;
929
+ }
930
+ goto st5;
931
+ tr15:
932
+ #line 14 "markup.rl"
933
+ {
934
+ identifier.end = p;
935
+ }
936
+ #line 141 "markup.rl"
937
+ {
938
+ if (has_value == 1) {
939
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
940
+ } else if (has_value == 2) {
941
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
942
+ } else {
943
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
944
+ }
945
+ }
946
+ #line 125 "markup.rl"
947
+ {
948
+ self_closing = 1;
949
+ }
950
+ goto st5;
951
+ tr27:
952
+ #line 133 "markup.rl"
953
+ {
954
+ has_value = 1;
955
+ }
956
+ #line 141 "markup.rl"
957
+ {
958
+ if (has_value == 1) {
959
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
960
+ } else if (has_value == 2) {
961
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
962
+ } else {
963
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
964
+ }
965
+ }
966
+ #line 125 "markup.rl"
967
+ {
968
+ self_closing = 1;
969
+ }
970
+ goto st5;
971
+ tr33:
972
+ #line 137 "markup.rl"
973
+ {
974
+ has_value = 2;
975
+ }
976
+ #line 141 "markup.rl"
977
+ {
978
+ if (has_value == 1) {
979
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
980
+ } else if (has_value == 2) {
981
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
982
+ } else {
983
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
984
+ }
985
+ }
986
+ #line 125 "markup.rl"
987
+ {
988
+ self_closing = 1;
989
+ }
990
+ goto st5;
991
+ st5:
992
+ if ( ++p == pe )
993
+ goto _test_eof5;
994
+ case 5:
995
+ #line 996 "markup.c"
996
+ if ( (*p) == 62 )
997
+ goto st51;
998
+ goto tr1;
999
+ tr8:
1000
+ #line 14 "markup.rl"
1001
+ {
1002
+ identifier.end = p;
1003
+ }
1004
+ #line 115 "markup.rl"
1005
+ {
1006
+ // Reset self-closing state - we don't know yet.
1007
+ self_closing = 0;
1008
+
1009
+ rb_funcall(delegate, id_open_tag_begin, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
1010
+ }
1011
+ goto st51;
1012
+ tr17:
1013
+ #line 14 "markup.rl"
1014
+ {
1015
+ identifier.end = p;
1016
+ }
1017
+ #line 141 "markup.rl"
1018
+ {
1019
+ if (has_value == 1) {
1020
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
1021
+ } else if (has_value == 2) {
1022
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
1023
+ } else {
1024
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
1025
+ }
1026
+ }
1027
+ goto st51;
1028
+ tr28:
1029
+ #line 133 "markup.rl"
1030
+ {
1031
+ has_value = 1;
1032
+ }
1033
+ #line 141 "markup.rl"
1034
+ {
1035
+ if (has_value == 1) {
1036
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
1037
+ } else if (has_value == 2) {
1038
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
1039
+ } else {
1040
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
1041
+ }
1042
+ }
1043
+ goto st51;
1044
+ tr34:
1045
+ #line 137 "markup.rl"
1046
+ {
1047
+ has_value = 2;
1048
+ }
1049
+ #line 141 "markup.rl"
1050
+ {
1051
+ if (has_value == 1) {
1052
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), pcdata);
1053
+ } else if (has_value == 2) {
1054
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), empty_string);
1055
+ } else {
1056
+ rb_funcall(delegate, id_attribute, 2, Trenni_token(identifier, encoding), Qtrue);
1057
+ }
1058
+ }
1059
+ goto st51;
1060
+ st51:
1061
+ if ( ++p == pe )
1062
+ goto _test_eof51;
1063
+ case 51:
1064
+ #line 1065 "markup.c"
1065
+ switch( (*p) ) {
1066
+ case 38: goto tr97;
1067
+ case 60: goto tr98;
1068
+ }
1069
+ goto tr96;
1070
+ tr16:
1071
+ #line 14 "markup.rl"
1072
+ {
1073
+ identifier.end = p;
1074
+ }
1075
+ goto st6;
1076
+ st6:
1077
+ if ( ++p == pe )
1078
+ goto _test_eof6;
1079
+ case 6:
1080
+ #line 1081 "markup.c"
1081
+ switch( (*p) ) {
1082
+ case 34: goto st7;
1083
+ case 39: goto st12;
1084
+ }
1085
+ goto tr1;
1086
+ st7:
1087
+ if ( ++p == pe )
1088
+ goto _test_eof7;
1089
+ case 7:
1090
+ switch( (*p) ) {
1091
+ case 34: goto st11;
1092
+ case 38: goto tr22;
1093
+ case 60: goto tr1;
1094
+ }
1095
+ goto tr20;
1096
+ tr20:
1097
+ #line 18 "markup.rl"
1098
+ {
1099
+ pcdata = Qnil;
1100
+ }
1101
+ #line 25 "markup.rl"
1102
+ {
1103
+ characters.begin = p;
1104
+ }
1105
+ goto st8;
1106
+ tr23:
1107
+ #line 29 "markup.rl"
1108
+ {
1109
+ characters.end = p;
1110
+
1111
+ Trenni_append_token(&pcdata, encoding, characters);
1112
+ }
1113
+ #line 25 "markup.rl"
1114
+ {
1115
+ characters.begin = p;
1116
+ }
1117
+ goto st8;
1118
+ tr29:
1119
+ #line 25 "markup.rl"
1120
+ {
1121
+ characters.begin = p;
1122
+ }
1123
+ goto st8;
1124
+ st8:
1125
+ if ( ++p == pe )
1126
+ goto _test_eof8;
1127
+ case 8:
1128
+ #line 1129 "markup.c"
1129
+ switch( (*p) ) {
1130
+ case 34: goto tr24;
1131
+ case 38: goto tr25;
1132
+ case 60: goto tr1;
1133
+ }
1134
+ goto tr23;
1135
+ tr24:
1136
+ #line 29 "markup.rl"
1137
+ {
1138
+ characters.end = p;
1139
+
1140
+ Trenni_append_token(&pcdata, encoding, characters);
1141
+ }
1142
+ #line 22 "markup.rl"
1143
+ {
1144
+ }
1145
+ goto st9;
1146
+ tr30:
1147
+ #line 22 "markup.rl"
1148
+ {
1149
+ }
1150
+ goto st9;
1151
+ st9:
1152
+ if ( ++p == pe )
1153
+ goto _test_eof9;
1154
+ case 9:
1155
+ #line 1156 "markup.c"
1156
+ switch( (*p) ) {
1157
+ case 32: goto tr26;
1158
+ case 47: goto tr27;
1159
+ case 62: goto tr28;
1160
+ }
1161
+ if ( 9 <= (*p) && (*p) <= 13 )
1162
+ goto tr26;
1163
+ goto tr1;
1164
+ tr22:
1165
+ #line 18 "markup.rl"
1166
+ {
1167
+ pcdata = Qnil;
1168
+ }
1169
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1170
+ {{stack[top++] = 10; goto st42;}}
1171
+ goto st10;
1172
+ tr25:
1173
+ #line 29 "markup.rl"
1174
+ {
1175
+ characters.end = p;
1176
+
1177
+ Trenni_append_token(&pcdata, encoding, characters);
1178
+ }
1179
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1180
+ {{stack[top++] = 10; goto st42;}}
1181
+ goto st10;
1182
+ tr31:
1183
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1184
+ {{stack[top++] = 10; goto st42;}}
1185
+ goto st10;
1186
+ st10:
1187
+ if ( ++p == pe )
1188
+ goto _test_eof10;
1189
+ case 10:
1190
+ #line 1191 "markup.c"
1191
+ switch( (*p) ) {
1192
+ case 34: goto tr30;
1193
+ case 38: goto tr31;
1194
+ case 60: goto tr1;
1195
+ }
1196
+ goto tr29;
1197
+ st11:
1198
+ if ( ++p == pe )
1199
+ goto _test_eof11;
1200
+ case 11:
1201
+ switch( (*p) ) {
1202
+ case 32: goto tr32;
1203
+ case 47: goto tr33;
1204
+ case 62: goto tr34;
1205
+ }
1206
+ if ( 9 <= (*p) && (*p) <= 13 )
1207
+ goto tr32;
1208
+ goto tr1;
1209
+ st12:
1210
+ if ( ++p == pe )
1211
+ goto _test_eof12;
1212
+ case 12:
1213
+ switch( (*p) ) {
1214
+ case 38: goto tr36;
1215
+ case 39: goto st11;
1216
+ case 60: goto tr1;
1217
+ }
1218
+ goto tr35;
1219
+ tr35:
1220
+ #line 18 "markup.rl"
1221
+ {
1222
+ pcdata = Qnil;
1223
+ }
1224
+ #line 25 "markup.rl"
1225
+ {
1226
+ characters.begin = p;
1227
+ }
1228
+ goto st13;
1229
+ tr37:
1230
+ #line 29 "markup.rl"
1231
+ {
1232
+ characters.end = p;
1233
+
1234
+ Trenni_append_token(&pcdata, encoding, characters);
1235
+ }
1236
+ #line 25 "markup.rl"
1237
+ {
1238
+ characters.begin = p;
1239
+ }
1240
+ goto st13;
1241
+ tr39:
1242
+ #line 25 "markup.rl"
1243
+ {
1244
+ characters.begin = p;
1245
+ }
1246
+ goto st13;
1247
+ st13:
1248
+ if ( ++p == pe )
1249
+ goto _test_eof13;
1250
+ case 13:
1251
+ #line 1252 "markup.c"
1252
+ switch( (*p) ) {
1253
+ case 38: goto tr38;
1254
+ case 39: goto tr24;
1255
+ case 60: goto tr1;
1256
+ }
1257
+ goto tr37;
1258
+ tr36:
1259
+ #line 18 "markup.rl"
1260
+ {
1261
+ pcdata = Qnil;
1262
+ }
1263
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1264
+ {{stack[top++] = 14; goto st42;}}
1265
+ goto st14;
1266
+ tr38:
1267
+ #line 29 "markup.rl"
1268
+ {
1269
+ characters.end = p;
1270
+
1271
+ Trenni_append_token(&pcdata, encoding, characters);
1272
+ }
1273
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1274
+ {{stack[top++] = 14; goto st42;}}
1275
+ goto st14;
1276
+ tr40:
1277
+ #line 10 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1278
+ {{stack[top++] = 14; goto st42;}}
1279
+ goto st14;
1280
+ st14:
1281
+ if ( ++p == pe )
1282
+ goto _test_eof14;
1283
+ case 14:
1284
+ #line 1285 "markup.c"
1285
+ switch( (*p) ) {
1286
+ case 38: goto tr40;
1287
+ case 39: goto tr30;
1288
+ case 60: goto tr1;
1289
+ }
1290
+ goto tr39;
1291
+ st15:
1292
+ if ( ++p == pe )
1293
+ goto _test_eof15;
1294
+ case 15:
1295
+ switch( (*p) ) {
1296
+ case 45: goto st16;
1297
+ case 68: goto st20;
1298
+ case 91: goto st27;
1299
+ }
1300
+ goto st0;
1301
+ st16:
1302
+ if ( ++p == pe )
1303
+ goto _test_eof16;
1304
+ case 16:
1305
+ if ( (*p) == 45 )
1306
+ goto st17;
1307
+ goto st0;
1308
+ st17:
1309
+ if ( ++p == pe )
1310
+ goto _test_eof17;
1311
+ case 17:
1312
+ if ( (*p) == 45 )
1313
+ goto st18;
1314
+ goto st17;
1315
+ st18:
1316
+ if ( ++p == pe )
1317
+ goto _test_eof18;
1318
+ case 18:
1319
+ if ( (*p) == 45 )
1320
+ goto st19;
1321
+ goto st17;
1322
+ st19:
1323
+ if ( ++p == pe )
1324
+ goto _test_eof19;
1325
+ case 19:
1326
+ switch( (*p) ) {
1327
+ case 45: goto st19;
1328
+ case 62: goto st52;
1329
+ }
1330
+ goto st17;
1331
+ st52:
1332
+ if ( ++p == pe )
1333
+ goto _test_eof52;
1334
+ case 52:
1335
+ switch( (*p) ) {
1336
+ case 38: goto tr100;
1337
+ case 60: goto tr101;
1338
+ }
1339
+ goto tr99;
1340
+ st20:
1341
+ if ( ++p == pe )
1342
+ goto _test_eof20;
1343
+ case 20:
1344
+ if ( (*p) == 79 )
1345
+ goto st21;
1346
+ goto st0;
1347
+ st21:
1348
+ if ( ++p == pe )
1349
+ goto _test_eof21;
1350
+ case 21:
1351
+ if ( (*p) == 67 )
1352
+ goto st22;
1353
+ goto st0;
1354
+ st22:
1355
+ if ( ++p == pe )
1356
+ goto _test_eof22;
1357
+ case 22:
1358
+ if ( (*p) == 84 )
1359
+ goto st23;
1360
+ goto st0;
1361
+ st23:
1362
+ if ( ++p == pe )
1363
+ goto _test_eof23;
1364
+ case 23:
1365
+ if ( (*p) == 89 )
1366
+ goto st24;
1367
+ goto st0;
1368
+ st24:
1369
+ if ( ++p == pe )
1370
+ goto _test_eof24;
1371
+ case 24:
1372
+ if ( (*p) == 80 )
1373
+ goto st25;
1374
+ goto st0;
1375
+ st25:
1376
+ if ( ++p == pe )
1377
+ goto _test_eof25;
1378
+ case 25:
1379
+ if ( (*p) == 69 )
1380
+ goto st26;
1381
+ goto st0;
1382
+ st26:
1383
+ if ( ++p == pe )
1384
+ goto _test_eof26;
1385
+ case 26:
1386
+ if ( (*p) == 62 )
1387
+ goto st53;
1388
+ goto st26;
1389
+ st53:
1390
+ if ( ++p == pe )
1391
+ goto _test_eof53;
1392
+ case 53:
1393
+ switch( (*p) ) {
1394
+ case 38: goto tr103;
1395
+ case 60: goto tr104;
1396
+ }
1397
+ goto tr102;
1398
+ st27:
1399
+ if ( ++p == pe )
1400
+ goto _test_eof27;
1401
+ case 27:
1402
+ if ( (*p) == 67 )
1403
+ goto st28;
1404
+ goto st0;
1405
+ st28:
1406
+ if ( ++p == pe )
1407
+ goto _test_eof28;
1408
+ case 28:
1409
+ if ( (*p) == 68 )
1410
+ goto st29;
1411
+ goto st0;
1412
+ st29:
1413
+ if ( ++p == pe )
1414
+ goto _test_eof29;
1415
+ case 29:
1416
+ if ( (*p) == 65 )
1417
+ goto st30;
1418
+ goto st0;
1419
+ st30:
1420
+ if ( ++p == pe )
1421
+ goto _test_eof30;
1422
+ case 30:
1423
+ if ( (*p) == 84 )
1424
+ goto st31;
1425
+ goto st0;
1426
+ st31:
1427
+ if ( ++p == pe )
1428
+ goto _test_eof31;
1429
+ case 31:
1430
+ if ( (*p) == 65 )
1431
+ goto st32;
1432
+ goto st0;
1433
+ st32:
1434
+ if ( ++p == pe )
1435
+ goto _test_eof32;
1436
+ case 32:
1437
+ if ( (*p) == 91 )
1438
+ goto st33;
1439
+ goto st0;
1440
+ st33:
1441
+ if ( ++p == pe )
1442
+ goto _test_eof33;
1443
+ case 33:
1444
+ if ( (*p) == 93 )
1445
+ goto st34;
1446
+ goto st33;
1447
+ st34:
1448
+ if ( ++p == pe )
1449
+ goto _test_eof34;
1450
+ case 34:
1451
+ if ( (*p) == 93 )
1452
+ goto st35;
1453
+ goto st33;
1454
+ st35:
1455
+ if ( ++p == pe )
1456
+ goto _test_eof35;
1457
+ case 35:
1458
+ switch( (*p) ) {
1459
+ case 62: goto st54;
1460
+ case 93: goto st35;
1461
+ }
1462
+ goto st33;
1463
+ st54:
1464
+ if ( ++p == pe )
1465
+ goto _test_eof54;
1466
+ case 54:
1467
+ switch( (*p) ) {
1468
+ case 38: goto tr106;
1469
+ case 60: goto tr107;
1470
+ }
1471
+ goto tr105;
1472
+ st36:
1473
+ if ( ++p == pe )
1474
+ goto _test_eof36;
1475
+ case 36:
1476
+ switch( (*p) ) {
1477
+ case 47: goto tr1;
1478
+ case 96: goto tr1;
1479
+ }
1480
+ if ( (*p) < 59 ) {
1481
+ if ( 0 <= (*p) && (*p) <= 44 )
1482
+ goto tr1;
1483
+ } else if ( (*p) > 64 ) {
1484
+ if ( (*p) > 94 ) {
1485
+ if ( 123 <= (*p) )
1486
+ goto tr1;
1487
+ } else if ( (*p) >= 91 )
1488
+ goto tr1;
1489
+ } else
1490
+ goto tr1;
1491
+ goto tr65;
1492
+ tr65:
1493
+ #line 10 "markup.rl"
1494
+ {
1495
+ identifier.begin = p;
1496
+ }
1497
+ goto st37;
1498
+ st37:
1499
+ if ( ++p == pe )
1500
+ goto _test_eof37;
1501
+ case 37:
1502
+ #line 1503 "markup.c"
1503
+ switch( (*p) ) {
1504
+ case 47: goto tr1;
1505
+ case 62: goto tr67;
1506
+ case 96: goto tr1;
1507
+ }
1508
+ if ( (*p) < 59 ) {
1509
+ if ( 0 <= (*p) && (*p) <= 44 )
1510
+ goto tr1;
1511
+ } else if ( (*p) > 64 ) {
1512
+ if ( (*p) > 94 ) {
1513
+ if ( 123 <= (*p) )
1514
+ goto tr1;
1515
+ } else if ( (*p) >= 91 )
1516
+ goto tr1;
1517
+ } else
1518
+ goto tr1;
1519
+ goto st37;
1520
+ tr67:
1521
+ #line 14 "markup.rl"
1522
+ {
1523
+ identifier.end = p;
1524
+ }
1525
+ goto st55;
1526
+ st55:
1527
+ if ( ++p == pe )
1528
+ goto _test_eof55;
1529
+ case 55:
1530
+ #line 1531 "markup.c"
1531
+ switch( (*p) ) {
1532
+ case 38: goto tr109;
1533
+ case 60: goto tr110;
1534
+ }
1535
+ goto tr108;
1536
+ st38:
1537
+ if ( ++p == pe )
1538
+ goto _test_eof38;
1539
+ case 38:
1540
+ switch( (*p) ) {
1541
+ case 47: goto tr69;
1542
+ case 96: goto tr69;
1543
+ }
1544
+ if ( (*p) < 59 ) {
1545
+ if ( 0 <= (*p) && (*p) <= 44 )
1546
+ goto tr69;
1547
+ } else if ( (*p) > 64 ) {
1548
+ if ( (*p) > 94 ) {
1549
+ if ( 123 <= (*p) )
1550
+ goto tr69;
1551
+ } else if ( (*p) >= 91 )
1552
+ goto tr69;
1553
+ } else
1554
+ goto tr69;
1555
+ goto tr68;
1556
+ tr68:
1557
+ #line 10 "markup.rl"
1558
+ {
1559
+ identifier.begin = p;
1560
+ }
1561
+ goto st39;
1562
+ st39:
1563
+ if ( ++p == pe )
1564
+ goto _test_eof39;
1565
+ case 39:
1566
+ #line 1567 "markup.c"
1567
+ switch( (*p) ) {
1568
+ case 32: goto tr71;
1569
+ case 47: goto tr69;
1570
+ case 96: goto tr69;
1571
+ }
1572
+ if ( (*p) < 14 ) {
1573
+ if ( (*p) > 8 ) {
1574
+ if ( 9 <= (*p) && (*p) <= 13 )
1575
+ goto tr71;
1576
+ } else if ( (*p) >= 0 )
1577
+ goto tr69;
1578
+ } else if ( (*p) > 44 ) {
1579
+ if ( (*p) < 91 ) {
1580
+ if ( 59 <= (*p) && (*p) <= 64 )
1581
+ goto tr69;
1582
+ } else if ( (*p) > 94 ) {
1583
+ if ( 123 <= (*p) )
1584
+ goto tr69;
1585
+ } else
1586
+ goto tr69;
1587
+ } else
1588
+ goto tr69;
1589
+ goto st39;
1590
+ tr71:
1591
+ #line 14 "markup.rl"
1592
+ {
1593
+ identifier.end = p;
1594
+ }
1595
+ #line 99 "markup.rl"
1596
+ {
1597
+ }
1598
+ goto st40;
1599
+ st40:
1600
+ if ( ++p == pe )
1601
+ goto _test_eof40;
1602
+ case 40:
1603
+ #line 1604 "markup.c"
1604
+ if ( (*p) == 63 )
1605
+ goto tr73;
1606
+ goto st40;
1607
+ tr73:
1608
+ #line 102 "markup.rl"
1609
+ {
1610
+ }
1611
+ goto st41;
1612
+ st41:
1613
+ if ( ++p == pe )
1614
+ goto _test_eof41;
1615
+ case 41:
1616
+ #line 1617 "markup.c"
1617
+ switch( (*p) ) {
1618
+ case 62: goto st56;
1619
+ case 63: goto tr73;
1620
+ }
1621
+ goto st40;
1622
+ st56:
1623
+ if ( ++p == pe )
1624
+ goto _test_eof56;
1625
+ case 56:
1626
+ switch( (*p) ) {
1627
+ case 38: goto tr112;
1628
+ case 60: goto tr113;
1629
+ }
1630
+ goto tr111;
1631
+ st42:
1632
+ if ( ++p == pe )
1633
+ goto _test_eof42;
1634
+ case 42:
1635
+ if ( (*p) == 35 )
1636
+ goto st43;
1637
+ if ( (*p) < 65 ) {
1638
+ if ( 48 <= (*p) && (*p) <= 57 )
1639
+ goto tr77;
1640
+ } else if ( (*p) > 90 ) {
1641
+ if ( 97 <= (*p) && (*p) <= 122 )
1642
+ goto tr77;
1643
+ } else
1644
+ goto tr77;
1645
+ goto tr75;
1646
+ st43:
1647
+ if ( ++p == pe )
1648
+ goto _test_eof43;
1649
+ case 43:
1650
+ if ( (*p) == 120 )
1651
+ goto st45;
1652
+ if ( 48 <= (*p) && (*p) <= 57 )
1653
+ goto tr78;
1654
+ goto tr75;
1655
+ tr78:
1656
+ #line 39 "markup.rl"
1657
+ {
1658
+ entity.begin = p;
1659
+ }
1660
+ goto st44;
1661
+ st44:
1662
+ if ( ++p == pe )
1663
+ goto _test_eof44;
1664
+ case 44:
1665
+ #line 1666 "markup.c"
1666
+ if ( (*p) == 59 )
1667
+ goto tr81;
1668
+ if ( 48 <= (*p) && (*p) <= 57 )
1669
+ goto st44;
1670
+ goto tr75;
1671
+ tr81:
1672
+ #line 59 "markup.rl"
1673
+ {
1674
+ entity.end = p;
1675
+
1676
+ codepoint = strtoul(entity.begin, (char **)&entity.end, 10);
1677
+
1678
+ Trenni_append_codepoint(&pcdata, encoding, codepoint);
1679
+ }
1680
+ #line 8 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1681
+ {{cs = stack[--top];goto _again;}}
1682
+ goto st57;
1683
+ tr84:
1684
+ #line 51 "markup.rl"
1685
+ {
1686
+ entity.end = p;
1687
+
1688
+ codepoint = strtoul(entity.begin, (char **)&entity.end, 16);
1689
+
1690
+ Trenni_append_codepoint(&pcdata, encoding, codepoint);
1691
+ }
1692
+ #line 8 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1693
+ {{cs = stack[--top];goto _again;}}
1694
+ goto st57;
1695
+ tr86:
1696
+ #line 43 "markup.rl"
1697
+ {
1698
+ entity.end = p;
1699
+
1700
+ Trenni_append_string(&pcdata, encoding,
1701
+ rb_funcall(entities, rb_intern("[]"), 1, Trenni_token(entity, encoding))
1702
+ );
1703
+ }
1704
+ #line 8 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/entities.rl"
1705
+ {{cs = stack[--top];goto _again;}}
1706
+ goto st57;
1707
+ st57:
1708
+ if ( ++p == pe )
1709
+ goto _test_eof57;
1710
+ case 57:
1711
+ #line 1712 "markup.c"
1712
+ goto st0;
1713
+ st45:
1714
+ if ( ++p == pe )
1715
+ goto _test_eof45;
1716
+ case 45:
1717
+ if ( (*p) < 65 ) {
1718
+ if ( 48 <= (*p) && (*p) <= 57 )
1719
+ goto tr82;
1720
+ } else if ( (*p) > 70 ) {
1721
+ if ( 97 <= (*p) && (*p) <= 102 )
1722
+ goto tr82;
1723
+ } else
1724
+ goto tr82;
1725
+ goto tr75;
1726
+ tr82:
1727
+ #line 39 "markup.rl"
1728
+ {
1729
+ entity.begin = p;
1730
+ }
1731
+ goto st46;
1732
+ st46:
1733
+ if ( ++p == pe )
1734
+ goto _test_eof46;
1735
+ case 46:
1736
+ #line 1737 "markup.c"
1737
+ if ( (*p) == 59 )
1738
+ goto tr84;
1739
+ if ( (*p) < 65 ) {
1740
+ if ( 48 <= (*p) && (*p) <= 57 )
1741
+ goto st46;
1742
+ } else if ( (*p) > 70 ) {
1743
+ if ( 97 <= (*p) && (*p) <= 102 )
1744
+ goto st46;
1745
+ } else
1746
+ goto st46;
1747
+ goto tr75;
1748
+ tr77:
1749
+ #line 39 "markup.rl"
1750
+ {
1751
+ entity.begin = p;
1752
+ }
1753
+ goto st47;
1754
+ st47:
1755
+ if ( ++p == pe )
1756
+ goto _test_eof47;
1757
+ case 47:
1758
+ #line 1759 "markup.c"
1759
+ if ( (*p) == 59 )
1760
+ goto tr86;
1761
+ if ( (*p) < 65 ) {
1762
+ if ( 48 <= (*p) && (*p) <= 57 )
1763
+ goto st47;
1764
+ } else if ( (*p) > 90 ) {
1765
+ if ( 97 <= (*p) && (*p) <= 122 )
1766
+ goto st47;
1767
+ } else
1768
+ goto st47;
1769
+ goto tr75;
1770
+ }
1771
+ _test_eof48: cs = 48; goto _test_eof;
1772
+ _test_eof49: cs = 49; goto _test_eof;
1773
+ _test_eof50: cs = 50; goto _test_eof;
1774
+ _test_eof1: cs = 1; goto _test_eof;
1775
+ _test_eof2: cs = 2; goto _test_eof;
1776
+ _test_eof3: cs = 3; goto _test_eof;
1777
+ _test_eof4: cs = 4; goto _test_eof;
1778
+ _test_eof5: cs = 5; goto _test_eof;
1779
+ _test_eof51: cs = 51; goto _test_eof;
1780
+ _test_eof6: cs = 6; goto _test_eof;
1781
+ _test_eof7: cs = 7; goto _test_eof;
1782
+ _test_eof8: cs = 8; goto _test_eof;
1783
+ _test_eof9: cs = 9; goto _test_eof;
1784
+ _test_eof10: cs = 10; goto _test_eof;
1785
+ _test_eof11: cs = 11; goto _test_eof;
1786
+ _test_eof12: cs = 12; goto _test_eof;
1787
+ _test_eof13: cs = 13; goto _test_eof;
1788
+ _test_eof14: cs = 14; goto _test_eof;
1789
+ _test_eof15: cs = 15; goto _test_eof;
1790
+ _test_eof16: cs = 16; goto _test_eof;
1791
+ _test_eof17: cs = 17; goto _test_eof;
1792
+ _test_eof18: cs = 18; goto _test_eof;
1793
+ _test_eof19: cs = 19; goto _test_eof;
1794
+ _test_eof52: cs = 52; goto _test_eof;
1795
+ _test_eof20: cs = 20; goto _test_eof;
1796
+ _test_eof21: cs = 21; goto _test_eof;
1797
+ _test_eof22: cs = 22; goto _test_eof;
1798
+ _test_eof23: cs = 23; goto _test_eof;
1799
+ _test_eof24: cs = 24; goto _test_eof;
1800
+ _test_eof25: cs = 25; goto _test_eof;
1801
+ _test_eof26: cs = 26; goto _test_eof;
1802
+ _test_eof53: cs = 53; goto _test_eof;
1803
+ _test_eof27: cs = 27; goto _test_eof;
1804
+ _test_eof28: cs = 28; goto _test_eof;
1805
+ _test_eof29: cs = 29; goto _test_eof;
1806
+ _test_eof30: cs = 30; goto _test_eof;
1807
+ _test_eof31: cs = 31; goto _test_eof;
1808
+ _test_eof32: cs = 32; goto _test_eof;
1809
+ _test_eof33: cs = 33; goto _test_eof;
1810
+ _test_eof34: cs = 34; goto _test_eof;
1811
+ _test_eof35: cs = 35; goto _test_eof;
1812
+ _test_eof54: cs = 54; goto _test_eof;
1813
+ _test_eof36: cs = 36; goto _test_eof;
1814
+ _test_eof37: cs = 37; goto _test_eof;
1815
+ _test_eof55: cs = 55; goto _test_eof;
1816
+ _test_eof38: cs = 38; goto _test_eof;
1817
+ _test_eof39: cs = 39; goto _test_eof;
1818
+ _test_eof40: cs = 40; goto _test_eof;
1819
+ _test_eof41: cs = 41; goto _test_eof;
1820
+ _test_eof56: cs = 56; goto _test_eof;
1821
+ _test_eof42: cs = 42; goto _test_eof;
1822
+ _test_eof43: cs = 43; goto _test_eof;
1823
+ _test_eof44: cs = 44; goto _test_eof;
1824
+ _test_eof57: cs = 57; goto _test_eof;
1825
+ _test_eof45: cs = 45; goto _test_eof;
1826
+ _test_eof46: cs = 46; goto _test_eof;
1827
+ _test_eof47: cs = 47; goto _test_eof;
1828
+
1829
+ _test_eof: {}
1830
+ if ( p == eof )
1831
+ {
1832
+ switch ( cs ) {
1833
+ case 42:
1834
+ case 43:
1835
+ case 44:
1836
+ case 45:
1837
+ case 46:
1838
+ case 47:
1839
+ #line 35 "markup.rl"
1840
+ {
1841
+ Trenni_raise_error("could not parse entity", buffer, p-s);
1842
+ }
1843
+ break;
1844
+ case 53:
1845
+ #line 71 "markup.rl"
1846
+ {
1847
+ doctype.end = p;
1848
+
1849
+ rb_funcall(delegate, id_doctype, 1, Trenni_token(doctype, encoding));
1850
+ }
1851
+ break;
1852
+ case 26:
1853
+ #line 77 "markup.rl"
1854
+ {
1855
+ Trenni_raise_error("could not parse doctype", buffer, p-s);
1856
+ }
1857
+ break;
1858
+ case 52:
1859
+ #line 85 "markup.rl"
1860
+ {
1861
+ comment.end = p;
1862
+
1863
+ rb_funcall(delegate, id_comment, 1, Trenni_token(comment, encoding));
1864
+ }
1865
+ break;
1866
+ case 17:
1867
+ case 18:
1868
+ case 19:
1869
+ #line 91 "markup.rl"
1870
+ {
1871
+ Trenni_raise_error("could not parse comment", buffer, p-s);
1872
+ }
1873
+ break;
1874
+ case 56:
1875
+ #line 105 "markup.rl"
1876
+ {
1877
+ instruction.end = p;
1878
+
1879
+ rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
1880
+ }
1881
+ break;
1882
+ case 38:
1883
+ case 39:
1884
+ case 40:
1885
+ case 41:
1886
+ #line 111 "markup.rl"
1887
+ {
1888
+ Trenni_raise_error("could not parse instruction", buffer, p-s);
1889
+ }
1890
+ break;
1891
+ case 51:
1892
+ #line 151 "markup.rl"
1893
+ {
1894
+ rb_funcall(delegate, id_open_tag_end, 1, self_closing == 1 ? Qtrue : Qfalse);
1895
+ }
1896
+ break;
1897
+ case 55:
1898
+ #line 158 "markup.rl"
1899
+ {
1900
+ rb_funcall(delegate, id_close_tag, 2, Trenni_token(identifier, encoding), ULONG2NUM(identifier.begin-s));
1901
+ }
1902
+ break;
1903
+ case 1:
1904
+ case 2:
1905
+ case 3:
1906
+ case 4:
1907
+ case 5:
1908
+ case 6:
1909
+ case 7:
1910
+ case 8:
1911
+ case 9:
1912
+ case 10:
1913
+ case 11:
1914
+ case 12:
1915
+ case 13:
1916
+ case 14:
1917
+ case 36:
1918
+ case 37:
1919
+ #line 162 "markup.rl"
1920
+ {
1921
+ Trenni_raise_error("could not parse tag", buffer, p-s);
1922
+ }
1923
+ break;
1924
+ case 54:
1925
+ #line 170 "markup.rl"
1926
+ {
1927
+ cdata.end = p;
1928
+
1929
+ rb_funcall(delegate, id_cdata, 1, Trenni_token(cdata, encoding));
1930
+ }
1931
+ break;
1932
+ case 33:
1933
+ case 34:
1934
+ case 35:
1935
+ #line 176 "markup.rl"
1936
+ {
1937
+ Trenni_raise_error("could not parse cdata", buffer, p-s);
1938
+ }
1939
+ break;
1940
+ case 50:
1941
+ #line 22 "markup.rl"
1942
+ {
1943
+ }
1944
+ #line 184 "markup.rl"
1945
+ {
1946
+ // Entities are handled separately:
1947
+ rb_funcall(delegate, id_text, 1, pcdata);
1948
+ }
1949
+ break;
1950
+ case 49:
1951
+ #line 29 "markup.rl"
1952
+ {
1953
+ characters.end = p;
1954
+
1955
+ Trenni_append_token(&pcdata, encoding, characters);
1956
+ }
1957
+ #line 22 "markup.rl"
1958
+ {
1959
+ }
1960
+ #line 184 "markup.rl"
1961
+ {
1962
+ // Entities are handled separately:
1963
+ rb_funcall(delegate, id_text, 1, pcdata);
1964
+ }
1965
+ break;
1966
+ #line 1967 "markup.c"
1967
+ }
1968
+ }
1969
+
1970
+ _out: {}
1971
+ }
1972
+
1973
+ #line 216 "markup.rl"
1974
+
1975
+
1976
+ if (p != eof) {
1977
+ Trenni_raise_error("could not parse all input", buffer, p-s);
1978
+ }
1979
+
1980
+ return Qnil;
1981
+ }