nokogiri 1.6.0 → 1.13.2

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 (340) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -19
  3. data/LICENSE-DEPENDENCIES.md +1903 -0
  4. data/LICENSE.md +9 -0
  5. data/README.md +280 -0
  6. data/bin/nokogiri +84 -31
  7. data/dependencies.yml +23 -4
  8. data/ext/nokogiri/depend +38 -358
  9. data/ext/nokogiri/extconf.rb +952 -132
  10. data/ext/nokogiri/gumbo.c +584 -0
  11. data/ext/nokogiri/html4_document.c +166 -0
  12. data/ext/nokogiri/html4_element_description.c +294 -0
  13. data/ext/nokogiri/html4_entity_lookup.c +37 -0
  14. data/ext/nokogiri/html4_sax_parser_context.c +120 -0
  15. data/ext/nokogiri/html4_sax_push_parser.c +95 -0
  16. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  17. data/ext/nokogiri/nokogiri.c +231 -96
  18. data/ext/nokogiri/nokogiri.h +188 -129
  19. data/ext/nokogiri/test_global_handlers.c +40 -0
  20. data/ext/nokogiri/xml_attr.c +49 -40
  21. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  22. data/ext/nokogiri/xml_cdata.c +24 -23
  23. data/ext/nokogiri/xml_comment.c +29 -21
  24. data/ext/nokogiri/xml_document.c +327 -223
  25. data/ext/nokogiri/xml_document_fragment.c +12 -16
  26. data/ext/nokogiri/xml_dtd.c +56 -50
  27. data/ext/nokogiri/xml_element_content.c +31 -26
  28. data/ext/nokogiri/xml_element_decl.c +22 -22
  29. data/ext/nokogiri/xml_encoding_handler.c +45 -20
  30. data/ext/nokogiri/xml_entity_decl.c +32 -30
  31. data/ext/nokogiri/xml_entity_reference.c +16 -18
  32. data/ext/nokogiri/xml_namespace.c +74 -32
  33. data/ext/nokogiri/xml_node.c +1290 -680
  34. data/ext/nokogiri/xml_node_set.c +239 -208
  35. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  36. data/ext/nokogiri/xml_reader.c +227 -189
  37. data/ext/nokogiri/xml_relax_ng.c +52 -28
  38. data/ext/nokogiri/xml_sax_parser.c +123 -125
  39. data/ext/nokogiri/xml_sax_parser_context.c +138 -79
  40. data/ext/nokogiri/xml_sax_push_parser.c +88 -35
  41. data/ext/nokogiri/xml_schema.c +112 -33
  42. data/ext/nokogiri/xml_syntax_error.c +50 -23
  43. data/ext/nokogiri/xml_text.c +14 -18
  44. data/ext/nokogiri/xml_xpath_context.c +227 -140
  45. data/ext/nokogiri/xslt_stylesheet.c +269 -177
  46. data/gumbo-parser/CHANGES.md +63 -0
  47. data/gumbo-parser/Makefile +101 -0
  48. data/gumbo-parser/THANKS +27 -0
  49. data/gumbo-parser/src/Makefile +34 -0
  50. data/gumbo-parser/src/README.md +41 -0
  51. data/gumbo-parser/src/ascii.c +75 -0
  52. data/gumbo-parser/src/ascii.h +115 -0
  53. data/gumbo-parser/src/attribute.c +42 -0
  54. data/gumbo-parser/src/attribute.h +17 -0
  55. data/gumbo-parser/src/char_ref.c +22225 -0
  56. data/gumbo-parser/src/char_ref.h +29 -0
  57. data/gumbo-parser/src/char_ref.rl +2154 -0
  58. data/gumbo-parser/src/error.c +626 -0
  59. data/gumbo-parser/src/error.h +148 -0
  60. data/gumbo-parser/src/foreign_attrs.c +104 -0
  61. data/gumbo-parser/src/foreign_attrs.gperf +27 -0
  62. data/gumbo-parser/src/gumbo.h +943 -0
  63. data/gumbo-parser/src/insertion_mode.h +33 -0
  64. data/gumbo-parser/src/macros.h +91 -0
  65. data/gumbo-parser/src/parser.c +4875 -0
  66. data/gumbo-parser/src/parser.h +41 -0
  67. data/gumbo-parser/src/replacement.h +33 -0
  68. data/gumbo-parser/src/string_buffer.c +103 -0
  69. data/gumbo-parser/src/string_buffer.h +68 -0
  70. data/gumbo-parser/src/string_piece.c +48 -0
  71. data/gumbo-parser/src/svg_attrs.c +174 -0
  72. data/gumbo-parser/src/svg_attrs.gperf +77 -0
  73. data/gumbo-parser/src/svg_tags.c +137 -0
  74. data/gumbo-parser/src/svg_tags.gperf +55 -0
  75. data/gumbo-parser/src/tag.c +222 -0
  76. data/gumbo-parser/src/tag_lookup.c +382 -0
  77. data/gumbo-parser/src/tag_lookup.gperf +169 -0
  78. data/gumbo-parser/src/tag_lookup.h +13 -0
  79. data/gumbo-parser/src/token_buffer.c +79 -0
  80. data/gumbo-parser/src/token_buffer.h +71 -0
  81. data/gumbo-parser/src/token_type.h +17 -0
  82. data/gumbo-parser/src/tokenizer.c +3463 -0
  83. data/gumbo-parser/src/tokenizer.h +112 -0
  84. data/gumbo-parser/src/tokenizer_states.h +339 -0
  85. data/gumbo-parser/src/utf8.c +245 -0
  86. data/gumbo-parser/src/utf8.h +164 -0
  87. data/gumbo-parser/src/util.c +68 -0
  88. data/gumbo-parser/src/util.h +30 -0
  89. data/gumbo-parser/src/vector.c +111 -0
  90. data/gumbo-parser/src/vector.h +45 -0
  91. data/lib/nokogiri/class_resolver.rb +67 -0
  92. data/lib/nokogiri/css/node.rb +10 -58
  93. data/lib/nokogiri/css/parser.rb +407 -357
  94. data/lib/nokogiri/css/parser.y +265 -246
  95. data/lib/nokogiri/css/parser_extras.rb +52 -49
  96. data/lib/nokogiri/css/syntax_error.rb +3 -1
  97. data/lib/nokogiri/css/tokenizer.rb +107 -104
  98. data/lib/nokogiri/css/tokenizer.rex +8 -7
  99. data/lib/nokogiri/css/xpath_visitor.rb +266 -80
  100. data/lib/nokogiri/css.rb +50 -17
  101. data/lib/nokogiri/decorators/slop.rb +17 -8
  102. data/lib/nokogiri/extension.rb +31 -0
  103. data/lib/nokogiri/gumbo.rb +15 -0
  104. data/lib/nokogiri/html.rb +38 -27
  105. data/lib/nokogiri/{html → html4}/builder.rb +4 -2
  106. data/lib/nokogiri/html4/document.rb +331 -0
  107. data/lib/nokogiri/html4/document_fragment.rb +54 -0
  108. data/lib/nokogiri/{html → html4}/element_description.rb +3 -1
  109. data/lib/nokogiri/html4/element_description_defaults.rb +578 -0
  110. data/lib/nokogiri/{html → html4}/entity_lookup.rb +4 -2
  111. data/lib/nokogiri/{html → html4}/sax/parser.rb +24 -15
  112. data/lib/nokogiri/html4/sax/parser_context.rb +20 -0
  113. data/lib/nokogiri/html4/sax/push_parser.rb +37 -0
  114. data/lib/nokogiri/html4.rb +46 -0
  115. data/lib/nokogiri/html5/document.rb +88 -0
  116. data/lib/nokogiri/html5/document_fragment.rb +83 -0
  117. data/lib/nokogiri/html5/node.rb +96 -0
  118. data/lib/nokogiri/html5.rb +477 -0
  119. data/lib/nokogiri/jruby/dependencies.rb +21 -0
  120. data/lib/nokogiri/syntax_error.rb +2 -0
  121. data/lib/nokogiri/version/constant.rb +6 -0
  122. data/lib/nokogiri/version/info.rb +221 -0
  123. data/lib/nokogiri/version.rb +3 -105
  124. data/lib/nokogiri/xml/attr.rb +6 -3
  125. data/lib/nokogiri/xml/attribute_decl.rb +3 -1
  126. data/lib/nokogiri/xml/builder.rb +96 -54
  127. data/lib/nokogiri/xml/cdata.rb +3 -1
  128. data/lib/nokogiri/xml/character_data.rb +2 -0
  129. data/lib/nokogiri/xml/document.rb +234 -95
  130. data/lib/nokogiri/xml/document_fragment.rb +86 -36
  131. data/lib/nokogiri/xml/dtd.rb +16 -4
  132. data/lib/nokogiri/xml/element_content.rb +2 -0
  133. data/lib/nokogiri/xml/element_decl.rb +3 -1
  134. data/lib/nokogiri/xml/entity_decl.rb +4 -2
  135. data/lib/nokogiri/xml/entity_reference.rb +20 -0
  136. data/lib/nokogiri/xml/namespace.rb +3 -0
  137. data/lib/nokogiri/xml/node/save_options.rb +8 -4
  138. data/lib/nokogiri/xml/node.rb +947 -502
  139. data/lib/nokogiri/xml/node_set.rb +168 -159
  140. data/lib/nokogiri/xml/notation.rb +13 -0
  141. data/lib/nokogiri/xml/parse_options.rb +40 -5
  142. data/lib/nokogiri/xml/pp/character_data.rb +9 -6
  143. data/lib/nokogiri/xml/pp/node.rb +25 -26
  144. data/lib/nokogiri/xml/pp.rb +4 -2
  145. data/lib/nokogiri/xml/processing_instruction.rb +3 -1
  146. data/lib/nokogiri/xml/reader.rb +23 -28
  147. data/lib/nokogiri/xml/relax_ng.rb +8 -2
  148. data/lib/nokogiri/xml/sax/document.rb +45 -49
  149. data/lib/nokogiri/xml/sax/parser.rb +43 -41
  150. data/lib/nokogiri/xml/sax/parser_context.rb +8 -3
  151. data/lib/nokogiri/xml/sax/push_parser.rb +6 -5
  152. data/lib/nokogiri/xml/sax.rb +6 -4
  153. data/lib/nokogiri/xml/schema.rb +19 -9
  154. data/lib/nokogiri/xml/searchable.rb +270 -0
  155. data/lib/nokogiri/xml/syntax_error.rb +25 -1
  156. data/lib/nokogiri/xml/text.rb +2 -0
  157. data/lib/nokogiri/xml/xpath/syntax_error.rb +4 -2
  158. data/lib/nokogiri/xml/xpath.rb +15 -4
  159. data/lib/nokogiri/xml/xpath_context.rb +3 -3
  160. data/lib/nokogiri/xml.rb +38 -36
  161. data/lib/nokogiri/xslt/stylesheet.rb +3 -1
  162. data/lib/nokogiri/xslt.rb +29 -20
  163. data/lib/nokogiri.rb +69 -69
  164. data/lib/xsd/xmlparser/nokogiri.rb +26 -24
  165. data/patches/libxml2/0001-Remove-script-macro-support.patch +40 -0
  166. data/patches/libxml2/0002-Update-entities-to-remove-handling-of-ssi.patch +44 -0
  167. data/patches/libxml2/0003-libxml2.la-is-in-top_builddir.patch +25 -0
  168. data/patches/libxml2/0004-use-glibc-strlen.patch +53 -0
  169. data/patches/libxml2/0005-avoid-isnan-isinf.patch +81 -0
  170. data/patches/libxml2/0006-update-automake-files-for-arm64.patch +3040 -0
  171. data/patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch +61 -0
  172. data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
  173. data/patches/libxslt/0001-update-automake-files-for-arm64.patch +3037 -0
  174. data/ports/archives/libxml2-2.9.13.tar.xz +0 -0
  175. data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
  176. metadata +278 -362
  177. data/.autotest +0 -26
  178. data/.gemtest +0 -0
  179. data/.travis.yml +0 -27
  180. data/CHANGELOG.ja.rdoc +0 -819
  181. data/CHANGELOG.rdoc +0 -819
  182. data/C_CODING_STYLE.rdoc +0 -33
  183. data/Manifest.txt +0 -315
  184. data/README.ja.rdoc +0 -106
  185. data/README.rdoc +0 -175
  186. data/ROADMAP.md +0 -90
  187. data/Rakefile +0 -246
  188. data/STANDARD_RESPONSES.md +0 -47
  189. data/Y_U_NO_GEMSPEC.md +0 -155
  190. data/build_all +0 -105
  191. data/ext/nokogiri/html_document.c +0 -170
  192. data/ext/nokogiri/html_document.h +0 -10
  193. data/ext/nokogiri/html_element_description.c +0 -279
  194. data/ext/nokogiri/html_element_description.h +0 -10
  195. data/ext/nokogiri/html_entity_lookup.c +0 -32
  196. data/ext/nokogiri/html_entity_lookup.h +0 -8
  197. data/ext/nokogiri/html_sax_parser_context.c +0 -116
  198. data/ext/nokogiri/html_sax_parser_context.h +0 -11
  199. data/ext/nokogiri/html_sax_push_parser.c +0 -87
  200. data/ext/nokogiri/html_sax_push_parser.h +0 -9
  201. data/ext/nokogiri/xml_attr.h +0 -9
  202. data/ext/nokogiri/xml_attribute_decl.h +0 -9
  203. data/ext/nokogiri/xml_cdata.h +0 -9
  204. data/ext/nokogiri/xml_comment.h +0 -9
  205. data/ext/nokogiri/xml_document.h +0 -23
  206. data/ext/nokogiri/xml_document_fragment.h +0 -10
  207. data/ext/nokogiri/xml_dtd.h +0 -10
  208. data/ext/nokogiri/xml_element_content.h +0 -10
  209. data/ext/nokogiri/xml_element_decl.h +0 -9
  210. data/ext/nokogiri/xml_encoding_handler.h +0 -8
  211. data/ext/nokogiri/xml_entity_decl.h +0 -10
  212. data/ext/nokogiri/xml_entity_reference.h +0 -9
  213. data/ext/nokogiri/xml_io.c +0 -56
  214. data/ext/nokogiri/xml_io.h +0 -11
  215. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
  216. data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
  217. data/ext/nokogiri/xml_namespace.h +0 -13
  218. data/ext/nokogiri/xml_node.h +0 -13
  219. data/ext/nokogiri/xml_node_set.h +0 -14
  220. data/ext/nokogiri/xml_processing_instruction.h +0 -9
  221. data/ext/nokogiri/xml_reader.h +0 -10
  222. data/ext/nokogiri/xml_relax_ng.h +0 -9
  223. data/ext/nokogiri/xml_sax_parser.h +0 -39
  224. data/ext/nokogiri/xml_sax_parser_context.h +0 -10
  225. data/ext/nokogiri/xml_sax_push_parser.h +0 -9
  226. data/ext/nokogiri/xml_schema.h +0 -9
  227. data/ext/nokogiri/xml_syntax_error.h +0 -13
  228. data/ext/nokogiri/xml_text.h +0 -9
  229. data/ext/nokogiri/xml_xpath_context.h +0 -10
  230. data/ext/nokogiri/xslt_stylesheet.h +0 -14
  231. data/lib/nokogiri/html/document.rb +0 -254
  232. data/lib/nokogiri/html/document_fragment.rb +0 -41
  233. data/lib/nokogiri/html/element_description_defaults.rb +0 -671
  234. data/lib/nokogiri/html/sax/parser_context.rb +0 -16
  235. data/lib/nokogiri/html/sax/push_parser.rb +0 -16
  236. data/ports/archives/libxml2-2.8.0.tar.gz +0 -0
  237. data/ports/archives/libxslt-1.1.26.tar.gz +0 -0
  238. data/tasks/cross_compile.rb +0 -132
  239. data/tasks/nokogiri.org.rb +0 -24
  240. data/tasks/test.rb +0 -95
  241. data/test/css/test_nthiness.rb +0 -159
  242. data/test/css/test_parser.rb +0 -341
  243. data/test/css/test_tokenizer.rb +0 -198
  244. data/test/css/test_xpath_visitor.rb +0 -91
  245. data/test/decorators/test_slop.rb +0 -16
  246. data/test/files/2ch.html +0 -108
  247. data/test/files/address_book.rlx +0 -12
  248. data/test/files/address_book.xml +0 -10
  249. data/test/files/bar/bar.xsd +0 -4
  250. data/test/files/bogus.xml +0 -0
  251. data/test/files/dont_hurt_em_why.xml +0 -422
  252. data/test/files/encoding.html +0 -82
  253. data/test/files/encoding.xhtml +0 -84
  254. data/test/files/exslt.xml +0 -8
  255. data/test/files/exslt.xslt +0 -35
  256. data/test/files/foo/foo.xsd +0 -4
  257. data/test/files/metacharset.html +0 -10
  258. data/test/files/noencoding.html +0 -47
  259. data/test/files/po.xml +0 -32
  260. data/test/files/po.xsd +0 -66
  261. data/test/files/saml/saml20assertion_schema.xsd +0 -283
  262. data/test/files/saml/saml20protocol_schema.xsd +0 -302
  263. data/test/files/saml/xenc_schema.xsd +0 -146
  264. data/test/files/saml/xmldsig_schema.xsd +0 -318
  265. data/test/files/shift_jis.html +0 -10
  266. data/test/files/shift_jis.xml +0 -5
  267. data/test/files/snuggles.xml +0 -3
  268. data/test/files/staff.dtd +0 -10
  269. data/test/files/staff.xml +0 -59
  270. data/test/files/staff.xslt +0 -32
  271. data/test/files/test_document_url/bar.xml +0 -2
  272. data/test/files/test_document_url/document.dtd +0 -4
  273. data/test/files/test_document_url/document.xml +0 -6
  274. data/test/files/tlm.html +0 -850
  275. data/test/files/to_be_xincluded.xml +0 -2
  276. data/test/files/valid_bar.xml +0 -2
  277. data/test/files/xinclude.xml +0 -4
  278. data/test/helper.rb +0 -154
  279. data/test/html/sax/test_parser.rb +0 -141
  280. data/test/html/sax/test_parser_context.rb +0 -46
  281. data/test/html/test_builder.rb +0 -164
  282. data/test/html/test_document.rb +0 -552
  283. data/test/html/test_document_encoding.rb +0 -138
  284. data/test/html/test_document_fragment.rb +0 -261
  285. data/test/html/test_element_description.rb +0 -105
  286. data/test/html/test_named_characters.rb +0 -14
  287. data/test/html/test_node.rb +0 -196
  288. data/test/html/test_node_encoding.rb +0 -27
  289. data/test/namespaces/test_additional_namespaces_in_builder_doc.rb +0 -14
  290. data/test/namespaces/test_namespaces_in_builder_doc.rb +0 -75
  291. data/test/namespaces/test_namespaces_in_created_doc.rb +0 -75
  292. data/test/namespaces/test_namespaces_in_parsed_doc.rb +0 -66
  293. data/test/test_convert_xpath.rb +0 -135
  294. data/test/test_css_cache.rb +0 -45
  295. data/test/test_encoding_handler.rb +0 -46
  296. data/test/test_memory_leak.rb +0 -156
  297. data/test/test_nokogiri.rb +0 -132
  298. data/test/test_reader.rb +0 -555
  299. data/test/test_soap4r_sax.rb +0 -52
  300. data/test/test_xslt_transforms.rb +0 -254
  301. data/test/xml/node/test_save_options.rb +0 -28
  302. data/test/xml/node/test_subclass.rb +0 -44
  303. data/test/xml/sax/test_parser.rb +0 -366
  304. data/test/xml/sax/test_parser_context.rb +0 -106
  305. data/test/xml/sax/test_push_parser.rb +0 -157
  306. data/test/xml/test_attr.rb +0 -64
  307. data/test/xml/test_attribute_decl.rb +0 -86
  308. data/test/xml/test_builder.rb +0 -306
  309. data/test/xml/test_c14n.rb +0 -151
  310. data/test/xml/test_cdata.rb +0 -48
  311. data/test/xml/test_comment.rb +0 -29
  312. data/test/xml/test_document.rb +0 -828
  313. data/test/xml/test_document_encoding.rb +0 -28
  314. data/test/xml/test_document_fragment.rb +0 -223
  315. data/test/xml/test_dtd.rb +0 -103
  316. data/test/xml/test_dtd_encoding.rb +0 -33
  317. data/test/xml/test_element_content.rb +0 -56
  318. data/test/xml/test_element_decl.rb +0 -73
  319. data/test/xml/test_entity_decl.rb +0 -122
  320. data/test/xml/test_entity_reference.rb +0 -245
  321. data/test/xml/test_namespace.rb +0 -95
  322. data/test/xml/test_node.rb +0 -1137
  323. data/test/xml/test_node_attributes.rb +0 -96
  324. data/test/xml/test_node_encoding.rb +0 -107
  325. data/test/xml/test_node_inheritance.rb +0 -32
  326. data/test/xml/test_node_reparenting.rb +0 -374
  327. data/test/xml/test_node_set.rb +0 -755
  328. data/test/xml/test_parse_options.rb +0 -64
  329. data/test/xml/test_processing_instruction.rb +0 -30
  330. data/test/xml/test_reader_encoding.rb +0 -142
  331. data/test/xml/test_relax_ng.rb +0 -60
  332. data/test/xml/test_schema.rb +0 -103
  333. data/test/xml/test_syntax_error.rb +0 -12
  334. data/test/xml/test_text.rb +0 -45
  335. data/test/xml/test_unparented_node.rb +0 -422
  336. data/test/xml/test_xinclude.rb +0 -83
  337. data/test/xml/test_xpath.rb +0 -295
  338. data/test/xslt/test_custom_functions.rb +0 -133
  339. data/test/xslt/test_exception_handling.rb +0 -37
  340. data/test_all +0 -81
@@ -1,189 +1,242 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.8
4
- # from Racc grammer file "".
4
+ # This file is automatically generated by Racc 1.6.0
5
+ # from Racc grammar file "".
5
6
  #
6
7
 
7
8
  require 'racc/parser.rb'
8
9
 
9
10
 
10
- require 'nokogiri/css/parser_extras'
11
+ require_relative "parser_extras"
12
+
13
+ module Nokogiri
14
+ module CSS
15
+ # :nodoc: all
16
+ class Parser < Racc::Parser
17
+ end
18
+ end
19
+ end
20
+
11
21
  module Nokogiri
12
22
  module CSS
13
23
  class Parser < Racc::Parser
24
+
25
+
26
+ def unescape_css_identifier(identifier)
27
+ identifier.gsub(/\\(?:([^0-9a-fA-F])|([0-9a-fA-F]{1,6})\s?)/){ |m| $1 || [$2.hex].pack('U') }
28
+ end
29
+
30
+ def unescape_css_string(str)
31
+ str.gsub(/\\(?:([^0-9a-fA-F])|([0-9a-fA-F]{1,6})\s?)/) do |m|
32
+ if $1=="\n"
33
+ ''
34
+ else
35
+ $1 || [$2.hex].pack('U')
36
+ end
37
+ end
38
+ end
14
39
  ##### State transition tables begin ###
15
40
 
16
41
  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 ]
42
+ 27, 11, 38, 99, 36, 12, 40, 26, 48, 25,
43
+ 49, 27, 100, 12, 30, 36, 105, 99, -26, 28,
44
+ 25, -26, 26, 27, 29, 14, 21, 23, 80, 30,
45
+ 28, 36, 72, 26, -26, 29, 14, 21, 23, 27,
46
+ 30, 91, 56, 36, 97, 96, 43, 29, 25, 26,
47
+ 27, 92, 94, 21, 36, 95, 30, 98, 28, 25,
48
+ 101, 26, 102, 29, 14, 21, 23, 96, 30, 28,
49
+ 36, 36, 26, 103, 29, 14, 21, 23, 27, 30,
50
+ 108, 107, 36, 109, 106, 43, 43, 25, 26, 26,
51
+ 27, 110, 21, 21, 111, 30, 30, 28, 99, 50,
52
+ 26, 53, 29, 14, 21, 23, 36, 30, 36, 56,
53
+ 61, 64, 113, 66, 29, 14, 116, 36, 118, 36,
54
+ nil, 43, nil, 43, 26, nil, 26, 14, 21, 23,
55
+ 21, 30, 43, 30, 43, 26, nil, 26, 36, 21,
56
+ 36, 21, 30, 25, 30, nil, nil, nil, nil, nil,
57
+ nil, 61, 62, 43, 60, 43, 26, nil, 26, nil,
58
+ 21, 23, 21, 30, 57, 30, 88, 89, 14, nil,
59
+ nil, 88, 89, nil, nil, nil, nil, 84, 85, 86,
60
+ nil, 87, 84, 85, 86, 83, 87, nil, 61, 93,
61
+ 83, 66, 61, 93, nil, 66, 61, 93, nil, 66,
62
+ 61, 93, nil, 66, nil, 14, nil, 61, 93, 14,
63
+ 66, nil, nil, 14, nil, nil, nil, 14, 4, 5,
64
+ 10, nil, nil, nil, 14, 4, 5, 47, 6, nil,
65
+ 8, 7, 4, 5, 10, 6, nil, 8, 7, nil,
66
+ nil, nil, 6, nil, 8, 7 ]
34
67
 
35
68
  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 ]
69
+ 3, 1, 11, 64, 3, 70, 14, 17, 21, 3,
70
+ 24, 9, 62, 1, 17, 9, 70, 62, 25, 3,
71
+ 9, 64, 3, 30, 3, 3, 3, 3, 49, 3,
72
+ 9, 16, 30, 9, 50, 9, 9, 9, 9, 12,
73
+ 9, 53, 30, 12, 60, 60, 16, 30, 12, 16,
74
+ 46, 54, 58, 16, 46, 59, 16, 61, 12, 46,
75
+ 63, 12, 65, 12, 12, 12, 12, 66, 12, 46,
76
+ 31, 32, 46, 67, 46, 46, 46, 46, 47, 46,
77
+ 82, 82, 47, 82, 81, 31, 32, 47, 31, 32,
78
+ 26, 90, 31, 32, 92, 31, 32, 47, 93, 26,
79
+ 47, 26, 47, 47, 47, 47, 28, 47, 33, 26,
80
+ 28, 28, 97, 28, 26, 26, 100, 34, 113, 35,
81
+ nil, 28, nil, 33, 28, nil, 33, 28, 28, 28,
82
+ 33, 28, 34, 33, 35, 34, nil, 35, 43, 34,
83
+ 68, 35, 34, 43, 35, nil, nil, nil, nil, nil,
84
+ nil, 27, 27, 43, 27, 68, 43, nil, 68, nil,
85
+ 43, 43, 68, 43, 27, 68, 51, 51, 27, nil,
86
+ nil, 52, 52, nil, nil, nil, nil, 51, 51, 51,
87
+ nil, 51, 52, 52, 52, 51, 52, nil, 56, 56,
88
+ 52, 56, 96, 96, nil, 96, 98, 98, nil, 98,
89
+ 99, 99, nil, 99, nil, 56, nil, 101, 101, 96,
90
+ 101, nil, nil, 98, nil, nil, nil, 99, 0, 0,
91
+ 0, nil, nil, nil, 101, 20, 20, 20, 0, nil,
92
+ 0, 0, 29, 29, 29, 20, nil, 20, 20, nil,
93
+ nil, nil, 29, nil, 29, 29 ]
53
94
 
54
95
  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 ]
96
+ 211, 1, nil, -2, nil, nil, nil, nil, nil, 9,
97
+ nil, 2, 37, nil, -5, nil, 25, -17, nil, nil,
98
+ 218, -3, nil, nil, -20, -12, 88, 141, 100, 225,
99
+ 21, 64, 65, 102, 111, 113, nil, nil, nil, nil,
100
+ nil, nil, nil, 132, nil, nil, 48, 76, nil, 17,
101
+ 4, 163, 168, 16, 21, nil, 178, nil, 29, 32,
102
+ 33, 45, 5, 48, -9, 39, 55, 50, 134, nil,
103
+ -7, nil, nil, nil, nil, nil, nil, nil, nil, nil,
104
+ nil, 59, 70, nil, nil, nil, nil, nil, nil, nil,
105
+ 66, nil, 83, 86, nil, nil, 182, 105, 186, 190,
106
+ 103, 197, nil, nil, nil, nil, nil, nil, nil, nil,
107
+ nil, nil, nil, 105, nil, nil, nil, nil, nil ]
66
108
 
67
109
  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 ]
110
+ -81, -82, -2, -27, -4, -5, -6, -7, -8, -27,
111
+ -80, -82, -27, -3, -82, -10, -53, -12, -15, -16,
112
+ -20, -82, -22, -23, -82, -25, -27, -82, -27, -81,
113
+ -82, -59, -60, -61, -62, -63, -64, -17, 119, -1,
114
+ -9, -11, -52, -27, -13, -14, -27, -27, -21, -82,
115
+ -32, -68, -68, -82, -82, -33, -82, -34, -82, -82,
116
+ -43, -44, -45, -46, -25, -82, -43, -82, -77, -79,
117
+ -82, -50, -51, -54, -55, -56, -57, -58, -18, -19,
118
+ -24, -82, -82, -69, -70, -71, -72, -73, -74, -75,
119
+ -82, -30, -82, -45, -35, -36, -82, -49, -82, -82,
120
+ -82, -82, -37, -76, -78, -38, -28, -65, -66, -67,
121
+ -29, -31, -39, -82, -40, -41, -48, -42, -47 ]
79
122
 
80
123
  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 ]
124
+ 58, 42, 13, 1, 46, 52, 19, 68, 37, 71,
125
+ 41, 39, 19, 69, 44, 19, 73, 74, 75, 76,
126
+ 77, 45, 68, 81, 90, 54, 51, 59, 69, 55,
127
+ nil, nil, 70, nil, nil, nil, nil, nil, nil, nil,
128
+ nil, nil, nil, nil, nil, 78, 79, nil, nil, 19,
129
+ 19, nil, nil, 104, nil, nil, nil, nil, nil, nil,
130
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 112,
131
+ nil, 114, 115, nil, 117 ]
88
132
 
89
133
  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 ]
134
+ 20, 14, 2, 1, 5, 11, 7, 9, 2, 11,
135
+ 10, 2, 7, 14, 12, 7, 14, 14, 14, 14,
136
+ 14, 13, 9, 19, 19, 17, 18, 21, 14, 7,
137
+ nil, nil, 1, nil, nil, nil, nil, nil, nil, nil,
138
+ nil, nil, nil, nil, nil, 2, 2, nil, nil, 7,
139
+ 7, nil, nil, 14, nil, nil, nil, nil, nil, nil,
140
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 20,
141
+ nil, 20, 20, nil, 20 ]
97
142
 
98
143
  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 ]
144
+ nil, 3, -1, nil, nil, -16, nil, 3, nil, -21,
145
+ -6, -21, -3, 4, -15, nil, nil, -1, 0, -28,
146
+ -27, 0, nil, nil, nil, nil ]
102
147
 
103
148
  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 ]
149
+ nil, nil, nil, 2, 3, 9, 15, 63, 20, 16,
150
+ nil, 17, 34, 33, 18, 32, 22, 24, nil, nil,
151
+ 65, nil, 31, 35, 82, 67 ]
107
152
 
108
153
  racc_reduce_table = [
109
154
  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,
155
+ 3, 33, :_reduce_1,
156
+ 1, 33, :_reduce_2,
157
+ 2, 33, :_reduce_3,
158
+ 1, 37, :_reduce_4,
159
+ 1, 37, :_reduce_5,
160
+ 1, 37, :_reduce_6,
161
+ 1, 37, :_reduce_7,
162
+ 1, 37, :_reduce_8,
163
+ 2, 38, :_reduce_9,
164
+ 1, 39, :_reduce_10,
165
+ 2, 40, :_reduce_11,
166
+ 1, 40, :_reduce_none,
167
+ 2, 40, :_reduce_13,
168
+ 2, 40, :_reduce_14,
169
+ 1, 40, :_reduce_15,
170
+ 1, 40, :_reduce_none,
171
+ 2, 35, :_reduce_17,
172
+ 3, 34, :_reduce_18,
173
+ 3, 34, :_reduce_19,
174
+ 1, 34, :_reduce_none,
175
+ 2, 47, :_reduce_21,
176
+ 1, 41, :_reduce_none,
177
+ 1, 41, :_reduce_23,
178
+ 3, 48, :_reduce_24,
179
+ 1, 48, :_reduce_25,
180
+ 1, 49, :_reduce_26,
181
+ 0, 49, :_reduce_none,
182
+ 4, 45, :_reduce_28,
183
+ 4, 45, :_reduce_29,
184
+ 3, 45, :_reduce_30,
185
+ 3, 50, :_reduce_31,
186
+ 1, 50, :_reduce_32,
187
+ 1, 50, :_reduce_none,
188
+ 2, 43, :_reduce_34,
189
+ 3, 43, :_reduce_35,
190
+ 3, 43, :_reduce_36,
191
+ 3, 43, :_reduce_37,
192
+ 3, 43, :_reduce_38,
193
+ 3, 52, :_reduce_39,
194
+ 3, 52, :_reduce_40,
195
+ 3, 52, :_reduce_41,
196
+ 3, 52, :_reduce_42,
197
+ 1, 52, :_reduce_none,
198
+ 1, 52, :_reduce_none,
199
+ 1, 52, :_reduce_45,
200
+ 1, 52, :_reduce_none,
201
+ 4, 53, :_reduce_47,
202
+ 3, 53, :_reduce_48,
203
+ 2, 53, :_reduce_49,
204
+ 2, 44, :_reduce_50,
205
+ 2, 44, :_reduce_51,
206
+ 1, 42, :_reduce_none,
207
+ 0, 42, :_reduce_none,
208
+ 2, 46, :_reduce_54,
209
+ 2, 46, :_reduce_55,
210
+ 2, 46, :_reduce_56,
211
+ 2, 46, :_reduce_57,
212
+ 2, 46, :_reduce_58,
213
+ 1, 46, :_reduce_none,
214
+ 1, 46, :_reduce_none,
215
+ 1, 46, :_reduce_none,
216
+ 1, 46, :_reduce_none,
217
+ 1, 46, :_reduce_none,
218
+ 1, 54, :_reduce_64,
219
+ 2, 51, :_reduce_65,
220
+ 2, 51, :_reduce_66,
221
+ 2, 51, :_reduce_67,
222
+ 0, 51, :_reduce_none,
223
+ 1, 56, :_reduce_69,
224
+ 1, 56, :_reduce_70,
225
+ 1, 56, :_reduce_71,
226
+ 1, 56, :_reduce_72,
227
+ 1, 56, :_reduce_73,
228
+ 1, 56, :_reduce_74,
229
+ 1, 56, :_reduce_75,
230
+ 3, 55, :_reduce_76,
231
+ 1, 57, :_reduce_none,
232
+ 2, 57, :_reduce_none,
233
+ 1, 57, :_reduce_none,
122
234
  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
235
+ 0, 36, :_reduce_none ]
236
+
237
+ racc_reduce_n = 82
238
+
239
+ racc_shift_n = 119
187
240
 
188
241
  racc_token_table = {
189
242
  false => 0,
@@ -213,12 +266,13 @@ racc_token_table = {
213
266
  :LSQUARE => 24,
214
267
  :RSQUARE => 25,
215
268
  :HAS => 26,
216
- "." => 27,
217
- "*" => 28,
218
- "|" => 29,
219
- ":" => 30 }
269
+ "@" => 27,
270
+ "." => 28,
271
+ "*" => 29,
272
+ "|" => 30,
273
+ ":" => 31 }
220
274
 
221
- racc_nt_base = 31
275
+ racc_nt_base = 32
222
276
 
223
277
  racc_use_result_var = true
224
278
 
@@ -266,6 +320,7 @@ Racc_token_to_s_table = [
266
320
  "LSQUARE",
267
321
  "RSQUARE",
268
322
  "HAS",
323
+ "\"@\"",
269
324
  "\".\"",
270
325
  "\"*\"",
271
326
  "\"|\"",
@@ -274,23 +329,26 @@ Racc_token_to_s_table = [
274
329
  "selector",
275
330
  "simple_selector_1toN",
276
331
  "prefixless_combinator_selector",
332
+ "optional_S",
277
333
  "combinator",
334
+ "xpath_attribute_name",
335
+ "xpath_attribute",
278
336
  "simple_selector",
279
337
  "element_name",
280
338
  "hcap_0toN",
281
- "hcap_1toN",
282
- "negation",
283
339
  "function",
284
340
  "pseudo",
285
341
  "attrib",
342
+ "hcap_1toN",
286
343
  "class",
287
344
  "namespaced_ident",
288
345
  "namespace",
289
346
  "attrib_name",
290
347
  "attrib_val_0or1",
291
348
  "expr",
292
- "an_plus_b",
349
+ "nth",
293
350
  "attribute_id",
351
+ "negation",
294
352
  "eql_incl_dash",
295
353
  "negation_arg" ]
296
354
 
@@ -301,420 +359,412 @@ Racc_debug_parser = false
301
359
  # reduce 0 omitted
302
360
 
303
361
  def _reduce_1(val, _values, result)
304
- result = [val.first, val.last].flatten
305
-
362
+ result = [val[0], val[2]].flatten
363
+
306
364
  result
307
365
  end
308
366
 
309
367
  def _reduce_2(val, _values, result)
310
- result = val.flatten
368
+ result = val.flatten
311
369
  result
312
370
  end
313
371
 
314
372
  def _reduce_3(val, _values, result)
315
- result = val.flatten
373
+ result = [val[1]].flatten
316
374
  result
317
375
  end
318
376
 
319
377
  def _reduce_4(val, _values, result)
320
- result = :DIRECT_ADJACENT_SELECTOR
378
+ result = :DIRECT_ADJACENT_SELECTOR
321
379
  result
322
380
  end
323
381
 
324
382
  def _reduce_5(val, _values, result)
325
- result = :CHILD_SELECTOR
383
+ result = :CHILD_SELECTOR
326
384
  result
327
385
  end
328
386
 
329
387
  def _reduce_6(val, _values, result)
330
- result = :FOLLOWING_SELECTOR
388
+ result = :FOLLOWING_SELECTOR
331
389
  result
332
390
  end
333
391
 
334
392
  def _reduce_7(val, _values, result)
335
- result = :DESCENDANT_SELECTOR
393
+ result = :DESCENDANT_SELECTOR
336
394
  result
337
395
  end
338
396
 
339
397
  def _reduce_8(val, _values, result)
340
- result = :DESCENDANT_SELECTOR
398
+ result = :CHILD_SELECTOR
341
399
  result
342
400
  end
343
401
 
344
402
  def _reduce_9(val, _values, result)
345
- result = :CHILD_SELECTOR
403
+ result = val[1]
346
404
  result
347
405
  end
348
406
 
349
407
  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
-
408
+ result = Node.new(:ATTRIB_NAME, [val[0]])
356
409
  result
357
410
  end
358
411
 
359
412
  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
-
413
+ result = if val[1].nil?
414
+ val[0]
415
+ else
416
+ Node.new(:CONDITIONAL_SELECTOR, [val[0], val[1]])
417
+ end
418
+
367
419
  result
368
420
  end
369
421
 
370
- def _reduce_12(val, _values, result)
371
- result = Node.new(:CONDITIONAL_SELECTOR, val)
372
-
422
+ # reduce 12 omitted
423
+
424
+ def _reduce_13(val, _values, result)
425
+ result = Node.new(:CONDITIONAL_SELECTOR, val)
373
426
  result
374
427
  end
375
428
 
376
- # reduce 13 omitted
377
-
378
429
  def _reduce_14(val, _values, result)
379
- result = Node.new(:CONDITIONAL_SELECTOR, val)
380
-
430
+ result = Node.new(:CONDITIONAL_SELECTOR, val)
381
431
  result
382
432
  end
383
433
 
384
434
  def _reduce_15(val, _values, result)
385
- result = Node.new(:CONDITIONAL_SELECTOR, val)
386
-
435
+ result = Node.new(:CONDITIONAL_SELECTOR, [Node.new(:ELEMENT_NAME, ['*']), val[0]])
387
436
  result
388
437
  end
389
438
 
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
439
+ # reduce 16 omitted
400
440
 
401
441
  def _reduce_17(val, _values, result)
402
- result = Node.new(:CONDITIONAL_SELECTOR,
403
- [Node.new(:ELEMENT_NAME, ['*']), val.first]
404
- )
405
-
442
+ result = Node.new(val[0], [nil, val[1]])
406
443
  result
407
444
  end
408
445
 
409
446
  def _reduce_18(val, _values, result)
410
- result = Node.new(val.first, [nil, val.last])
411
-
447
+ result = Node.new(val[1], [val[0], val[2]])
412
448
  result
413
449
  end
414
450
 
415
451
  def _reduce_19(val, _values, result)
416
- result = Node.new(val[1], [val.first, val.last])
417
-
452
+ result = Node.new(:DESCENDANT_SELECTOR, [val[0], val[2]])
418
453
  result
419
454
  end
420
455
 
421
456
  # reduce 20 omitted
422
457
 
423
458
  def _reduce_21(val, _values, result)
424
- result = Node.new(:CLASS_CONDITION, [val[1]])
459
+ result = Node.new(:CLASS_CONDITION, [unescape_css_identifier(val[1])])
425
460
  result
426
461
  end
427
462
 
428
463
  # reduce 22 omitted
429
464
 
430
465
  def _reduce_23(val, _values, result)
431
- result = Node.new(:ELEMENT_NAME, val)
466
+ result = Node.new(:ELEMENT_NAME, val)
432
467
  result
433
468
  end
434
469
 
435
470
  def _reduce_24(val, _values, result)
436
- result = Node.new(:ELEMENT_NAME,
437
- [[val.first, val.last].compact.join(':')]
438
- )
439
-
471
+ result = Node.new(:ELEMENT_NAME, [[val[0], val[2]].compact.join(':')])
440
472
  result
441
473
  end
442
474
 
443
475
  def _reduce_25(val, _values, result)
444
- name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
445
- result = Node.new(:ELEMENT_NAME, [name])
446
-
476
+ name = @namespaces.key?('xmlns') ? "xmlns:#{val[0]}" : val[0]
477
+ result = Node.new(:ELEMENT_NAME, [name])
478
+
447
479
  result
448
480
  end
449
481
 
450
482
  def _reduce_26(val, _values, result)
451
- result = val[0]
483
+ result = val[0]
452
484
  result
453
485
  end
454
486
 
455
487
  # reduce 27 omitted
456
488
 
457
489
  def _reduce_28(val, _values, result)
458
- result = Node.new(:ATTRIBUTE_CONDITION,
459
- [val[1]] + (val[2] || [])
460
- )
461
-
490
+ result = Node.new(:ATTRIBUTE_CONDITION, [val[1]] + (val[2] || []))
491
+
462
492
  result
463
493
  end
464
494
 
465
495
  def _reduce_29(val, _values, result)
466
- result = Node.new(:ATTRIBUTE_CONDITION,
467
- [val[1]] + (val[2] || [])
468
- )
469
-
496
+ result = Node.new(:ATTRIBUTE_CONDITION, [val[1]] + (val[2] || []))
497
+
470
498
  result
471
499
  end
472
500
 
473
501
  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
-
502
+ result = Node.new(:PSEUDO_CLASS, [Node.new(:FUNCTION, ['nth-child(', val[1]])])
503
+
479
504
  result
480
505
  end
481
506
 
482
507
  def _reduce_31(val, _values, result)
483
- result = Node.new(:ELEMENT_NAME,
484
- [[val.first, val.last].compact.join(':')]
485
- )
486
-
508
+ result = Node.new(:ATTRIB_NAME, [[val[0], val[2]].compact.join(':')])
487
509
  result
488
510
  end
489
511
 
490
512
  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
-
513
+ result = Node.new(:ATTRIB_NAME, [val[0]])
495
514
  result
496
515
  end
497
516
 
498
- def _reduce_33(val, _values, result)
499
- result = Node.new(:FUNCTION, [val.first.strip])
500
-
501
- result
502
- end
517
+ # reduce 33 omitted
503
518
 
504
519
  def _reduce_34(val, _values, result)
505
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
506
-
520
+ result = Node.new(:FUNCTION, [val[0].strip])
521
+
507
522
  result
508
523
  end
509
524
 
510
525
  def _reduce_35(val, _values, result)
511
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
512
-
526
+ result = Node.new(:FUNCTION, [val[0].strip, val[1]].flatten)
527
+
513
528
  result
514
529
  end
515
530
 
516
531
  def _reduce_36(val, _values, result)
517
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
518
-
532
+ result = Node.new(:FUNCTION, [val[0].strip, val[1]].flatten)
533
+
519
534
  result
520
535
  end
521
536
 
522
537
  def _reduce_37(val, _values, result)
523
- result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
524
-
538
+ result = Node.new(:FUNCTION, [val[0].strip, val[1]].flatten)
539
+
525
540
  result
526
541
  end
527
542
 
528
543
  def _reduce_38(val, _values, result)
529
- result = [val.first, val.last]
544
+ result = Node.new(:FUNCTION, [val[0].strip, val[1]].flatten)
545
+
530
546
  result
531
547
  end
532
548
 
533
549
  def _reduce_39(val, _values, result)
534
- result = [val.first, val.last]
550
+ result = [val[0], val[2]]
535
551
  result
536
552
  end
537
553
 
538
554
  def _reduce_40(val, _values, result)
539
- result = [val.first, val.last]
555
+ result = [val[0], val[2]]
540
556
  result
541
557
  end
542
558
 
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
-
559
+ def _reduce_41(val, _values, result)
560
+ result = [val[0], val[2]]
562
561
  result
563
562
  end
564
563
 
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
-
564
+ def _reduce_42(val, _values, result)
565
+ result = [val[0], val[2]]
572
566
  result
573
567
  end
574
568
 
569
+ # reduce 43 omitted
570
+
571
+ # reduce 44 omitted
572
+
575
573
  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
574
+ case val[0]
575
+ when 'even'
576
+ result = Node.new(:NTH, ['2','n','+','0'])
577
+ when 'odd'
578
+ result = Node.new(:NTH, ['2','n','+','1'])
579
+ when 'n'
580
+ result = Node.new(:NTH, ['1','n','+','0'])
581
+ else
582
+ result = val
583
+ end
590
584
 
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
585
  result
601
586
  end
602
587
 
588
+ # reduce 46 omitted
589
+
603
590
  def _reduce_47(val, _values, result)
604
- result = Node.new(:PSEUDO_CLASS, [val[1]])
605
-
591
+ if val[1] == 'n'
592
+ result = Node.new(:NTH, val)
593
+ else
594
+ raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
595
+ end
596
+
606
597
  result
607
598
  end
608
599
 
609
600
  def _reduce_48(val, _values, result)
610
- result = Node.new(:PSEUDO_CLASS, [val[1]])
601
+ # n+3, -n+3
602
+ if val[0] == 'n'
603
+ val.unshift("1")
604
+ result = Node.new(:NTH, val)
605
+ elsif val[0] == '-n'
606
+ val[0] = 'n'
607
+ val.unshift("-1")
608
+ result = Node.new(:NTH, val)
609
+ else
610
+ raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
611
+ end
612
+
611
613
  result
612
614
  end
613
615
 
614
- # reduce 49 omitted
615
-
616
- # reduce 50 omitted
616
+ def _reduce_49(val, _values, result)
617
+ # 5n, -5n, 10n-1
618
+ n = val[1]
619
+ if n[0, 2] == 'n-'
620
+ val[1] = 'n'
621
+ val << "-"
622
+ # b is contained in n as n is the string "n-b"
623
+ val << n[2, n.size]
624
+ result = Node.new(:NTH, val)
625
+ elsif n == 'n'
626
+ val << "+"
627
+ val << "0"
628
+ result = Node.new(:NTH, val)
629
+ else
630
+ raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
631
+ end
617
632
 
618
- def _reduce_51(val, _values, result)
619
- result = Node.new(:COMBINATOR, val)
620
-
621
633
  result
622
634
  end
623
635
 
624
- def _reduce_52(val, _values, result)
625
- result = Node.new(:COMBINATOR, val)
626
-
636
+ def _reduce_50(val, _values, result)
637
+ result = Node.new(:PSEUDO_CLASS, [val[1]])
638
+
627
639
  result
628
640
  end
629
641
 
630
- def _reduce_53(val, _values, result)
631
- result = Node.new(:COMBINATOR, val)
632
-
642
+ def _reduce_51(val, _values, result)
643
+ result = Node.new(:PSEUDO_CLASS, [val[1]])
633
644
  result
634
645
  end
635
646
 
647
+ # reduce 52 omitted
648
+
649
+ # reduce 53 omitted
650
+
636
651
  def _reduce_54(val, _values, result)
637
- result = Node.new(:COMBINATOR, val)
638
-
652
+ result = Node.new(:COMBINATOR, val)
653
+
639
654
  result
640
655
  end
641
656
 
642
- # reduce 55 omitted
657
+ def _reduce_55(val, _values, result)
658
+ result = Node.new(:COMBINATOR, val)
643
659
 
644
- # reduce 56 omitted
645
-
646
- # reduce 57 omitted
660
+ result
661
+ end
647
662
 
648
- # reduce 58 omitted
663
+ def _reduce_56(val, _values, result)
664
+ result = Node.new(:COMBINATOR, val)
649
665
 
650
- def _reduce_59(val, _values, result)
651
- result = Node.new(:ID, val)
652
666
  result
653
667
  end
654
668
 
655
- def _reduce_60(val, _values, result)
656
- result = [val.first, val[1]]
669
+ def _reduce_57(val, _values, result)
670
+ result = Node.new(:COMBINATOR, val)
671
+
657
672
  result
658
673
  end
659
674
 
660
- def _reduce_61(val, _values, result)
661
- result = [val.first, val[1]]
675
+ def _reduce_58(val, _values, result)
676
+ result = Node.new(:COMBINATOR, val)
677
+
662
678
  result
663
679
  end
664
680
 
681
+ # reduce 59 omitted
682
+
683
+ # reduce 60 omitted
684
+
685
+ # reduce 61 omitted
686
+
665
687
  # reduce 62 omitted
666
688
 
667
- def _reduce_63(val, _values, result)
668
- result = :equal
669
- result
670
- end
689
+ # reduce 63 omitted
671
690
 
672
691
  def _reduce_64(val, _values, result)
673
- result = :prefix_match
692
+ result = Node.new(:ID, [unescape_css_identifier(val[0])])
674
693
  result
675
694
  end
676
695
 
677
696
  def _reduce_65(val, _values, result)
678
- result = :suffix_match
697
+ result = [val[0], unescape_css_identifier(val[1])]
679
698
  result
680
699
  end
681
700
 
682
701
  def _reduce_66(val, _values, result)
683
- result = :substring_match
702
+ result = [val[0], unescape_css_string(val[1])]
684
703
  result
685
704
  end
686
705
 
687
706
  def _reduce_67(val, _values, result)
688
- result = :not_equal
707
+ result = [val[0], val[1]]
689
708
  result
690
709
  end
691
710
 
692
- def _reduce_68(val, _values, result)
693
- result = :includes
694
- result
695
- end
711
+ # reduce 68 omitted
696
712
 
697
713
  def _reduce_69(val, _values, result)
698
- result = :dash_match
714
+ result = :equal
699
715
  result
700
716
  end
701
717
 
702
718
  def _reduce_70(val, _values, result)
703
- result = Node.new(:NOT, [val[1]])
704
-
719
+ result = :prefix_match
705
720
  result
706
721
  end
707
722
 
708
- # reduce 71 omitted
723
+ def _reduce_71(val, _values, result)
724
+ result = :suffix_match
725
+ result
726
+ end
727
+
728
+ def _reduce_72(val, _values, result)
729
+ result = :substring_match
730
+ result
731
+ end
732
+
733
+ def _reduce_73(val, _values, result)
734
+ result = :not_equal
735
+ result
736
+ end
737
+
738
+ def _reduce_74(val, _values, result)
739
+ result = :includes
740
+ result
741
+ end
742
+
743
+ def _reduce_75(val, _values, result)
744
+ result = :dash_match
745
+ result
746
+ end
747
+
748
+ def _reduce_76(val, _values, result)
749
+ result = Node.new(:NOT, [val[1]])
750
+
751
+ result
752
+ end
753
+
754
+ # reduce 77 omitted
755
+
756
+ # reduce 78 omitted
757
+
758
+ # reduce 79 omitted
709
759
 
710
- # reduce 72 omitted
760
+ # reduce 80 omitted
711
761
 
712
- # reduce 73 omitted
762
+ # reduce 81 omitted
713
763
 
714
764
  def _reduce_none(val, _values, result)
715
765
  val[0]
716
766
  end
717
767
 
718
768
  end # class Parser
719
- end # module CSS
720
- end # module Nokogiri
769
+ end # module CSS
770
+ end # module Nokogiri