rubyjedi-oga 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +13 -0
  3. data/LICENSE +362 -0
  4. data/README.md +317 -0
  5. data/doc/css/common.css +77 -0
  6. data/doc/css_selectors.md +935 -0
  7. data/doc/manually_creating_documents.md +67 -0
  8. data/doc/migrating_from_nokogiri.md +169 -0
  9. data/doc/xml_namespaces.md +63 -0
  10. data/ext/c/extconf.rb +11 -0
  11. data/ext/c/lexer.c +2595 -0
  12. data/ext/c/lexer.h +16 -0
  13. data/ext/c/lexer.rl +198 -0
  14. data/ext/c/liboga.c +6 -0
  15. data/ext/c/liboga.h +11 -0
  16. data/ext/java/Liboga.java +14 -0
  17. data/ext/java/org/liboga/xml/Lexer.java +1363 -0
  18. data/ext/java/org/liboga/xml/Lexer.rl +223 -0
  19. data/ext/ragel/base_lexer.rl +633 -0
  20. data/lib/oga.rb +57 -0
  21. data/lib/oga/blacklist.rb +40 -0
  22. data/lib/oga/css/lexer.rb +743 -0
  23. data/lib/oga/css/parser.rb +976 -0
  24. data/lib/oga/entity_decoder.rb +21 -0
  25. data/lib/oga/html/entities.rb +2150 -0
  26. data/lib/oga/html/parser.rb +25 -0
  27. data/lib/oga/html/sax_parser.rb +18 -0
  28. data/lib/oga/lru.rb +160 -0
  29. data/lib/oga/oga.rb +57 -0
  30. data/lib/oga/version.rb +3 -0
  31. data/lib/oga/whitelist.rb +20 -0
  32. data/lib/oga/xml/attribute.rb +136 -0
  33. data/lib/oga/xml/cdata.rb +17 -0
  34. data/lib/oga/xml/character_node.rb +37 -0
  35. data/lib/oga/xml/comment.rb +17 -0
  36. data/lib/oga/xml/default_namespace.rb +13 -0
  37. data/lib/oga/xml/doctype.rb +82 -0
  38. data/lib/oga/xml/document.rb +108 -0
  39. data/lib/oga/xml/element.rb +428 -0
  40. data/lib/oga/xml/entities.rb +122 -0
  41. data/lib/oga/xml/html_void_elements.rb +15 -0
  42. data/lib/oga/xml/lexer.rb +550 -0
  43. data/lib/oga/xml/namespace.rb +48 -0
  44. data/lib/oga/xml/node.rb +219 -0
  45. data/lib/oga/xml/node_set.rb +333 -0
  46. data/lib/oga/xml/parser.rb +631 -0
  47. data/lib/oga/xml/processing_instruction.rb +37 -0
  48. data/lib/oga/xml/pull_parser.rb +175 -0
  49. data/lib/oga/xml/querying.rb +56 -0
  50. data/lib/oga/xml/sax_parser.rb +192 -0
  51. data/lib/oga/xml/text.rb +66 -0
  52. data/lib/oga/xml/traversal.rb +50 -0
  53. data/lib/oga/xml/xml_declaration.rb +65 -0
  54. data/lib/oga/xpath/evaluator.rb +1798 -0
  55. data/lib/oga/xpath/lexer.rb +1958 -0
  56. data/lib/oga/xpath/parser.rb +622 -0
  57. data/oga.gemspec +45 -0
  58. metadata +227 -0
@@ -0,0 +1,631 @@
1
+ # This file is automatically generated by ruby-ll. Manually changing this file
2
+ # is not recommended as any changes will be lost the next time this parser is
3
+ # re-generated.
4
+ require 'll/setup'
5
+
6
+ module Oga
7
+ module XML
8
+ ##
9
+ # DOM parser for both XML and HTML.
10
+ #
11
+ # This parser does not produce a dedicated AST, instead it emits XML nodes
12
+ # directly. Basic usage of this parser is as following:
13
+ #
14
+ # parser = Oga::XML::Parser.new('<foo></foo>')
15
+ # document = parser.parse
16
+ #
17
+ # To enable HTML parsing you'd use the following instead:
18
+ #
19
+ # parser = Oga::XML::Parser.new('<foo></foo>', :html => true)
20
+ # document = parser.parse
21
+ #
22
+ # In both cases you can use either a String or an IO as the parser input. IO
23
+ # instances will result in lower memory overhead, especially when parsing large
24
+ # files.
25
+ #
26
+ class Parser < LL::Driver
27
+ CONFIG = LL::DriverConfig.new
28
+
29
+ CONFIG.terminals = [
30
+ :$EOF, # 0
31
+ :T_TEXT, # 1
32
+ :T_STRING_SQUOTE, # 2
33
+ :T_STRING_DQUOTE, # 3
34
+ :T_STRING_BODY, # 4
35
+ :T_DOCTYPE_START, # 5
36
+ :T_DOCTYPE_END, # 6
37
+ :T_DOCTYPE_TYPE, # 7
38
+ :T_DOCTYPE_NAME, # 8
39
+ :T_DOCTYPE_INLINE, # 9
40
+ :T_COMMENT_START, # 10
41
+ :T_COMMENT_BODY, # 11
42
+ :T_COMMENT_END, # 12
43
+ :T_CDATA_START, # 13
44
+ :T_CDATA_BODY, # 14
45
+ :T_CDATA_END, # 15
46
+ :T_ELEM_NAME, # 16
47
+ :T_ELEM_NS, # 17
48
+ :T_ELEM_END, # 18
49
+ :T_ATTR, # 19
50
+ :T_ATTR_NS, # 20
51
+ :T_XML_DECL_START, # 21
52
+ :T_XML_DECL_END, # 22
53
+ :T_PROC_INS_START, # 23
54
+ :T_PROC_INS_NAME, # 24
55
+ :T_PROC_INS_BODY, # 25
56
+ :T_PROC_INS_END, # 26
57
+ ].freeze
58
+
59
+ CONFIG.rules = [
60
+ [3, 0, 0, 1], # 0
61
+ [3, 1, 4, 23, 6, 0], # 1
62
+ [3, 2, 0, 3], # 2
63
+ [3, 3, 0, 7], # 3
64
+ [3, 4, 0, 9], # 4
65
+ [3, 5, 0, 11], # 5
66
+ [3, 6, 0, 19], # 6
67
+ [3, 7, 0, 15], # 7
68
+ [3, 8, 0, 18], # 8
69
+ [3, 9, 0, 4, 1, 8, 1, 5], # 9
70
+ [3, 10, 1, 6], # 10
71
+ [3, 11, 0, 6, 1, 7], # 11
72
+ [3, 12, 1, 6, 0, 5], # 12
73
+ [3, 13, 5, 24, 6, 0], # 13
74
+ [3, 14, 1, 6, 8, 25, 0, 21], # 14
75
+ [3, 15, 1, 6], # 15
76
+ [3, 16, 1, 15, 0, 8, 1, 13], # 16
77
+ [3, 17, 0, 8, 1, 14], # 17
78
+ [3, 18, 2, 0], # 18
79
+ [3, 19, 1, 12, 0, 10, 1, 10], # 19
80
+ [3, 20, 0, 10, 1, 11], # 20
81
+ [3, 21, 2, 0], # 21
82
+ [3, 22, 1, 26, 0, 12, 1, 24, 1, 23], # 22
83
+ [3, 23, 0, 12, 1, 25], # 23
84
+ [3, 24, 2, 0], # 24
85
+ [3, 25, 1, 16], # 25
86
+ [3, 26, 1, 16, 1, 17], # 26
87
+ [3, 27, 0, 16, 0, 13], # 27
88
+ [3, 28, 1, 18, 0, 1, 0, 14], # 28
89
+ [3, 29, 4, 26, 6, 0], # 29
90
+ [3, 30, 8, 27, 1, 19, 1, 20], # 30
91
+ [3, 31, 8, 28, 1, 19], # 31
92
+ [3, 32, 1, 22, 0, 16, 1, 21], # 32
93
+ [3, 33, 0, 20, 1, 1], # 33
94
+ [3, 34, 0, 20, 1, 1], # 34
95
+ [3, 35, 2, 0], # 35
96
+ [3, 36, 1, 3, 0, 22, 1, 3], # 36
97
+ [3, 37, 1, 2, 0, 22, 1, 2], # 37
98
+ [3, 38, 0, 22, 1, 4], # 38
99
+ [3, 39, 2, 0], # 39
100
+ [3, 40, 0, 2], # 40
101
+ [3, 41, 1, 9], # 41
102
+ [3, 42, 0, 21], # 42
103
+ [3, 43, 0, 17], # 43
104
+ [3, 44, 0, 21], # 44
105
+ [3, 45, 0, 21], # 45
106
+ ].freeze
107
+
108
+ CONFIG.table = [
109
+ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # 0
110
+ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], # 1
111
+ [-1, 6, -1, -1, -1, 2, -1, -1, -1, -1, 4, -1, -1, 3, -1, -1, 7, 7, -1, -1, -1, 8, -1, 5, -1, -1, -1], # 2
112
+ [-1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 3
113
+ [12, 12, 12, 12, 12, 12, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], # 4
114
+ [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13], # 5
115
+ [-1, -1, 14, 14, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 6
116
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 7
117
+ [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18], # 8
118
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 9
119
+ [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21], # 10
120
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1], # 11
121
+ [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 24], # 12
122
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 25, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 13
123
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 27, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 14
124
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 28, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 15
125
+ [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29], # 16
126
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 31, 30, -1, -1, -1, -1, -1, -1], # 17
127
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, -1, -1, -1], # 18
128
+ [-1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 19
129
+ [35, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35], # 20
130
+ [-1, -1, 37, 36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 21
131
+ [39, 39, 39, 39, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39], # 22
132
+ [-1, 40, -1, -1, -1, 40, -1, -1, -1, -1, 40, -1, -1, 40, -1, -1, 40, 40, -1, -1, -1, 40, -1, 40, -1, -1, -1], # 23
133
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 24
134
+ [-1, -1, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 25
135
+ [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, -1, -1], # 26
136
+ [-1, -1, 44, 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 27
137
+ [-1, -1, 45, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], # 28
138
+ ].freeze
139
+
140
+ CONFIG.actions = [
141
+ [:_rule_0, 1], # 0
142
+ [:_rule_1, 1], # 1
143
+ [:_rule_2, 1], # 2
144
+ [:_rule_3, 1], # 3
145
+ [:_rule_4, 1], # 4
146
+ [:_rule_5, 1], # 5
147
+ [:_rule_6, 1], # 6
148
+ [:_rule_7, 1], # 7
149
+ [:_rule_8, 1], # 8
150
+ [:_rule_9, 3], # 9
151
+ [:_rule_10, 1], # 10
152
+ [:_rule_11, 2], # 11
153
+ [:_rule_12, 2], # 12
154
+ [:_rule_13, 1], # 13
155
+ [:_rule_14, 3], # 14
156
+ [:_rule_15, 1], # 15
157
+ [:_rule_16, 3], # 16
158
+ [:_rule_17, 2], # 17
159
+ [:_rule_18, 0], # 18
160
+ [:_rule_19, 3], # 19
161
+ [:_rule_20, 2], # 20
162
+ [:_rule_21, 0], # 21
163
+ [:_rule_22, 4], # 22
164
+ [:_rule_23, 2], # 23
165
+ [:_rule_24, 0], # 24
166
+ [:_rule_25, 1], # 25
167
+ [:_rule_26, 2], # 26
168
+ [:_rule_27, 2], # 27
169
+ [:_rule_28, 3], # 28
170
+ [:_rule_29, 1], # 29
171
+ [:_rule_30, 3], # 30
172
+ [:_rule_31, 2], # 31
173
+ [:_rule_32, 3], # 32
174
+ [:_rule_33, 2], # 33
175
+ [:_rule_34, 2], # 34
176
+ [:_rule_35, 0], # 35
177
+ [:_rule_36, 3], # 36
178
+ [:_rule_37, 3], # 37
179
+ [:_rule_38, 2], # 38
180
+ [:_rule_39, 0], # 39
181
+ [:_rule_40, 1], # 40
182
+ [:_rule_41, 1], # 41
183
+ [:_rule_42, 1], # 42
184
+ [:_rule_43, 1], # 43
185
+ [:_rule_44, 1], # 44
186
+ [:_rule_45, 1], # 45
187
+ ].freeze
188
+
189
+ ##
190
+ # Hash mapping token types and dedicated error labels.
191
+ #
192
+ # @return [Hash]
193
+ #
194
+ TOKEN_ERROR_MAPPING = {
195
+ :T_STRING => 'string',
196
+ :T_TEXT => 'text',
197
+ :T_DOCTYPE_START => 'doctype start',
198
+ :T_DOCTYPE_END => 'doctype closing tag',
199
+ :T_DOCTYPE_TYPE => 'doctype type',
200
+ :T_DOCTYPE_NAME => 'doctype name',
201
+ :T_DOCTYPE_INLINE => 'inline doctype rules',
202
+ :T_CDATA => 'CDATA',
203
+ :T_COMMENT => 'comment',
204
+ :T_ELEM_START => 'element start',
205
+ :T_ELEM_NAME => 'element name',
206
+ :T_ELEM_NS => 'element namespace',
207
+ :T_ELEM_END => 'element closing tag',
208
+ :T_ATTR => 'attribute',
209
+ :T_ATTR_NS => 'attribute namespace',
210
+ :T_XML_DECL_START => 'XML declaration start',
211
+ :T_XML_DECL_END => 'XML declaration end',
212
+ :T_PROC_INS_START => 'processing-instruction start',
213
+ :T_PROC_INS_NAME => 'processing-instruction name',
214
+ :T_PROC_INS_END => 'processing-instruction closing tag',
215
+ -1 => 'end of input'
216
+ }
217
+
218
+ ##
219
+ # @param [String|IO] data The input to parse.
220
+ # @param [Hash] options
221
+ # @see [Oga::XML::Lexer#initialize]
222
+ #
223
+ def initialize(data, options = {})
224
+ @data = data
225
+ @lexer = Lexer.new(data, options)
226
+
227
+ reset
228
+ end
229
+
230
+ ##
231
+ # Resets the internal state of the parser.
232
+ #
233
+ def reset
234
+ @line = 1
235
+
236
+ @lexer.reset
237
+ end
238
+
239
+ ##
240
+ # Yields the next token from the lexer.
241
+ #
242
+ # @yieldparam [Array]
243
+ #
244
+ def each_token
245
+ @lexer.advance do |type, value, line|
246
+ @line = line if line
247
+
248
+ yield [type, value]
249
+ end
250
+
251
+ yield [-1, -1]
252
+ end
253
+
254
+ ##
255
+ # @param [Fixnum] stack_type
256
+ # @param [Fixnum] stack_value
257
+ # @param [Symbol] token_type
258
+ # @param [String] token_value
259
+ #
260
+ def parser_error(stack_type, stack_value, token_type, token_value)
261
+ case id_to_type(stack_type)
262
+ when :rule
263
+ message = "Unexpected #{token_type} for rule #{stack_value}"
264
+ when :terminal
265
+ expected = id_to_terminal(stack_value)
266
+ expected = TOKEN_ERROR_MAPPING[expected] || expected
267
+ got = TOKEN_ERROR_MAPPING[token_type] || token_type
268
+ message = "Unexpected #{got}, expected #{expected} instead"
269
+ when :eof
270
+ message = 'Unexpected end of input'
271
+ end
272
+
273
+ message += " on line #{@line}"
274
+
275
+ raise LL::ParserError, message
276
+ end
277
+
278
+ ##
279
+ # @see [LL::Driver#parse]
280
+ #
281
+ def parse
282
+ retval = super
283
+
284
+ reset
285
+
286
+ return retval
287
+ end
288
+
289
+ ##
290
+ # @param [Array] children
291
+ # @return [Oga::XML::Document]
292
+ #
293
+ def on_document(children = [])
294
+ document = Document.new(:type => @lexer.html? ? :html : :xml)
295
+
296
+ children.each do |child|
297
+ if child.is_a?(Doctype)
298
+ document.doctype = child
299
+
300
+ elsif child.is_a?(XmlDeclaration)
301
+ document.xml_declaration = child
302
+
303
+ else
304
+ document.children << child
305
+ end
306
+ end
307
+
308
+ return document
309
+ end
310
+
311
+ ##
312
+ # @param [Hash] options
313
+ #
314
+ def on_doctype(options = {})
315
+ return Doctype.new(options)
316
+ end
317
+
318
+ ##
319
+ # @param [String] text
320
+ # @return [Oga::XML::Cdata]
321
+ #
322
+ def on_cdata(text = nil)
323
+ return Cdata.new(:text => text)
324
+ end
325
+
326
+ ##
327
+ # @param [String] text
328
+ # @return [Oga::XML::Comment]
329
+ #
330
+ def on_comment(text = nil)
331
+ return Comment.new(:text => text)
332
+ end
333
+
334
+ ##
335
+ # @param [String] name
336
+ # @param [String] text
337
+ # @return [Oga::XML::ProcessingInstruction]
338
+ #
339
+ def on_proc_ins(name, text = nil)
340
+ return ProcessingInstruction.new(:name => name, :text => text)
341
+ end
342
+
343
+ ##
344
+ # @param [Array] attributes
345
+ # @return [Oga::XML::XmlDeclaration]
346
+ #
347
+ def on_xml_decl(attributes = [])
348
+ options = {}
349
+
350
+ attributes.each do |attr|
351
+ options[attr.name.to_sym] = attr.value
352
+ end
353
+
354
+ return XmlDeclaration.new(options)
355
+ end
356
+
357
+ ##
358
+ # @param [String] text
359
+ # @return [Oga::XML::Text]
360
+ #
361
+ def on_text(text)
362
+ return Text.new(:text => text)
363
+ end
364
+
365
+ ##
366
+ # @param [String] namespace
367
+ # @param [String] name
368
+ # @param [Hash] attributes
369
+ # @return [Oga::XML::Element]
370
+ #
371
+ def on_element(namespace, name, attributes = {})
372
+ element = Element.new(
373
+ :namespace_name => namespace,
374
+ :name => name,
375
+ :attributes => attributes
376
+ )
377
+
378
+ return element
379
+ end
380
+
381
+ ##
382
+ # @param [Oga::XML::Element] element
383
+ # @param [Array] children
384
+ # @return [Oga::XML::Element]
385
+ #
386
+ def on_element_children(element, children = [])
387
+ element.children = children
388
+
389
+ return element
390
+ end
391
+
392
+ ##
393
+ # @param [Oga::XML::Element] element
394
+ # @return [Oga::XML::Element]
395
+ #
396
+ def after_element(element)
397
+ return element
398
+ end
399
+
400
+ ##
401
+ # @param [String] name
402
+ # @param [String] ns_name
403
+ # @param [String] value
404
+ # @return [Oga::XML::Attribute]
405
+ #
406
+ def on_attribute(name, ns_name = nil, value = nil)
407
+ return Attribute.new(
408
+ :namespace_name => ns_name,
409
+ :name => name,
410
+ :value => value
411
+ )
412
+ end
413
+
414
+ ##
415
+ # @param [Array] attrs
416
+ #
417
+ def on_attributes(attrs)
418
+ return attrs
419
+ end
420
+
421
+ def _rule_0(val)
422
+ on_document(val[0])
423
+ end
424
+
425
+ def _rule_1(val)
426
+ val[0]
427
+ end
428
+
429
+ def _rule_2(val)
430
+ val[0]
431
+ end
432
+
433
+ def _rule_3(val)
434
+ val[0]
435
+ end
436
+
437
+ def _rule_4(val)
438
+ val[0]
439
+ end
440
+
441
+ def _rule_5(val)
442
+ val[0]
443
+ end
444
+
445
+ def _rule_6(val)
446
+ val[0]
447
+ end
448
+
449
+ def _rule_7(val)
450
+ val[0]
451
+ end
452
+
453
+ def _rule_8(val)
454
+ val[0]
455
+ end
456
+
457
+ def _rule_9(val)
458
+
459
+ name = val[1]
460
+ follow = val[2]
461
+
462
+ on_doctype(
463
+ :name => name,
464
+ :type => follow[0],
465
+ :public_id => follow[1],
466
+ :system_id => follow[2],
467
+ :inline_rules => follow[3]
468
+ )
469
+
470
+ end
471
+
472
+ def _rule_10(val)
473
+ []
474
+ end
475
+
476
+ def _rule_11(val)
477
+ [val[0], *val[1]]
478
+ end
479
+
480
+ def _rule_12(val)
481
+ [nil, nil, nil, val[0]]
482
+ end
483
+
484
+ def _rule_13(val)
485
+ val[0].inject(:+)
486
+ end
487
+
488
+ def _rule_14(val)
489
+ [val[0], val[1]]
490
+ end
491
+
492
+ def _rule_15(val)
493
+ nil
494
+ end
495
+
496
+ def _rule_16(val)
497
+ on_cdata(val[1])
498
+ end
499
+
500
+ def _rule_17(val)
501
+ val[0] + val[1]
502
+ end
503
+
504
+ def _rule_18(val)
505
+ ''
506
+ end
507
+
508
+ def _rule_19(val)
509
+ on_comment(val[1])
510
+ end
511
+
512
+ def _rule_20(val)
513
+ val[0] + val[1]
514
+ end
515
+
516
+ def _rule_21(val)
517
+ ''
518
+ end
519
+
520
+ def _rule_22(val)
521
+
522
+ on_proc_ins(val[1], val[2])
523
+
524
+ end
525
+
526
+ def _rule_23(val)
527
+ val[0] + val[1]
528
+ end
529
+
530
+ def _rule_24(val)
531
+ ''
532
+ end
533
+
534
+ def _rule_25(val)
535
+ [nil, val[0]]
536
+ end
537
+
538
+ def _rule_26(val)
539
+ val
540
+ end
541
+
542
+ def _rule_27(val)
543
+
544
+ on_element(val[0][0], val[0][1], val[1])
545
+
546
+ end
547
+
548
+ def _rule_28(val)
549
+
550
+ if val[0]
551
+ on_element_children(val[0], val[1])
552
+ end
553
+
554
+ after_element(val[0])
555
+
556
+ end
557
+
558
+ def _rule_29(val)
559
+ on_attributes(val[0])
560
+ end
561
+
562
+ def _rule_30(val)
563
+ on_attribute(val[1], val[0], val[2])
564
+ end
565
+
566
+ def _rule_31(val)
567
+ on_attribute(val[0], nil, val[1])
568
+ end
569
+
570
+ def _rule_32(val)
571
+ on_xml_decl(val[1])
572
+ end
573
+
574
+ def _rule_33(val)
575
+
576
+ text = val[1] ? val[0] + val[1] : val[0]
577
+
578
+ on_text(text)
579
+
580
+ end
581
+
582
+ def _rule_34(val)
583
+ val[1] ? val[0] + val[1] : val[0]
584
+ end
585
+
586
+ def _rule_35(val)
587
+ nil
588
+ end
589
+
590
+ def _rule_36(val)
591
+ val[1]
592
+ end
593
+
594
+ def _rule_37(val)
595
+ val[1]
596
+ end
597
+
598
+ def _rule_38(val)
599
+ val[0] + val[1]
600
+ end
601
+
602
+ def _rule_39(val)
603
+ ''
604
+ end
605
+
606
+ def _rule_40(val)
607
+ val[0]
608
+ end
609
+
610
+ def _rule_41(val)
611
+ val[0]
612
+ end
613
+
614
+ def _rule_42(val)
615
+ val[0]
616
+ end
617
+
618
+ def _rule_43(val)
619
+ val[0]
620
+ end
621
+
622
+ def _rule_44(val)
623
+ val[0]
624
+ end
625
+
626
+ def _rule_45(val)
627
+ val[0]
628
+ end
629
+ end
630
+ end
631
+ end