nokogiri 1.6.2.rc1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

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