xrb 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/xrb/template.c +944 -667
- data/ext/xrb/template.rl +44 -5
- data/lib/xrb/fallback/markup.rb +24 -25
- data/lib/xrb/fallback/markup.rl +3 -2
- data/lib/xrb/fallback/query.rb +0 -2
- data/lib/xrb/fallback/template.rb +715 -393
- data/lib/xrb/fallback/template.rl +35 -1
- data/lib/xrb/template.rb +1 -3
- data/lib/xrb/version.rb +1 -1
- data/notes.md +0 -0
- data.tar.gz.sig +0 -0
- metadata +3 -12
- metadata.gz.sig +0 -0
- data/ext/Makefile +0 -270
- data/ext/XRB_Extension.bundle +0 -0
- data/ext/escape.o +0 -0
- data/ext/extconf.h +0 -5
- data/ext/markup.o +0 -0
- data/ext/mkmf.log +0 -69
- data/ext/query.o +0 -0
- data/ext/tag.o +0 -0
- data/ext/template.o +0 -0
- data/ext/xrb.o +0 -0
data/ext/xrb/template.rl
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
rb_funcall(delegate, id_instruction, 1, XRB_Token_string(instruction, encoding));
|
17
17
|
}
|
18
18
|
|
19
|
-
action
|
19
|
+
action emit_multiline_instruction {
|
20
20
|
rb_funcall(delegate, id_instruction, 2, XRB_Token_string(instruction, encoding), newline);
|
21
21
|
}
|
22
22
|
|
@@ -33,15 +33,54 @@
|
|
33
33
|
}
|
34
34
|
|
35
35
|
action emit_expression {
|
36
|
-
|
36
|
+
if (expression.end > expression.begin) {
|
37
|
+
rb_funcall(delegate, id_expression, 1, XRB_Token_string(expression, encoding));
|
38
|
+
}
|
37
39
|
}
|
38
40
|
|
39
41
|
action expression_error {
|
40
42
|
XRB_raise_error("failed to parse expression", buffer, p-s);
|
41
43
|
}
|
42
44
|
|
45
|
+
action text_begin {
|
46
|
+
text.begin = p;
|
47
|
+
|
48
|
+
delimiter.begin = NULL;
|
49
|
+
delimiter.end = NULL;
|
50
|
+
}
|
51
|
+
|
52
|
+
action text_end {
|
53
|
+
text.end = p;
|
54
|
+
}
|
55
|
+
|
56
|
+
action text_delimiter_begin {
|
57
|
+
delimiter.begin = p;
|
58
|
+
}
|
59
|
+
|
60
|
+
action text_delimiter_end {
|
61
|
+
delimiter.end = p;
|
62
|
+
}
|
63
|
+
|
43
64
|
action emit_text {
|
44
|
-
|
65
|
+
if (delimiter.begin && delimiter.end) {
|
66
|
+
text.end = delimiter.begin;
|
67
|
+
|
68
|
+
// Backtrack:
|
69
|
+
p = delimiter.begin - 1;
|
70
|
+
}
|
71
|
+
|
72
|
+
rb_funcall(delegate, id_text, 1, XRB_Token_string(text, encoding));
|
73
|
+
}
|
74
|
+
|
75
|
+
action emit_multiline_text {
|
76
|
+
text.begin = ts;
|
77
|
+
text.end = te;
|
78
|
+
|
79
|
+
rb_funcall(delegate, id_text, 1, XRB_Token_string(text, encoding));
|
80
|
+
}
|
81
|
+
|
82
|
+
action emit_newline {
|
83
|
+
rb_funcall(delegate, id_instruction, 1, newline);
|
45
84
|
}
|
46
85
|
|
47
86
|
include template "xrb/template.rl";
|
@@ -57,9 +96,9 @@ VALUE XRB_Native_parse_template(VALUE self, VALUE buffer, VALUE delegate) {
|
|
57
96
|
VALUE newline = rb_obj_freeze(rb_enc_str_new("\n", 1, encoding));
|
58
97
|
|
59
98
|
const char *s, *p, *pe, *eof, *ts, *te;
|
60
|
-
unsigned long cs,
|
99
|
+
unsigned long cs, top = 0, stack[32] = {0}, act;
|
61
100
|
|
62
|
-
XRB_Token expression = {0}, instruction = {0};
|
101
|
+
XRB_Token expression = {0}, instruction = {0}, text = {0}, delimiter = {0};
|
63
102
|
|
64
103
|
s = p = RSTRING_PTR(string);
|
65
104
|
eof = pe = p + RSTRING_LEN(string);
|
data/lib/xrb/fallback/markup.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# Released under the MIT License.
|
3
|
-
# Copyright, 2016-2024, by Samuel Williams.
|
4
2
|
|
5
3
|
# line 1 "lib/xrb/fallback/markup.rl"
|
6
4
|
# Released under the MIT License.
|
@@ -423,6 +421,7 @@ module XRB
|
|
423
421
|
def self.parse_markup(buffer, delegate, entities)
|
424
422
|
data = buffer.read
|
425
423
|
bytes = data.bytes
|
424
|
+
encoding = data.encoding
|
426
425
|
|
427
426
|
p = 0
|
428
427
|
# Must set pe here or it gets incorrectly set to data.length
|
@@ -440,7 +439,7 @@ module XRB
|
|
440
439
|
has_entities = has_value = false
|
441
440
|
|
442
441
|
|
443
|
-
# line
|
442
|
+
# line 442 "lib/xrb/fallback/markup.rb"
|
444
443
|
begin
|
445
444
|
p ||= 0
|
446
445
|
pe ||= data.length
|
@@ -448,9 +447,9 @@ module XRB
|
|
448
447
|
top = 0
|
449
448
|
end
|
450
449
|
|
451
|
-
# line
|
450
|
+
# line 219 "lib/xrb/fallback/markup.rl"
|
452
451
|
|
453
|
-
# line
|
452
|
+
# line 452 "lib/xrb/fallback/markup.rb"
|
454
453
|
begin
|
455
454
|
testEof = false
|
456
455
|
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
@@ -602,7 +601,7 @@ module XRB
|
|
602
601
|
# line 15 "lib/xrb/fallback/markup.rl"
|
603
602
|
begin
|
604
603
|
|
605
|
-
pcdata =
|
604
|
+
pcdata = String.new(encoding: encoding)
|
606
605
|
has_entities = false
|
607
606
|
end
|
608
607
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -614,7 +613,7 @@ module XRB
|
|
614
613
|
# line 15 "lib/xrb/fallback/markup.rl"
|
615
614
|
begin
|
616
615
|
|
617
|
-
pcdata =
|
616
|
+
pcdata = String.new(encoding: encoding)
|
618
617
|
has_entities = false
|
619
618
|
end
|
620
619
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -718,7 +717,7 @@ module XRB
|
|
718
717
|
begin
|
719
718
|
|
720
719
|
has_value = false
|
721
|
-
pcdata =
|
720
|
+
pcdata = String.new(encoding: encoding)
|
722
721
|
end
|
723
722
|
# line 7 "lib/xrb/fallback/markup.rl"
|
724
723
|
begin
|
@@ -813,7 +812,7 @@ module XRB
|
|
813
812
|
# line 15 "lib/xrb/fallback/markup.rl"
|
814
813
|
begin
|
815
814
|
|
816
|
-
pcdata =
|
815
|
+
pcdata = String.new(encoding: encoding)
|
817
816
|
has_entities = false
|
818
817
|
end
|
819
818
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -829,7 +828,7 @@ module XRB
|
|
829
828
|
# line 15 "lib/xrb/fallback/markup.rl"
|
830
829
|
begin
|
831
830
|
|
832
|
-
pcdata =
|
831
|
+
pcdata = String.new(encoding: encoding)
|
833
832
|
has_entities = false
|
834
833
|
end
|
835
834
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -905,7 +904,7 @@ module XRB
|
|
905
904
|
# line 15 "lib/xrb/fallback/markup.rl"
|
906
905
|
begin
|
907
906
|
|
908
|
-
pcdata =
|
907
|
+
pcdata = String.new(encoding: encoding)
|
909
908
|
has_entities = false
|
910
909
|
end
|
911
910
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -928,7 +927,7 @@ module XRB
|
|
928
927
|
# line 15 "lib/xrb/fallback/markup.rl"
|
929
928
|
begin
|
930
929
|
|
931
|
-
pcdata =
|
930
|
+
pcdata = String.new(encoding: encoding)
|
932
931
|
has_entities = false
|
933
932
|
end
|
934
933
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -956,7 +955,7 @@ module XRB
|
|
956
955
|
# line 15 "lib/xrb/fallback/markup.rl"
|
957
956
|
begin
|
958
957
|
|
959
|
-
pcdata =
|
958
|
+
pcdata = String.new(encoding: encoding)
|
960
959
|
has_entities = false
|
961
960
|
end
|
962
961
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -979,7 +978,7 @@ module XRB
|
|
979
978
|
# line 15 "lib/xrb/fallback/markup.rl"
|
980
979
|
begin
|
981
980
|
|
982
|
-
pcdata =
|
981
|
+
pcdata = String.new(encoding: encoding)
|
983
982
|
has_entities = false
|
984
983
|
end
|
985
984
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -1005,7 +1004,7 @@ module XRB
|
|
1005
1004
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1006
1005
|
begin
|
1007
1006
|
|
1008
|
-
pcdata =
|
1007
|
+
pcdata = String.new(encoding: encoding)
|
1009
1008
|
has_entities = false
|
1010
1009
|
end
|
1011
1010
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -1026,7 +1025,7 @@ module XRB
|
|
1026
1025
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1027
1026
|
begin
|
1028
1027
|
|
1029
|
-
pcdata =
|
1028
|
+
pcdata = String.new(encoding: encoding)
|
1030
1029
|
has_entities = false
|
1031
1030
|
end
|
1032
1031
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -1052,7 +1051,7 @@ module XRB
|
|
1052
1051
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1053
1052
|
begin
|
1054
1053
|
|
1055
|
-
pcdata =
|
1054
|
+
pcdata = String.new(encoding: encoding)
|
1056
1055
|
has_entities = false
|
1057
1056
|
end
|
1058
1057
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -1073,7 +1072,7 @@ module XRB
|
|
1073
1072
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1074
1073
|
begin
|
1075
1074
|
|
1076
|
-
pcdata =
|
1075
|
+
pcdata = String.new(encoding: encoding)
|
1077
1076
|
has_entities = false
|
1078
1077
|
end
|
1079
1078
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -1099,7 +1098,7 @@ module XRB
|
|
1099
1098
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1100
1099
|
begin
|
1101
1100
|
|
1102
|
-
pcdata =
|
1101
|
+
pcdata = String.new(encoding: encoding)
|
1103
1102
|
has_entities = false
|
1104
1103
|
end
|
1105
1104
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -1120,7 +1119,7 @@ module XRB
|
|
1120
1119
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1121
1120
|
begin
|
1122
1121
|
|
1123
|
-
pcdata =
|
1122
|
+
pcdata = String.new(encoding: encoding)
|
1124
1123
|
has_entities = false
|
1125
1124
|
end
|
1126
1125
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -1148,7 +1147,7 @@ module XRB
|
|
1148
1147
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1149
1148
|
begin
|
1150
1149
|
|
1151
|
-
pcdata =
|
1150
|
+
pcdata = String.new(encoding: encoding)
|
1152
1151
|
has_entities = false
|
1153
1152
|
end
|
1154
1153
|
# line 32 "lib/xrb/fallback/markup.rl"
|
@@ -1171,7 +1170,7 @@ module XRB
|
|
1171
1170
|
# line 15 "lib/xrb/fallback/markup.rl"
|
1172
1171
|
begin
|
1173
1172
|
|
1174
|
-
pcdata =
|
1173
|
+
pcdata = String.new(encoding: encoding)
|
1175
1174
|
has_entities = false
|
1176
1175
|
end
|
1177
1176
|
# line 10 "parsers/xrb/entities.rl"
|
@@ -1510,7 +1509,7 @@ module XRB
|
|
1510
1509
|
|
1511
1510
|
cdata_begin = p
|
1512
1511
|
end
|
1513
|
-
# line
|
1512
|
+
# line 1512 "lib/xrb/fallback/markup.rb"
|
1514
1513
|
end
|
1515
1514
|
end
|
1516
1515
|
end
|
@@ -1637,7 +1636,7 @@ module XRB
|
|
1637
1636
|
|
1638
1637
|
delegate.text(pcdata)
|
1639
1638
|
end
|
1640
|
-
# line
|
1639
|
+
# line 1639 "lib/xrb/fallback/markup.rb"
|
1641
1640
|
end
|
1642
1641
|
end
|
1643
1642
|
|
@@ -1648,7 +1647,7 @@ module XRB
|
|
1648
1647
|
end
|
1649
1648
|
end
|
1650
1649
|
|
1651
|
-
# line
|
1650
|
+
# line 220 "lib/xrb/fallback/markup.rl"
|
1652
1651
|
|
1653
1652
|
if p != eof
|
1654
1653
|
raise ParseError.new("could not consume all input", buffer, p)
|
data/lib/xrb/fallback/markup.rl
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
}
|
14
14
|
|
15
15
|
action pcdata_begin {
|
16
|
-
pcdata =
|
16
|
+
pcdata = String.new(encoding: encoding)
|
17
17
|
has_entities = false
|
18
18
|
}
|
19
19
|
|
@@ -131,7 +131,7 @@
|
|
131
131
|
|
132
132
|
action attribute_begin {
|
133
133
|
has_value = false
|
134
|
-
pcdata =
|
134
|
+
pcdata = String.new(encoding: encoding)
|
135
135
|
}
|
136
136
|
|
137
137
|
action attribute_value {
|
@@ -198,6 +198,7 @@ module XRB
|
|
198
198
|
def self.parse_markup(buffer, delegate, entities)
|
199
199
|
data = buffer.read
|
200
200
|
bytes = data.bytes
|
201
|
+
encoding = data.encoding
|
201
202
|
|
202
203
|
p = 0
|
203
204
|
# Must set pe here or it gets incorrectly set to data.length
|