nokogiri 1.5.10 → 1.13.0

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