trenni 3.7.1 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/bake/trenni/entities.rb +57 -0
  3. data/bake/trenni/parsers.rb +66 -0
  4. data/ext/Rakefile +1 -0
  5. data/ext/tmp/x86_64-linux/lib/trenni/trenni.so +0 -0
  6. data/ext/tmp/x86_64-linux/trenni/2.4.0/Makefile +263 -0
  7. data/ext/tmp/x86_64-linux/trenni/2.4.0/escape.o +0 -0
  8. data/ext/tmp/x86_64-linux/trenni/2.4.0/markup.o +0 -0
  9. data/ext/tmp/x86_64-linux/trenni/2.4.0/mkmf.log +108 -0
  10. data/ext/tmp/x86_64-linux/trenni/2.4.0/tag.o +0 -0
  11. data/ext/tmp/x86_64-linux/trenni/2.4.0/template.o +0 -0
  12. data/ext/tmp/x86_64-linux/trenni/2.4.0/trenni.o +0 -0
  13. data/ext/tmp/x86_64-linux/trenni/2.4.0/trenni.so +0 -0
  14. data/ext/tmp/x86_64-linux/trenni/2.7.0/Makefile +266 -0
  15. data/ext/tmp/x86_64-linux/trenni/2.7.0/escape.o +0 -0
  16. data/ext/tmp/x86_64-linux/trenni/2.7.0/markup.o +0 -0
  17. data/ext/tmp/x86_64-linux/trenni/2.7.0/mkmf.log +113 -0
  18. data/ext/tmp/x86_64-linux/trenni/2.7.0/query.o +0 -0
  19. data/ext/tmp/x86_64-linux/trenni/2.7.0/tag.o +0 -0
  20. data/ext/tmp/x86_64-linux/trenni/2.7.0/template.o +0 -0
  21. data/ext/tmp/x86_64-linux/trenni/2.7.0/trenni.o +0 -0
  22. data/ext/tmp/x86_64-linux/trenni/2.7.0/trenni.so +0 -0
  23. data/ext/tmp/x86_64-linux/trenni/2.7.1/Makefile +266 -0
  24. data/ext/tmp/x86_64-linux/trenni/2.7.1/escape.o +0 -0
  25. data/ext/tmp/x86_64-linux/trenni/2.7.1/markup.o +0 -0
  26. data/ext/tmp/x86_64-linux/trenni/2.7.1/mkmf.log +113 -0
  27. data/ext/tmp/x86_64-linux/trenni/2.7.1/query.o +0 -0
  28. data/ext/tmp/x86_64-linux/trenni/2.7.1/tag.o +0 -0
  29. data/ext/tmp/x86_64-linux/trenni/2.7.1/template.o +0 -0
  30. data/ext/tmp/x86_64-linux/trenni/2.7.1/trenni.o +0 -0
  31. data/ext/tmp/x86_64-linux/trenni/2.7.1/trenni.so +0 -0
  32. data/ext/trenni/extconf.rb +1 -0
  33. data/ext/trenni/markup.c +85 -85
  34. data/ext/trenni/markup.rl +11 -11
  35. data/ext/trenni/query.c +619 -0
  36. data/ext/trenni/query.h +6 -0
  37. data/ext/trenni/query.rl +82 -0
  38. data/ext/trenni/tag.c +8 -6
  39. data/ext/trenni/template.c +57 -57
  40. data/ext/trenni/template.rl +4 -4
  41. data/ext/trenni/trenni.c +9 -1
  42. data/ext/trenni/trenni.h +8 -3
  43. data/lib/trenni.rb +4 -0
  44. data/lib/trenni/buffer.rb +2 -0
  45. data/lib/trenni/builder.rb +64 -12
  46. data/lib/trenni/entities.rb +2082 -2082
  47. data/lib/trenni/entities.trenni +1 -3
  48. data/lib/trenni/{parse_error.rb → error.rb} +6 -1
  49. data/lib/trenni/fallback/markup.rb +1623 -1575
  50. data/lib/trenni/fallback/markup.rl +3 -2
  51. data/lib/trenni/fallback/markup.rl.dot +278 -0
  52. data/lib/trenni/fallback/markup.rl.pdf +0 -0
  53. data/lib/trenni/fallback/query.rb +565 -0
  54. data/lib/trenni/fallback/query.rl +105 -0
  55. data/lib/trenni/fallback/query.rl.dot +54 -0
  56. data/lib/trenni/fallback/query.rl.pdf +0 -0
  57. data/lib/trenni/fallback/template.rb +756 -747
  58. data/lib/trenni/fallback/template.rl +1 -1
  59. data/lib/trenni/fallback/template.rl.dot +270 -0
  60. data/lib/trenni/fallback/template.rl.pdf +0 -0
  61. data/lib/trenni/markup.rb +2 -0
  62. data/lib/trenni/native.rb +3 -1
  63. data/lib/trenni/parse_delegate.rb +2 -0
  64. data/lib/trenni/parsers.rb +2 -0
  65. data/lib/trenni/query.rb +94 -0
  66. data/lib/trenni/reference.rb +125 -0
  67. data/lib/trenni/strings.rb +17 -4
  68. data/lib/trenni/tag.rb +2 -0
  69. data/lib/trenni/template.rb +25 -22
  70. data/lib/trenni/trenni.so +0 -0
  71. data/lib/trenni/uri.rb +3 -0
  72. data/lib/trenni/version.rb +3 -1
  73. data/parsers/trenni/query.rl +23 -0
  74. data/spec/spec_helper.rb +1 -0
  75. data/spec/trenni/builder_spec.rb +14 -1
  76. data/spec/trenni/corpus/large.rb +2 -0
  77. data/spec/trenni/markup_parser_spec.rb +1 -0
  78. data/spec/trenni/markup_performance_spec.rb +15 -2
  79. data/spec/trenni/markup_spec.rb +1 -0
  80. data/spec/trenni/parsers_performance_spec.rb +32 -0
  81. data/spec/trenni/query_spec.rb +51 -0
  82. data/spec/trenni/reference_spec.rb +87 -0
  83. data/spec/trenni/strings_spec.rb +1 -0
  84. data/spec/trenni/tag_spec.rb +2 -0
  85. data/spec/trenni/template_error_spec.rb +1 -0
  86. data/spec/trenni/template_performance_spec.rb +1 -0
  87. data/spec/trenni/template_spec.rb +1 -0
  88. data/spec/trenni/template_spec/builder.trenni +2 -2
  89. data/spec/trenni/uri_spec.rb +1 -0
  90. metadata +95 -62
  91. data/.gitignore +0 -19
  92. data/.rspec +0 -5
  93. data/.simplecov +0 -9
  94. data/.travis.yml +0 -23
  95. data/Gemfile +0 -20
  96. data/README.md +0 -312
  97. data/Rakefile +0 -19
  98. data/benchmark/call_vs_yield.rb +0 -51
  99. data/benchmark/interpolation_vs_concat.rb +0 -29
  100. data/benchmark/io_vs_string.rb +0 -90
  101. data/entities.json +0 -2233
  102. data/tasks/entities.rake +0 -33
  103. data/tasks/parsers.rake +0 -43
  104. data/trenni.gemspec +0 -33
@@ -0,0 +1,6 @@
1
+
2
+ #pragma once
3
+
4
+ #include "trenni.h"
5
+
6
+ VALUE Trenni_Native_parse_query(VALUE self, VALUE string, VALUE delegate);
@@ -0,0 +1,82 @@
1
+
2
+ #include "query.h"
3
+
4
+ %%{
5
+ machine Trenni_query_parser;
6
+
7
+ action string_begin {
8
+ string_token.begin = p;
9
+ }
10
+
11
+ action string_end {
12
+ string_token.end = p;
13
+
14
+ rb_funcall(delegate, id_string, 2, Trenni_Token_string(string_token, encoding), encoded ? Qtrue : Qfalse);
15
+
16
+ encoded = 0;
17
+ }
18
+
19
+ action integer_begin {
20
+ integer_token.begin = p;
21
+ }
22
+
23
+ action integer_end {
24
+ integer_token.end = p;
25
+
26
+ rb_funcall(delegate, id_integer, 1, Trenni_Token_string(integer_token, encoding));
27
+ }
28
+
29
+ action append {
30
+ rb_funcall(delegate, id_append, 0);
31
+ }
32
+
33
+ action value_begin {
34
+ value_token.begin = p;
35
+ }
36
+
37
+ action value_end {
38
+ value_token.end = p;
39
+
40
+ rb_funcall(delegate, id_assign, 2, Trenni_Token_string(value_token, encoding), encoded ? Qtrue : Qfalse);
41
+
42
+ encoded = 0;
43
+ }
44
+
45
+ action pair {
46
+ rb_funcall(delegate, id_pair, 0);
47
+ }
48
+
49
+ action encoded {
50
+ encoded = 1;
51
+ }
52
+
53
+ include query "trenni/query.rl";
54
+
55
+ write data;
56
+ }%%
57
+
58
+ VALUE Trenni_Native_parse_query(VALUE self, VALUE buffer, VALUE delegate) {
59
+ VALUE string = rb_funcall(buffer, id_read, 0);
60
+
61
+ rb_encoding *encoding = rb_enc_get(string);
62
+
63
+ const char *s, *p, *pe, *eof;
64
+ unsigned long cs;
65
+
66
+ Trenni_Token string_token = {0}, integer_token = {0}, value_token = {0};
67
+ unsigned encoded = 0;
68
+
69
+ s = p = RSTRING_PTR(string);
70
+ eof = pe = p + RSTRING_LEN(string);
71
+
72
+ %%{
73
+ write init;
74
+ write exec;
75
+ }%%
76
+
77
+ if (p != eof) {
78
+ Trenni_raise_error("could not parse all input", buffer, p-s);
79
+ }
80
+
81
+ return Qnil;
82
+ }
@@ -73,13 +73,15 @@ static void Trenni_Tag_append_tag_attribute(VALUE buffer, VALUE key, VALUE value
73
73
  }
74
74
  }
75
75
 
76
- struct TagAttributeForeachArg {
76
+ typedef struct {
77
77
  VALUE buffer;
78
78
  VALUE prefix;
79
- };
79
+ } Trenni_Tag_Accumulation;
80
80
 
81
- static int Trenni_Tag_append_tag_attribute_foreach(VALUE key, VALUE value, struct TagAttributeForeachArg * arg) {
82
- Trenni_Tag_append_tag_attribute(arg->buffer, key, value, arg->prefix);
81
+ static int Trenni_Tag_append_tag_attribute_foreach(VALUE key, VALUE value, VALUE _argument) {
82
+ Trenni_Tag_Accumulation * argument = (Trenni_Tag_Accumulation *)_argument;
83
+
84
+ Trenni_Tag_append_tag_attribute(argument->buffer, key, value, argument->prefix);
83
85
 
84
86
  return ST_CONTINUE;
85
87
  }
@@ -88,8 +90,8 @@ VALUE Trenni_Tag_append_attributes(VALUE self, VALUE buffer, VALUE attributes, V
88
90
  int type = rb_type(attributes);
89
91
 
90
92
  if (type == T_HASH) {
91
- struct TagAttributeForeachArg arg = {buffer, prefix};
92
- rb_hash_foreach(attributes, &Trenni_Tag_append_tag_attribute_foreach, (VALUE)&arg);
93
+ Trenni_Tag_Accumulation argument = {buffer, prefix};
94
+ rb_hash_foreach(attributes, &Trenni_Tag_append_tag_attribute_foreach, (VALUE)&argument);
93
95
  } else if (type == T_ARRAY) {
94
96
  long i;
95
97
 
@@ -27,7 +27,7 @@ VALUE Trenni_Native_parse_template(VALUE self, VALUE buffer, VALUE delegate) {
27
27
  const char *s, *p, *pe, *eof, *ts, *te;
28
28
  unsigned long cs, act, top = 0, stack[32] = {0};
29
29
 
30
- Token expression = {0}, instruction = {0};
30
+ Trenni_Token expression = {0}, instruction = {0};
31
31
 
32
32
  s = p = RSTRING_PTR(string);
33
33
  eof = pe = p + RSTRING_LEN(string);
@@ -142,7 +142,7 @@ tr14:
142
142
  { switch( act ) {
143
143
  case 3:
144
144
  {{p = ((te))-1;}
145
- rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
145
+ rb_funcall(delegate, id_instruction, 1, Trenni_Token_string(instruction, encoding));
146
146
  }
147
147
  break;
148
148
  case 6:
@@ -156,7 +156,7 @@ tr14:
156
156
  tr15:
157
157
  #line 19 "template.rl"
158
158
  {te = p+1;{
159
- rb_funcall(delegate, id_instruction, 2, Trenni_token(instruction, encoding), newline);
159
+ rb_funcall(delegate, id_instruction, 2, Trenni_Token_string(instruction, encoding), newline);
160
160
  }}
161
161
  goto st43;
162
162
  tr23:
@@ -183,13 +183,13 @@ tr82:
183
183
  {
184
184
  expression.begin = p;
185
185
  }
186
- #line 53 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
186
+ #line 53 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
187
187
  {te = p;p--;{cs = 32;}}
188
188
  goto _again;
189
189
  tr83:
190
190
  #line 15 "template.rl"
191
191
  {te = p;p--;{
192
- rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
192
+ rb_funcall(delegate, id_instruction, 1, Trenni_Token_string(instruction, encoding));
193
193
  }}
194
194
  goto st43;
195
195
  st43:
@@ -525,8 +525,8 @@ case 48:
525
525
  goto st11;
526
526
  goto tr83;
527
527
  tr31:
528
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
529
- {{stack[top++] = 21; goto st21;}}
528
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
529
+ {{stack[top++] = 21;goto st21;}}
530
530
  goto st21;
531
531
  st21:
532
532
  #line 1 "NONE"
@@ -543,8 +543,8 @@ case 21:
543
543
  }
544
544
  goto st21;
545
545
  tr47:
546
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
547
- {{stack[top++] = 22; goto st21;}}
546
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
547
+ {{stack[top++] = 22;goto st21;}}
548
548
  goto st22;
549
549
  st22:
550
550
  #line 1 "NONE"
@@ -559,14 +559,14 @@ case 22:
559
559
  }
560
560
  goto st22;
561
561
  tr37:
562
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
563
- {{stack[top++] = 23; goto st21;}}
562
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
563
+ {{stack[top++] = 23;goto st21;}}
564
564
  goto st23;
565
565
  tr39:
566
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
567
- {{stack[top++] = 23; goto st21;}}
568
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
569
- {{stack[top++] = 23; goto st21;}}
566
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
567
+ {{stack[top++] = 23;goto st21;}}
568
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
569
+ {{stack[top++] = 23;goto st21;}}
570
570
  goto st23;
571
571
  st23:
572
572
  #line 1 "NONE"
@@ -594,8 +594,8 @@ case 24:
594
594
  }
595
595
  goto st23;
596
596
  tr46:
597
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
598
- {{stack[top++] = 25; goto st21;}}
597
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
598
+ {{stack[top++] = 25;goto st21;}}
599
599
  goto st25;
600
600
  st25:
601
601
  #line 1 "NONE"
@@ -611,14 +611,14 @@ case 25:
611
611
  }
612
612
  goto st25;
613
613
  tr43:
614
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
615
- {{stack[top++] = 26; goto st21;}}
614
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
615
+ {{stack[top++] = 26;goto st21;}}
616
616
  goto st26;
617
617
  tr45:
618
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
619
- {{stack[top++] = 26; goto st21;}}
620
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
621
- {{stack[top++] = 26; goto st21;}}
618
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
619
+ {{stack[top++] = 26;goto st21;}}
620
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
621
+ {{stack[top++] = 26;goto st21;}}
622
622
  goto st26;
623
623
  st26:
624
624
  #line 1 "NONE"
@@ -644,7 +644,7 @@ case 27:
644
644
  }
645
645
  goto st26;
646
646
  tr44:
647
- #line 20 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
647
+ #line 20 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
648
648
  {{cs = stack[--top];goto _again;}}
649
649
  goto st49;
650
650
  st49:
@@ -670,7 +670,7 @@ case 28:
670
670
  }
671
671
  goto st25;
672
672
  tr38:
673
- #line 20 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
673
+ #line 20 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
674
674
  {{cs = stack[--top];goto _again;}}
675
675
  goto st50;
676
676
  st50:
@@ -701,8 +701,8 @@ case 30:
701
701
  goto st31;
702
702
  goto st30;
703
703
  tr49:
704
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
705
- {{stack[top++] = 31; goto st21;}}
704
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
705
+ {{stack[top++] = 31;goto st21;}}
706
706
  goto st31;
707
707
  st31:
708
708
  #line 1 "NONE"
@@ -718,7 +718,7 @@ case 31:
718
718
  }
719
719
  goto st31;
720
720
  tr50:
721
- #line 20 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
721
+ #line 20 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
722
722
  {{cs = stack[--top];goto _again;}}
723
723
  goto st51;
724
724
  st51:
@@ -730,7 +730,7 @@ case 51:
730
730
  goto st31;
731
731
  goto st30;
732
732
  tr32:
733
- #line 20 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
733
+ #line 20 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
734
734
  {{cs = stack[--top];goto _again;}}
735
735
  goto st52;
736
736
  st52:
@@ -740,8 +740,8 @@ case 52:
740
740
  #line 741 "template.c"
741
741
  goto st0;
742
742
  tr54:
743
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
744
- {{stack[top++] = 32; goto st21;}}
743
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
744
+ {{stack[top++] = 32;goto st21;}}
745
745
  goto st32;
746
746
  st32:
747
747
  #line 1 "NONE"
@@ -758,8 +758,8 @@ case 32:
758
758
  }
759
759
  goto st32;
760
760
  tr70:
761
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
762
- {{stack[top++] = 33; goto st21;}}
761
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
762
+ {{stack[top++] = 33;goto st21;}}
763
763
  goto st33;
764
764
  st33:
765
765
  #line 1 "NONE"
@@ -774,14 +774,14 @@ case 33:
774
774
  }
775
775
  goto st33;
776
776
  tr60:
777
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
778
- {{stack[top++] = 34; goto st21;}}
777
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
778
+ {{stack[top++] = 34;goto st21;}}
779
779
  goto st34;
780
780
  tr62:
781
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
782
- {{stack[top++] = 34; goto st21;}}
783
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
784
- {{stack[top++] = 34; goto st21;}}
781
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
782
+ {{stack[top++] = 34;goto st21;}}
783
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
784
+ {{stack[top++] = 34;goto st21;}}
785
785
  goto st34;
786
786
  st34:
787
787
  #line 1 "NONE"
@@ -809,8 +809,8 @@ case 35:
809
809
  }
810
810
  goto st34;
811
811
  tr69:
812
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
813
- {{stack[top++] = 36; goto st21;}}
812
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
813
+ {{stack[top++] = 36;goto st21;}}
814
814
  goto st36;
815
815
  st36:
816
816
  #line 1 "NONE"
@@ -826,14 +826,14 @@ case 36:
826
826
  }
827
827
  goto st36;
828
828
  tr66:
829
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
830
- {{stack[top++] = 37; goto st21;}}
829
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
830
+ {{stack[top++] = 37;goto st21;}}
831
831
  goto st37;
832
832
  tr68:
833
- #line 13 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
834
- {{stack[top++] = 37; goto st21;}}
835
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
836
- {{stack[top++] = 37; goto st21;}}
833
+ #line 13 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
834
+ {{stack[top++] = 37;goto st21;}}
835
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
836
+ {{stack[top++] = 37;goto st21;}}
837
837
  goto st37;
838
838
  st37:
839
839
  #line 1 "NONE"
@@ -866,9 +866,9 @@ tr67:
866
866
  }
867
867
  #line 35 "template.rl"
868
868
  {
869
- rb_funcall(delegate, id_expression, 1, Trenni_token(expression, encoding));
869
+ rb_funcall(delegate, id_expression, 1, Trenni_Token_string(expression, encoding));
870
870
  }
871
- #line 21 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
871
+ #line 21 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
872
872
  {cs = 43;}
873
873
  goto _again;
874
874
  st53:
@@ -901,9 +901,9 @@ tr61:
901
901
  }
902
902
  #line 35 "template.rl"
903
903
  {
904
- rb_funcall(delegate, id_expression, 1, Trenni_token(expression, encoding));
904
+ rb_funcall(delegate, id_expression, 1, Trenni_Token_string(expression, encoding));
905
905
  }
906
- #line 21 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
906
+ #line 21 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
907
907
  {cs = 43;}
908
908
  goto _again;
909
909
  st54:
@@ -934,8 +934,8 @@ case 41:
934
934
  goto st42;
935
935
  goto st41;
936
936
  tr72:
937
- #line 17 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
938
- {{stack[top++] = 42; goto st21;}}
937
+ #line 17 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
938
+ {{stack[top++] = 42;goto st21;}}
939
939
  goto st42;
940
940
  st42:
941
941
  #line 1 "NONE"
@@ -958,9 +958,9 @@ tr73:
958
958
  }
959
959
  #line 35 "template.rl"
960
960
  {
961
- rb_funcall(delegate, id_expression, 1, Trenni_token(expression, encoding));
961
+ rb_funcall(delegate, id_expression, 1, Trenni_Token_string(expression, encoding));
962
962
  }
963
- #line 21 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
963
+ #line 21 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
964
964
  {cs = 43;}
965
965
  goto _again;
966
966
  st55:
@@ -979,9 +979,9 @@ tr55:
979
979
  }
980
980
  #line 35 "template.rl"
981
981
  {
982
- rb_funcall(delegate, id_expression, 1, Trenni_token(expression, encoding));
982
+ rb_funcall(delegate, id_expression, 1, Trenni_Token_string(expression, encoding));
983
983
  }
984
- #line 21 "/Users/samuel/Documents/Programming/ioquatix/trenni/parsers/trenni/template.rl"
984
+ #line 21 "/home/samuel/Documents/ioquatix/trenni/parsers/trenni/template.rl"
985
985
  {cs = 43;}
986
986
  goto _again;
987
987
  st56:
@@ -13,11 +13,11 @@
13
13
  }
14
14
 
15
15
  action emit_instruction {
16
- rb_funcall(delegate, id_instruction, 1, Trenni_token(instruction, encoding));
16
+ rb_funcall(delegate, id_instruction, 1, Trenni_Token_string(instruction, encoding));
17
17
  }
18
18
 
19
19
  action emit_instruction_line {
20
- rb_funcall(delegate, id_instruction, 2, Trenni_token(instruction, encoding), newline);
20
+ rb_funcall(delegate, id_instruction, 2, Trenni_Token_string(instruction, encoding), newline);
21
21
  }
22
22
 
23
23
  action instruction_error {
@@ -33,7 +33,7 @@
33
33
  }
34
34
 
35
35
  action emit_expression {
36
- rb_funcall(delegate, id_expression, 1, Trenni_token(expression, encoding));
36
+ rb_funcall(delegate, id_expression, 1, Trenni_Token_string(expression, encoding));
37
37
  }
38
38
 
39
39
  action expression_error {
@@ -59,7 +59,7 @@ VALUE Trenni_Native_parse_template(VALUE self, VALUE buffer, VALUE delegate) {
59
59
  const char *s, *p, *pe, *eof, *ts, *te;
60
60
  unsigned long cs, act, top = 0, stack[32] = {0};
61
61
 
62
- Token expression = {0}, instruction = {0};
62
+ Trenni_Token expression = {0}, instruction = {0};
63
63
 
64
64
  s = p = RSTRING_PTR(string);
65
65
  eof = pe = p + RSTRING_LEN(string);
@@ -3,11 +3,12 @@
3
3
 
4
4
  #include "markup.h"
5
5
  #include "template.h"
6
+ #include "query.h"
6
7
  #include "tag.h"
7
8
  #include "escape.h"
8
9
 
9
10
  VALUE rb_Trenni = Qnil, rb_Trenni_Native = Qnil, rb_Trenni_Tag = Qnil, rb_Trenni_Markup = Qnil, rb_Trenni_MarkupString = Qnil, rb_Trenni_ParseError = Qnil;
10
- ID id_cdata, id_open_tag_begin, id_open_tag_end, id_attribute, id_close_tag, id_text, id_doctype, id_comment, id_instruction, id_read, id_expression, id_key_get, id_new, id_name, id_attributes, id_closed, id_to_s, id_is_a;
11
+ ID id_cdata, id_open_tag_begin, id_open_tag_end, id_attribute, id_close_tag, id_text, id_doctype, id_comment, id_instruction, id_read, id_expression, id_key_get, id_string, id_integer, id_append, id_assign, id_pair, id_new, id_name, id_attributes, id_closed, id_to_s, id_is_a;
11
12
 
12
13
  void Trenni_raise_error(const char * message, VALUE buffer, size_t offset) {
13
14
  VALUE exception = rb_funcall(rb_Trenni_ParseError, id_new, 3, rb_str_new_cstr(message), buffer, ULONG2NUM(offset));
@@ -37,6 +38,12 @@ void Init_trenni() {
37
38
 
38
39
  id_key_get = rb_intern("[]");
39
40
 
41
+ id_string = rb_intern("string");
42
+ id_integer = rb_intern("integer");
43
+ id_append = rb_intern("append");
44
+ id_assign = rb_intern("assign");
45
+ id_pair = rb_intern("pair");
46
+
40
47
  id_to_s = rb_intern("to_s");
41
48
  id_is_a = rb_intern("is_a?");
42
49
 
@@ -50,6 +57,7 @@ void Init_trenni() {
50
57
 
51
58
  rb_define_module_function(rb_Trenni_Native, "parse_markup", Trenni_Native_parse_markup, 3);
52
59
  rb_define_module_function(rb_Trenni_Native, "parse_template", Trenni_Native_parse_template, 2);
60
+ rb_define_module_function(rb_Trenni_Native, "parse_query", Trenni_Native_parse_query, 2);
53
61
 
54
62
  rb_Trenni_Tag = rb_const_get_at(rb_Trenni, rb_intern("Tag"));
55
63