thbar-hpricot 0.8.3.1

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