hpricot 0.8.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +88 -0
- data/COPYING +18 -0
- data/README +275 -0
- data/Rakefile +272 -0
- data/ext/fast_xs/FastXsService.java +1030 -0
- data/ext/fast_xs/extconf.rb +4 -0
- data/ext/fast_xs/fast_xs.c +201 -0
- data/ext/hpricot_scan/HpricotCss.java +831 -0
- data/ext/hpricot_scan/HpricotScanService.java +2086 -0
- data/ext/hpricot_scan/extconf.rb +6 -0
- data/ext/hpricot_scan/hpricot_common.rl +76 -0
- data/ext/hpricot_scan/hpricot_css.c +3503 -0
- data/ext/hpricot_scan/hpricot_css.java.rl +155 -0
- data/ext/hpricot_scan/hpricot_css.rl +115 -0
- data/ext/hpricot_scan/hpricot_scan.c +6927 -0
- data/ext/hpricot_scan/hpricot_scan.h +79 -0
- data/ext/hpricot_scan/hpricot_scan.java.rl +1152 -0
- data/ext/hpricot_scan/hpricot_scan.rl +788 -0
- data/extras/mingw-rbconfig.rb +176 -0
- data/lib/fast_xs.jar +0 -0
- data/lib/hpricot.rb +26 -0
- data/lib/hpricot/blankslate.rb +63 -0
- data/lib/hpricot/builder.rb +216 -0
- data/lib/hpricot/elements.rb +510 -0
- data/lib/hpricot/htmlinfo.rb +691 -0
- data/lib/hpricot/inspect.rb +103 -0
- data/lib/hpricot/modules.rb +40 -0
- data/lib/hpricot/parse.rb +38 -0
- data/lib/hpricot/tag.rb +219 -0
- data/lib/hpricot/tags.rb +164 -0
- data/lib/hpricot/traverse.rb +839 -0
- data/lib/hpricot/xchar.rb +94 -0
- data/lib/hpricot_scan.jar +0 -0
- data/test/files/basic.xhtml +17 -0
- data/test/files/boingboing.html +2266 -0
- data/test/files/cy0.html +3653 -0
- data/test/files/immob.html +400 -0
- data/test/files/pace_application.html +1320 -0
- data/test/files/tenderlove.html +16 -0
- data/test/files/uswebgen.html +220 -0
- data/test/files/utf8.html +1054 -0
- data/test/files/week9.html +1723 -0
- data/test/files/why.xml +19 -0
- data/test/load_files.rb +7 -0
- data/test/nokogiri-bench.rb +64 -0
- data/test/test_alter.rb +96 -0
- data/test/test_builder.rb +37 -0
- data/test/test_parser.rb +428 -0
- data/test/test_paths.rb +25 -0
- data/test/test_preserved.rb +88 -0
- data/test/test_xml.rb +28 -0
- metadata +112 -0
@@ -0,0 +1,2086 @@
|
|
1
|
+
// line 1 "hpricot_scan.java.rl"
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
|
5
|
+
import org.jruby.Ruby;
|
6
|
+
import org.jruby.RubyArray;
|
7
|
+
import org.jruby.RubyClass;
|
8
|
+
import org.jruby.RubyHash;
|
9
|
+
import org.jruby.RubyModule;
|
10
|
+
import org.jruby.RubyNumeric;
|
11
|
+
import org.jruby.RubyObject;
|
12
|
+
import org.jruby.RubyObjectAdapter;
|
13
|
+
import org.jruby.RubyRegexp;
|
14
|
+
import org.jruby.RubyString;
|
15
|
+
import org.jruby.anno.JRubyMethod;
|
16
|
+
import org.jruby.exceptions.RaiseException;
|
17
|
+
import org.jruby.javasupport.JavaEmbedUtils;
|
18
|
+
import org.jruby.runtime.Arity;
|
19
|
+
import org.jruby.runtime.Block;
|
20
|
+
import org.jruby.runtime.ObjectAllocator;
|
21
|
+
import org.jruby.runtime.ThreadContext;
|
22
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
23
|
+
import org.jruby.runtime.callback.Callback;
|
24
|
+
import org.jruby.exceptions.RaiseException;
|
25
|
+
import org.jruby.runtime.load.BasicLibraryService;
|
26
|
+
import org.jruby.util.ByteList;
|
27
|
+
|
28
|
+
public class HpricotScanService implements BasicLibraryService {
|
29
|
+
public static byte[] realloc(byte[] input, int size) {
|
30
|
+
byte[] newArray = new byte[size];
|
31
|
+
System.arraycopy(input, 0, newArray, 0, input.length);
|
32
|
+
return newArray;
|
33
|
+
}
|
34
|
+
|
35
|
+
// hpricot_state
|
36
|
+
public static class State {
|
37
|
+
public IRubyObject doc;
|
38
|
+
public IRubyObject focus;
|
39
|
+
public IRubyObject last;
|
40
|
+
public IRubyObject EC;
|
41
|
+
public boolean xml, strict, fixup;
|
42
|
+
}
|
43
|
+
|
44
|
+
static boolean OPT(IRubyObject opts, String key) {
|
45
|
+
Ruby runtime = opts.getRuntime();
|
46
|
+
return !opts.isNil() && ((RubyHash)opts).op_aref(runtime.getCurrentContext(), runtime.newSymbol(key)).isTrue();
|
47
|
+
}
|
48
|
+
|
49
|
+
// H_PROP(name, H_ELE_TAG)
|
50
|
+
public static IRubyObject hpricot_ele_set_name(IRubyObject self, IRubyObject x) {
|
51
|
+
H_ELE_SET(self, H_ELE_TAG, x);
|
52
|
+
return self;
|
53
|
+
}
|
54
|
+
|
55
|
+
public static IRubyObject hpricot_ele_clear_name(IRubyObject self) {
|
56
|
+
H_ELE_SET(self, H_ELE_TAG, self.getRuntime().getNil());
|
57
|
+
return self.getRuntime().getTrue();
|
58
|
+
}
|
59
|
+
|
60
|
+
public static IRubyObject hpricot_ele_get_name(IRubyObject self) {
|
61
|
+
return H_ELE_GET(self, H_ELE_TAG);
|
62
|
+
}
|
63
|
+
|
64
|
+
// H_PROP(raw, H_ELE_RAW)
|
65
|
+
public static IRubyObject hpricot_ele_set_raw(IRubyObject self, IRubyObject x) {
|
66
|
+
H_ELE_SET(self, H_ELE_RAW, x);
|
67
|
+
return self;
|
68
|
+
}
|
69
|
+
|
70
|
+
public static IRubyObject hpricot_ele_clear_raw(IRubyObject self) {
|
71
|
+
H_ELE_SET(self, H_ELE_RAW, self.getRuntime().getNil());
|
72
|
+
return self.getRuntime().getTrue();
|
73
|
+
}
|
74
|
+
|
75
|
+
public static IRubyObject hpricot_ele_get_raw(IRubyObject self) {
|
76
|
+
return H_ELE_GET(self, H_ELE_RAW);
|
77
|
+
}
|
78
|
+
|
79
|
+
// H_PROP(parent, H_ELE_PARENT)
|
80
|
+
public static IRubyObject hpricot_ele_set_parent(IRubyObject self, IRubyObject x) {
|
81
|
+
H_ELE_SET(self, H_ELE_PARENT, x);
|
82
|
+
return self;
|
83
|
+
}
|
84
|
+
|
85
|
+
public static IRubyObject hpricot_ele_clear_parent(IRubyObject self) {
|
86
|
+
H_ELE_SET(self, H_ELE_PARENT, self.getRuntime().getNil());
|
87
|
+
return self.getRuntime().getTrue();
|
88
|
+
}
|
89
|
+
|
90
|
+
public static IRubyObject hpricot_ele_get_parent(IRubyObject self) {
|
91
|
+
return H_ELE_GET(self, H_ELE_PARENT);
|
92
|
+
}
|
93
|
+
|
94
|
+
// H_PROP(attr, H_ELE_ATTR)
|
95
|
+
public static IRubyObject hpricot_ele_set_attr(IRubyObject self, IRubyObject x) {
|
96
|
+
H_ELE_SET(self, H_ELE_ATTR, x);
|
97
|
+
return self;
|
98
|
+
}
|
99
|
+
|
100
|
+
public static IRubyObject hpricot_ele_clear_attr(IRubyObject self) {
|
101
|
+
H_ELE_SET(self, H_ELE_ATTR, self.getRuntime().getNil());
|
102
|
+
return self.getRuntime().getTrue();
|
103
|
+
}
|
104
|
+
|
105
|
+
public static IRubyObject hpricot_ele_get_attr(IRubyObject self) {
|
106
|
+
return H_ELE_GET(self, H_ELE_ATTR);
|
107
|
+
}
|
108
|
+
|
109
|
+
// H_PROP(etag, H_ELE_ETAG)
|
110
|
+
public static IRubyObject hpricot_ele_set_etag(IRubyObject self, IRubyObject x) {
|
111
|
+
H_ELE_SET(self, H_ELE_ETAG, x);
|
112
|
+
return self;
|
113
|
+
}
|
114
|
+
|
115
|
+
public static IRubyObject hpricot_ele_clear_etag(IRubyObject self) {
|
116
|
+
H_ELE_SET(self, H_ELE_ETAG, self.getRuntime().getNil());
|
117
|
+
return self.getRuntime().getTrue();
|
118
|
+
}
|
119
|
+
|
120
|
+
public static IRubyObject hpricot_ele_get_etag(IRubyObject self) {
|
121
|
+
return H_ELE_GET(self, H_ELE_ETAG);
|
122
|
+
}
|
123
|
+
|
124
|
+
// H_PROP(children, H_ELE_CHILDREN)
|
125
|
+
public static IRubyObject hpricot_ele_set_children(IRubyObject self, IRubyObject x) {
|
126
|
+
H_ELE_SET(self, H_ELE_CHILDREN, x);
|
127
|
+
return self;
|
128
|
+
}
|
129
|
+
|
130
|
+
public static IRubyObject hpricot_ele_clear_children(IRubyObject self) {
|
131
|
+
H_ELE_SET(self, H_ELE_CHILDREN, self.getRuntime().getNil());
|
132
|
+
return self.getRuntime().getTrue();
|
133
|
+
}
|
134
|
+
|
135
|
+
public static IRubyObject hpricot_ele_get_children(IRubyObject self) {
|
136
|
+
return H_ELE_GET(self, H_ELE_CHILDREN);
|
137
|
+
}
|
138
|
+
|
139
|
+
// H_ATTR(target)
|
140
|
+
public static IRubyObject hpricot_ele_set_target(IRubyObject self, IRubyObject x) {
|
141
|
+
((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("target"), x);
|
142
|
+
return self;
|
143
|
+
}
|
144
|
+
|
145
|
+
public static IRubyObject hpricot_ele_get_target(IRubyObject self) {
|
146
|
+
return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("target"));
|
147
|
+
}
|
148
|
+
|
149
|
+
// H_ATTR(encoding)
|
150
|
+
public static IRubyObject hpricot_ele_set_encoding(IRubyObject self, IRubyObject x) {
|
151
|
+
((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("encoding"), x);
|
152
|
+
return self;
|
153
|
+
}
|
154
|
+
|
155
|
+
public static IRubyObject hpricot_ele_get_encoding(IRubyObject self) {
|
156
|
+
return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("encoding"));
|
157
|
+
}
|
158
|
+
|
159
|
+
// H_ATTR(version)
|
160
|
+
public static IRubyObject hpricot_ele_set_version(IRubyObject self, IRubyObject x) {
|
161
|
+
((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("version"), x);
|
162
|
+
return self;
|
163
|
+
}
|
164
|
+
|
165
|
+
public static IRubyObject hpricot_ele_get_version(IRubyObject self) {
|
166
|
+
return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("version"));
|
167
|
+
}
|
168
|
+
|
169
|
+
// H_ATTR(standalone)
|
170
|
+
public static IRubyObject hpricot_ele_set_standalone(IRubyObject self, IRubyObject x) {
|
171
|
+
((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("standalone"), x);
|
172
|
+
return self;
|
173
|
+
}
|
174
|
+
|
175
|
+
public static IRubyObject hpricot_ele_get_standalone(IRubyObject self) {
|
176
|
+
return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("standalone"));
|
177
|
+
}
|
178
|
+
|
179
|
+
// H_ATTR(system_id)
|
180
|
+
public static IRubyObject hpricot_ele_set_system_id(IRubyObject self, IRubyObject x) {
|
181
|
+
((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("system_id"), x);
|
182
|
+
return self;
|
183
|
+
}
|
184
|
+
|
185
|
+
public static IRubyObject hpricot_ele_get_system_id(IRubyObject self) {
|
186
|
+
return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("system_id"));
|
187
|
+
}
|
188
|
+
|
189
|
+
// H_ATTR(public_id)
|
190
|
+
public static IRubyObject hpricot_ele_set_public_id(IRubyObject self, IRubyObject x) {
|
191
|
+
((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("public_id"), x);
|
192
|
+
return self;
|
193
|
+
}
|
194
|
+
|
195
|
+
public static IRubyObject hpricot_ele_get_public_id(IRubyObject self) {
|
196
|
+
return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("public_id"));
|
197
|
+
}
|
198
|
+
|
199
|
+
public static class Scanner {
|
200
|
+
public IRubyObject SET(int mark, int E, IRubyObject org) {
|
201
|
+
if(mark == -1 || E == mark) {
|
202
|
+
return runtime.newString("");
|
203
|
+
} else if(E > mark) {
|
204
|
+
return RubyString.newString(runtime, data, mark, E-mark);
|
205
|
+
} else {
|
206
|
+
return org;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
public int SLIDE(int N) {
|
211
|
+
if(N > ts) {
|
212
|
+
return N - ts;
|
213
|
+
} else {
|
214
|
+
return N;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
public IRubyObject CAT(IRubyObject N, int mark, int E) {
|
219
|
+
if(N.isNil()) {
|
220
|
+
return SET(mark, E, N);
|
221
|
+
} else {
|
222
|
+
((RubyString)N).cat(data, mark, E-mark);
|
223
|
+
return N;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
public void ATTR(IRubyObject K, IRubyObject V) {
|
228
|
+
if(!K.isNil()) {
|
229
|
+
if(attr.isNil()) {
|
230
|
+
attr = RubyHash.newHash(runtime);
|
231
|
+
}
|
232
|
+
((RubyHash)attr).fastASet(K, V);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
public void TEXT_PASS() {
|
237
|
+
if(!text) {
|
238
|
+
if(ele_open) {
|
239
|
+
ele_open = false;
|
240
|
+
if(ts != -1) {
|
241
|
+
mark_tag = ts;
|
242
|
+
}
|
243
|
+
} else {
|
244
|
+
mark_tag = p;
|
245
|
+
}
|
246
|
+
attr = runtime.getNil();
|
247
|
+
tag = runtime.getNil();
|
248
|
+
text = true;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
public void ELE(IRubyObject N) {
|
253
|
+
if(te > ts || text) {
|
254
|
+
int raw = -1;
|
255
|
+
int rawlen = 0;
|
256
|
+
ele_open = false;
|
257
|
+
text = false;
|
258
|
+
|
259
|
+
if(ts != -1 && N != x.sym_cdata && N != x.sym_text && N != x.sym_procins && N != x.sym_comment) {
|
260
|
+
raw = ts;
|
261
|
+
rawlen = te - ts;
|
262
|
+
}
|
263
|
+
|
264
|
+
if(block.isGiven()) {
|
265
|
+
IRubyObject raw_string = runtime.getNil();
|
266
|
+
if(raw != -1) {
|
267
|
+
raw_string = RubyString.newString(runtime, data, raw, rawlen);
|
268
|
+
}
|
269
|
+
yieldTokens(N, tag, attr, runtime.getNil(), taint);
|
270
|
+
} else {
|
271
|
+
hpricotToken(S, N, tag, attr, raw, rawlen, taint);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
|
277
|
+
public void EBLK(IRubyObject N, int T) {
|
278
|
+
tag = CAT(tag, mark_tag, p - T + 1);
|
279
|
+
ELE(N);
|
280
|
+
}
|
281
|
+
|
282
|
+
public void hpricotAdd(IRubyObject focus, IRubyObject ele) {
|
283
|
+
IRubyObject children = H_ELE_GET(focus, H_ELE_CHILDREN);
|
284
|
+
if(children.isNil()) {
|
285
|
+
H_ELE_SET(focus, H_ELE_CHILDREN, children = RubyArray.newArray(runtime, 1));
|
286
|
+
}
|
287
|
+
((RubyArray)children).append(ele);
|
288
|
+
H_ELE_SET(ele, H_ELE_PARENT, focus);
|
289
|
+
}
|
290
|
+
|
291
|
+
private static class TokenInfo {
|
292
|
+
public IRubyObject sym;
|
293
|
+
public IRubyObject tag;
|
294
|
+
public IRubyObject attr;
|
295
|
+
public int raw;
|
296
|
+
public int rawlen;
|
297
|
+
public IRubyObject ec;
|
298
|
+
public IRubyObject ele;
|
299
|
+
public Extra x;
|
300
|
+
public Ruby runtime;
|
301
|
+
public Scanner scanner;
|
302
|
+
public State S;
|
303
|
+
|
304
|
+
public void H_ELE(RubyClass klass) {
|
305
|
+
ele = klass.allocate();
|
306
|
+
if(klass == x.cElem) {
|
307
|
+
H_ELE_SET(ele, H_ELE_TAG, tag);
|
308
|
+
H_ELE_SET(ele, H_ELE_ATTR, attr);
|
309
|
+
H_ELE_SET(ele, H_ELE_EC, ec);
|
310
|
+
if(raw != -1 && (sym == x.sym_emptytag || sym == x.sym_stag || sym == x.sym_doctype)) {
|
311
|
+
H_ELE_SET(ele, H_ELE_RAW, RubyString.newString(runtime, scanner.data, raw, rawlen));
|
312
|
+
}
|
313
|
+
} else if(klass == x.cDocType || klass == x.cProcIns || klass == x.cXMLDecl || klass == x.cBogusETag) {
|
314
|
+
if(klass == x.cBogusETag) {
|
315
|
+
H_ELE_SET(ele, H_ELE_TAG, tag);
|
316
|
+
if(raw != -1) {
|
317
|
+
H_ELE_SET(ele, H_ELE_ATTR, RubyString.newString(runtime, scanner.data, raw, rawlen));
|
318
|
+
}
|
319
|
+
} else {
|
320
|
+
if(klass == x.cDocType) {
|
321
|
+
scanner.ATTR(runtime.newSymbol("target"), tag);
|
322
|
+
}
|
323
|
+
H_ELE_SET(ele, H_ELE_ATTR, attr);
|
324
|
+
if(klass != x.cProcIns) {
|
325
|
+
tag = runtime.getNil();
|
326
|
+
if(raw != -1) {
|
327
|
+
tag = RubyString.newString(runtime, scanner.data, raw, rawlen);
|
328
|
+
}
|
329
|
+
}
|
330
|
+
H_ELE_SET(ele, H_ELE_TAG, tag);
|
331
|
+
}
|
332
|
+
} else {
|
333
|
+
H_ELE_SET(ele, H_ELE_TAG, tag);
|
334
|
+
}
|
335
|
+
S.last = ele;
|
336
|
+
}
|
337
|
+
|
338
|
+
public void hpricotToken(boolean taint) {
|
339
|
+
//
|
340
|
+
// in html mode, fix up start tags incorrectly formed as empty tags
|
341
|
+
//
|
342
|
+
if(!S.xml) {
|
343
|
+
if(sym == x.sym_emptytag || sym == x.sym_stag || sym == x.sym_etag) {
|
344
|
+
ec = ((RubyHash)S.EC).op_aref(scanner.ctx, tag);
|
345
|
+
if(ec.isNil()) {
|
346
|
+
tag = tag.callMethod(scanner.ctx, "downcase");
|
347
|
+
ec = ((RubyHash)S.EC).op_aref(scanner.ctx, tag);
|
348
|
+
}
|
349
|
+
}
|
350
|
+
|
351
|
+
if(H_ELE_GET(S.focus, H_ELE_EC) == x.sym_CDATA &&
|
352
|
+
(sym != x.sym_procins && sym != x.sym_comment && sym != x.sym_cdata && sym != x.sym_text) &&
|
353
|
+
!(sym == x.sym_etag && runtime.newFixnum(tag.hashCode()).equals(H_ELE_GET(S.focus, H_ELE_HASH)))) {
|
354
|
+
sym = x.sym_text;
|
355
|
+
tag = RubyString.newString(runtime, scanner.data, raw, rawlen);
|
356
|
+
}
|
357
|
+
|
358
|
+
if(!ec.isNil()) {
|
359
|
+
if(sym == x.sym_emptytag) {
|
360
|
+
if(ec != x.sym_EMPTY) {
|
361
|
+
sym = x.sym_stag;
|
362
|
+
}
|
363
|
+
} else if(sym == x.sym_stag) {
|
364
|
+
if(ec == x.sym_EMPTY) {
|
365
|
+
sym = x.sym_emptytag;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
if(sym == x.sym_emptytag || sym == x.sym_stag) {
|
372
|
+
IRubyObject name = runtime.newFixnum(tag.hashCode());
|
373
|
+
H_ELE(x.cElem);
|
374
|
+
H_ELE_SET(ele, H_ELE_HASH, name);
|
375
|
+
|
376
|
+
if(!S.xml) {
|
377
|
+
IRubyObject match = runtime.getNil(), e = S.focus;
|
378
|
+
while(e != S.doc) {
|
379
|
+
IRubyObject hEC = H_ELE_GET(e, H_ELE_EC);
|
380
|
+
if(hEC instanceof RubyHash) {
|
381
|
+
IRubyObject has = ((RubyHash)hEC).op_aref(scanner.ctx, name);
|
382
|
+
if(!has.isNil()) {
|
383
|
+
if(has == runtime.getTrue()) {
|
384
|
+
if(match.isNil()) {
|
385
|
+
match = e;
|
386
|
+
}
|
387
|
+
} else if(has == x.symAllow) {
|
388
|
+
match = S.focus;
|
389
|
+
} else if(has == x.symDeny) {
|
390
|
+
match = runtime.getNil();
|
391
|
+
}
|
392
|
+
}
|
393
|
+
}
|
394
|
+
e = H_ELE_GET(e, H_ELE_PARENT);
|
395
|
+
}
|
396
|
+
|
397
|
+
if(match.isNil()) {
|
398
|
+
match = S.focus;
|
399
|
+
}
|
400
|
+
S.focus = match;
|
401
|
+
}
|
402
|
+
|
403
|
+
scanner.hpricotAdd(S.focus, ele);
|
404
|
+
|
405
|
+
//
|
406
|
+
// in the case of a start tag that should be empty, just
|
407
|
+
// skip the step that focuses the element. focusing moves
|
408
|
+
// us deeper into the document.
|
409
|
+
//
|
410
|
+
if(sym == x.sym_stag) {
|
411
|
+
if(S.xml || ec != x.sym_EMPTY) {
|
412
|
+
S.focus = ele;
|
413
|
+
S.last = runtime.getNil();
|
414
|
+
}
|
415
|
+
}
|
416
|
+
} else if(sym == x.sym_etag) {
|
417
|
+
IRubyObject name, match = runtime.getNil(), e = S.focus;
|
418
|
+
if(S.strict) {
|
419
|
+
if(((RubyHash)S.EC).op_aref(scanner.ctx, tag).isNil()) {
|
420
|
+
tag = runtime.newString("div");
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
name = runtime.newFixnum(tag.hashCode());
|
425
|
+
while(e != S.doc) {
|
426
|
+
if(H_ELE_GET(e, H_ELE_HASH).equals(name)) {
|
427
|
+
match = e;
|
428
|
+
break;
|
429
|
+
}
|
430
|
+
e = H_ELE_GET(e, H_ELE_PARENT);
|
431
|
+
|
432
|
+
}
|
433
|
+
if(match.isNil()) {
|
434
|
+
H_ELE(x.cBogusETag);
|
435
|
+
scanner.hpricotAdd(S.focus, ele);
|
436
|
+
} else {
|
437
|
+
ele = runtime.getNil();
|
438
|
+
if(raw != -1) {
|
439
|
+
ele = RubyString.newString(runtime, scanner.data, raw, rawlen);
|
440
|
+
}
|
441
|
+
H_ELE_SET(match, H_ELE_ETAG, ele);
|
442
|
+
S.focus = H_ELE_GET(match, H_ELE_PARENT);
|
443
|
+
S.last = runtime.getNil();
|
444
|
+
|
445
|
+
}
|
446
|
+
} else if(sym == x.sym_cdata) {
|
447
|
+
H_ELE(x.cCData);
|
448
|
+
scanner.hpricotAdd(S.focus, ele);
|
449
|
+
} else if(sym == x.sym_comment) {
|
450
|
+
H_ELE(x.cComment);
|
451
|
+
scanner.hpricotAdd(S.focus, ele);
|
452
|
+
} else if(sym == x.sym_doctype) {
|
453
|
+
H_ELE(x.cDocType);
|
454
|
+
if(S.strict) {
|
455
|
+
RubyHash h = (RubyHash)attr;
|
456
|
+
h.fastASet(runtime.newSymbol("system_id"), runtime.newString("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
|
457
|
+
h.fastASet(runtime.newSymbol("public_id"), runtime.newString("-//W3C//DTD XHTML 1.0 Strict//EN"));
|
458
|
+
}
|
459
|
+
scanner.hpricotAdd(S.focus, ele);
|
460
|
+
} else if(sym == x.sym_procins) {
|
461
|
+
IRubyObject match = tag.callMethod(scanner.ctx, "match", x.reProcInsParse);
|
462
|
+
tag = RubyRegexp.nth_match(1, match);
|
463
|
+
attr = RubyRegexp.nth_match(2, match);
|
464
|
+
H_ELE(x.cProcIns);
|
465
|
+
scanner.hpricotAdd(S.focus, ele);
|
466
|
+
} else if(sym == x.sym_text) {
|
467
|
+
if(!S.last.isNil() && S.last.getType() == x.cText) {
|
468
|
+
((RubyString)H_ELE_GET(S.last, H_ELE_TAG)).append(tag);
|
469
|
+
} else {
|
470
|
+
H_ELE(x.cText);
|
471
|
+
scanner.hpricotAdd(S.focus, ele);
|
472
|
+
}
|
473
|
+
} else if(sym == x.sym_xmldecl) {
|
474
|
+
H_ELE(x.cXMLDecl);
|
475
|
+
scanner.hpricotAdd(S.focus, ele);
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
479
|
+
|
480
|
+
public void hpricotToken(State S, IRubyObject _sym, IRubyObject _tag, IRubyObject _attr, int _raw, int _rawlen, boolean taint) {
|
481
|
+
TokenInfo t = new TokenInfo();
|
482
|
+
t.sym = _sym;
|
483
|
+
t.tag = _tag;
|
484
|
+
t.attr = _attr;
|
485
|
+
t.raw = _raw;
|
486
|
+
t.rawlen = _rawlen;
|
487
|
+
t.ec = runtime.getNil();
|
488
|
+
t.ele = runtime.getNil();
|
489
|
+
t.x = x;
|
490
|
+
t.runtime = runtime;
|
491
|
+
t.scanner = this;
|
492
|
+
t.S = S;
|
493
|
+
|
494
|
+
t.hpricotToken(taint);
|
495
|
+
}
|
496
|
+
|
497
|
+
public void yieldTokens(IRubyObject sym, IRubyObject tag, IRubyObject attr, IRubyObject raw, boolean taint) {
|
498
|
+
if(sym == x.sym_text) {
|
499
|
+
raw = tag;
|
500
|
+
}
|
501
|
+
IRubyObject ary = RubyArray.newArrayNoCopy(runtime, new IRubyObject[]{sym, tag, attr, raw});
|
502
|
+
if(taint) {
|
503
|
+
ary.setTaint(true);
|
504
|
+
tag.setTaint(true);
|
505
|
+
attr.setTaint(true);
|
506
|
+
raw.setTaint(true);
|
507
|
+
}
|
508
|
+
|
509
|
+
block.yield(ctx, ary);
|
510
|
+
}
|
511
|
+
|
512
|
+
// line 561 "hpricot_scan.java.rl"
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
// line 517 "HpricotScanService.java"
|
517
|
+
private static byte[] init__hpricot_scan_actions_0()
|
518
|
+
{
|
519
|
+
return new byte [] {
|
520
|
+
0, 1, 1, 1, 2, 1, 4, 1, 5, 1, 6, 1,
|
521
|
+
7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1,
|
522
|
+
14, 1, 16, 1, 20, 1, 21, 1, 22, 1, 24, 1,
|
523
|
+
25, 1, 26, 1, 28, 1, 29, 1, 30, 1, 32, 1,
|
524
|
+
33, 1, 38, 1, 39, 1, 40, 1, 41, 1, 42, 1,
|
525
|
+
43, 1, 44, 1, 45, 1, 46, 1, 47, 1, 48, 1,
|
526
|
+
49, 1, 50, 1, 51, 2, 2, 5, 2, 2, 6, 2,
|
527
|
+
2, 11, 2, 2, 12, 2, 2, 14, 2, 4, 39, 2,
|
528
|
+
4, 40, 2, 4, 41, 2, 5, 2, 2, 6, 14, 2,
|
529
|
+
7, 6, 2, 7, 14, 2, 11, 12, 2, 13, 3, 2,
|
530
|
+
14, 6, 2, 14, 40, 2, 15, 24, 2, 15, 28, 2,
|
531
|
+
15, 32, 2, 15, 45, 2, 17, 23, 2, 18, 27, 2,
|
532
|
+
19, 31, 2, 22, 34, 2, 22, 36, 3, 2, 6, 14,
|
533
|
+
3, 2, 14, 6, 3, 6, 7, 14, 3, 6, 14, 40,
|
534
|
+
3, 7, 14, 40, 3, 11, 2, 12, 3, 14, 6, 40,
|
535
|
+
3, 14, 13, 3, 3, 22, 0, 37, 3, 22, 2, 34,
|
536
|
+
3, 22, 14, 35, 4, 2, 14, 13, 3, 4, 6, 7,
|
537
|
+
14, 40, 4, 22, 2, 14, 35, 4, 22, 6, 14, 35,
|
538
|
+
4, 22, 7, 14, 35, 4, 22, 14, 6, 35, 5, 22,
|
539
|
+
2, 6, 14, 35, 5, 22, 2, 14, 6, 35, 5, 22,
|
540
|
+
6, 7, 14, 35
|
541
|
+
};
|
542
|
+
}
|
543
|
+
|
544
|
+
private static final byte _hpricot_scan_actions[] = init__hpricot_scan_actions_0();
|
545
|
+
|
546
|
+
|
547
|
+
private static short[] init__hpricot_scan_key_offsets_0()
|
548
|
+
{
|
549
|
+
return new short [] {
|
550
|
+
0, 3, 4, 5, 6, 7, 8, 9, 10, 13, 22, 37,
|
551
|
+
44, 45, 46, 47, 48, 49, 52, 57, 69, 81, 86, 93,
|
552
|
+
94, 95, 100, 101, 105, 106, 107, 121, 135, 152, 169, 186,
|
553
|
+
203, 210, 212, 214, 220, 222, 227, 232, 238, 240, 245, 251,
|
554
|
+
265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276,
|
555
|
+
282, 296, 300, 313, 326, 340, 354, 355, 366, 375, 388, 405,
|
556
|
+
423, 441, 450, 461, 480, 499, 510, 521, 536, 538, 540, 556,
|
557
|
+
572, 575, 587, 599, 619, 639, 658, 677, 697, 717, 728, 739,
|
558
|
+
751, 763, 775, 791, 794, 809, 811, 813, 829, 845, 848, 860,
|
559
|
+
871, 890, 910, 930, 941, 952, 964, 984, 1004, 1016, 1036, 1057,
|
560
|
+
1074, 1091, 1095, 1098, 1110, 1122, 1142, 1162, 1182, 1194, 1206, 1226,
|
561
|
+
1242, 1258, 1270, 1291, 1310, 1313, 1328, 1340, 1355, 1358, 1369, 1371,
|
562
|
+
1373, 1384, 1391, 1404, 1418, 1432, 1445, 1446, 1447, 1448, 1449, 1450,
|
563
|
+
1451, 1455, 1460, 1469, 1479, 1484, 1491, 1492, 1493, 1494, 1495, 1496,
|
564
|
+
1497, 1498, 1499, 1503, 1508, 1512, 1522, 1527, 1533, 1534, 1535, 1536,
|
565
|
+
1537, 1538, 1539, 1540, 1541, 1542, 1546, 1551, 1553, 1554, 1555, 1560,
|
566
|
+
1561, 1562, 1564, 1565, 1566, 1567, 1568, 1572, 1582, 1591, 1601, 1602,
|
567
|
+
1603, 1605, 1614, 1615, 1616, 1617, 1619, 1621, 1624, 1627, 1631, 1633,
|
568
|
+
1634, 1636, 1637, 1640
|
569
|
+
};
|
570
|
+
}
|
571
|
+
|
572
|
+
private static final short _hpricot_scan_key_offsets[] = init__hpricot_scan_key_offsets_0();
|
573
|
+
|
574
|
+
|
575
|
+
private static char[] init__hpricot_scan_trans_keys_0()
|
576
|
+
{
|
577
|
+
return new char [] {
|
578
|
+
45, 68, 91, 45, 79, 67, 84, 89, 80, 69, 32, 9,
|
579
|
+
13, 32, 58, 95, 9, 13, 65, 90, 97, 122, 32, 62,
|
580
|
+
63, 91, 95, 9, 13, 45, 46, 48, 58, 65, 90, 97,
|
581
|
+
122, 32, 62, 80, 83, 91, 9, 13, 85, 66, 76, 73,
|
582
|
+
67, 32, 9, 13, 32, 34, 39, 9, 13, 9, 34, 61,
|
583
|
+
95, 32, 37, 39, 59, 63, 90, 97, 122, 9, 34, 61,
|
584
|
+
95, 32, 37, 39, 59, 63, 90, 97, 122, 32, 62, 91,
|
585
|
+
9, 13, 32, 34, 39, 62, 91, 9, 13, 34, 34, 32,
|
586
|
+
62, 91, 9, 13, 93, 32, 62, 9, 13, 39, 39, 9,
|
587
|
+
39, 61, 95, 32, 33, 35, 37, 40, 59, 63, 90, 97,
|
588
|
+
122, 9, 39, 61, 95, 32, 33, 35, 37, 40, 59, 63,
|
589
|
+
90, 97, 122, 9, 32, 33, 39, 62, 91, 95, 10, 13,
|
590
|
+
35, 37, 40, 59, 61, 90, 97, 122, 9, 32, 34, 39,
|
591
|
+
62, 91, 95, 10, 13, 33, 37, 40, 59, 61, 90, 97,
|
592
|
+
122, 9, 32, 33, 39, 62, 91, 95, 10, 13, 35, 37,
|
593
|
+
40, 59, 61, 90, 97, 122, 9, 32, 34, 39, 62, 91,
|
594
|
+
95, 10, 13, 33, 37, 40, 59, 61, 90, 97, 122, 32,
|
595
|
+
34, 39, 62, 91, 9, 13, 34, 39, 34, 39, 32, 39,
|
596
|
+
62, 91, 9, 13, 39, 93, 32, 62, 93, 9, 13, 32,
|
597
|
+
39, 62, 9, 13, 32, 34, 62, 91, 9, 13, 34, 93,
|
598
|
+
32, 34, 62, 9, 13, 32, 39, 62, 91, 9, 13, 9,
|
599
|
+
39, 61, 95, 32, 33, 35, 37, 40, 59, 63, 90, 97,
|
600
|
+
122, 89, 83, 84, 69, 77, 67, 68, 65, 84, 65, 91,
|
601
|
+
58, 95, 65, 90, 97, 122, 32, 62, 63, 95, 9, 13,
|
602
|
+
45, 46, 48, 58, 65, 90, 97, 122, 32, 62, 9, 13,
|
603
|
+
32, 47, 62, 63, 95, 9, 13, 45, 58, 65, 90, 97,
|
604
|
+
122, 32, 47, 62, 63, 95, 9, 13, 45, 58, 65, 90,
|
605
|
+
97, 122, 32, 47, 61, 62, 63, 95, 9, 13, 45, 58,
|
606
|
+
65, 90, 97, 122, 32, 47, 61, 62, 63, 95, 9, 13,
|
607
|
+
45, 58, 65, 90, 97, 122, 62, 13, 32, 34, 39, 47,
|
608
|
+
60, 62, 9, 10, 11, 12, 13, 32, 47, 60, 62, 9,
|
609
|
+
10, 11, 12, 32, 47, 62, 63, 95, 9, 13, 45, 58,
|
610
|
+
65, 90, 97, 122, 13, 32, 47, 60, 62, 63, 95, 9,
|
611
|
+
10, 11, 12, 45, 58, 65, 90, 97, 122, 13, 32, 47,
|
612
|
+
60, 61, 62, 63, 95, 9, 10, 11, 12, 45, 58, 65,
|
613
|
+
90, 97, 122, 13, 32, 47, 60, 61, 62, 63, 95, 9,
|
614
|
+
10, 11, 12, 45, 58, 65, 90, 97, 122, 13, 32, 47,
|
615
|
+
60, 62, 9, 10, 11, 12, 13, 32, 34, 39, 47, 60,
|
616
|
+
62, 9, 10, 11, 12, 13, 32, 34, 39, 47, 60, 62,
|
617
|
+
63, 95, 9, 10, 11, 12, 45, 58, 65, 90, 97, 122,
|
618
|
+
13, 32, 34, 39, 47, 60, 62, 63, 95, 9, 10, 11,
|
619
|
+
12, 45, 58, 65, 90, 97, 122, 13, 32, 34, 47, 60,
|
620
|
+
62, 92, 9, 10, 11, 12, 13, 32, 34, 47, 60, 62,
|
621
|
+
92, 9, 10, 11, 12, 32, 34, 47, 62, 63, 92, 95,
|
622
|
+
9, 13, 45, 58, 65, 90, 97, 122, 34, 92, 34, 92,
|
623
|
+
32, 34, 47, 61, 62, 63, 92, 95, 9, 13, 45, 58,
|
624
|
+
65, 90, 97, 122, 32, 34, 47, 61, 62, 63, 92, 95,
|
625
|
+
9, 13, 45, 58, 65, 90, 97, 122, 34, 62, 92, 13,
|
626
|
+
32, 34, 39, 47, 60, 62, 92, 9, 10, 11, 12, 13,
|
627
|
+
32, 34, 39, 47, 60, 62, 92, 9, 10, 11, 12, 13,
|
628
|
+
32, 34, 39, 47, 60, 62, 63, 92, 95, 9, 10, 11,
|
629
|
+
12, 45, 58, 65, 90, 97, 122, 13, 32, 34, 39, 47,
|
630
|
+
60, 62, 63, 92, 95, 9, 10, 11, 12, 45, 58, 65,
|
631
|
+
90, 97, 122, 13, 32, 34, 47, 60, 62, 63, 92, 95,
|
632
|
+
9, 10, 11, 12, 45, 58, 65, 90, 97, 122, 13, 32,
|
633
|
+
34, 47, 60, 62, 63, 92, 95, 9, 10, 11, 12, 45,
|
634
|
+
58, 65, 90, 97, 122, 13, 32, 34, 47, 60, 61, 62,
|
635
|
+
63, 92, 95, 9, 10, 11, 12, 45, 58, 65, 90, 97,
|
636
|
+
122, 13, 32, 34, 47, 60, 61, 62, 63, 92, 95, 9,
|
637
|
+
10, 11, 12, 45, 58, 65, 90, 97, 122, 13, 32, 34,
|
638
|
+
47, 60, 62, 92, 9, 10, 11, 12, 13, 32, 34, 47,
|
639
|
+
60, 62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47,
|
640
|
+
60, 62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47,
|
641
|
+
60, 62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47,
|
642
|
+
60, 62, 92, 9, 10, 11, 12, 32, 34, 39, 47, 62,
|
643
|
+
63, 92, 95, 9, 13, 45, 58, 65, 90, 97, 122, 34,
|
644
|
+
39, 92, 32, 39, 47, 62, 63, 92, 95, 9, 13, 45,
|
645
|
+
58, 65, 90, 97, 122, 39, 92, 39, 92, 32, 39, 47,
|
646
|
+
61, 62, 63, 92, 95, 9, 13, 45, 58, 65, 90, 97,
|
647
|
+
122, 32, 39, 47, 61, 62, 63, 92, 95, 9, 13, 45,
|
648
|
+
58, 65, 90, 97, 122, 39, 62, 92, 13, 32, 34, 39,
|
649
|
+
47, 60, 62, 92, 9, 10, 11, 12, 13, 32, 39, 47,
|
650
|
+
60, 62, 92, 9, 10, 11, 12, 13, 32, 39, 47, 60,
|
651
|
+
62, 63, 92, 95, 9, 10, 11, 12, 45, 58, 65, 90,
|
652
|
+
97, 122, 13, 32, 39, 47, 60, 61, 62, 63, 92, 95,
|
653
|
+
9, 10, 11, 12, 45, 58, 65, 90, 97, 122, 13, 32,
|
654
|
+
39, 47, 60, 61, 62, 63, 92, 95, 9, 10, 11, 12,
|
655
|
+
45, 58, 65, 90, 97, 122, 13, 32, 39, 47, 60, 62,
|
656
|
+
92, 9, 10, 11, 12, 13, 32, 39, 47, 60, 62, 92,
|
657
|
+
9, 10, 11, 12, 13, 32, 34, 39, 47, 60, 62, 92,
|
658
|
+
9, 10, 11, 12, 13, 32, 34, 39, 47, 60, 62, 63,
|
659
|
+
92, 95, 9, 10, 11, 12, 45, 58, 65, 90, 97, 122,
|
660
|
+
13, 32, 34, 39, 47, 60, 62, 63, 92, 95, 9, 10,
|
661
|
+
11, 12, 45, 58, 65, 90, 97, 122, 13, 32, 34, 39,
|
662
|
+
47, 60, 62, 92, 9, 10, 11, 12, 13, 32, 34, 39,
|
663
|
+
47, 60, 62, 63, 92, 95, 9, 10, 11, 12, 45, 58,
|
664
|
+
65, 90, 97, 122, 13, 32, 34, 39, 47, 60, 61, 62,
|
665
|
+
63, 92, 95, 9, 10, 11, 12, 45, 58, 65, 90, 97,
|
666
|
+
122, 32, 34, 39, 47, 61, 62, 63, 92, 95, 9, 13,
|
667
|
+
45, 58, 65, 90, 97, 122, 32, 34, 39, 47, 61, 62,
|
668
|
+
63, 92, 95, 9, 13, 45, 58, 65, 90, 97, 122, 34,
|
669
|
+
39, 62, 92, 34, 39, 92, 13, 32, 34, 39, 47, 60,
|
670
|
+
62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47, 60,
|
671
|
+
62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47, 60,
|
672
|
+
62, 63, 92, 95, 9, 10, 11, 12, 45, 58, 65, 90,
|
673
|
+
97, 122, 13, 32, 34, 39, 47, 60, 62, 63, 92, 95,
|
674
|
+
9, 10, 11, 12, 45, 58, 65, 90, 97, 122, 13, 32,
|
675
|
+
34, 39, 47, 60, 62, 63, 92, 95, 9, 10, 11, 12,
|
676
|
+
45, 58, 65, 90, 97, 122, 13, 32, 34, 39, 47, 60,
|
677
|
+
62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47, 60,
|
678
|
+
62, 92, 9, 10, 11, 12, 13, 32, 34, 39, 47, 60,
|
679
|
+
62, 63, 92, 95, 9, 10, 11, 12, 45, 58, 65, 90,
|
680
|
+
97, 122, 32, 34, 39, 47, 62, 63, 92, 95, 9, 13,
|
681
|
+
45, 58, 65, 90, 97, 122, 32, 34, 39, 47, 62, 63,
|
682
|
+
92, 95, 9, 13, 45, 58, 65, 90, 97, 122, 13, 32,
|
683
|
+
34, 39, 47, 60, 62, 92, 9, 10, 11, 12, 13, 32,
|
684
|
+
34, 39, 47, 60, 61, 62, 63, 92, 95, 9, 10, 11,
|
685
|
+
12, 45, 58, 65, 90, 97, 122, 13, 32, 39, 47, 60,
|
686
|
+
62, 63, 92, 95, 9, 10, 11, 12, 45, 58, 65, 90,
|
687
|
+
97, 122, 34, 39, 92, 32, 39, 47, 62, 63, 92, 95,
|
688
|
+
9, 13, 45, 58, 65, 90, 97, 122, 13, 32, 34, 39,
|
689
|
+
47, 60, 62, 92, 9, 10, 11, 12, 32, 34, 47, 62,
|
690
|
+
63, 92, 95, 9, 13, 45, 58, 65, 90, 97, 122, 34,
|
691
|
+
39, 92, 13, 32, 39, 47, 60, 62, 92, 9, 10, 11,
|
692
|
+
12, 34, 92, 39, 92, 13, 32, 34, 39, 47, 60, 62,
|
693
|
+
9, 10, 11, 12, 58, 95, 120, 65, 90, 97, 122, 32,
|
694
|
+
63, 95, 9, 13, 45, 46, 48, 58, 65, 90, 97, 122,
|
695
|
+
32, 63, 95, 109, 9, 13, 45, 46, 48, 58, 65, 90,
|
696
|
+
97, 122, 32, 63, 95, 108, 9, 13, 45, 46, 48, 58,
|
697
|
+
65, 90, 97, 122, 32, 63, 95, 9, 13, 45, 46, 48,
|
698
|
+
58, 65, 90, 97, 122, 101, 114, 115, 105, 111, 110, 32,
|
699
|
+
61, 9, 13, 32, 34, 39, 9, 13, 95, 45, 46, 48,
|
700
|
+
58, 65, 90, 97, 122, 34, 95, 45, 46, 48, 58, 65,
|
701
|
+
90, 97, 122, 32, 62, 63, 9, 13, 32, 62, 63, 101,
|
702
|
+
115, 9, 13, 62, 110, 99, 111, 100, 105, 110, 103, 32,
|
703
|
+
61, 9, 13, 32, 34, 39, 9, 13, 65, 90, 97, 122,
|
704
|
+
34, 95, 45, 46, 48, 57, 65, 90, 97, 122, 32, 62,
|
705
|
+
63, 9, 13, 32, 62, 63, 115, 9, 13, 116, 97, 110,
|
706
|
+
100, 97, 108, 111, 110, 101, 32, 61, 9, 13, 32, 34,
|
707
|
+
39, 9, 13, 110, 121, 111, 34, 32, 62, 63, 9, 13,
|
708
|
+
101, 115, 110, 121, 111, 39, 101, 115, 65, 90, 97, 122,
|
709
|
+
39, 95, 45, 46, 48, 57, 65, 90, 97, 122, 95, 45,
|
710
|
+
46, 48, 58, 65, 90, 97, 122, 39, 95, 45, 46, 48,
|
711
|
+
58, 65, 90, 97, 122, 62, 62, 10, 60, 33, 47, 58,
|
712
|
+
63, 95, 65, 90, 97, 122, 39, 93, 34, 34, 92, 39,
|
713
|
+
92, 34, 39, 92, 32, 9, 13, 32, 118, 9, 13, 10,
|
714
|
+
45, 45, 10, 93, 93, 10, 62, 63, 62, 0
|
715
|
+
};
|
716
|
+
}
|
717
|
+
|
718
|
+
private static final char _hpricot_scan_trans_keys[] = init__hpricot_scan_trans_keys_0();
|
719
|
+
|
720
|
+
|
721
|
+
private static byte[] init__hpricot_scan_single_lengths_0()
|
722
|
+
{
|
723
|
+
return new byte [] {
|
724
|
+
3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 5,
|
725
|
+
1, 1, 1, 1, 1, 1, 3, 4, 4, 3, 5, 1,
|
726
|
+
1, 3, 1, 2, 1, 1, 4, 4, 7, 7, 7, 7,
|
727
|
+
5, 2, 2, 4, 2, 3, 3, 4, 2, 3, 4, 4,
|
728
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
|
729
|
+
4, 2, 5, 5, 6, 6, 1, 7, 5, 5, 7, 8,
|
730
|
+
8, 5, 7, 9, 9, 7, 7, 7, 2, 2, 8, 8,
|
731
|
+
3, 8, 8, 10, 10, 9, 9, 10, 10, 7, 7, 8,
|
732
|
+
8, 8, 8, 3, 7, 2, 2, 8, 8, 3, 8, 7,
|
733
|
+
9, 10, 10, 7, 7, 8, 10, 10, 8, 10, 11, 9,
|
734
|
+
9, 4, 3, 8, 8, 10, 10, 10, 8, 8, 10, 8,
|
735
|
+
8, 8, 11, 9, 3, 7, 8, 7, 3, 7, 2, 2,
|
736
|
+
7, 3, 3, 4, 4, 3, 1, 1, 1, 1, 1, 1,
|
737
|
+
2, 3, 1, 2, 3, 5, 1, 1, 1, 1, 1, 1,
|
738
|
+
1, 1, 2, 3, 0, 2, 3, 4, 1, 1, 1, 1,
|
739
|
+
1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 3, 1,
|
740
|
+
1, 2, 1, 1, 1, 1, 0, 2, 1, 2, 1, 1,
|
741
|
+
2, 5, 1, 1, 1, 2, 2, 3, 1, 2, 2, 1,
|
742
|
+
2, 1, 3, 1
|
743
|
+
};
|
744
|
+
}
|
745
|
+
|
746
|
+
private static final byte _hpricot_scan_single_lengths[] = init__hpricot_scan_single_lengths_0();
|
747
|
+
|
748
|
+
|
749
|
+
private static byte[] init__hpricot_scan_range_lengths_0()
|
750
|
+
{
|
751
|
+
return new byte [] {
|
752
|
+
0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 1,
|
753
|
+
0, 0, 0, 0, 0, 1, 1, 4, 4, 1, 1, 0,
|
754
|
+
0, 1, 0, 1, 0, 0, 5, 5, 5, 5, 5, 5,
|
755
|
+
1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 5,
|
756
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
|
757
|
+
5, 1, 4, 4, 4, 4, 0, 2, 2, 4, 5, 5,
|
758
|
+
5, 2, 2, 5, 5, 2, 2, 4, 0, 0, 4, 4,
|
759
|
+
0, 2, 2, 5, 5, 5, 5, 5, 5, 2, 2, 2,
|
760
|
+
2, 2, 4, 0, 4, 0, 0, 4, 4, 0, 2, 2,
|
761
|
+
5, 5, 5, 2, 2, 2, 5, 5, 2, 5, 5, 4,
|
762
|
+
4, 0, 0, 2, 2, 5, 5, 5, 2, 2, 5, 4,
|
763
|
+
4, 2, 5, 5, 0, 4, 2, 4, 0, 2, 0, 0,
|
764
|
+
2, 2, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
|
765
|
+
1, 1, 4, 4, 1, 1, 0, 0, 0, 0, 0, 0,
|
766
|
+
0, 0, 1, 1, 2, 4, 1, 1, 0, 0, 0, 0,
|
767
|
+
0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0,
|
768
|
+
0, 0, 0, 0, 0, 0, 2, 4, 4, 4, 0, 0,
|
769
|
+
0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
|
770
|
+
0, 0, 0, 0
|
771
|
+
};
|
772
|
+
}
|
773
|
+
|
774
|
+
private static final byte _hpricot_scan_range_lengths[] = init__hpricot_scan_range_lengths_0();
|
775
|
+
|
776
|
+
|
777
|
+
private static short[] init__hpricot_scan_index_offsets_0()
|
778
|
+
{
|
779
|
+
return new short [] {
|
780
|
+
0, 4, 6, 8, 10, 12, 14, 16, 18, 21, 28, 39,
|
781
|
+
46, 48, 50, 52, 54, 56, 59, 64, 73, 82, 87, 94,
|
782
|
+
96, 98, 103, 105, 109, 111, 113, 123, 133, 146, 159, 172,
|
783
|
+
185, 192, 195, 198, 204, 207, 212, 217, 223, 226, 231, 237,
|
784
|
+
247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269,
|
785
|
+
274, 284, 288, 298, 308, 319, 330, 332, 342, 350, 360, 373,
|
786
|
+
387, 401, 409, 419, 434, 449, 459, 469, 481, 484, 487, 500,
|
787
|
+
513, 517, 528, 539, 555, 571, 586, 601, 617, 633, 643, 653,
|
788
|
+
664, 675, 686, 699, 703, 715, 718, 721, 734, 747, 751, 762,
|
789
|
+
772, 787, 803, 819, 829, 839, 850, 866, 882, 893, 909, 926,
|
790
|
+
940, 954, 959, 963, 974, 985, 1001, 1017, 1033, 1044, 1055, 1071,
|
791
|
+
1084, 1097, 1108, 1125, 1140, 1144, 1156, 1167, 1179, 1183, 1193, 1196,
|
792
|
+
1199, 1209, 1215, 1224, 1234, 1244, 1253, 1255, 1257, 1259, 1261, 1263,
|
793
|
+
1265, 1269, 1274, 1280, 1287, 1292, 1299, 1301, 1303, 1305, 1307, 1309,
|
794
|
+
1311, 1313, 1315, 1319, 1324, 1327, 1334, 1339, 1345, 1347, 1349, 1351,
|
795
|
+
1353, 1355, 1357, 1359, 1361, 1363, 1367, 1372, 1375, 1377, 1379, 1384,
|
796
|
+
1386, 1388, 1391, 1393, 1395, 1397, 1399, 1402, 1409, 1415, 1422, 1424,
|
797
|
+
1426, 1429, 1437, 1439, 1441, 1443, 1446, 1449, 1453, 1456, 1460, 1463,
|
798
|
+
1465, 1468, 1470, 1474
|
799
|
+
};
|
800
|
+
}
|
801
|
+
|
802
|
+
private static final short _hpricot_scan_index_offsets[] = init__hpricot_scan_index_offsets_0();
|
803
|
+
|
804
|
+
|
805
|
+
private static short[] init__hpricot_scan_indicies_0()
|
806
|
+
{
|
807
|
+
return new short [] {
|
808
|
+
1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0,
|
809
|
+
8, 0, 9, 0, 10, 0, 11, 11, 0, 11, 12, 12,
|
810
|
+
11, 12, 12, 0, 13, 15, 14, 16, 14, 13, 14, 14,
|
811
|
+
14, 14, 0, 17, 18, 19, 20, 21, 17, 0, 22, 0,
|
812
|
+
23, 0, 24, 0, 25, 0, 26, 0, 27, 27, 0, 27,
|
813
|
+
28, 29, 27, 0, 30, 31, 30, 30, 30, 30, 30, 30,
|
814
|
+
0, 32, 33, 32, 32, 32, 32, 32, 32, 0, 34, 18,
|
815
|
+
21, 34, 0, 34, 35, 36, 18, 21, 34, 0, 38, 37,
|
816
|
+
41, 40, 42, 18, 21, 42, 39, 43, 21, 43, 18, 43,
|
817
|
+
39, 38, 44, 41, 45, 46, 47, 46, 46, 46, 46, 46,
|
818
|
+
46, 46, 0, 48, 49, 48, 48, 48, 48, 48, 48, 48,
|
819
|
+
0, 50, 50, 48, 49, 18, 21, 48, 34, 48, 48, 48,
|
820
|
+
48, 0, 50, 50, 35, 51, 18, 21, 48, 34, 48, 48,
|
821
|
+
48, 48, 0, 52, 52, 54, 55, 56, 57, 54, 53, 54,
|
822
|
+
54, 54, 54, 44, 58, 58, 61, 62, 63, 64, 60, 59,
|
823
|
+
60, 60, 60, 60, 45, 59, 61, 65, 63, 64, 59, 45,
|
824
|
+
67, 68, 66, 70, 71, 69, 72, 41, 63, 64, 72, 45,
|
825
|
+
73, 74, 64, 75, 76, 43, 75, 21, 74, 41, 63, 74,
|
826
|
+
45, 77, 41, 78, 79, 77, 40, 73, 80, 79, 80, 41,
|
827
|
+
78, 80, 40, 81, 38, 56, 57, 81, 44, 60, 82, 60,
|
828
|
+
60, 60, 60, 60, 60, 60, 45, 83, 0, 84, 0, 85,
|
829
|
+
0, 86, 0, 87, 0, 88, 0, 89, 0, 90, 0, 91,
|
830
|
+
0, 92, 0, 93, 0, 94, 94, 94, 94, 0, 95, 97,
|
831
|
+
96, 96, 95, 96, 96, 96, 96, 0, 98, 99, 98, 0,
|
832
|
+
100, 102, 103, 101, 101, 100, 101, 101, 101, 0, 104, 106,
|
833
|
+
107, 105, 105, 104, 105, 105, 105, 0, 108, 110, 111, 112,
|
834
|
+
109, 109, 108, 109, 109, 109, 39, 113, 115, 116, 117, 114,
|
835
|
+
114, 113, 114, 114, 114, 39, 118, 39, 120, 120, 122, 123,
|
836
|
+
124, 39, 117, 120, 121, 119, 126, 126, 128, 39, 129, 126,
|
837
|
+
127, 125, 130, 115, 117, 114, 114, 130, 114, 114, 114, 39,
|
838
|
+
126, 126, 132, 39, 133, 131, 131, 126, 127, 131, 131, 131,
|
839
|
+
125, 134, 134, 137, 39, 138, 139, 136, 136, 134, 135, 136,
|
840
|
+
136, 136, 125, 140, 140, 132, 39, 142, 133, 131, 131, 140,
|
841
|
+
141, 131, 131, 131, 125, 126, 126, 128, 39, 129, 126, 127,
|
842
|
+
125, 143, 143, 145, 146, 147, 39, 129, 143, 144, 119, 148,
|
843
|
+
148, 122, 123, 124, 39, 117, 150, 150, 148, 149, 150, 150,
|
844
|
+
150, 119, 143, 143, 145, 146, 151, 39, 133, 150, 150, 143,
|
845
|
+
144, 150, 150, 150, 119, 153, 153, 155, 156, 157, 158, 159,
|
846
|
+
153, 154, 152, 161, 161, 163, 164, 165, 166, 167, 161, 162,
|
847
|
+
160, 168, 169, 171, 172, 170, 173, 170, 168, 170, 170, 170,
|
848
|
+
165, 169, 173, 165, 174, 173, 165, 175, 169, 177, 178, 179,
|
849
|
+
176, 173, 176, 175, 176, 176, 176, 165, 180, 169, 171, 181,
|
850
|
+
172, 170, 173, 170, 180, 170, 170, 170, 165, 169, 182, 173,
|
851
|
+
165, 183, 183, 185, 186, 187, 165, 172, 159, 183, 184, 152,
|
852
|
+
188, 188, 185, 186, 187, 165, 172, 159, 188, 189, 152, 188,
|
853
|
+
188, 185, 186, 187, 165, 172, 190, 159, 190, 188, 189, 190,
|
854
|
+
190, 190, 152, 191, 191, 193, 194, 195, 165, 196, 190, 159,
|
855
|
+
190, 191, 192, 190, 190, 190, 152, 153, 153, 155, 195, 157,
|
856
|
+
197, 190, 159, 190, 153, 154, 190, 190, 190, 152, 161, 161,
|
857
|
+
163, 199, 165, 196, 198, 167, 198, 161, 162, 198, 198, 198,
|
858
|
+
160, 200, 200, 163, 203, 165, 204, 205, 202, 167, 202, 200,
|
859
|
+
201, 202, 202, 202, 160, 206, 206, 163, 199, 165, 208, 196,
|
860
|
+
198, 167, 198, 206, 207, 198, 198, 198, 160, 161, 161, 163,
|
861
|
+
164, 165, 166, 167, 161, 162, 160, 161, 161, 209, 164, 165,
|
862
|
+
166, 167, 161, 162, 160, 191, 191, 193, 194, 156, 165, 166,
|
863
|
+
159, 191, 192, 152, 211, 211, 213, 214, 215, 216, 217, 218,
|
864
|
+
211, 212, 210, 220, 220, 222, 209, 223, 224, 225, 226, 220,
|
865
|
+
221, 219, 227, 228, 174, 230, 231, 229, 232, 229, 227, 229,
|
866
|
+
229, 229, 224, 228, 174, 232, 224, 234, 169, 236, 237, 235,
|
867
|
+
238, 235, 234, 235, 235, 235, 233, 169, 238, 233, 228, 238,
|
868
|
+
233, 239, 169, 241, 242, 243, 240, 238, 240, 239, 240, 240,
|
869
|
+
240, 233, 244, 169, 236, 245, 237, 235, 238, 235, 244, 235,
|
870
|
+
235, 235, 233, 169, 246, 238, 233, 248, 248, 250, 251, 252,
|
871
|
+
233, 237, 253, 248, 249, 247, 255, 255, 163, 257, 233, 258,
|
872
|
+
259, 255, 256, 254, 255, 255, 163, 261, 233, 262, 260, 259,
|
873
|
+
260, 255, 256, 260, 260, 260, 254, 263, 263, 163, 266, 233,
|
874
|
+
267, 268, 265, 259, 265, 263, 264, 265, 265, 265, 254, 269,
|
875
|
+
269, 163, 261, 233, 271, 262, 260, 259, 260, 269, 270, 260,
|
876
|
+
260, 260, 254, 255, 255, 163, 257, 233, 258, 259, 255, 256,
|
877
|
+
254, 255, 255, 222, 257, 233, 258, 259, 255, 256, 254, 272,
|
878
|
+
272, 274, 275, 276, 233, 258, 253, 272, 273, 247, 277, 277,
|
879
|
+
250, 251, 252, 233, 237, 279, 253, 279, 277, 278, 279, 279,
|
880
|
+
279, 247, 272, 272, 274, 275, 280, 233, 262, 279, 253, 279,
|
881
|
+
272, 273, 279, 279, 279, 247, 211, 211, 281, 214, 215, 216,
|
882
|
+
217, 218, 211, 212, 210, 220, 220, 222, 209, 283, 224, 284,
|
883
|
+
282, 226, 282, 220, 221, 282, 282, 282, 219, 285, 285, 222,
|
884
|
+
209, 288, 224, 289, 290, 287, 226, 287, 285, 286, 287, 287,
|
885
|
+
287, 219, 291, 228, 174, 230, 292, 231, 229, 232, 229, 291,
|
886
|
+
229, 229, 229, 224, 293, 228, 174, 295, 296, 297, 294, 232,
|
887
|
+
294, 293, 294, 294, 294, 224, 228, 174, 298, 232, 224, 299,
|
888
|
+
299, 232, 224, 300, 300, 302, 303, 304, 224, 231, 218, 300,
|
889
|
+
301, 210, 305, 305, 302, 303, 304, 224, 231, 218, 305, 306,
|
890
|
+
210, 305, 305, 302, 303, 304, 224, 231, 307, 218, 307, 305,
|
891
|
+
306, 307, 307, 307, 210, 308, 308, 310, 311, 312, 224, 284,
|
892
|
+
307, 218, 307, 308, 309, 307, 307, 307, 210, 211, 211, 281,
|
893
|
+
214, 312, 216, 313, 307, 218, 307, 211, 212, 307, 307, 307,
|
894
|
+
210, 220, 220, 222, 209, 223, 224, 225, 226, 220, 221, 219,
|
895
|
+
220, 220, 314, 314, 223, 224, 225, 226, 220, 221, 219, 211,
|
896
|
+
211, 213, 214, 312, 216, 313, 307, 218, 307, 211, 212, 307,
|
897
|
+
307, 307, 210, 315, 316, 317, 319, 320, 318, 321, 318, 315,
|
898
|
+
318, 318, 318, 216, 315, 322, 317, 319, 320, 318, 321, 318,
|
899
|
+
315, 318, 318, 318, 216, 308, 308, 310, 311, 215, 224, 225,
|
900
|
+
218, 308, 309, 210, 323, 323, 222, 209, 283, 224, 325, 284,
|
901
|
+
282, 226, 282, 323, 324, 282, 282, 282, 219, 326, 326, 155,
|
902
|
+
280, 328, 329, 279, 253, 279, 326, 327, 279, 279, 279, 247,
|
903
|
+
316, 317, 321, 216, 330, 331, 333, 334, 332, 335, 332, 330,
|
904
|
+
332, 332, 332, 328, 277, 277, 250, 251, 252, 233, 237, 253,
|
905
|
+
277, 278, 247, 336, 331, 338, 339, 337, 340, 337, 336, 337,
|
906
|
+
337, 337, 157, 322, 317, 321, 216, 326, 326, 155, 276, 328,
|
907
|
+
341, 253, 326, 327, 247, 331, 340, 157, 331, 335, 328, 148,
|
908
|
+
148, 122, 123, 124, 39, 117, 148, 149, 119, 342, 342, 343,
|
909
|
+
342, 342, 0, 344, 345, 345, 344, 345, 345, 345, 345, 0,
|
910
|
+
344, 345, 345, 346, 344, 345, 345, 345, 345, 0, 344, 345,
|
911
|
+
345, 347, 344, 345, 345, 345, 345, 0, 348, 345, 345, 348,
|
912
|
+
345, 345, 345, 345, 0, 350, 349, 351, 349, 352, 349, 353,
|
913
|
+
349, 354, 349, 355, 349, 355, 356, 355, 349, 356, 357, 358,
|
914
|
+
356, 349, 359, 359, 359, 359, 359, 349, 360, 361, 361, 361,
|
915
|
+
361, 361, 349, 362, 363, 364, 362, 349, 362, 363, 364, 365,
|
916
|
+
366, 362, 349, 363, 349, 367, 349, 368, 349, 369, 349, 370,
|
917
|
+
349, 371, 349, 372, 349, 373, 349, 373, 374, 373, 349, 374,
|
918
|
+
375, 376, 374, 349, 377, 377, 349, 378, 379, 379, 379, 379,
|
919
|
+
379, 349, 380, 363, 364, 380, 349, 380, 363, 364, 366, 380,
|
920
|
+
349, 381, 349, 382, 349, 383, 349, 384, 349, 385, 349, 386,
|
921
|
+
349, 387, 349, 388, 349, 389, 349, 389, 390, 389, 349, 390,
|
922
|
+
391, 392, 390, 349, 393, 394, 349, 395, 349, 396, 349, 397,
|
923
|
+
363, 364, 397, 349, 398, 349, 395, 349, 399, 400, 349, 401,
|
924
|
+
349, 396, 349, 402, 349, 401, 349, 403, 403, 349, 378, 404,
|
925
|
+
404, 404, 404, 404, 349, 405, 405, 405, 405, 405, 349, 360,
|
926
|
+
406, 406, 406, 406, 406, 349, 408, 407, 410, 409, 412, 413,
|
927
|
+
411, 415, 416, 417, 418, 417, 417, 417, 414, 41, 45, 43,
|
928
|
+
21, 41, 40, 169, 173, 165, 169, 238, 233, 228, 174, 232,
|
929
|
+
224, 344, 344, 420, 348, 421, 348, 420, 423, 424, 422, 426,
|
930
|
+
425, 428, 429, 427, 431, 430, 433, 434, 435, 432, 434, 436,
|
931
|
+
0
|
932
|
+
};
|
933
|
+
}
|
934
|
+
|
935
|
+
private static final short _hpricot_scan_indicies[] = init__hpricot_scan_indicies_0();
|
936
|
+
|
937
|
+
|
938
|
+
private static short[] init__hpricot_scan_trans_targs_wi_0()
|
939
|
+
{
|
940
|
+
return new short [] {
|
941
|
+
204, 1, 2, 53, 204, 3, 4, 5, 6, 7, 8, 9,
|
942
|
+
10, 11, 10, 204, 26, 11, 204, 12, 48, 26, 13, 14,
|
943
|
+
15, 16, 17, 18, 19, 30, 20, 21, 20, 21, 22, 23,
|
944
|
+
28, 24, 25, 204, 24, 25, 25, 27, 29, 29, 31, 32,
|
945
|
+
31, 32, 33, 34, 35, 36, 47, 32, 206, 40, 35, 36,
|
946
|
+
47, 37, 34, 206, 40, 46, 38, 39, 43, 38, 39, 43,
|
947
|
+
39, 41, 42, 41, 207, 43, 208, 44, 45, 39, 32, 49,
|
948
|
+
50, 51, 52, 21, 54, 55, 56, 57, 58, 204, 60, 61,
|
949
|
+
60, 204, 61, 204, 63, 62, 66, 204, 63, 64, 66, 204,
|
950
|
+
65, 64, 66, 67, 204, 65, 64, 66, 67, 204, 204, 68,
|
951
|
+
144, 74, 142, 143, 73, 68, 69, 70, 73, 204, 69, 71,
|
952
|
+
73, 204, 65, 72, 71, 73, 74, 204, 65, 72, 74, 75,
|
953
|
+
76, 77, 141, 73, 75, 76, 71, 73, 78, 79, 90, 70,
|
954
|
+
93, 80, 209, 94, 78, 79, 90, 70, 93, 80, 209, 94,
|
955
|
+
79, 69, 82, 84, 209, 81, 79, 83, 82, 84, 85, 209,
|
956
|
+
83, 85, 209, 86, 95, 139, 140, 93, 87, 88, 91, 87,
|
957
|
+
88, 89, 96, 93, 209, 209, 91, 93, 83, 92, 91, 93,
|
958
|
+
95, 209, 83, 92, 95, 90, 97, 98, 117, 108, 90, 128,
|
959
|
+
99, 211, 129, 97, 98, 117, 108, 128, 99, 211, 129, 98,
|
960
|
+
100, 120, 121, 211, 122, 101, 100, 103, 105, 210, 102, 104,
|
961
|
+
103, 105, 106, 210, 104, 106, 210, 107, 138, 113, 136, 137,
|
962
|
+
111, 112, 107, 100, 108, 111, 210, 112, 109, 111, 210, 104,
|
963
|
+
110, 109, 111, 113, 210, 104, 110, 113, 114, 115, 116, 135,
|
964
|
+
111, 114, 115, 109, 111, 108, 118, 128, 211, 119, 134, 118,
|
965
|
+
128, 133, 211, 119, 123, 119, 120, 121, 123, 211, 211, 98,
|
966
|
+
124, 133, 131, 132, 128, 125, 126, 118, 125, 126, 127, 130,
|
967
|
+
128, 211, 117, 98, 100, 79, 120, 121, 211, 122, 100, 119,
|
968
|
+
134, 133, 100, 108, 101, 210, 100, 69, 103, 105, 210, 102,
|
969
|
+
79, 82, 84, 209, 81, 210, 146, 147, 212, 146, 148, 149,
|
970
|
+
213, 204, 151, 152, 153, 154, 155, 156, 157, 158, 200, 159,
|
971
|
+
160, 159, 161, 204, 162, 163, 176, 164, 165, 166, 167, 168,
|
972
|
+
169, 170, 171, 172, 198, 173, 174, 173, 175, 177, 178, 179,
|
973
|
+
180, 181, 182, 183, 184, 185, 186, 187, 193, 188, 191, 189,
|
974
|
+
190, 190, 192, 194, 196, 195, 197, 199, 199, 201, 201, 214,
|
975
|
+
214, 216, 216, 204, 204, 205, 204, 0, 59, 62, 145, 204,
|
976
|
+
204, 150, 214, 214, 215, 214, 202, 216, 216, 217, 216, 203,
|
977
|
+
218, 218, 218, 219, 218
|
978
|
+
};
|
979
|
+
}
|
980
|
+
|
981
|
+
private static final short _hpricot_scan_trans_targs_wi[] = init__hpricot_scan_trans_targs_wi_0();
|
982
|
+
|
983
|
+
|
984
|
+
private static short[] init__hpricot_scan_trans_actions_wi_0()
|
985
|
+
{
|
986
|
+
return new short [] {
|
987
|
+
73, 0, 0, 0, 59, 0, 0, 0, 0, 0, 0, 0,
|
988
|
+
1, 5, 0, 92, 5, 0, 51, 0, 0, 0, 0, 0,
|
989
|
+
0, 0, 0, 0, 0, 0, 3, 83, 0, 19, 0, 0,
|
990
|
+
0, 3, 86, 75, 0, 21, 0, 0, 3, 0, 3, 83,
|
991
|
+
0, 19, 0, 19, 3, 3, 3, 172, 188, 3, 0, 0,
|
992
|
+
0, 0, 113, 146, 0, 21, 3, 86, 86, 0, 21, 21,
|
993
|
+
0, 21, 0, 0, 146, 0, 146, 0, 0, 3, 113, 0,
|
994
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 1, 5,
|
995
|
+
0, 98, 0, 55, 5, 0, 5, 95, 0, 116, 0, 53,
|
996
|
+
11, 0, 110, 11, 168, 0, 180, 23, 0, 122, 57, 3,
|
997
|
+
3, 3, 0, 0, 89, 0, 9, 9, 104, 164, 0, 180,
|
998
|
+
119, 176, 107, 107, 0, 160, 11, 201, 9, 9, 0, 80,
|
999
|
+
80, 0, 0, 152, 3, 3, 196, 156, 3, 80, 80, 77,
|
1000
|
+
152, 3, 226, 3, 0, 9, 9, 7, 104, 0, 211, 0,
|
1001
|
+
0, 7, 180, 23, 192, 0, 7, 11, 0, 110, 11, 216,
|
1002
|
+
0, 0, 149, 3, 3, 7, 0, 89, 3, 3, 196, 80,
|
1003
|
+
80, 7, 0, 156, 221, 232, 180, 119, 107, 107, 0, 160,
|
1004
|
+
11, 238, 9, 9, 0, 7, 3, 80, 80, 101, 77, 152,
|
1005
|
+
3, 226, 3, 0, 9, 9, 7, 104, 0, 211, 0, 0,
|
1006
|
+
7, 180, 23, 192, 0, 0, 0, 180, 23, 192, 0, 11,
|
1007
|
+
0, 110, 11, 216, 0, 0, 149, 3, 3, 3, 0, 7,
|
1008
|
+
89, 3, 0, 9, 9, 104, 211, 0, 180, 119, 221, 107,
|
1009
|
+
107, 0, 160, 11, 238, 9, 9, 0, 80, 80, 0, 7,
|
1010
|
+
152, 3, 3, 196, 156, 77, 180, 119, 221, 107, 107, 0,
|
1011
|
+
160, 11, 238, 0, 0, 11, 0, 110, 11, 216, 149, 7,
|
1012
|
+
3, 3, 7, 7, 89, 3, 3, 196, 80, 80, 7, 7,
|
1013
|
+
156, 232, 7, 3, 77, 77, 196, 89, 206, 3, 101, 9,
|
1014
|
+
9, 0, 80, 80, 3, 232, 3, 77, 196, 89, 206, 3,
|
1015
|
+
3, 196, 89, 206, 3, 226, 25, 25, 0, 0, 0, 0,
|
1016
|
+
31, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
|
1017
|
+
13, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0,
|
1018
|
+
0, 0, 0, 0, 0, 3, 15, 0, 0, 0, 0, 0,
|
1019
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0,
|
1020
|
+
17, 0, 0, 3, 3, 0, 0, 3, 0, 3, 0, 37,
|
1021
|
+
137, 43, 140, 63, 134, 184, 69, 0, 0, 1, 0, 65,
|
1022
|
+
67, 0, 33, 125, 31, 35, 0, 39, 128, 31, 41, 0,
|
1023
|
+
45, 131, 143, 0, 47
|
1024
|
+
};
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
private static final short _hpricot_scan_trans_actions_wi[] = init__hpricot_scan_trans_actions_wi_0();
|
1028
|
+
|
1029
|
+
|
1030
|
+
private static short[] init__hpricot_scan_to_state_actions_0()
|
1031
|
+
{
|
1032
|
+
return new short [] {
|
1033
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1034
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1035
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1036
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1037
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1038
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1039
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1040
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1041
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1042
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1043
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1044
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1045
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1046
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1047
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1048
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1049
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1050
|
+
27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0,
|
1051
|
+
27, 0, 27, 0
|
1052
|
+
};
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
private static final short _hpricot_scan_to_state_actions[] = init__hpricot_scan_to_state_actions_0();
|
1056
|
+
|
1057
|
+
|
1058
|
+
private static short[] init__hpricot_scan_from_state_actions_0()
|
1059
|
+
{
|
1060
|
+
return new short [] {
|
1061
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1062
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1063
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1064
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1065
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1066
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1067
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1068
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1069
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1070
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1071
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1072
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1073
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1074
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1075
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1076
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1077
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
1078
|
+
29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
|
1079
|
+
29, 0, 29, 0
|
1080
|
+
};
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
private static final short _hpricot_scan_from_state_actions[] = init__hpricot_scan_from_state_actions_0();
|
1084
|
+
|
1085
|
+
|
1086
|
+
private static short[] init__hpricot_scan_eof_trans_0()
|
1087
|
+
{
|
1088
|
+
return new short [] {
|
1089
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1090
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1091
|
+
40, 40, 40, 40, 1, 40, 1, 1, 1, 1, 1, 1,
|
1092
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1093
|
+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
1094
|
+
1, 1, 1, 1, 40, 40, 40, 40, 40, 40, 40, 40,
|
1095
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
1096
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
1097
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
1098
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
1099
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
1100
|
+
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
|
1101
|
+
40, 1, 1, 1, 1, 1, 350, 350, 350, 350, 350, 350,
|
1102
|
+
350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350,
|
1103
|
+
350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350,
|
1104
|
+
350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350,
|
1105
|
+
350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 408, 410,
|
1106
|
+
0, 415, 420, 420, 420, 40, 40, 40, 421, 421, 0, 426,
|
1107
|
+
0, 431, 0, 437
|
1108
|
+
};
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
private static final short _hpricot_scan_eof_trans[] = init__hpricot_scan_eof_trans_0();
|
1112
|
+
|
1113
|
+
|
1114
|
+
static final int hpricot_scan_start = 204;
|
1115
|
+
static final int hpricot_scan_error = -1;
|
1116
|
+
|
1117
|
+
static final int hpricot_scan_en_html_comment = 214;
|
1118
|
+
static final int hpricot_scan_en_html_cdata = 216;
|
1119
|
+
static final int hpricot_scan_en_html_procins = 218;
|
1120
|
+
static final int hpricot_scan_en_main = 204;
|
1121
|
+
|
1122
|
+
// line 564 "hpricot_scan.java.rl"
|
1123
|
+
|
1124
|
+
public final static int BUFSIZE = 16384;
|
1125
|
+
|
1126
|
+
|
1127
|
+
private int cs, act, have = 0, nread = 0, curline = 1;
|
1128
|
+
private int ts = 0, te = 0, eof = -1, p = -1, pe = -1, buf = 0;
|
1129
|
+
private byte[] data;
|
1130
|
+
private State S = null;
|
1131
|
+
private IRubyObject port, opts, attr, tag, akey, aval, bufsize;
|
1132
|
+
private int mark_tag = -1, mark_akey = -1, mark_aval = -1;
|
1133
|
+
private boolean done = false, ele_open = false, taint = false, io = false, text = false;
|
1134
|
+
private int buffer_size = 0;
|
1135
|
+
|
1136
|
+
private Extra x;
|
1137
|
+
|
1138
|
+
private IRubyObject self;
|
1139
|
+
private Ruby runtime;
|
1140
|
+
private ThreadContext ctx;
|
1141
|
+
private Block block;
|
1142
|
+
|
1143
|
+
private IRubyObject xmldecl, doctype, stag, etag, emptytag, comment, cdata, procins;
|
1144
|
+
|
1145
|
+
private RaiseException newRaiseException(RubyClass exceptionClass, String message) {
|
1146
|
+
return new RaiseException(runtime, exceptionClass, message, true);
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
public Scanner(IRubyObject self, IRubyObject[] args, Block block) {
|
1150
|
+
this.self = self;
|
1151
|
+
this.runtime = self.getRuntime();
|
1152
|
+
this.ctx = runtime.getCurrentContext();
|
1153
|
+
this.block = block;
|
1154
|
+
attr = runtime.getNil();
|
1155
|
+
tag = runtime.getNil();
|
1156
|
+
akey = runtime.getNil();
|
1157
|
+
aval = runtime.getNil();
|
1158
|
+
bufsize = runtime.getNil();
|
1159
|
+
|
1160
|
+
this.x = (Extra)this.runtime.getModule("Hpricot").dataGetStruct();
|
1161
|
+
|
1162
|
+
this.xmldecl = x.sym_xmldecl;
|
1163
|
+
this.doctype = x.sym_doctype;
|
1164
|
+
this.stag = x.sym_stag;
|
1165
|
+
this.etag = x.sym_etag;
|
1166
|
+
this.emptytag = x.sym_emptytag;
|
1167
|
+
this.comment = x.sym_comment;
|
1168
|
+
this.cdata = x.sym_cdata;
|
1169
|
+
this.procins = x.sym_procins;
|
1170
|
+
|
1171
|
+
port = args[0];
|
1172
|
+
if(args.length == 2) {
|
1173
|
+
opts = args[1];
|
1174
|
+
} else {
|
1175
|
+
opts = runtime.getNil();
|
1176
|
+
}
|
1177
|
+
|
1178
|
+
taint = port.isTaint();
|
1179
|
+
io = port.respondsTo("read");
|
1180
|
+
if(!io) {
|
1181
|
+
if(port.respondsTo("to_str")) {
|
1182
|
+
port = port.callMethod(ctx, "to_str");
|
1183
|
+
port = port.convertToString();
|
1184
|
+
} else {
|
1185
|
+
throw runtime.newArgumentError("an Hpricot document must be built from an input source (a String or IO object.)");
|
1186
|
+
}
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
if(!(opts instanceof RubyHash)) {
|
1190
|
+
opts = runtime.getNil();
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
if(!block.isGiven()) {
|
1194
|
+
S = new State();
|
1195
|
+
S.doc = x.cDoc.allocate();
|
1196
|
+
S.focus = S.doc;
|
1197
|
+
S.last = runtime.getNil();
|
1198
|
+
S.xml = OPT(opts, "xml");
|
1199
|
+
S.strict = OPT(opts, "xhtml_strict");
|
1200
|
+
S.fixup = OPT(opts, "fixup_tags");
|
1201
|
+
if(S.strict) {
|
1202
|
+
S.fixup = true;
|
1203
|
+
}
|
1204
|
+
S.doc.getInstanceVariables().fastSetInstanceVariable("@options", opts);
|
1205
|
+
S.EC = x.mHpricot.getConstant("ElementContent");
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
buffer_size = BUFSIZE;
|
1209
|
+
if(self.getInstanceVariables().fastHasInstanceVariable("@buffer_size")) {
|
1210
|
+
bufsize = self.getInstanceVariables().fastGetInstanceVariable("@buffer_size");
|
1211
|
+
if(!bufsize.isNil()) {
|
1212
|
+
buffer_size = RubyNumeric.fix2int(bufsize);
|
1213
|
+
}
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
if(io) {
|
1217
|
+
buf = 0;
|
1218
|
+
data = new byte[buffer_size];
|
1219
|
+
}
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
private int len, space;
|
1223
|
+
// hpricot_scan
|
1224
|
+
public IRubyObject scan() {
|
1225
|
+
|
1226
|
+
// line 1227 "HpricotScanService.java"
|
1227
|
+
{
|
1228
|
+
cs = hpricot_scan_start;
|
1229
|
+
ts = -1;
|
1230
|
+
te = -1;
|
1231
|
+
act = 0;
|
1232
|
+
}
|
1233
|
+
// line 667 "hpricot_scan.java.rl"
|
1234
|
+
while(!done) {
|
1235
|
+
p = pe = len = buf;
|
1236
|
+
space = buffer_size - have;
|
1237
|
+
|
1238
|
+
if(io) {
|
1239
|
+
if(space == 0) {
|
1240
|
+
/* We've used up the entire buffer storing an already-parsed token
|
1241
|
+
* prefix that must be preserved. Likely caused by super-long attributes.
|
1242
|
+
* Increase buffer size and continue */
|
1243
|
+
buffer_size += BUFSIZE;
|
1244
|
+
data = realloc(data, buffer_size);
|
1245
|
+
space = buffer_size - have;
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
p = have;
|
1249
|
+
IRubyObject str = port.callMethod(ctx, "read", runtime.newFixnum(space));
|
1250
|
+
ByteList bl = str.convertToString().getByteList();
|
1251
|
+
len = bl.realSize;
|
1252
|
+
System.arraycopy(bl.bytes, bl.begin, data, p, len);
|
1253
|
+
} else {
|
1254
|
+
ByteList bl = port.convertToString().getByteList();
|
1255
|
+
data = bl.bytes;
|
1256
|
+
buf = bl.begin;
|
1257
|
+
p = bl.begin;
|
1258
|
+
len = bl.realSize + 1;
|
1259
|
+
if(p + len >= data.length) {
|
1260
|
+
data = new byte[len];
|
1261
|
+
System.arraycopy(bl.bytes, bl.begin, data, 0, bl.realSize);
|
1262
|
+
p = 0;
|
1263
|
+
buf = 0;
|
1264
|
+
}
|
1265
|
+
done = true;
|
1266
|
+
eof = p + len;
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
nread += len;
|
1270
|
+
|
1271
|
+
/* If this is the last buffer, tack on an EOF. */
|
1272
|
+
if(io && len < space) {
|
1273
|
+
data[p + len++] = 0;
|
1274
|
+
eof = p + len;
|
1275
|
+
done = true;
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
pe = p + len;
|
1279
|
+
|
1280
|
+
|
1281
|
+
// line 1282 "HpricotScanService.java"
|
1282
|
+
{
|
1283
|
+
int _klen;
|
1284
|
+
int _trans = 0;
|
1285
|
+
int _acts;
|
1286
|
+
int _nacts;
|
1287
|
+
int _keys;
|
1288
|
+
int _goto_targ = 0;
|
1289
|
+
|
1290
|
+
_goto: while (true) {
|
1291
|
+
switch ( _goto_targ ) {
|
1292
|
+
case 0:
|
1293
|
+
if ( p == pe ) {
|
1294
|
+
_goto_targ = 4;
|
1295
|
+
continue _goto;
|
1296
|
+
}
|
1297
|
+
case 1:
|
1298
|
+
_acts = _hpricot_scan_from_state_actions[cs];
|
1299
|
+
_nacts = (int) _hpricot_scan_actions[_acts++];
|
1300
|
+
while ( _nacts-- > 0 ) {
|
1301
|
+
switch ( _hpricot_scan_actions[_acts++] ) {
|
1302
|
+
case 21:
|
1303
|
+
// line 1 "hpricot_scan.java.rl"
|
1304
|
+
{ts = p;}
|
1305
|
+
break;
|
1306
|
+
// line 1307 "HpricotScanService.java"
|
1307
|
+
}
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
_match: do {
|
1311
|
+
_keys = _hpricot_scan_key_offsets[cs];
|
1312
|
+
_trans = _hpricot_scan_index_offsets[cs];
|
1313
|
+
_klen = _hpricot_scan_single_lengths[cs];
|
1314
|
+
if ( _klen > 0 ) {
|
1315
|
+
int _lower = _keys;
|
1316
|
+
int _mid;
|
1317
|
+
int _upper = _keys + _klen - 1;
|
1318
|
+
while (true) {
|
1319
|
+
if ( _upper < _lower )
|
1320
|
+
break;
|
1321
|
+
|
1322
|
+
_mid = _lower + ((_upper-_lower) >> 1);
|
1323
|
+
if ( data[p] < _hpricot_scan_trans_keys[_mid] )
|
1324
|
+
_upper = _mid - 1;
|
1325
|
+
else if ( data[p] > _hpricot_scan_trans_keys[_mid] )
|
1326
|
+
_lower = _mid + 1;
|
1327
|
+
else {
|
1328
|
+
_trans += (_mid - _keys);
|
1329
|
+
break _match;
|
1330
|
+
}
|
1331
|
+
}
|
1332
|
+
_keys += _klen;
|
1333
|
+
_trans += _klen;
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
_klen = _hpricot_scan_range_lengths[cs];
|
1337
|
+
if ( _klen > 0 ) {
|
1338
|
+
int _lower = _keys;
|
1339
|
+
int _mid;
|
1340
|
+
int _upper = _keys + (_klen<<1) - 2;
|
1341
|
+
while (true) {
|
1342
|
+
if ( _upper < _lower )
|
1343
|
+
break;
|
1344
|
+
|
1345
|
+
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
|
1346
|
+
if ( data[p] < _hpricot_scan_trans_keys[_mid] )
|
1347
|
+
_upper = _mid - 2;
|
1348
|
+
else if ( data[p] > _hpricot_scan_trans_keys[_mid+1] )
|
1349
|
+
_lower = _mid + 2;
|
1350
|
+
else {
|
1351
|
+
_trans += ((_mid - _keys)>>1);
|
1352
|
+
break _match;
|
1353
|
+
}
|
1354
|
+
}
|
1355
|
+
_trans += _klen;
|
1356
|
+
}
|
1357
|
+
} while (false);
|
1358
|
+
|
1359
|
+
_trans = _hpricot_scan_indicies[_trans];
|
1360
|
+
case 3:
|
1361
|
+
cs = _hpricot_scan_trans_targs_wi[_trans];
|
1362
|
+
|
1363
|
+
if ( _hpricot_scan_trans_actions_wi[_trans] != 0 ) {
|
1364
|
+
_acts = _hpricot_scan_trans_actions_wi[_trans];
|
1365
|
+
_nacts = (int) _hpricot_scan_actions[_acts++];
|
1366
|
+
while ( _nacts-- > 0 )
|
1367
|
+
{
|
1368
|
+
switch ( _hpricot_scan_actions[_acts++] )
|
1369
|
+
{
|
1370
|
+
case 0:
|
1371
|
+
// line 514 "hpricot_scan.java.rl"
|
1372
|
+
{
|
1373
|
+
if(text) {
|
1374
|
+
tag = CAT(tag, mark_tag, p);
|
1375
|
+
ELE(x.sym_text);
|
1376
|
+
text = false;
|
1377
|
+
}
|
1378
|
+
attr = runtime.getNil();
|
1379
|
+
tag = runtime.getNil();
|
1380
|
+
mark_tag = -1;
|
1381
|
+
ele_open = true;
|
1382
|
+
}
|
1383
|
+
break;
|
1384
|
+
case 1:
|
1385
|
+
// line 526 "hpricot_scan.java.rl"
|
1386
|
+
{ mark_tag = p; }
|
1387
|
+
break;
|
1388
|
+
case 2:
|
1389
|
+
// line 527 "hpricot_scan.java.rl"
|
1390
|
+
{ mark_aval = p; }
|
1391
|
+
break;
|
1392
|
+
case 3:
|
1393
|
+
// line 528 "hpricot_scan.java.rl"
|
1394
|
+
{ mark_akey = p; }
|
1395
|
+
break;
|
1396
|
+
case 4:
|
1397
|
+
// line 529 "hpricot_scan.java.rl"
|
1398
|
+
{ tag = SET(mark_tag, p, tag); }
|
1399
|
+
break;
|
1400
|
+
case 5:
|
1401
|
+
// line 531 "hpricot_scan.java.rl"
|
1402
|
+
{ aval = SET(mark_aval, p, aval); }
|
1403
|
+
break;
|
1404
|
+
case 6:
|
1405
|
+
// line 532 "hpricot_scan.java.rl"
|
1406
|
+
{
|
1407
|
+
if(data[p-1] == '"' || data[p-1] == '\'') {
|
1408
|
+
aval = SET(mark_aval, p-1, aval);
|
1409
|
+
} else {
|
1410
|
+
aval = SET(mark_aval, p, aval);
|
1411
|
+
}
|
1412
|
+
}
|
1413
|
+
break;
|
1414
|
+
case 7:
|
1415
|
+
// line 539 "hpricot_scan.java.rl"
|
1416
|
+
{ akey = SET(mark_akey, p, akey); }
|
1417
|
+
break;
|
1418
|
+
case 8:
|
1419
|
+
// line 540 "hpricot_scan.java.rl"
|
1420
|
+
{ aval = SET(mark_aval, p, aval); ATTR(runtime.newSymbol("version"), aval); }
|
1421
|
+
break;
|
1422
|
+
case 9:
|
1423
|
+
// line 541 "hpricot_scan.java.rl"
|
1424
|
+
{ aval = SET(mark_aval, p, aval); ATTR(runtime.newSymbol("encoding"), aval); }
|
1425
|
+
break;
|
1426
|
+
case 10:
|
1427
|
+
// line 542 "hpricot_scan.java.rl"
|
1428
|
+
{ aval = SET(mark_aval, p, aval); ATTR(runtime.newSymbol("standalone"), aval); }
|
1429
|
+
break;
|
1430
|
+
case 11:
|
1431
|
+
// line 543 "hpricot_scan.java.rl"
|
1432
|
+
{ aval = SET(mark_aval, p, aval); ATTR(runtime.newSymbol("public_id"), aval); }
|
1433
|
+
break;
|
1434
|
+
case 12:
|
1435
|
+
// line 544 "hpricot_scan.java.rl"
|
1436
|
+
{ aval = SET(mark_aval, p, aval); ATTR(runtime.newSymbol("system_id"), aval); }
|
1437
|
+
break;
|
1438
|
+
case 13:
|
1439
|
+
// line 546 "hpricot_scan.java.rl"
|
1440
|
+
{
|
1441
|
+
akey = runtime.getNil();
|
1442
|
+
aval = runtime.getNil();
|
1443
|
+
mark_akey = -1;
|
1444
|
+
mark_aval = -1;
|
1445
|
+
}
|
1446
|
+
break;
|
1447
|
+
case 14:
|
1448
|
+
// line 553 "hpricot_scan.java.rl"
|
1449
|
+
{
|
1450
|
+
if(!S.xml) {
|
1451
|
+
akey = akey.callMethod(runtime.getCurrentContext(), "downcase");
|
1452
|
+
}
|
1453
|
+
ATTR(akey, aval);
|
1454
|
+
}
|
1455
|
+
break;
|
1456
|
+
case 15:
|
1457
|
+
// line 9 "hpricot_scan.java.rl"
|
1458
|
+
{curline += 1;}
|
1459
|
+
break;
|
1460
|
+
case 16:
|
1461
|
+
// line 46 "hpricot_scan.java.rl"
|
1462
|
+
{ TEXT_PASS(); }
|
1463
|
+
break;
|
1464
|
+
case 17:
|
1465
|
+
// line 50 "hpricot_scan.java.rl"
|
1466
|
+
{ EBLK(comment, 3); {cs = 204; _goto_targ = 2; if (true) continue _goto;} }
|
1467
|
+
break;
|
1468
|
+
case 18:
|
1469
|
+
// line 55 "hpricot_scan.java.rl"
|
1470
|
+
{ EBLK(cdata, 3); {cs = 204; _goto_targ = 2; if (true) continue _goto;} }
|
1471
|
+
break;
|
1472
|
+
case 19:
|
1473
|
+
// line 60 "hpricot_scan.java.rl"
|
1474
|
+
{ EBLK(procins, 2); {cs = 204; _goto_targ = 2; if (true) continue _goto;} }
|
1475
|
+
break;
|
1476
|
+
case 22:
|
1477
|
+
// line 1 "hpricot_scan.java.rl"
|
1478
|
+
{te = p+1;}
|
1479
|
+
break;
|
1480
|
+
case 23:
|
1481
|
+
// line 50 "hpricot_scan.java.rl"
|
1482
|
+
{te = p+1;}
|
1483
|
+
break;
|
1484
|
+
case 24:
|
1485
|
+
// line 51 "hpricot_scan.java.rl"
|
1486
|
+
{te = p+1;{ TEXT_PASS(); }}
|
1487
|
+
break;
|
1488
|
+
case 25:
|
1489
|
+
// line 51 "hpricot_scan.java.rl"
|
1490
|
+
{te = p;p--;{ TEXT_PASS(); }}
|
1491
|
+
break;
|
1492
|
+
case 26:
|
1493
|
+
// line 51 "hpricot_scan.java.rl"
|
1494
|
+
{{p = ((te))-1;}{ TEXT_PASS(); }}
|
1495
|
+
break;
|
1496
|
+
case 27:
|
1497
|
+
// line 55 "hpricot_scan.java.rl"
|
1498
|
+
{te = p+1;}
|
1499
|
+
break;
|
1500
|
+
case 28:
|
1501
|
+
// line 56 "hpricot_scan.java.rl"
|
1502
|
+
{te = p+1;{ TEXT_PASS(); }}
|
1503
|
+
break;
|
1504
|
+
case 29:
|
1505
|
+
// line 56 "hpricot_scan.java.rl"
|
1506
|
+
{te = p;p--;{ TEXT_PASS(); }}
|
1507
|
+
break;
|
1508
|
+
case 30:
|
1509
|
+
// line 56 "hpricot_scan.java.rl"
|
1510
|
+
{{p = ((te))-1;}{ TEXT_PASS(); }}
|
1511
|
+
break;
|
1512
|
+
case 31:
|
1513
|
+
// line 60 "hpricot_scan.java.rl"
|
1514
|
+
{te = p+1;}
|
1515
|
+
break;
|
1516
|
+
case 32:
|
1517
|
+
// line 61 "hpricot_scan.java.rl"
|
1518
|
+
{te = p+1;{ TEXT_PASS(); }}
|
1519
|
+
break;
|
1520
|
+
case 33:
|
1521
|
+
// line 61 "hpricot_scan.java.rl"
|
1522
|
+
{te = p;p--;{ TEXT_PASS(); }}
|
1523
|
+
break;
|
1524
|
+
case 34:
|
1525
|
+
// line 66 "hpricot_scan.java.rl"
|
1526
|
+
{act = 8;}
|
1527
|
+
break;
|
1528
|
+
case 35:
|
1529
|
+
// line 68 "hpricot_scan.java.rl"
|
1530
|
+
{act = 10;}
|
1531
|
+
break;
|
1532
|
+
case 36:
|
1533
|
+
// line 70 "hpricot_scan.java.rl"
|
1534
|
+
{act = 12;}
|
1535
|
+
break;
|
1536
|
+
case 37:
|
1537
|
+
// line 73 "hpricot_scan.java.rl"
|
1538
|
+
{act = 15;}
|
1539
|
+
break;
|
1540
|
+
case 38:
|
1541
|
+
// line 65 "hpricot_scan.java.rl"
|
1542
|
+
{te = p+1;{ ELE(xmldecl); }}
|
1543
|
+
break;
|
1544
|
+
case 39:
|
1545
|
+
// line 66 "hpricot_scan.java.rl"
|
1546
|
+
{te = p+1;{ ELE(doctype); }}
|
1547
|
+
break;
|
1548
|
+
case 40:
|
1549
|
+
// line 68 "hpricot_scan.java.rl"
|
1550
|
+
{te = p+1;{ ELE(stag); }}
|
1551
|
+
break;
|
1552
|
+
case 41:
|
1553
|
+
// line 69 "hpricot_scan.java.rl"
|
1554
|
+
{te = p+1;{ ELE(etag); }}
|
1555
|
+
break;
|
1556
|
+
case 42:
|
1557
|
+
// line 70 "hpricot_scan.java.rl"
|
1558
|
+
{te = p+1;{ ELE(emptytag); }}
|
1559
|
+
break;
|
1560
|
+
case 43:
|
1561
|
+
// line 71 "hpricot_scan.java.rl"
|
1562
|
+
{te = p+1;{ {cs = 214; _goto_targ = 2; if (true) continue _goto;} }}
|
1563
|
+
break;
|
1564
|
+
case 44:
|
1565
|
+
// line 72 "hpricot_scan.java.rl"
|
1566
|
+
{te = p+1;{ {cs = 216; _goto_targ = 2; if (true) continue _goto;} }}
|
1567
|
+
break;
|
1568
|
+
case 45:
|
1569
|
+
// line 73 "hpricot_scan.java.rl"
|
1570
|
+
{te = p+1;{ TEXT_PASS(); }}
|
1571
|
+
break;
|
1572
|
+
case 46:
|
1573
|
+
// line 66 "hpricot_scan.java.rl"
|
1574
|
+
{te = p;p--;{ ELE(doctype); }}
|
1575
|
+
break;
|
1576
|
+
case 47:
|
1577
|
+
// line 67 "hpricot_scan.java.rl"
|
1578
|
+
{te = p;p--;{ {cs = 218; _goto_targ = 2; if (true) continue _goto;} }}
|
1579
|
+
break;
|
1580
|
+
case 48:
|
1581
|
+
// line 73 "hpricot_scan.java.rl"
|
1582
|
+
{te = p;p--;{ TEXT_PASS(); }}
|
1583
|
+
break;
|
1584
|
+
case 49:
|
1585
|
+
// line 67 "hpricot_scan.java.rl"
|
1586
|
+
{{p = ((te))-1;}{ {cs = 218; _goto_targ = 2; if (true) continue _goto;} }}
|
1587
|
+
break;
|
1588
|
+
case 50:
|
1589
|
+
// line 73 "hpricot_scan.java.rl"
|
1590
|
+
{{p = ((te))-1;}{ TEXT_PASS(); }}
|
1591
|
+
break;
|
1592
|
+
case 51:
|
1593
|
+
// line 1 "hpricot_scan.java.rl"
|
1594
|
+
{ switch( act ) {
|
1595
|
+
case 8:
|
1596
|
+
{{p = ((te))-1;} ELE(doctype); }
|
1597
|
+
break;
|
1598
|
+
case 10:
|
1599
|
+
{{p = ((te))-1;} ELE(stag); }
|
1600
|
+
break;
|
1601
|
+
case 12:
|
1602
|
+
{{p = ((te))-1;} ELE(emptytag); }
|
1603
|
+
break;
|
1604
|
+
case 15:
|
1605
|
+
{{p = ((te))-1;} TEXT_PASS(); }
|
1606
|
+
break;
|
1607
|
+
default: break;
|
1608
|
+
}
|
1609
|
+
}
|
1610
|
+
break;
|
1611
|
+
// line 1612 "HpricotScanService.java"
|
1612
|
+
}
|
1613
|
+
}
|
1614
|
+
}
|
1615
|
+
|
1616
|
+
case 2:
|
1617
|
+
_acts = _hpricot_scan_to_state_actions[cs];
|
1618
|
+
_nacts = (int) _hpricot_scan_actions[_acts++];
|
1619
|
+
while ( _nacts-- > 0 ) {
|
1620
|
+
switch ( _hpricot_scan_actions[_acts++] ) {
|
1621
|
+
case 20:
|
1622
|
+
// line 1 "hpricot_scan.java.rl"
|
1623
|
+
{ts = -1;}
|
1624
|
+
break;
|
1625
|
+
// line 1626 "HpricotScanService.java"
|
1626
|
+
}
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
if ( ++p != pe ) {
|
1630
|
+
_goto_targ = 1;
|
1631
|
+
continue _goto;
|
1632
|
+
}
|
1633
|
+
case 4:
|
1634
|
+
if ( p == eof )
|
1635
|
+
{
|
1636
|
+
if ( _hpricot_scan_eof_trans[cs] > 0 ) {
|
1637
|
+
_trans = _hpricot_scan_eof_trans[cs] - 1;
|
1638
|
+
_goto_targ = 3;
|
1639
|
+
continue _goto;
|
1640
|
+
}
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
case 5:
|
1644
|
+
}
|
1645
|
+
break; }
|
1646
|
+
}
|
1647
|
+
// line 714 "hpricot_scan.java.rl"
|
1648
|
+
|
1649
|
+
if(cs == hpricot_scan_error) {
|
1650
|
+
if(!tag.isNil()) {
|
1651
|
+
throw newRaiseException(x.rb_eHpricotParseError, "parse error on element <" + tag + ">, starting on line " + curline + ".\n" + NO_WAY_SERIOUSLY);
|
1652
|
+
} else {
|
1653
|
+
throw newRaiseException(x.rb_eHpricotParseError, "parse error on line " + curline + ".\n" + NO_WAY_SERIOUSLY);
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
|
1657
|
+
if(done && ele_open) {
|
1658
|
+
ele_open = false;
|
1659
|
+
if(ts > 0) {
|
1660
|
+
mark_tag = ts;
|
1661
|
+
ts = 0;
|
1662
|
+
text = true;
|
1663
|
+
}
|
1664
|
+
}
|
1665
|
+
|
1666
|
+
if(ts == -1) {
|
1667
|
+
have = 0;
|
1668
|
+
if(mark_tag != -1 && text) {
|
1669
|
+
if(done) {
|
1670
|
+
if(mark_tag < p - 1) {
|
1671
|
+
tag = CAT(tag, mark_tag, p-1);
|
1672
|
+
ELE(x.sym_text);
|
1673
|
+
}
|
1674
|
+
} else {
|
1675
|
+
tag = CAT(tag, mark_tag, p);
|
1676
|
+
}
|
1677
|
+
}
|
1678
|
+
if(io) {
|
1679
|
+
mark_tag = 0;
|
1680
|
+
} else {
|
1681
|
+
mark_tag = ((RubyString)port).getByteList().begin;
|
1682
|
+
}
|
1683
|
+
} else if(io) {
|
1684
|
+
have = pe - ts;
|
1685
|
+
System.arraycopy(data, ts, data, buf, have);
|
1686
|
+
mark_tag = SLIDE(mark_tag);
|
1687
|
+
mark_akey = SLIDE(mark_akey);
|
1688
|
+
mark_aval = SLIDE(mark_aval);
|
1689
|
+
te -= ts;
|
1690
|
+
ts = 0;
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
if(S != null) {
|
1695
|
+
return S.doc;
|
1696
|
+
}
|
1697
|
+
|
1698
|
+
return runtime.getNil();
|
1699
|
+
}
|
1700
|
+
}
|
1701
|
+
|
1702
|
+
public static class HpricotModule {
|
1703
|
+
// hpricot_scan
|
1704
|
+
@JRubyMethod(module = true, optional = 1, required = 1, frame = true)
|
1705
|
+
public static IRubyObject scan(IRubyObject self, IRubyObject[] args, Block block) {
|
1706
|
+
return new Scanner(self, args, block).scan();
|
1707
|
+
}
|
1708
|
+
|
1709
|
+
// hpricot_css
|
1710
|
+
@JRubyMethod(module = true)
|
1711
|
+
public static IRubyObject css(IRubyObject self, IRubyObject mod, IRubyObject str, IRubyObject node) {
|
1712
|
+
return new HpricotCss(self, mod, str, node).scan();
|
1713
|
+
}
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
public static class CData {
|
1717
|
+
@JRubyMethod
|
1718
|
+
public static IRubyObject content(IRubyObject self) {
|
1719
|
+
return hpricot_ele_get_name(self);
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
@JRubyMethod(name = "content=")
|
1723
|
+
public static IRubyObject content_set(IRubyObject self, IRubyObject value) {
|
1724
|
+
return hpricot_ele_set_name(self, value);
|
1725
|
+
}
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
public static class Comment {
|
1729
|
+
@JRubyMethod
|
1730
|
+
public static IRubyObject content(IRubyObject self) {
|
1731
|
+
return hpricot_ele_get_name(self);
|
1732
|
+
}
|
1733
|
+
|
1734
|
+
@JRubyMethod(name = "content=")
|
1735
|
+
public static IRubyObject content_set(IRubyObject self, IRubyObject value) {
|
1736
|
+
return hpricot_ele_set_name(self, value);
|
1737
|
+
}
|
1738
|
+
}
|
1739
|
+
|
1740
|
+
public static class DocType {
|
1741
|
+
@JRubyMethod
|
1742
|
+
public static IRubyObject raw_string(IRubyObject self) {
|
1743
|
+
return hpricot_ele_get_name(self);
|
1744
|
+
}
|
1745
|
+
|
1746
|
+
@JRubyMethod
|
1747
|
+
public static IRubyObject clear_raw(IRubyObject self) {
|
1748
|
+
return hpricot_ele_clear_name(self);
|
1749
|
+
}
|
1750
|
+
|
1751
|
+
@JRubyMethod
|
1752
|
+
public static IRubyObject target(IRubyObject self) {
|
1753
|
+
return hpricot_ele_get_target(self);
|
1754
|
+
}
|
1755
|
+
|
1756
|
+
@JRubyMethod(name = "target=")
|
1757
|
+
public static IRubyObject target_set(IRubyObject self, IRubyObject value) {
|
1758
|
+
return hpricot_ele_set_target(self, value);
|
1759
|
+
}
|
1760
|
+
|
1761
|
+
@JRubyMethod
|
1762
|
+
public static IRubyObject public_id(IRubyObject self) {
|
1763
|
+
return hpricot_ele_get_public_id(self);
|
1764
|
+
}
|
1765
|
+
|
1766
|
+
@JRubyMethod(name = "public_id=")
|
1767
|
+
public static IRubyObject public_id_set(IRubyObject self, IRubyObject value) {
|
1768
|
+
return hpricot_ele_set_public_id(self, value);
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
@JRubyMethod
|
1772
|
+
public static IRubyObject system_id(IRubyObject self) {
|
1773
|
+
return hpricot_ele_get_system_id(self);
|
1774
|
+
}
|
1775
|
+
|
1776
|
+
@JRubyMethod(name = "system_id=")
|
1777
|
+
public static IRubyObject system_id_set(IRubyObject self, IRubyObject value) {
|
1778
|
+
return hpricot_ele_set_system_id(self, value);
|
1779
|
+
}
|
1780
|
+
}
|
1781
|
+
|
1782
|
+
public static class Elem {
|
1783
|
+
@JRubyMethod
|
1784
|
+
public static IRubyObject clear_raw(IRubyObject self) {
|
1785
|
+
return hpricot_ele_clear_raw(self);
|
1786
|
+
}
|
1787
|
+
}
|
1788
|
+
|
1789
|
+
public static class BogusETag {
|
1790
|
+
@JRubyMethod
|
1791
|
+
public static IRubyObject raw_string(IRubyObject self) {
|
1792
|
+
return hpricot_ele_get_attr(self);
|
1793
|
+
}
|
1794
|
+
|
1795
|
+
@JRubyMethod
|
1796
|
+
public static IRubyObject clear_raw(IRubyObject self) {
|
1797
|
+
return hpricot_ele_clear_attr(self);
|
1798
|
+
}
|
1799
|
+
}
|
1800
|
+
|
1801
|
+
public static class Text {
|
1802
|
+
@JRubyMethod
|
1803
|
+
public static IRubyObject raw_string(IRubyObject self) {
|
1804
|
+
return hpricot_ele_get_name(self);
|
1805
|
+
}
|
1806
|
+
|
1807
|
+
@JRubyMethod
|
1808
|
+
public static IRubyObject clear_raw(IRubyObject self) {
|
1809
|
+
return hpricot_ele_clear_name(self);
|
1810
|
+
}
|
1811
|
+
|
1812
|
+
@JRubyMethod
|
1813
|
+
public static IRubyObject content(IRubyObject self) {
|
1814
|
+
return hpricot_ele_get_name(self);
|
1815
|
+
}
|
1816
|
+
|
1817
|
+
@JRubyMethod(name = "content=")
|
1818
|
+
public static IRubyObject content_set(IRubyObject self, IRubyObject value) {
|
1819
|
+
return hpricot_ele_set_name(self, value);
|
1820
|
+
}
|
1821
|
+
}
|
1822
|
+
|
1823
|
+
public static class XMLDecl {
|
1824
|
+
@JRubyMethod
|
1825
|
+
public static IRubyObject raw_string(IRubyObject self) {
|
1826
|
+
return hpricot_ele_get_name(self);
|
1827
|
+
}
|
1828
|
+
|
1829
|
+
@JRubyMethod
|
1830
|
+
public static IRubyObject clear_raw(IRubyObject self) {
|
1831
|
+
return hpricot_ele_clear_name(self);
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
@JRubyMethod
|
1835
|
+
public static IRubyObject encoding(IRubyObject self) {
|
1836
|
+
return hpricot_ele_get_encoding(self);
|
1837
|
+
}
|
1838
|
+
|
1839
|
+
@JRubyMethod(name = "encoding=")
|
1840
|
+
public static IRubyObject encoding_set(IRubyObject self, IRubyObject value) {
|
1841
|
+
return hpricot_ele_set_encoding(self, value);
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
@JRubyMethod
|
1845
|
+
public static IRubyObject standalone(IRubyObject self) {
|
1846
|
+
return hpricot_ele_get_standalone(self);
|
1847
|
+
}
|
1848
|
+
|
1849
|
+
@JRubyMethod(name = "standalone=")
|
1850
|
+
public static IRubyObject standalone_set(IRubyObject self, IRubyObject value) {
|
1851
|
+
return hpricot_ele_set_standalone(self, value);
|
1852
|
+
}
|
1853
|
+
|
1854
|
+
@JRubyMethod
|
1855
|
+
public static IRubyObject version(IRubyObject self) {
|
1856
|
+
return hpricot_ele_get_version(self);
|
1857
|
+
}
|
1858
|
+
|
1859
|
+
@JRubyMethod(name = "version=")
|
1860
|
+
public static IRubyObject version_set(IRubyObject self, IRubyObject value) {
|
1861
|
+
return hpricot_ele_set_version(self, value);
|
1862
|
+
}
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
public static class ProcIns {
|
1866
|
+
@JRubyMethod
|
1867
|
+
public static IRubyObject target(IRubyObject self) {
|
1868
|
+
return hpricot_ele_get_name(self);
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
@JRubyMethod(name = "target=")
|
1872
|
+
public static IRubyObject target_set(IRubyObject self, IRubyObject value) {
|
1873
|
+
return hpricot_ele_set_name(self, value);
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
@JRubyMethod
|
1877
|
+
public static IRubyObject content(IRubyObject self) {
|
1878
|
+
return hpricot_ele_get_attr(self);
|
1879
|
+
}
|
1880
|
+
|
1881
|
+
@JRubyMethod(name = "content=")
|
1882
|
+
public static IRubyObject content_set(IRubyObject self, IRubyObject value) {
|
1883
|
+
return hpricot_ele_set_attr(self, value);
|
1884
|
+
}
|
1885
|
+
}
|
1886
|
+
|
1887
|
+
public final static String NO_WAY_SERIOUSLY = "*** This should not happen, please send a bug report with the HTML you're parsing to why@whytheluckystiff.net. So sorry!";
|
1888
|
+
|
1889
|
+
public final static int H_ELE_TAG = 0;
|
1890
|
+
public final static int H_ELE_PARENT = 1;
|
1891
|
+
public final static int H_ELE_ATTR = 2;
|
1892
|
+
public final static int H_ELE_ETAG = 3;
|
1893
|
+
public final static int H_ELE_RAW = 4;
|
1894
|
+
public final static int H_ELE_EC = 5;
|
1895
|
+
public final static int H_ELE_HASH = 6;
|
1896
|
+
public final static int H_ELE_CHILDREN = 7;
|
1897
|
+
|
1898
|
+
public static IRubyObject H_ELE_GET(IRubyObject recv, int n) {
|
1899
|
+
return ((IRubyObject[])recv.dataGetStruct())[n];
|
1900
|
+
}
|
1901
|
+
|
1902
|
+
public static IRubyObject H_ELE_SET(IRubyObject recv, int n, IRubyObject value) {
|
1903
|
+
((IRubyObject[])recv.dataGetStruct())[n] = value;
|
1904
|
+
return value;
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
private static class RefCallback implements Callback {
|
1908
|
+
private final int n;
|
1909
|
+
public RefCallback(int n) { this.n = n; }
|
1910
|
+
|
1911
|
+
public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
|
1912
|
+
return H_ELE_GET(recv, n);
|
1913
|
+
}
|
1914
|
+
|
1915
|
+
public Arity getArity() {
|
1916
|
+
return Arity.NO_ARGUMENTS;
|
1917
|
+
}
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
private static class SetCallback implements Callback {
|
1921
|
+
private final int n;
|
1922
|
+
public SetCallback(int n) { this.n = n; }
|
1923
|
+
|
1924
|
+
public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) {
|
1925
|
+
return H_ELE_SET(recv, n, args[0]);
|
1926
|
+
}
|
1927
|
+
|
1928
|
+
public Arity getArity() {
|
1929
|
+
return Arity.ONE_ARGUMENT;
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
|
1933
|
+
private final static Callback[] ref_func = new Callback[]{
|
1934
|
+
new RefCallback(0),
|
1935
|
+
new RefCallback(1),
|
1936
|
+
new RefCallback(2),
|
1937
|
+
new RefCallback(3),
|
1938
|
+
new RefCallback(4),
|
1939
|
+
new RefCallback(5),
|
1940
|
+
new RefCallback(6),
|
1941
|
+
new RefCallback(7),
|
1942
|
+
new RefCallback(8),
|
1943
|
+
new RefCallback(9)};
|
1944
|
+
|
1945
|
+
private final static Callback[] set_func = new Callback[]{
|
1946
|
+
new SetCallback(0),
|
1947
|
+
new SetCallback(1),
|
1948
|
+
new SetCallback(2),
|
1949
|
+
new SetCallback(3),
|
1950
|
+
new SetCallback(4),
|
1951
|
+
new SetCallback(5),
|
1952
|
+
new SetCallback(6),
|
1953
|
+
new SetCallback(7),
|
1954
|
+
new SetCallback(8),
|
1955
|
+
new SetCallback(9)};
|
1956
|
+
|
1957
|
+
public final static ObjectAllocator alloc_hpricot_struct = new ObjectAllocator() {
|
1958
|
+
// alloc_hpricot_struct
|
1959
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
1960
|
+
RubyClass kurrent = klass;
|
1961
|
+
Object sz = kurrent.fastGetInternalVariable("__size__");
|
1962
|
+
while(sz == null && kurrent != null) {
|
1963
|
+
kurrent = kurrent.getSuperClass();
|
1964
|
+
sz = kurrent.fastGetInternalVariable("__size__");
|
1965
|
+
}
|
1966
|
+
int size = RubyNumeric.fix2int((RubyObject)sz);
|
1967
|
+
RubyObject obj = new RubyObject(runtime, klass);
|
1968
|
+
IRubyObject[] all = new IRubyObject[size];
|
1969
|
+
java.util.Arrays.fill(all, runtime.getNil());
|
1970
|
+
obj.dataWrapStruct(all);
|
1971
|
+
return obj;
|
1972
|
+
}
|
1973
|
+
};
|
1974
|
+
|
1975
|
+
public static RubyClass makeHpricotStruct(Ruby runtime, IRubyObject[] members) {
|
1976
|
+
RubyClass klass = RubyClass.newClass(runtime, runtime.getObject());
|
1977
|
+
klass.fastSetInternalVariable("__size__", runtime.newFixnum(members.length));
|
1978
|
+
klass.setAllocator(alloc_hpricot_struct);
|
1979
|
+
|
1980
|
+
for(int i = 0; i < members.length; i++) {
|
1981
|
+
String id = members[i].toString();
|
1982
|
+
klass.defineMethod(id, ref_func[i]);
|
1983
|
+
klass.defineMethod(id + "=", set_func[i]);
|
1984
|
+
}
|
1985
|
+
|
1986
|
+
return klass;
|
1987
|
+
}
|
1988
|
+
|
1989
|
+
public boolean basicLoad(final Ruby runtime) throws IOException {
|
1990
|
+
Init_hpricot_scan(runtime);
|
1991
|
+
return true;
|
1992
|
+
}
|
1993
|
+
|
1994
|
+
public static class Extra {
|
1995
|
+
IRubyObject symAllow, symDeny, sym_xmldecl, sym_doctype,
|
1996
|
+
sym_procins, sym_stag, sym_etag, sym_emptytag,
|
1997
|
+
sym_allowed, sym_children, sym_comment,
|
1998
|
+
sym_cdata, sym_name, sym_parent,
|
1999
|
+
sym_raw_attributes, sym_raw_string, sym_tagno,
|
2000
|
+
sym_text, sym_EMPTY, sym_CDATA;
|
2001
|
+
|
2002
|
+
public RubyModule mHpricot;
|
2003
|
+
public RubyClass structElem;
|
2004
|
+
public RubyClass structAttr;
|
2005
|
+
public RubyClass structBasic;
|
2006
|
+
public RubyClass cDoc;
|
2007
|
+
public RubyClass cCData;
|
2008
|
+
public RubyClass cComment;
|
2009
|
+
public RubyClass cDocType;
|
2010
|
+
public RubyClass cElem;
|
2011
|
+
public RubyClass cBogusETag;
|
2012
|
+
public RubyClass cText;
|
2013
|
+
public RubyClass cXMLDecl;
|
2014
|
+
public RubyClass cProcIns;
|
2015
|
+
public RubyClass rb_eHpricotParseError;
|
2016
|
+
public IRubyObject reProcInsParse;
|
2017
|
+
|
2018
|
+
public Extra(Ruby runtime) {
|
2019
|
+
symAllow = runtime.newSymbol("allow");
|
2020
|
+
symDeny = runtime.newSymbol("deny");
|
2021
|
+
sym_xmldecl = runtime.newSymbol("xmldecl");
|
2022
|
+
sym_doctype = runtime.newSymbol("doctype");
|
2023
|
+
sym_procins = runtime.newSymbol("procins");
|
2024
|
+
sym_stag = runtime.newSymbol("stag");
|
2025
|
+
sym_etag = runtime.newSymbol("etag");
|
2026
|
+
sym_emptytag = runtime.newSymbol("emptytag");
|
2027
|
+
sym_allowed = runtime.newSymbol("allowed");
|
2028
|
+
sym_children = runtime.newSymbol("children");
|
2029
|
+
sym_comment = runtime.newSymbol("comment");
|
2030
|
+
sym_cdata = runtime.newSymbol("cdata");
|
2031
|
+
sym_name = runtime.newSymbol("name");
|
2032
|
+
sym_parent = runtime.newSymbol("parent");
|
2033
|
+
sym_raw_attributes = runtime.newSymbol("raw_attributes");
|
2034
|
+
sym_raw_string = runtime.newSymbol("raw_string");
|
2035
|
+
sym_tagno = runtime.newSymbol("tagno");
|
2036
|
+
sym_text = runtime.newSymbol("text");
|
2037
|
+
sym_EMPTY = runtime.newSymbol("EMPTY");
|
2038
|
+
sym_CDATA = runtime.newSymbol("CDATA");
|
2039
|
+
}
|
2040
|
+
}
|
2041
|
+
|
2042
|
+
public static void Init_hpricot_scan(Ruby runtime) {
|
2043
|
+
Extra x = new Extra(runtime);
|
2044
|
+
|
2045
|
+
x.mHpricot = runtime.defineModule("Hpricot");
|
2046
|
+
x.mHpricot.dataWrapStruct(x);
|
2047
|
+
|
2048
|
+
x.mHpricot.getSingletonClass().attr_accessor(runtime.getCurrentContext(),new IRubyObject[]{runtime.newSymbol("buffer_size")});
|
2049
|
+
x.mHpricot.defineAnnotatedMethods(HpricotModule.class);
|
2050
|
+
|
2051
|
+
x.rb_eHpricotParseError = x.mHpricot.defineClassUnder("ParseError",runtime.getClass("StandardError"),runtime.getClass("StandardError").getAllocator());
|
2052
|
+
|
2053
|
+
x.structElem = makeHpricotStruct(runtime, new IRubyObject[] {x.sym_name, x.sym_parent, x.sym_raw_attributes, x.sym_etag, x.sym_raw_string, x.sym_allowed, x.sym_tagno, x.sym_children});
|
2054
|
+
x.structAttr = makeHpricotStruct(runtime, new IRubyObject[] {x.sym_name, x.sym_parent, x.sym_raw_attributes});
|
2055
|
+
x.structBasic= makeHpricotStruct(runtime, new IRubyObject[] {x.sym_name, x.sym_parent});
|
2056
|
+
|
2057
|
+
x.cDoc = x.mHpricot.defineClassUnder("Doc", x.structElem, x.structElem.getAllocator());
|
2058
|
+
|
2059
|
+
x.cCData = x.mHpricot.defineClassUnder("CData", x.structBasic, x.structBasic.getAllocator());
|
2060
|
+
x.cCData.defineAnnotatedMethods(CData.class);
|
2061
|
+
|
2062
|
+
x.cComment = x.mHpricot.defineClassUnder("Comment", x.structBasic, x.structBasic.getAllocator());
|
2063
|
+
x.cComment.defineAnnotatedMethods(Comment.class);
|
2064
|
+
|
2065
|
+
x.cDocType = x.mHpricot.defineClassUnder("DocType", x.structAttr, x.structAttr.getAllocator());
|
2066
|
+
x.cDocType.defineAnnotatedMethods(DocType.class);
|
2067
|
+
|
2068
|
+
x.cElem = x.mHpricot.defineClassUnder("Elem", x.structElem, x.structElem.getAllocator());
|
2069
|
+
x.cElem.defineAnnotatedMethods(Elem.class);
|
2070
|
+
|
2071
|
+
x.cBogusETag = x.mHpricot.defineClassUnder("BogusETag", x.structAttr, x.structAttr.getAllocator());
|
2072
|
+
x.cBogusETag.defineAnnotatedMethods(BogusETag.class);
|
2073
|
+
|
2074
|
+
x.cText = x.mHpricot.defineClassUnder("Text", x.structBasic, x.structBasic.getAllocator());
|
2075
|
+
x.cText.defineAnnotatedMethods(Text.class);
|
2076
|
+
|
2077
|
+
x.cXMLDecl = x.mHpricot.defineClassUnder("XMLDecl", x.structAttr, x.structAttr.getAllocator());
|
2078
|
+
x.cXMLDecl.defineAnnotatedMethods(XMLDecl.class);
|
2079
|
+
|
2080
|
+
x.cProcIns = x.mHpricot.defineClassUnder("ProcIns", x.structAttr, x.structAttr.getAllocator());
|
2081
|
+
x.cProcIns.defineAnnotatedMethods(ProcIns.class);
|
2082
|
+
|
2083
|
+
x.reProcInsParse = runtime.evalScriptlet("/\\A<\\?(\\S+)\\s+(.+)/m");
|
2084
|
+
x.mHpricot.setConstant("ProcInsParse", x.reProcInsParse);
|
2085
|
+
}
|
2086
|
+
}
|