webtranslateit-hpricot 0.9.0

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