nokogiri-fitzsimmons 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. data/.autotest +26 -0
  2. data/.gemtest +0 -0
  3. data/CHANGELOG.ja.rdoc +666 -0
  4. data/CHANGELOG.rdoc +659 -0
  5. data/C_CODING_STYLE.rdoc +33 -0
  6. data/Manifest.txt +295 -0
  7. data/README.ja.rdoc +106 -0
  8. data/README.rdoc +178 -0
  9. data/ROADMAP.md +86 -0
  10. data/Rakefile +194 -0
  11. data/STANDARD_RESPONSES.md +47 -0
  12. data/Y_U_NO_GEMSPEC.md +155 -0
  13. data/bin/nokogiri +63 -0
  14. data/build_all +58 -0
  15. data/ext/nokogiri/depend +358 -0
  16. data/ext/nokogiri/extconf.rb +142 -0
  17. data/ext/nokogiri/html_document.c +170 -0
  18. data/ext/nokogiri/html_document.h +10 -0
  19. data/ext/nokogiri/html_element_description.c +276 -0
  20. data/ext/nokogiri/html_element_description.h +10 -0
  21. data/ext/nokogiri/html_entity_lookup.c +32 -0
  22. data/ext/nokogiri/html_entity_lookup.h +8 -0
  23. data/ext/nokogiri/html_sax_parser_context.c +116 -0
  24. data/ext/nokogiri/html_sax_parser_context.h +11 -0
  25. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  26. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  27. data/ext/nokogiri/nokogiri.c +133 -0
  28. data/ext/nokogiri/nokogiri.h +160 -0
  29. data/ext/nokogiri/xml_attr.c +94 -0
  30. data/ext/nokogiri/xml_attr.h +9 -0
  31. data/ext/nokogiri/xml_attribute_decl.c +70 -0
  32. data/ext/nokogiri/xml_attribute_decl.h +9 -0
  33. data/ext/nokogiri/xml_cdata.c +56 -0
  34. data/ext/nokogiri/xml_cdata.h +9 -0
  35. data/ext/nokogiri/xml_comment.c +54 -0
  36. data/ext/nokogiri/xml_comment.h +9 -0
  37. data/ext/nokogiri/xml_document.c +576 -0
  38. data/ext/nokogiri/xml_document.h +23 -0
  39. data/ext/nokogiri/xml_document_fragment.c +48 -0
  40. data/ext/nokogiri/xml_document_fragment.h +10 -0
  41. data/ext/nokogiri/xml_dtd.c +202 -0
  42. data/ext/nokogiri/xml_dtd.h +10 -0
  43. data/ext/nokogiri/xml_element_content.c +123 -0
  44. data/ext/nokogiri/xml_element_content.h +10 -0
  45. data/ext/nokogiri/xml_element_decl.c +69 -0
  46. data/ext/nokogiri/xml_element_decl.h +9 -0
  47. data/ext/nokogiri/xml_encoding_handler.c +79 -0
  48. data/ext/nokogiri/xml_encoding_handler.h +8 -0
  49. data/ext/nokogiri/xml_entity_decl.c +110 -0
  50. data/ext/nokogiri/xml_entity_decl.h +10 -0
  51. data/ext/nokogiri/xml_entity_reference.c +52 -0
  52. data/ext/nokogiri/xml_entity_reference.h +9 -0
  53. data/ext/nokogiri/xml_io.c +56 -0
  54. data/ext/nokogiri/xml_io.h +11 -0
  55. data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
  56. data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
  57. data/ext/nokogiri/xml_namespace.c +78 -0
  58. data/ext/nokogiri/xml_namespace.h +13 -0
  59. data/ext/nokogiri/xml_node.c +1480 -0
  60. data/ext/nokogiri/xml_node.h +13 -0
  61. data/ext/nokogiri/xml_node_set.c +467 -0
  62. data/ext/nokogiri/xml_node_set.h +14 -0
  63. data/ext/nokogiri/xml_processing_instruction.c +56 -0
  64. data/ext/nokogiri/xml_processing_instruction.h +9 -0
  65. data/ext/nokogiri/xml_reader.c +684 -0
  66. data/ext/nokogiri/xml_reader.h +10 -0
  67. data/ext/nokogiri/xml_relax_ng.c +161 -0
  68. data/ext/nokogiri/xml_relax_ng.h +9 -0
  69. data/ext/nokogiri/xml_sax_parser.c +293 -0
  70. data/ext/nokogiri/xml_sax_parser.h +39 -0
  71. data/ext/nokogiri/xml_sax_parser_context.c +222 -0
  72. data/ext/nokogiri/xml_sax_parser_context.h +10 -0
  73. data/ext/nokogiri/xml_sax_push_parser.c +115 -0
  74. data/ext/nokogiri/xml_sax_push_parser.h +9 -0
  75. data/ext/nokogiri/xml_schema.c +205 -0
  76. data/ext/nokogiri/xml_schema.h +9 -0
  77. data/ext/nokogiri/xml_syntax_error.c +58 -0
  78. data/ext/nokogiri/xml_syntax_error.h +13 -0
  79. data/ext/nokogiri/xml_text.c +52 -0
  80. data/ext/nokogiri/xml_text.h +9 -0
  81. data/ext/nokogiri/xml_xpath_context.c +319 -0
  82. data/ext/nokogiri/xml_xpath_context.h +10 -0
  83. data/ext/nokogiri/xslt_stylesheet.c +270 -0
  84. data/ext/nokogiri/xslt_stylesheet.h +14 -0
  85. data/lib/nokogiri.rb +127 -0
  86. data/lib/nokogiri/css.rb +27 -0
  87. data/lib/nokogiri/css/node.rb +102 -0
  88. data/lib/nokogiri/css/parser.rb +720 -0
  89. data/lib/nokogiri/css/parser.y +258 -0
  90. data/lib/nokogiri/css/parser_extras.rb +91 -0
  91. data/lib/nokogiri/css/syntax_error.rb +7 -0
  92. data/lib/nokogiri/css/tokenizer.rb +152 -0
  93. data/lib/nokogiri/css/tokenizer.rex +55 -0
  94. data/lib/nokogiri/css/xpath_visitor.rb +171 -0
  95. data/lib/nokogiri/decorators/slop.rb +35 -0
  96. data/lib/nokogiri/html.rb +37 -0
  97. data/lib/nokogiri/html/builder.rb +35 -0
  98. data/lib/nokogiri/html/document.rb +254 -0
  99. data/lib/nokogiri/html/document_fragment.rb +41 -0
  100. data/lib/nokogiri/html/element_description.rb +23 -0
  101. data/lib/nokogiri/html/element_description_defaults.rb +671 -0
  102. data/lib/nokogiri/html/entity_lookup.rb +13 -0
  103. data/lib/nokogiri/html/sax/parser.rb +52 -0
  104. data/lib/nokogiri/html/sax/parser_context.rb +16 -0
  105. data/lib/nokogiri/html/sax/push_parser.rb +16 -0
  106. data/lib/nokogiri/syntax_error.rb +4 -0
  107. data/lib/nokogiri/version.rb +88 -0
  108. data/lib/nokogiri/xml.rb +73 -0
  109. data/lib/nokogiri/xml/attr.rb +14 -0
  110. data/lib/nokogiri/xml/attribute_decl.rb +18 -0
  111. data/lib/nokogiri/xml/builder.rb +431 -0
  112. data/lib/nokogiri/xml/cdata.rb +11 -0
  113. data/lib/nokogiri/xml/character_data.rb +7 -0
  114. data/lib/nokogiri/xml/document.rb +267 -0
  115. data/lib/nokogiri/xml/document_fragment.rb +103 -0
  116. data/lib/nokogiri/xml/dtd.rb +22 -0
  117. data/lib/nokogiri/xml/element_content.rb +36 -0
  118. data/lib/nokogiri/xml/element_decl.rb +13 -0
  119. data/lib/nokogiri/xml/entity_decl.rb +19 -0
  120. data/lib/nokogiri/xml/namespace.rb +13 -0
  121. data/lib/nokogiri/xml/node.rb +946 -0
  122. data/lib/nokogiri/xml/node/save_options.rb +61 -0
  123. data/lib/nokogiri/xml/node_set.rb +357 -0
  124. data/lib/nokogiri/xml/notation.rb +6 -0
  125. data/lib/nokogiri/xml/parse_options.rb +98 -0
  126. data/lib/nokogiri/xml/pp.rb +2 -0
  127. data/lib/nokogiri/xml/pp/character_data.rb +18 -0
  128. data/lib/nokogiri/xml/pp/node.rb +56 -0
  129. data/lib/nokogiri/xml/processing_instruction.rb +8 -0
  130. data/lib/nokogiri/xml/reader.rb +112 -0
  131. data/lib/nokogiri/xml/relax_ng.rb +32 -0
  132. data/lib/nokogiri/xml/sax.rb +4 -0
  133. data/lib/nokogiri/xml/sax/document.rb +164 -0
  134. data/lib/nokogiri/xml/sax/parser.rb +115 -0
  135. data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
  136. data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
  137. data/lib/nokogiri/xml/schema.rb +63 -0
  138. data/lib/nokogiri/xml/syntax_error.rb +47 -0
  139. data/lib/nokogiri/xml/text.rb +9 -0
  140. data/lib/nokogiri/xml/xpath.rb +10 -0
  141. data/lib/nokogiri/xml/xpath/syntax_error.rb +11 -0
  142. data/lib/nokogiri/xml/xpath_context.rb +16 -0
  143. data/lib/nokogiri/xslt.rb +56 -0
  144. data/lib/nokogiri/xslt/stylesheet.rb +25 -0
  145. data/lib/xsd/xmlparser/nokogiri.rb +90 -0
  146. data/tasks/cross_compile.rb +153 -0
  147. data/tasks/nokogiri.org.rb +24 -0
  148. data/tasks/test.rb +95 -0
  149. data/test/css/test_nthiness.rb +159 -0
  150. data/test/css/test_parser.rb +341 -0
  151. data/test/css/test_tokenizer.rb +198 -0
  152. data/test/css/test_xpath_visitor.rb +91 -0
  153. data/test/decorators/test_slop.rb +16 -0
  154. data/test/files/2ch.html +108 -0
  155. data/test/files/address_book.rlx +12 -0
  156. data/test/files/address_book.xml +10 -0
  157. data/test/files/bar/bar.xsd +4 -0
  158. data/test/files/dont_hurt_em_why.xml +422 -0
  159. data/test/files/encoding.html +82 -0
  160. data/test/files/encoding.xhtml +84 -0
  161. data/test/files/exslt.xml +8 -0
  162. data/test/files/exslt.xslt +35 -0
  163. data/test/files/foo/foo.xsd +4 -0
  164. data/test/files/metacharset.html +10 -0
  165. data/test/files/noencoding.html +47 -0
  166. data/test/files/po.xml +32 -0
  167. data/test/files/po.xsd +66 -0
  168. data/test/files/shift_jis.html +10 -0
  169. data/test/files/shift_jis.xml +5 -0
  170. data/test/files/snuggles.xml +3 -0
  171. data/test/files/staff.dtd +10 -0
  172. data/test/files/staff.xml +59 -0
  173. data/test/files/staff.xslt +32 -0
  174. data/test/files/tlm.html +850 -0
  175. data/test/files/to_be_xincluded.xml +2 -0
  176. data/test/files/valid_bar.xml +2 -0
  177. data/test/files/xinclude.xml +4 -0
  178. data/test/helper.rb +147 -0
  179. data/test/html/sax/test_parser.rb +138 -0
  180. data/test/html/sax/test_parser_context.rb +46 -0
  181. data/test/html/test_builder.rb +164 -0
  182. data/test/html/test_document.rb +529 -0
  183. data/test/html/test_document_encoding.rb +138 -0
  184. data/test/html/test_document_fragment.rb +254 -0
  185. data/test/html/test_element_description.rb +100 -0
  186. data/test/html/test_named_characters.rb +14 -0
  187. data/test/html/test_node.rb +188 -0
  188. data/test/html/test_node_encoding.rb +27 -0
  189. data/test/test_convert_xpath.rb +135 -0
  190. data/test/test_css_cache.rb +45 -0
  191. data/test/test_encoding_handler.rb +46 -0
  192. data/test/test_memory_leak.rb +152 -0
  193. data/test/test_nokogiri.rb +132 -0
  194. data/test/test_reader.rb +488 -0
  195. data/test/test_soap4r_sax.rb +52 -0
  196. data/test/test_xslt_transforms.rb +254 -0
  197. data/test/xml/node/test_save_options.rb +28 -0
  198. data/test/xml/node/test_subclass.rb +44 -0
  199. data/test/xml/sax/test_parser.rb +338 -0
  200. data/test/xml/sax/test_parser_context.rb +106 -0
  201. data/test/xml/sax/test_push_parser.rb +157 -0
  202. data/test/xml/test_attr.rb +64 -0
  203. data/test/xml/test_attribute_decl.rb +86 -0
  204. data/test/xml/test_builder.rb +248 -0
  205. data/test/xml/test_c14n.rb +151 -0
  206. data/test/xml/test_cdata.rb +48 -0
  207. data/test/xml/test_comment.rb +29 -0
  208. data/test/xml/test_document.rb +742 -0
  209. data/test/xml/test_document_encoding.rb +28 -0
  210. data/test/xml/test_document_fragment.rb +216 -0
  211. data/test/xml/test_dtd.rb +103 -0
  212. data/test/xml/test_dtd_encoding.rb +33 -0
  213. data/test/xml/test_element_content.rb +56 -0
  214. data/test/xml/test_element_decl.rb +73 -0
  215. data/test/xml/test_entity_decl.rb +122 -0
  216. data/test/xml/test_entity_reference.rb +235 -0
  217. data/test/xml/test_namespace.rb +75 -0
  218. data/test/xml/test_node.rb +1029 -0
  219. data/test/xml/test_node_attributes.rb +53 -0
  220. data/test/xml/test_node_encoding.rb +107 -0
  221. data/test/xml/test_node_inheritance.rb +32 -0
  222. data/test/xml/test_node_reparenting.rb +374 -0
  223. data/test/xml/test_node_set.rb +755 -0
  224. data/test/xml/test_parse_options.rb +64 -0
  225. data/test/xml/test_processing_instruction.rb +30 -0
  226. data/test/xml/test_reader_encoding.rb +142 -0
  227. data/test/xml/test_relax_ng.rb +60 -0
  228. data/test/xml/test_schema.rb +94 -0
  229. data/test/xml/test_syntax_error.rb +12 -0
  230. data/test/xml/test_text.rb +45 -0
  231. data/test/xml/test_unparented_node.rb +413 -0
  232. data/test/xml/test_xinclude.rb +83 -0
  233. data/test/xml/test_xpath.rb +295 -0
  234. data/test/xslt/test_custom_functions.rb +129 -0
  235. data/test/xslt/test_exception_handling.rb +37 -0
  236. data/test_all +84 -0
  237. metadata +534 -0
@@ -0,0 +1,102 @@
1
+ module Nokogiri
2
+ module CSS
3
+ class Node
4
+ ALLOW_COMBINATOR_ON_SELF = [:DIRECT_ADJACENT_SELECTOR, :FOLLOWING_SELECTOR, :CHILD_SELECTOR]
5
+
6
+ # Get the type of this node
7
+ attr_accessor :type
8
+ # Get the value of this node
9
+ attr_accessor :value
10
+
11
+ # Create a new Node with +type+ and +value+
12
+ def initialize type, value
13
+ @type = type
14
+ @value = value
15
+ end
16
+
17
+ # Accept +visitor+
18
+ def accept visitor
19
+ visitor.send(:"visit_#{type.to_s.downcase}", self)
20
+ end
21
+
22
+ ###
23
+ # Convert this CSS node to xpath with +prefix+ using +visitor+
24
+ def to_xpath prefix = '//', visitor = XPathVisitor.new
25
+ self.preprocess!
26
+ prefix = '.' if ALLOW_COMBINATOR_ON_SELF.include?(type) && value.first.nil?
27
+ prefix + visitor.accept(self)
28
+ end
29
+
30
+ # Preprocess this node tree
31
+ def preprocess!
32
+ ### Deal with nth-child
33
+ matches = find_by_type(
34
+ [:CONDITIONAL_SELECTOR,
35
+ [:ELEMENT_NAME],
36
+ [:PSEUDO_CLASS,
37
+ [:FUNCTION]
38
+ ]
39
+ ]
40
+ )
41
+ matches.each do |match|
42
+ if match.value[1].value[0].value[0] =~ /^nth-(last-)?child/
43
+ tag_name = match.value[0].value.first
44
+ match.value[0].value = ['*']
45
+ match.value[1] = Node.new(:COMBINATOR, [
46
+ match.value[1].value[0],
47
+ Node.new(:FUNCTION, ['self(', tag_name])
48
+ ])
49
+ end
50
+ end
51
+
52
+ ### Deal with first-child, last-child
53
+ matches = find_by_type(
54
+ [:CONDITIONAL_SELECTOR,
55
+ [:ELEMENT_NAME], [:PSEUDO_CLASS]
56
+ ])
57
+ matches.each do |match|
58
+ if ['first-child', 'last-child'].include?(match.value[1].value.first)
59
+ which = match.value[1].value.first.gsub(/-\w*$/, '')
60
+ tag_name = match.value[0].value.first
61
+ match.value[0].value = ['*']
62
+ match.value[1] = Node.new(:COMBINATOR, [
63
+ Node.new(:FUNCTION, ["#{which}("]),
64
+ Node.new(:FUNCTION, ['self(', tag_name])
65
+ ])
66
+ elsif 'only-child' == match.value[1].value.first
67
+ tag_name = match.value[0].value.first
68
+ match.value[0].value = ['*']
69
+ match.value[1] = Node.new(:COMBINATOR, [
70
+ Node.new(:FUNCTION, ["#{match.value[1].value.first}("]),
71
+ Node.new(:FUNCTION, ['self(', tag_name])
72
+ ])
73
+ end
74
+ end
75
+
76
+ self
77
+ end
78
+
79
+ # Find a node by type using +types+
80
+ def find_by_type types
81
+ matches = []
82
+ matches << self if to_type == types
83
+ @value.each do |v|
84
+ matches += v.find_by_type(types) if v.respond_to?(:find_by_type)
85
+ end
86
+ matches
87
+ end
88
+
89
+ # Convert to_type
90
+ def to_type
91
+ [@type] + @value.map { |n|
92
+ n.to_type if n.respond_to?(:to_type)
93
+ }.compact
94
+ end
95
+
96
+ # Convert to array
97
+ def to_a
98
+ [@type] + @value.map { |n| n.respond_to?(:to_a) ? n.to_a : [n] }
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,720 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.8
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+
10
+ require 'nokogiri/css/parser_extras'
11
+ module Nokogiri
12
+ module CSS
13
+ class Parser < Racc::Parser
14
+ ##### State transition tables begin ###
15
+
16
+ racc_action_table = [
17
+ 21, 4, 5, 7, 29, 4, 5, 7, 30, 19,
18
+ -26, 6, 21, 9, 8, 6, 29, 9, 8, 22,
19
+ 31, 19, 20, 21, 23, 15, 17, 29, 24, 83,
20
+ 31, 22, 19, 84, 20, 21, 23, 15, 17, 29,
21
+ 24, 92, 22, 85, 19, 20, 21, 23, 15, 17,
22
+ 20, 24, 82, 90, 22, 59, 24, 20, 89, 23,
23
+ 15, 17, 21, 24, 88, 22, 29, 4, 5, 7,
24
+ 23, 19, 71, 29, 91, 29, 86, 6, 19, 9,
25
+ 8, 22, 29, 29, 20, 89, 23, 15, 17, 35,
26
+ 24, 20, 29, 20, 15, 17, 15, 24, 35, 24,
27
+ 20, 20, 29, 15, 15, 93, 24, 24, 21, 64,
28
+ 20, 95, 29, 15, 97, 96, 24, 43, -26, 46,
29
+ 20, 52, 53, 15, 51, 98, 24, 22, 79, 80,
30
+ 20, 99, 23, 15, 48, 42, 24, 79, 80, 75,
31
+ 76, 77, 101, 78, 87, 86, 41, 74, 75, 76,
32
+ 77, 35, 78, 104, 52, 56, 74, 55, 52, 56,
33
+ 105, 55, 52, 56, nil, 55, 52, 56, nil, 55 ]
34
+
35
+ racc_action_check = [
36
+ 0, 14, 14, 14, 0, 0, 0, 0, 1, 0,
37
+ 43, 14, 40, 14, 14, 0, 40, 0, 0, 0,
38
+ 1, 40, 0, 31, 0, 0, 0, 31, 0, 47,
39
+ 57, 40, 31, 49, 40, 13, 40, 40, 40, 13,
40
+ 40, 57, 31, 50, 13, 31, 24, 31, 31, 31,
41
+ 11, 31, 46, 53, 13, 24, 11, 13, 53, 13,
42
+ 13, 13, 23, 13, 52, 24, 23, 23, 23, 23,
43
+ 24, 23, 42, 35, 54, 28, 55, 23, 35, 23,
44
+ 23, 23, 27, 10, 23, 56, 23, 23, 23, 33,
45
+ 23, 35, 26, 28, 35, 35, 28, 35, 10, 28,
46
+ 27, 10, 25, 27, 10, 67, 27, 10, 20, 30,
47
+ 26, 72, 68, 26, 73, 73, 26, 20, 19, 20,
48
+ 25, 21, 21, 25, 21, 81, 25, 20, 45, 45,
49
+ 68, 83, 20, 68, 21, 18, 68, 44, 44, 45,
50
+ 45, 45, 87, 45, 51, 51, 15, 45, 44, 44,
51
+ 44, 12, 44, 90, 89, 89, 44, 89, 86, 86,
52
+ 101, 86, 88, 88, nil, 88, 22, 22, nil, 22 ]
53
+
54
+ racc_action_pointer = [
55
+ -2, 8, nil, nil, nil, nil, nil, nil, nil, nil,
56
+ 77, 26, 130, 33, -6, 135, nil, nil, 106, 89,
57
+ 106, 111, 156, 60, 44, 96, 86, 76, 69, nil,
58
+ 109, 21, nil, 68, nil, 67, nil, nil, nil, nil,
59
+ 10, nil, 61, -19, 134, 125, 27, 0, nil, 10,
60
+ 20, 133, 52, 46, 51, 64, 73, 18, nil, nil,
61
+ nil, nil, nil, nil, nil, nil, nil, 82, 106, nil,
62
+ nil, nil, 86, 104, nil, nil, nil, nil, nil, nil,
63
+ nil, 100, nil, 120, nil, nil, 148, 135, 152, 144,
64
+ 140, nil, nil, nil, nil, nil, nil, nil, nil, nil,
65
+ nil, 147, nil, nil, nil, nil ]
66
+
67
+ racc_action_default = [
68
+ -27, -74, -2, -3, -4, -5, -6, -7, -8, -9,
69
+ -50, -13, -17, -27, -20, -74, -22, -23, -74, -25,
70
+ -27, -74, -74, -27, -74, -55, -56, -57, -58, -59,
71
+ -74, -27, -10, -49, -12, -27, -14, -15, -16, -18,
72
+ -27, -21, -74, -32, -62, -62, -74, -74, -33, -74,
73
+ -74, -41, -42, -43, -74, -41, -43, -74, -47, -48,
74
+ -51, -52, -53, -54, 106, -1, -11, -74, -71, -73,
75
+ -19, -24, -74, -74, -63, -64, -65, -66, -67, -68,
76
+ -69, -74, -30, -74, -34, -35, -74, -46, -74, -74,
77
+ -74, -36, -37, -70, -72, -28, -60, -61, -29, -31,
78
+ -38, -74, -39, -40, -45, -44 ]
79
+
80
+ racc_goto_table = [
81
+ 49, 54, 33, 39, 36, 1, 34, 45, 38, 72,
82
+ 81, 58, 32, 37, 47, 44, 68, 60, 61, 62,
83
+ 63, 65, 40, 50, 67, nil, nil, 69, 57, 66,
84
+ 70, nil, nil, nil, nil, nil, nil, nil, nil, nil,
85
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
86
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
87
+ 94, nil, nil, nil, nil, 100, nil, 102, 103 ]
88
+
89
+ racc_goto_check = [
90
+ 18, 18, 8, 2, 11, 1, 9, 10, 9, 17,
91
+ 17, 10, 7, 12, 15, 16, 6, 8, 8, 8,
92
+ 8, 2, 4, 19, 22, nil, nil, 8, 1, 9,
93
+ 2, nil, nil, nil, nil, nil, nil, nil, nil, nil,
94
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
95
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
96
+ 8, nil, nil, nil, nil, 18, nil, 18, 18 ]
97
+
98
+ racc_goto_pointer = [
99
+ nil, 5, -10, nil, 8, nil, -19, 2, -8, -4,
100
+ -13, -7, 2, nil, nil, -6, -5, -35, -21, 2,
101
+ nil, nil, -11 ]
102
+
103
+ racc_goto_default = [
104
+ nil, nil, 3, 2, 13, 14, 10, nil, 12, nil,
105
+ 11, 28, 27, 26, 16, 18, nil, nil, nil, nil,
106
+ 25, 73, nil ]
107
+
108
+ racc_reduce_table = [
109
+ 0, 0, :racc_error,
110
+ 3, 32, :_reduce_1,
111
+ 1, 32, :_reduce_2,
112
+ 1, 32, :_reduce_3,
113
+ 1, 35, :_reduce_4,
114
+ 1, 35, :_reduce_5,
115
+ 1, 35, :_reduce_6,
116
+ 1, 35, :_reduce_7,
117
+ 1, 35, :_reduce_8,
118
+ 1, 35, :_reduce_9,
119
+ 2, 36, :_reduce_10,
120
+ 3, 36, :_reduce_11,
121
+ 2, 36, :_reduce_12,
122
+ 1, 36, :_reduce_none,
123
+ 2, 36, :_reduce_14,
124
+ 2, 36, :_reduce_15,
125
+ 2, 36, :_reduce_16,
126
+ 1, 36, :_reduce_17,
127
+ 2, 34, :_reduce_18,
128
+ 3, 33, :_reduce_19,
129
+ 1, 33, :_reduce_none,
130
+ 2, 44, :_reduce_21,
131
+ 1, 37, :_reduce_none,
132
+ 1, 37, :_reduce_23,
133
+ 3, 45, :_reduce_24,
134
+ 1, 45, :_reduce_25,
135
+ 1, 46, :_reduce_26,
136
+ 0, 46, :_reduce_none,
137
+ 4, 43, :_reduce_28,
138
+ 4, 43, :_reduce_29,
139
+ 3, 43, :_reduce_30,
140
+ 3, 47, :_reduce_31,
141
+ 1, 47, :_reduce_32,
142
+ 2, 41, :_reduce_33,
143
+ 3, 41, :_reduce_34,
144
+ 3, 41, :_reduce_35,
145
+ 3, 41, :_reduce_36,
146
+ 3, 41, :_reduce_37,
147
+ 3, 49, :_reduce_38,
148
+ 3, 49, :_reduce_39,
149
+ 3, 49, :_reduce_40,
150
+ 1, 49, :_reduce_none,
151
+ 1, 49, :_reduce_none,
152
+ 1, 49, :_reduce_43,
153
+ 4, 50, :_reduce_44,
154
+ 3, 50, :_reduce_45,
155
+ 2, 50, :_reduce_46,
156
+ 2, 42, :_reduce_47,
157
+ 2, 42, :_reduce_48,
158
+ 1, 38, :_reduce_none,
159
+ 0, 38, :_reduce_none,
160
+ 2, 39, :_reduce_51,
161
+ 2, 39, :_reduce_52,
162
+ 2, 39, :_reduce_53,
163
+ 2, 39, :_reduce_54,
164
+ 1, 39, :_reduce_none,
165
+ 1, 39, :_reduce_none,
166
+ 1, 39, :_reduce_none,
167
+ 1, 39, :_reduce_none,
168
+ 1, 51, :_reduce_59,
169
+ 2, 48, :_reduce_60,
170
+ 2, 48, :_reduce_61,
171
+ 0, 48, :_reduce_none,
172
+ 1, 52, :_reduce_63,
173
+ 1, 52, :_reduce_64,
174
+ 1, 52, :_reduce_65,
175
+ 1, 52, :_reduce_66,
176
+ 1, 52, :_reduce_67,
177
+ 1, 52, :_reduce_68,
178
+ 1, 52, :_reduce_69,
179
+ 3, 40, :_reduce_70,
180
+ 1, 53, :_reduce_none,
181
+ 2, 53, :_reduce_none,
182
+ 1, 53, :_reduce_none ]
183
+
184
+ racc_reduce_n = 74
185
+
186
+ racc_shift_n = 106
187
+
188
+ racc_token_table = {
189
+ false => 0,
190
+ :error => 1,
191
+ :FUNCTION => 2,
192
+ :INCLUDES => 3,
193
+ :DASHMATCH => 4,
194
+ :LBRACE => 5,
195
+ :HASH => 6,
196
+ :PLUS => 7,
197
+ :GREATER => 8,
198
+ :S => 9,
199
+ :STRING => 10,
200
+ :IDENT => 11,
201
+ :COMMA => 12,
202
+ :NUMBER => 13,
203
+ :PREFIXMATCH => 14,
204
+ :SUFFIXMATCH => 15,
205
+ :SUBSTRINGMATCH => 16,
206
+ :TILDE => 17,
207
+ :NOT_EQUAL => 18,
208
+ :SLASH => 19,
209
+ :DOUBLESLASH => 20,
210
+ :NOT => 21,
211
+ :EQUAL => 22,
212
+ :RPAREN => 23,
213
+ :LSQUARE => 24,
214
+ :RSQUARE => 25,
215
+ :HAS => 26,
216
+ "." => 27,
217
+ "*" => 28,
218
+ "|" => 29,
219
+ ":" => 30 }
220
+
221
+ racc_nt_base = 31
222
+
223
+ racc_use_result_var = true
224
+
225
+ Racc_arg = [
226
+ racc_action_table,
227
+ racc_action_check,
228
+ racc_action_default,
229
+ racc_action_pointer,
230
+ racc_goto_table,
231
+ racc_goto_check,
232
+ racc_goto_default,
233
+ racc_goto_pointer,
234
+ racc_nt_base,
235
+ racc_reduce_table,
236
+ racc_token_table,
237
+ racc_shift_n,
238
+ racc_reduce_n,
239
+ racc_use_result_var ]
240
+
241
+ Racc_token_to_s_table = [
242
+ "$end",
243
+ "error",
244
+ "FUNCTION",
245
+ "INCLUDES",
246
+ "DASHMATCH",
247
+ "LBRACE",
248
+ "HASH",
249
+ "PLUS",
250
+ "GREATER",
251
+ "S",
252
+ "STRING",
253
+ "IDENT",
254
+ "COMMA",
255
+ "NUMBER",
256
+ "PREFIXMATCH",
257
+ "SUFFIXMATCH",
258
+ "SUBSTRINGMATCH",
259
+ "TILDE",
260
+ "NOT_EQUAL",
261
+ "SLASH",
262
+ "DOUBLESLASH",
263
+ "NOT",
264
+ "EQUAL",
265
+ "RPAREN",
266
+ "LSQUARE",
267
+ "RSQUARE",
268
+ "HAS",
269
+ "\".\"",
270
+ "\"*\"",
271
+ "\"|\"",
272
+ "\":\"",
273
+ "$start",
274
+ "selector",
275
+ "simple_selector_1toN",
276
+ "prefixless_combinator_selector",
277
+ "combinator",
278
+ "simple_selector",
279
+ "element_name",
280
+ "hcap_0toN",
281
+ "hcap_1toN",
282
+ "negation",
283
+ "function",
284
+ "pseudo",
285
+ "attrib",
286
+ "class",
287
+ "namespaced_ident",
288
+ "namespace",
289
+ "attrib_name",
290
+ "attrib_val_0or1",
291
+ "expr",
292
+ "an_plus_b",
293
+ "attribute_id",
294
+ "eql_incl_dash",
295
+ "negation_arg" ]
296
+
297
+ Racc_debug_parser = false
298
+
299
+ ##### State transition tables end #####
300
+
301
+ # reduce 0 omitted
302
+
303
+ def _reduce_1(val, _values, result)
304
+ result = [val.first, val.last].flatten
305
+
306
+ result
307
+ end
308
+
309
+ def _reduce_2(val, _values, result)
310
+ result = val.flatten
311
+ result
312
+ end
313
+
314
+ def _reduce_3(val, _values, result)
315
+ result = val.flatten
316
+ result
317
+ end
318
+
319
+ def _reduce_4(val, _values, result)
320
+ result = :DIRECT_ADJACENT_SELECTOR
321
+ result
322
+ end
323
+
324
+ def _reduce_5(val, _values, result)
325
+ result = :CHILD_SELECTOR
326
+ result
327
+ end
328
+
329
+ def _reduce_6(val, _values, result)
330
+ result = :FOLLOWING_SELECTOR
331
+ result
332
+ end
333
+
334
+ def _reduce_7(val, _values, result)
335
+ result = :DESCENDANT_SELECTOR
336
+ result
337
+ end
338
+
339
+ def _reduce_8(val, _values, result)
340
+ result = :DESCENDANT_SELECTOR
341
+ result
342
+ end
343
+
344
+ def _reduce_9(val, _values, result)
345
+ result = :CHILD_SELECTOR
346
+ result
347
+ end
348
+
349
+ def _reduce_10(val, _values, result)
350
+ result = if val[1].nil?
351
+ val.first
352
+ else
353
+ Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
354
+ end
355
+
356
+ result
357
+ end
358
+
359
+ def _reduce_11(val, _values, result)
360
+ result = Node.new(:CONDITIONAL_SELECTOR,
361
+ [
362
+ val.first,
363
+ Node.new(:COMBINATOR, [val[1], val.last])
364
+ ]
365
+ )
366
+
367
+ result
368
+ end
369
+
370
+ def _reduce_12(val, _values, result)
371
+ result = Node.new(:CONDITIONAL_SELECTOR, val)
372
+
373
+ result
374
+ end
375
+
376
+ # reduce 13 omitted
377
+
378
+ def _reduce_14(val, _values, result)
379
+ result = Node.new(:CONDITIONAL_SELECTOR, val)
380
+
381
+ result
382
+ end
383
+
384
+ def _reduce_15(val, _values, result)
385
+ result = Node.new(:CONDITIONAL_SELECTOR, val)
386
+
387
+ result
388
+ end
389
+
390
+ def _reduce_16(val, _values, result)
391
+ result = Node.new(:CONDITIONAL_SELECTOR,
392
+ [
393
+ Node.new(:ELEMENT_NAME, ['*']),
394
+ Node.new(:COMBINATOR, val)
395
+ ]
396
+ )
397
+
398
+ result
399
+ end
400
+
401
+ def _reduce_17(val, _values, result)
402
+ result = Node.new(:CONDITIONAL_SELECTOR,
403
+ [Node.new(:ELEMENT_NAME, ['*']), val.first]
404
+ )
405
+
406
+ result
407
+ end
408
+
409
+ def _reduce_18(val, _values, result)
410
+ result = Node.new(val.first, [nil, val.last])
411
+
412
+ result
413
+ end
414
+
415
+ def _reduce_19(val, _values, result)
416
+ result = Node.new(val[1], [val.first, val.last])
417
+
418
+ result
419
+ end
420
+
421
+ # reduce 20 omitted
422
+
423
+ def _reduce_21(val, _values, result)
424
+ result = Node.new(:CLASS_CONDITION, [val[1]])
425
+ result
426
+ end
427
+
428
+ # reduce 22 omitted
429
+
430
+ def _reduce_23(val, _values, result)
431
+ result = Node.new(:ELEMENT_NAME, val)
432
+ result
433
+ end
434
+
435
+ def _reduce_24(val, _values, result)
436
+ result = Node.new(:ELEMENT_NAME,
437
+ [[val.first, val.last].compact.join(':')]
438
+ )
439
+
440
+ result
441
+ end
442
+
443
+ def _reduce_25(val, _values, result)
444
+ name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
445
+ result = Node.new(:ELEMENT_NAME, [name])
446
+
447
+ result
448
+ end
449
+
450
+ def _reduce_26(val, _values, result)
451
+ result = val[0]
452
+ result
453
+ end
454
+
455
+ # reduce 27 omitted
456
+
457
+ def _reduce_28(val, _values, result)
458
+ result = Node.new(:ATTRIBUTE_CONDITION,
459
+ [val[1]] + (val[2] || [])
460
+ )
461
+
462
+ result
463
+ end
464
+
465
+ def _reduce_29(val, _values, result)
466
+ result = Node.new(:ATTRIBUTE_CONDITION,
467
+ [val[1]] + (val[2] || [])
468
+ )
469
+
470
+ result
471
+ end
472
+
473
+ def _reduce_30(val, _values, result)
474
+ # Non standard, but hpricot supports it.
475
+ result = Node.new(:PSEUDO_CLASS,
476
+ [Node.new(:FUNCTION, ['nth-child(', val[1]])]
477
+ )
478
+
479
+ result
480
+ end
481
+
482
+ def _reduce_31(val, _values, result)
483
+ result = Node.new(:ELEMENT_NAME,
484
+ [[val.first, val.last].compact.join(':')]
485
+ )
486
+
487
+ result
488
+ end
489
+
490
+ def _reduce_32(val, _values, result)
491
+ # Default namespace is not applied to attributes.
492
+ # So we don't add prefix "xmlns:" as in namespaced_ident.
493
+ result = Node.new(:ELEMENT_NAME, [val.first])
494
+
495
+ result
496
+ end
497
+
498
+ def _reduce_33(val, _values, result)
499
+ result = Node.new(:FUNCTION, [val.first.strip])
500
+
501
+ result
502
+ end
503
+
504
+ def _reduce_34(val, _values, result)
505
+ result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
506
+
507
+ result
508
+ end
509
+
510
+ def _reduce_35(val, _values, result)
511
+ result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
512
+
513
+ result
514
+ end
515
+
516
+ def _reduce_36(val, _values, result)
517
+ result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
518
+
519
+ result
520
+ end
521
+
522
+ def _reduce_37(val, _values, result)
523
+ result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
524
+
525
+ result
526
+ end
527
+
528
+ def _reduce_38(val, _values, result)
529
+ result = [val.first, val.last]
530
+ result
531
+ end
532
+
533
+ def _reduce_39(val, _values, result)
534
+ result = [val.first, val.last]
535
+ result
536
+ end
537
+
538
+ def _reduce_40(val, _values, result)
539
+ result = [val.first, val.last]
540
+ result
541
+ end
542
+
543
+ # reduce 41 omitted
544
+
545
+ # reduce 42 omitted
546
+
547
+ def _reduce_43(val, _values, result)
548
+ if val[0] == 'even'
549
+ val = ["2","n","+","0"]
550
+ result = Node.new(:AN_PLUS_B, val)
551
+ elsif val[0] == 'odd'
552
+ val = ["2","n","+","1"]
553
+ result = Node.new(:AN_PLUS_B, val)
554
+ else
555
+ # This is not CSS standard. It allows us to support this:
556
+ # assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
557
+ # assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
558
+ # assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
559
+ result = val
560
+ end
561
+
562
+ result
563
+ end
564
+
565
+ def _reduce_44(val, _values, result)
566
+ if val[1] == 'n'
567
+ result = Node.new(:AN_PLUS_B, val)
568
+ else
569
+ raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
570
+ end
571
+
572
+ result
573
+ end
574
+
575
+ def _reduce_45(val, _values, result)
576
+ # n+3, -n+3
577
+ if val[0] == 'n'
578
+ val.unshift("1")
579
+ result = Node.new(:AN_PLUS_B, val)
580
+ elsif val[0] == '-n'
581
+ val[0] = 'n'
582
+ val.unshift("-1")
583
+ result = Node.new(:AN_PLUS_B, val)
584
+ else
585
+ raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
586
+ end
587
+
588
+ result
589
+ end
590
+
591
+ def _reduce_46(val, _values, result)
592
+ if val[1] == 'n'
593
+ val << "+"
594
+ val << "0"
595
+ result = Node.new(:AN_PLUS_B, val)
596
+ else
597
+ raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
598
+ end
599
+
600
+ result
601
+ end
602
+
603
+ def _reduce_47(val, _values, result)
604
+ result = Node.new(:PSEUDO_CLASS, [val[1]])
605
+
606
+ result
607
+ end
608
+
609
+ def _reduce_48(val, _values, result)
610
+ result = Node.new(:PSEUDO_CLASS, [val[1]])
611
+ result
612
+ end
613
+
614
+ # reduce 49 omitted
615
+
616
+ # reduce 50 omitted
617
+
618
+ def _reduce_51(val, _values, result)
619
+ result = Node.new(:COMBINATOR, val)
620
+
621
+ result
622
+ end
623
+
624
+ def _reduce_52(val, _values, result)
625
+ result = Node.new(:COMBINATOR, val)
626
+
627
+ result
628
+ end
629
+
630
+ def _reduce_53(val, _values, result)
631
+ result = Node.new(:COMBINATOR, val)
632
+
633
+ result
634
+ end
635
+
636
+ def _reduce_54(val, _values, result)
637
+ result = Node.new(:COMBINATOR, val)
638
+
639
+ result
640
+ end
641
+
642
+ # reduce 55 omitted
643
+
644
+ # reduce 56 omitted
645
+
646
+ # reduce 57 omitted
647
+
648
+ # reduce 58 omitted
649
+
650
+ def _reduce_59(val, _values, result)
651
+ result = Node.new(:ID, val)
652
+ result
653
+ end
654
+
655
+ def _reduce_60(val, _values, result)
656
+ result = [val.first, val[1]]
657
+ result
658
+ end
659
+
660
+ def _reduce_61(val, _values, result)
661
+ result = [val.first, val[1]]
662
+ result
663
+ end
664
+
665
+ # reduce 62 omitted
666
+
667
+ def _reduce_63(val, _values, result)
668
+ result = :equal
669
+ result
670
+ end
671
+
672
+ def _reduce_64(val, _values, result)
673
+ result = :prefix_match
674
+ result
675
+ end
676
+
677
+ def _reduce_65(val, _values, result)
678
+ result = :suffix_match
679
+ result
680
+ end
681
+
682
+ def _reduce_66(val, _values, result)
683
+ result = :substring_match
684
+ result
685
+ end
686
+
687
+ def _reduce_67(val, _values, result)
688
+ result = :not_equal
689
+ result
690
+ end
691
+
692
+ def _reduce_68(val, _values, result)
693
+ result = :includes
694
+ result
695
+ end
696
+
697
+ def _reduce_69(val, _values, result)
698
+ result = :dash_match
699
+ result
700
+ end
701
+
702
+ def _reduce_70(val, _values, result)
703
+ result = Node.new(:NOT, [val[1]])
704
+
705
+ result
706
+ end
707
+
708
+ # reduce 71 omitted
709
+
710
+ # reduce 72 omitted
711
+
712
+ # reduce 73 omitted
713
+
714
+ def _reduce_none(val, _values, result)
715
+ val[0]
716
+ end
717
+
718
+ end # class Parser
719
+ end # module CSS
720
+ end # module Nokogiri