glebm-nokogiri 1.4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +26 -0
- data/CHANGELOG.ja.rdoc +411 -0
- data/CHANGELOG.rdoc +397 -0
- data/Manifest.txt +276 -0
- data/README.ja.rdoc +106 -0
- data/README.rdoc +132 -0
- data/Rakefile +183 -0
- data/bin/nokogiri +49 -0
- data/deps.rip +5 -0
- data/ext/nokogiri/extconf.rb +97 -0
- data/ext/nokogiri/html_document.c +154 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +276 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +94 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/nokogiri.c +95 -0
- data/ext/nokogiri/nokogiri.h +153 -0
- data/ext/nokogiri/xml_attr.c +94 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +56 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +54 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +464 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +31 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_namespace.c +84 -0
- data/ext/nokogiri/xml_namespace.h +13 -0
- data/ext/nokogiri/xml_node.c +1347 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +418 -0
- data/ext/nokogiri/xml_node_set.h +9 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +665 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +168 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +286 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +159 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +115 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +205 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +58 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +50 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +276 -0
- data/ext/nokogiri/xml_xpath_context.h +9 -0
- data/ext/nokogiri/xslt_stylesheet.c +142 -0
- data/ext/nokogiri/xslt_stylesheet.h +9 -0
- data/lib/nokogiri.rb +133 -0
- data/lib/nokogiri/css.rb +25 -0
- data/lib/nokogiri/css/generated_parser.rb +669 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +145 -0
- data/lib/nokogiri/css/node.rb +99 -0
- data/lib/nokogiri/css/parser.rb +82 -0
- data/lib/nokogiri/css/parser.y +232 -0
- data/lib/nokogiri/css/syntax_error.rb +7 -0
- data/lib/nokogiri/css/tokenizer.rb +7 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +169 -0
- data/lib/nokogiri/decorators/slop.rb +33 -0
- data/lib/nokogiri/ffi/encoding_handler.rb +42 -0
- data/lib/nokogiri/ffi/html/document.rb +28 -0
- data/lib/nokogiri/ffi/html/element_description.rb +81 -0
- data/lib/nokogiri/ffi/html/entity_lookup.rb +16 -0
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +38 -0
- data/lib/nokogiri/ffi/io_callbacks.rb +42 -0
- data/lib/nokogiri/ffi/libxml.rb +386 -0
- data/lib/nokogiri/ffi/structs/common_node.rb +38 -0
- data/lib/nokogiri/ffi/structs/html_elem_desc.rb +24 -0
- data/lib/nokogiri/ffi/structs/html_entity_desc.rb +13 -0
- data/lib/nokogiri/ffi/structs/xml_alloc.rb +16 -0
- data/lib/nokogiri/ffi/structs/xml_attr.rb +19 -0
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +27 -0
- data/lib/nokogiri/ffi/structs/xml_buffer.rb +16 -0
- data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +11 -0
- data/lib/nokogiri/ffi/structs/xml_document.rb +117 -0
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +28 -0
- data/lib/nokogiri/ffi/structs/xml_element.rb +26 -0
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +17 -0
- data/lib/nokogiri/ffi/structs/xml_entity.rb +32 -0
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_node.rb +28 -0
- data/lib/nokogiri/ffi/structs/xml_node_set.rb +53 -0
- data/lib/nokogiri/ffi/structs/xml_notation.rb +11 -0
- data/lib/nokogiri/ffi/structs/xml_ns.rb +15 -0
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +19 -0
- data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +14 -0
- data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +51 -0
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +124 -0
- data/lib/nokogiri/ffi/structs/xml_schema.rb +13 -0
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +31 -0
- data/lib/nokogiri/ffi/structs/xml_text_reader.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +38 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +35 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +20 -0
- data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +13 -0
- data/lib/nokogiri/ffi/weak_bucket.rb +40 -0
- data/lib/nokogiri/ffi/xml/attr.rb +41 -0
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +27 -0
- data/lib/nokogiri/ffi/xml/cdata.rb +19 -0
- data/lib/nokogiri/ffi/xml/comment.rb +18 -0
- data/lib/nokogiri/ffi/xml/document.rb +162 -0
- data/lib/nokogiri/ffi/xml/document_fragment.rb +21 -0
- data/lib/nokogiri/ffi/xml/dtd.rb +67 -0
- data/lib/nokogiri/ffi/xml/element_content.rb +43 -0
- data/lib/nokogiri/ffi/xml/element_decl.rb +19 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +36 -0
- data/lib/nokogiri/ffi/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/ffi/xml/namespace.rb +44 -0
- data/lib/nokogiri/ffi/xml/node.rb +556 -0
- data/lib/nokogiri/ffi/xml/node_set.rb +149 -0
- data/lib/nokogiri/ffi/xml/processing_instruction.rb +20 -0
- data/lib/nokogiri/ffi/xml/reader.rb +232 -0
- data/lib/nokogiri/ffi/xml/relax_ng.rb +85 -0
- data/lib/nokogiri/ffi/xml/sax/parser.rb +135 -0
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +67 -0
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +51 -0
- data/lib/nokogiri/ffi/xml/schema.rb +109 -0
- data/lib/nokogiri/ffi/xml/syntax_error.rb +98 -0
- data/lib/nokogiri/ffi/xml/text.rb +18 -0
- data/lib/nokogiri/ffi/xml/xpath.rb +9 -0
- data/lib/nokogiri/ffi/xml/xpath_context.rb +148 -0
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +53 -0
- data/lib/nokogiri/html.rb +35 -0
- data/lib/nokogiri/html/builder.rb +35 -0
- data/lib/nokogiri/html/document.rb +90 -0
- data/lib/nokogiri/html/document_fragment.rb +36 -0
- data/lib/nokogiri/html/element_description.rb +23 -0
- data/lib/nokogiri/html/entity_lookup.rb +13 -0
- data/lib/nokogiri/html/sax/parser.rb +48 -0
- data/lib/nokogiri/html/sax/parser_context.rb +16 -0
- data/lib/nokogiri/syntax_error.rb +4 -0
- data/lib/nokogiri/version.rb +37 -0
- data/lib/nokogiri/version_warning.rb +14 -0
- data/lib/nokogiri/xml.rb +67 -0
- data/lib/nokogiri/xml/attr.rb +14 -0
- data/lib/nokogiri/xml/attribute_decl.rb +18 -0
- data/lib/nokogiri/xml/builder.rb +418 -0
- data/lib/nokogiri/xml/cdata.rb +11 -0
- data/lib/nokogiri/xml/character_data.rb +7 -0
- data/lib/nokogiri/xml/document.rb +194 -0
- data/lib/nokogiri/xml/document_fragment.rb +77 -0
- data/lib/nokogiri/xml/dtd.rb +11 -0
- data/lib/nokogiri/xml/element_content.rb +36 -0
- data/lib/nokogiri/xml/element_decl.rb +13 -0
- data/lib/nokogiri/xml/entity_decl.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +13 -0
- data/lib/nokogiri/xml/node.rb +793 -0
- data/lib/nokogiri/xml/node/save_options.rb +42 -0
- data/lib/nokogiri/xml/node_set.rb +325 -0
- data/lib/nokogiri/xml/notation.rb +6 -0
- data/lib/nokogiri/xml/parse_options.rb +85 -0
- data/lib/nokogiri/xml/pp.rb +2 -0
- data/lib/nokogiri/xml/pp/character_data.rb +18 -0
- data/lib/nokogiri/xml/pp/node.rb +56 -0
- data/lib/nokogiri/xml/processing_instruction.rb +8 -0
- data/lib/nokogiri/xml/reader.rb +74 -0
- data/lib/nokogiri/xml/relax_ng.rb +32 -0
- data/lib/nokogiri/xml/sax.rb +4 -0
- data/lib/nokogiri/xml/sax/document.rb +160 -0
- data/lib/nokogiri/xml/sax/parser.rb +115 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +60 -0
- data/lib/nokogiri/xml/schema.rb +57 -0
- data/lib/nokogiri/xml/syntax_error.rb +47 -0
- data/lib/nokogiri/xml/text.rb +9 -0
- data/lib/nokogiri/xml/xpath.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +11 -0
- data/lib/nokogiri/xml/xpath_context.rb +16 -0
- data/lib/nokogiri/xslt.rb +48 -0
- data/lib/nokogiri/xslt/stylesheet.rb +25 -0
- data/lib/xsd/xmlparser/nokogiri.rb +90 -0
- data/tasks/cross_compile.rb +158 -0
- data/tasks/test.rb +94 -0
- data/test/css/test_nthiness.rb +159 -0
- data/test/css/test_parser.rb +282 -0
- data/test/css/test_tokenizer.rb +190 -0
- data/test/css/test_xpath_visitor.rb +85 -0
- data/test/ffi/test_document.rb +35 -0
- data/test/files/2ch.html +108 -0
- data/test/files/address_book.rlx +12 -0
- data/test/files/address_book.xml +10 -0
- data/test/files/bar/bar.xsd +4 -0
- data/test/files/dont_hurt_em_why.xml +422 -0
- data/test/files/exslt.xml +8 -0
- data/test/files/exslt.xslt +35 -0
- data/test/files/foo/foo.xsd +4 -0
- data/test/files/po.xml +32 -0
- data/test/files/po.xsd +66 -0
- data/test/files/shift_jis.html +10 -0
- data/test/files/shift_jis.xml +5 -0
- data/test/files/snuggles.xml +3 -0
- data/test/files/staff.dtd +10 -0
- data/test/files/staff.xml +59 -0
- data/test/files/staff.xslt +32 -0
- data/test/files/tlm.html +850 -0
- data/test/files/valid_bar.xml +2 -0
- data/test/helper.rb +169 -0
- data/test/html/sax/test_parser.rb +74 -0
- data/test/html/sax/test_parser_context.rb +48 -0
- data/test/html/test_builder.rb +164 -0
- data/test/html/test_document.rb +398 -0
- data/test/html/test_document_encoding.rb +77 -0
- data/test/html/test_document_fragment.rb +182 -0
- data/test/html/test_element_description.rb +98 -0
- data/test/html/test_named_characters.rb +14 -0
- data/test/html/test_node.rb +181 -0
- data/test/html/test_node_encoding.rb +27 -0
- data/test/test_convert_xpath.rb +135 -0
- data/test/test_css_cache.rb +45 -0
- data/test/test_encoding_handler.rb +46 -0
- data/test/test_memory_leak.rb +87 -0
- data/test/test_nokogiri.rb +138 -0
- data/test/test_reader.rb +386 -0
- data/test/test_soap4r_sax.rb +52 -0
- data/test/test_xslt_transforms.rb +188 -0
- data/test/xml/node/test_save_options.rb +20 -0
- data/test/xml/node/test_subclass.rb +44 -0
- data/test/xml/sax/test_parser.rb +307 -0
- data/test/xml/sax/test_parser_context.rb +63 -0
- data/test/xml/sax/test_push_parser.rb +139 -0
- data/test/xml/test_attr.rb +38 -0
- data/test/xml/test_attribute_decl.rb +82 -0
- data/test/xml/test_builder.rb +210 -0
- data/test/xml/test_cdata.rb +50 -0
- data/test/xml/test_comment.rb +29 -0
- data/test/xml/test_document.rb +668 -0
- data/test/xml/test_document_encoding.rb +26 -0
- data/test/xml/test_document_fragment.rb +180 -0
- data/test/xml/test_dtd.rb +82 -0
- data/test/xml/test_dtd_encoding.rb +33 -0
- data/test/xml/test_element_content.rb +56 -0
- data/test/xml/test_element_decl.rb +73 -0
- data/test/xml/test_entity_decl.rb +120 -0
- data/test/xml/test_entity_reference.rb +21 -0
- data/test/xml/test_namespace.rb +68 -0
- data/test/xml/test_node.rb +865 -0
- data/test/xml/test_node_attributes.rb +34 -0
- data/test/xml/test_node_encoding.rb +107 -0
- data/test/xml/test_node_reparenting.rb +293 -0
- data/test/xml/test_node_set.rb +649 -0
- data/test/xml/test_parse_options.rb +52 -0
- data/test/xml/test_processing_instruction.rb +30 -0
- data/test/xml/test_reader_encoding.rb +126 -0
- data/test/xml/test_relax_ng.rb +60 -0
- data/test/xml/test_schema.rb +89 -0
- data/test/xml/test_syntax_error.rb +12 -0
- data/test/xml/test_text.rb +38 -0
- data/test/xml/test_unparented_node.rb +381 -0
- data/test/xml/test_xpath.rb +138 -0
- metadata +533 -0
data/lib/nokogiri.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Modify the PATH on windows so that the external DLLs will get loaded.
|
3
|
+
|
4
|
+
require 'rbconfig'
|
5
|
+
ENV['PATH'] = [File.expand_path(
|
6
|
+
File.join(File.dirname(__FILE__), "..", "ext", "nokogiri")
|
7
|
+
), ENV['PATH']].compact.join(';') if RbConfig::CONFIG['host_os'] =~ /(mswin|mingw)/i
|
8
|
+
|
9
|
+
if ENV['NOKOGIRI_FFI'] || RUBY_PLATFORM =~ /java/
|
10
|
+
require 'ffi'
|
11
|
+
require 'nokogiri/ffi/libxml'
|
12
|
+
else
|
13
|
+
require 'nokogiri/nokogiri'
|
14
|
+
end
|
15
|
+
|
16
|
+
warn(<<-eowarn) if '1.8.6' == RUBY_VERSION && $VERBOSE
|
17
|
+
!!! DEPRECATION WARNING !!!
|
18
|
+
Hey Champ! I see you're using Ruby 1.8.6! While I applaud you for sticking to
|
19
|
+
your guns and using The One True Ruby, I have to let you know that we're going
|
20
|
+
to stop supporting 1.8.6. I know, it's sad. But, we just don't have time to
|
21
|
+
support every version of Ruby out there. Whether we like it or not, time moves
|
22
|
+
forward and so does our software.
|
23
|
+
|
24
|
+
On August 1, 2010, we will no longer support Ruby 1.8.6. If nokogiri happens to
|
25
|
+
work on 1.8.6 after that date, then great! We will hownever, no longer test,
|
26
|
+
use, or endorse 1.8.6 as a supported platform.
|
27
|
+
|
28
|
+
Thanks,
|
29
|
+
|
30
|
+
Team Nokogiri
|
31
|
+
eowarn
|
32
|
+
|
33
|
+
require 'nokogiri/version'
|
34
|
+
require 'nokogiri/version_warning'
|
35
|
+
require 'nokogiri/syntax_error'
|
36
|
+
require 'nokogiri/xml'
|
37
|
+
require 'nokogiri/xslt'
|
38
|
+
require 'nokogiri/html'
|
39
|
+
require 'nokogiri/decorators/slop'
|
40
|
+
require 'nokogiri/css'
|
41
|
+
require 'nokogiri/html/builder'
|
42
|
+
|
43
|
+
# Nokogiri parses and searches XML/HTML very quickly, and also has
|
44
|
+
# correctly implemented CSS3 selector support as well as XPath support.
|
45
|
+
#
|
46
|
+
# Parsing a document returns either a Nokogiri::XML::Document, or a
|
47
|
+
# Nokogiri::HTML::Document depending on the kind of document you parse.
|
48
|
+
#
|
49
|
+
# Here is an example:
|
50
|
+
#
|
51
|
+
# require 'nokogiri'
|
52
|
+
# require 'open-uri'
|
53
|
+
#
|
54
|
+
# # Get a Nokogiri::HTML:Document for the page we’re interested in...
|
55
|
+
#
|
56
|
+
# doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
|
57
|
+
#
|
58
|
+
# # Do funky things with it using Nokogiri::XML::Node methods...
|
59
|
+
#
|
60
|
+
# ####
|
61
|
+
# # Search for nodes by css
|
62
|
+
# doc.css('h3.r a.l').each do |link|
|
63
|
+
# puts link.content
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# See Nokogiri::XML::Node#css for more information about CSS searching.
|
67
|
+
# See Nokogiri::XML::Node#xpath for more information about XPath searching.
|
68
|
+
module Nokogiri
|
69
|
+
class << self
|
70
|
+
###
|
71
|
+
# Parse an HTML or XML document. +string+ contains the document.
|
72
|
+
def parse string, url = nil, encoding = nil, options = nil
|
73
|
+
doc =
|
74
|
+
if string.respond_to?(:read) ||
|
75
|
+
string =~ /^\s*<[^Hh>]*html/i # Probably html
|
76
|
+
Nokogiri::HTML(
|
77
|
+
string,
|
78
|
+
url,
|
79
|
+
encoding, options || XML::ParseOptions::DEFAULT_HTML
|
80
|
+
)
|
81
|
+
else
|
82
|
+
Nokogiri::XML(string, url, encoding,
|
83
|
+
options || XML::ParseOptions::DEFAULT_XML)
|
84
|
+
end
|
85
|
+
yield doc if block_given?
|
86
|
+
doc
|
87
|
+
end
|
88
|
+
|
89
|
+
###
|
90
|
+
# Create a new Nokogiri::XML::DocumentFragment
|
91
|
+
def make input = nil, opts = {}, &blk
|
92
|
+
if input
|
93
|
+
Nokogiri::HTML.fragment(input).children.first
|
94
|
+
else
|
95
|
+
Nokogiri(&blk)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
###
|
100
|
+
# Parse a document and add the Slop decorator. The Slop decorator
|
101
|
+
# implements method_missing such that methods may be used instead of CSS
|
102
|
+
# or XPath. For example:
|
103
|
+
#
|
104
|
+
# doc = Nokogiri::Slop(<<-eohtml)
|
105
|
+
# <html>
|
106
|
+
# <body>
|
107
|
+
# <p>first</p>
|
108
|
+
# <p>second</p>
|
109
|
+
# </body>
|
110
|
+
# </html>
|
111
|
+
# eohtml
|
112
|
+
# assert_equal('second', doc.html.body.p[1].text)
|
113
|
+
#
|
114
|
+
def Slop(*args, &block)
|
115
|
+
Nokogiri(*args, &block).slop!
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
###
|
121
|
+
# Parser a document contained in +args+. Nokogiri will try to guess what
|
122
|
+
# type of document you are attempting to parse. For more information, see
|
123
|
+
# Nokogiri.parse
|
124
|
+
#
|
125
|
+
# To specify the type of document, use Nokogiri.XML or Nokogiri.HTML.
|
126
|
+
def Nokogiri(*args, &block)
|
127
|
+
if block_given?
|
128
|
+
builder = Nokogiri::HTML::Builder.new(&block)
|
129
|
+
return builder.doc.root
|
130
|
+
else
|
131
|
+
Nokogiri.parse(*args)
|
132
|
+
end
|
133
|
+
end
|
data/lib/nokogiri/css.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'nokogiri/css/node'
|
2
|
+
require 'nokogiri/css/xpath_visitor'
|
3
|
+
require 'nokogiri/css/generated_parser'
|
4
|
+
require 'nokogiri/css/generated_tokenizer'
|
5
|
+
require 'nokogiri/css/tokenizer'
|
6
|
+
require 'nokogiri/css/parser'
|
7
|
+
require 'nokogiri/css/syntax_error'
|
8
|
+
|
9
|
+
module Nokogiri
|
10
|
+
module CSS
|
11
|
+
class << self
|
12
|
+
###
|
13
|
+
# Parse this CSS selector in +selector+. Returns an AST.
|
14
|
+
def parse selector
|
15
|
+
Parser.new.parse selector
|
16
|
+
end
|
17
|
+
|
18
|
+
###
|
19
|
+
# Get the XPath for +selector+.
|
20
|
+
def xpath_for selector, options={}
|
21
|
+
Parser.new(options[:ns] || {}).xpath_for selector, options
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,669 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.6
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
|
10
|
+
module Nokogiri
|
11
|
+
module CSS
|
12
|
+
class GeneratedParser < Racc::Parser
|
13
|
+
##### State transition tables begin ###
|
14
|
+
|
15
|
+
racc_action_table = [
|
16
|
+
3, 55, 26, 21, 12, 24, 56, 3, 81, 1,
|
17
|
+
41, 12, 41, 56, 3, 23, 1, 80, 12, 18,
|
18
|
+
92, 91, 4, 1, 9, 10, 18, 13, 16, 4,
|
19
|
+
12, 9, 10, 18, 13, 16, 4, 12, 9, 10,
|
20
|
+
3, 13, 16, 73, 12, 12, 60, 61, 4, 1,
|
21
|
+
57, 10, 12, 44, 16, 4, 61, 1, 10, 18,
|
22
|
+
41, 16, 4, 4, 9, 10, 10, 13, 16, 16,
|
23
|
+
4, 3, 58, 10, 3, 13, 16, 57, 12, 12,
|
24
|
+
27, 82, 28, 48, 26, 51, 12, 53, 26, 51,
|
25
|
+
18, 53, 83, 18, 4, 9, 4, 4, 9, 10,
|
26
|
+
10, 63, 16, 16, 4, 66, 68, 10, 26, 51,
|
27
|
+
16, 53, 86, 87, 66, 68, 67, 69, 70, 62,
|
28
|
+
72, 59, 90, 54, 64, 67, 69, 70, 93, 72,
|
29
|
+
32, 34, 36, 64, 26, 51, -22, 53, 95, 96,
|
30
|
+
31, nil, 33, 35 ]
|
31
|
+
|
32
|
+
racc_action_check = [
|
33
|
+
0, 20, 3, 3, 0, 3, 43, 30, 52, 0,
|
34
|
+
39, 30, 11, 20, 56, 3, 30, 43, 56, 0,
|
35
|
+
71, 71, 0, 56, 0, 0, 30, 0, 0, 30,
|
36
|
+
8, 30, 30, 56, 30, 30, 56, 6, 56, 56,
|
37
|
+
9, 56, 56, 28, 9, 7, 24, 24, 8, 9,
|
38
|
+
51, 8, 41, 10, 8, 6, 53, 41, 6, 9,
|
39
|
+
7, 6, 9, 7, 9, 9, 7, 9, 9, 7,
|
40
|
+
41, 4, 21, 41, 16, 41, 41, 21, 15, 17,
|
41
|
+
4, 54, 4, 16, 63, 63, 77, 63, 61, 61,
|
42
|
+
4, 61, 55, 16, 14, 4, 15, 17, 16, 15,
|
43
|
+
17, 26, 15, 17, 77, 29, 29, 77, 57, 57,
|
44
|
+
77, 57, 58, 60, 27, 27, 29, 29, 29, 25,
|
45
|
+
29, 22, 65, 19, 29, 27, 27, 27, 74, 27,
|
46
|
+
5, 5, 5, 27, 18, 18, 1, 18, 79, 87,
|
47
|
+
5, nil, 5, 5 ]
|
48
|
+
|
49
|
+
racc_action_pointer = [
|
50
|
+
-2, 108, nil, -8, 69, 123, 31, 39, 24, 38,
|
51
|
+
42, -9, nil, nil, 70, 72, 72, 73, 124, 95,
|
52
|
+
1, 65, 98, nil, 35, 96, 89, 111, 18, 102,
|
53
|
+
5, nil, nil, nil, nil, nil, nil, nil, nil, -11,
|
54
|
+
nil, 46, nil, -6, nil, nil, nil, nil, nil, nil,
|
55
|
+
nil, 38, -15, 44, 70, 92, 12, 98, 99, nil,
|
56
|
+
106, 78, nil, 74, nil, 97, nil, nil, nil, nil,
|
57
|
+
nil, 10, nil, nil, 103, nil, nil, 80, nil, 115,
|
58
|
+
nil, nil, nil, nil, nil, nil, nil, 126, nil, nil,
|
59
|
+
nil, nil, nil, nil, nil, nil, nil ]
|
60
|
+
|
61
|
+
racc_action_default = [
|
62
|
+
-23, -20, -2, -68, -68, -17, -52, -44, -49, -23,
|
63
|
+
-68, -15, -53, -21, -12, -51, -68, -50, -68, -68,
|
64
|
+
-68, -37, -68, -27, -35, -68, -36, -56, -68, -56,
|
65
|
+
-23, -5, -3, -8, -4, -7, -6, -48, -9, -43,
|
66
|
+
-11, -23, -45, -68, -18, -14, -13, -47, -42, -41,
|
67
|
+
-46, -37, -68, -35, -68, -68, -23, -68, -68, -28,
|
68
|
+
-40, -68, -29, -68, -57, -68, -62, -58, -63, -59,
|
69
|
+
-60, -68, -61, -26, -68, -16, -10, -65, -67, -68,
|
70
|
+
-31, -30, -19, 97, -1, -34, -39, -68, -32, -33,
|
71
|
+
-24, -54, -55, -25, -66, -64, -38 ]
|
72
|
+
|
73
|
+
racc_goto_table = [
|
74
|
+
37, 39, 42, 22, 40, 75, 20, 29, 45, 47,
|
75
|
+
65, 50, 74, 38, 46, 43, 77, 30, 52, 49,
|
76
|
+
25, 79, nil, nil, nil, nil, nil, nil, nil, nil,
|
77
|
+
nil, 84, nil, nil, nil, 78, 76, nil, nil, nil,
|
78
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
79
|
+
nil, nil, nil, nil, nil, nil, nil, 85, nil, nil,
|
80
|
+
nil, 88, nil, 89, nil, nil, nil, nil, nil, nil,
|
81
|
+
nil, 94 ]
|
82
|
+
|
83
|
+
racc_goto_check = [
|
84
|
+
7, 7, 7, 14, 8, 2, 1, 9, 8, 7,
|
85
|
+
13, 7, 13, 6, 10, 1, 5, 3, 14, 9,
|
86
|
+
15, 19, nil, nil, nil, nil, nil, nil, nil, nil,
|
87
|
+
nil, 2, nil, nil, nil, 7, 8, nil, nil, nil,
|
88
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
89
|
+
nil, nil, nil, nil, nil, nil, nil, 14, nil, nil,
|
90
|
+
nil, 14, nil, 14, nil, nil, nil, nil, nil, nil,
|
91
|
+
nil, 7 ]
|
92
|
+
|
93
|
+
racc_goto_pointer = [
|
94
|
+
nil, 6, -25, 12, nil, -25, 6, -6, -3, 3,
|
95
|
+
0, nil, nil, -17, 0, 17, nil, nil, nil, -20 ]
|
96
|
+
|
97
|
+
racc_goto_default = [
|
98
|
+
nil, nil, 2, nil, 5, 7, nil, 11, nil, 14,
|
99
|
+
15, 17, 19, nil, nil, nil, 6, 8, 71, nil ]
|
100
|
+
|
101
|
+
racc_reduce_table = [
|
102
|
+
0, 0, :racc_error,
|
103
|
+
3, 32, :_reduce_1,
|
104
|
+
1, 32, :_reduce_2,
|
105
|
+
1, 34, :_reduce_3,
|
106
|
+
1, 34, :_reduce_4,
|
107
|
+
1, 34, :_reduce_5,
|
108
|
+
1, 34, :_reduce_6,
|
109
|
+
1, 34, :_reduce_7,
|
110
|
+
1, 34, :_reduce_8,
|
111
|
+
2, 35, :_reduce_9,
|
112
|
+
3, 35, :_reduce_10,
|
113
|
+
2, 35, :_reduce_11,
|
114
|
+
1, 35, :_reduce_none,
|
115
|
+
2, 35, :_reduce_13,
|
116
|
+
2, 35, :_reduce_14,
|
117
|
+
1, 35, :_reduce_15,
|
118
|
+
3, 33, :_reduce_16,
|
119
|
+
1, 33, :_reduce_none,
|
120
|
+
2, 42, :_reduce_18,
|
121
|
+
3, 36, :_reduce_19,
|
122
|
+
1, 36, :_reduce_20,
|
123
|
+
1, 36, :_reduce_21,
|
124
|
+
1, 43, :_reduce_22,
|
125
|
+
0, 43, :_reduce_none,
|
126
|
+
4, 41, :_reduce_24,
|
127
|
+
4, 41, :_reduce_25,
|
128
|
+
3, 41, :_reduce_26,
|
129
|
+
2, 40, :_reduce_27,
|
130
|
+
3, 40, :_reduce_28,
|
131
|
+
3, 40, :_reduce_29,
|
132
|
+
3, 40, :_reduce_30,
|
133
|
+
3, 40, :_reduce_31,
|
134
|
+
3, 45, :_reduce_32,
|
135
|
+
3, 45, :_reduce_33,
|
136
|
+
3, 45, :_reduce_34,
|
137
|
+
1, 45, :_reduce_none,
|
138
|
+
1, 45, :_reduce_none,
|
139
|
+
1, 45, :_reduce_37,
|
140
|
+
4, 46, :_reduce_38,
|
141
|
+
3, 46, :_reduce_39,
|
142
|
+
2, 46, :_reduce_40,
|
143
|
+
2, 47, :_reduce_41,
|
144
|
+
2, 47, :_reduce_42,
|
145
|
+
1, 37, :_reduce_none,
|
146
|
+
0, 37, :_reduce_none,
|
147
|
+
2, 38, :_reduce_45,
|
148
|
+
2, 38, :_reduce_46,
|
149
|
+
2, 38, :_reduce_47,
|
150
|
+
2, 38, :_reduce_48,
|
151
|
+
1, 38, :_reduce_none,
|
152
|
+
1, 38, :_reduce_none,
|
153
|
+
1, 38, :_reduce_none,
|
154
|
+
1, 38, :_reduce_none,
|
155
|
+
1, 48, :_reduce_53,
|
156
|
+
2, 44, :_reduce_54,
|
157
|
+
2, 44, :_reduce_55,
|
158
|
+
0, 44, :_reduce_none,
|
159
|
+
1, 49, :_reduce_57,
|
160
|
+
1, 49, :_reduce_58,
|
161
|
+
1, 49, :_reduce_59,
|
162
|
+
1, 49, :_reduce_60,
|
163
|
+
1, 49, :_reduce_61,
|
164
|
+
1, 49, :_reduce_62,
|
165
|
+
1, 49, :_reduce_63,
|
166
|
+
3, 39, :_reduce_64,
|
167
|
+
1, 50, :_reduce_none,
|
168
|
+
2, 50, :_reduce_none,
|
169
|
+
1, 50, :_reduce_none ]
|
170
|
+
|
171
|
+
racc_reduce_n = 68
|
172
|
+
|
173
|
+
racc_shift_n = 97
|
174
|
+
|
175
|
+
racc_token_table = {
|
176
|
+
false => 0,
|
177
|
+
:error => 1,
|
178
|
+
:FUNCTION => 2,
|
179
|
+
:INCLUDES => 3,
|
180
|
+
:DASHMATCH => 4,
|
181
|
+
:LBRACE => 5,
|
182
|
+
:HASH => 6,
|
183
|
+
:PLUS => 7,
|
184
|
+
:GREATER => 8,
|
185
|
+
:S => 9,
|
186
|
+
:STRING => 10,
|
187
|
+
:IDENT => 11,
|
188
|
+
:COMMA => 12,
|
189
|
+
:NUMBER => 13,
|
190
|
+
:PREFIXMATCH => 14,
|
191
|
+
:SUFFIXMATCH => 15,
|
192
|
+
:SUBSTRINGMATCH => 16,
|
193
|
+
:TILDE => 17,
|
194
|
+
:NOT_EQUAL => 18,
|
195
|
+
:SLASH => 19,
|
196
|
+
:DOUBLESLASH => 20,
|
197
|
+
:NOT => 21,
|
198
|
+
:EQUAL => 22,
|
199
|
+
:RPAREN => 23,
|
200
|
+
:LSQUARE => 24,
|
201
|
+
:RSQUARE => 25,
|
202
|
+
:HAS => 26,
|
203
|
+
"." => 27,
|
204
|
+
"|" => 28,
|
205
|
+
"*" => 29,
|
206
|
+
":" => 30 }
|
207
|
+
|
208
|
+
racc_nt_base = 31
|
209
|
+
|
210
|
+
racc_use_result_var = true
|
211
|
+
|
212
|
+
Racc_arg = [
|
213
|
+
racc_action_table,
|
214
|
+
racc_action_check,
|
215
|
+
racc_action_default,
|
216
|
+
racc_action_pointer,
|
217
|
+
racc_goto_table,
|
218
|
+
racc_goto_check,
|
219
|
+
racc_goto_default,
|
220
|
+
racc_goto_pointer,
|
221
|
+
racc_nt_base,
|
222
|
+
racc_reduce_table,
|
223
|
+
racc_token_table,
|
224
|
+
racc_shift_n,
|
225
|
+
racc_reduce_n,
|
226
|
+
racc_use_result_var ]
|
227
|
+
|
228
|
+
Racc_token_to_s_table = [
|
229
|
+
"$end",
|
230
|
+
"error",
|
231
|
+
"FUNCTION",
|
232
|
+
"INCLUDES",
|
233
|
+
"DASHMATCH",
|
234
|
+
"LBRACE",
|
235
|
+
"HASH",
|
236
|
+
"PLUS",
|
237
|
+
"GREATER",
|
238
|
+
"S",
|
239
|
+
"STRING",
|
240
|
+
"IDENT",
|
241
|
+
"COMMA",
|
242
|
+
"NUMBER",
|
243
|
+
"PREFIXMATCH",
|
244
|
+
"SUFFIXMATCH",
|
245
|
+
"SUBSTRINGMATCH",
|
246
|
+
"TILDE",
|
247
|
+
"NOT_EQUAL",
|
248
|
+
"SLASH",
|
249
|
+
"DOUBLESLASH",
|
250
|
+
"NOT",
|
251
|
+
"EQUAL",
|
252
|
+
"RPAREN",
|
253
|
+
"LSQUARE",
|
254
|
+
"RSQUARE",
|
255
|
+
"HAS",
|
256
|
+
"\".\"",
|
257
|
+
"\"|\"",
|
258
|
+
"\"*\"",
|
259
|
+
"\":\"",
|
260
|
+
"$start",
|
261
|
+
"selector",
|
262
|
+
"simple_selector_1toN",
|
263
|
+
"combinator",
|
264
|
+
"simple_selector",
|
265
|
+
"element_name",
|
266
|
+
"hcap_0toN",
|
267
|
+
"hcap_1toN",
|
268
|
+
"negation",
|
269
|
+
"function",
|
270
|
+
"attrib",
|
271
|
+
"class",
|
272
|
+
"namespace",
|
273
|
+
"attrib_val_0or1",
|
274
|
+
"expr",
|
275
|
+
"an_plus_b",
|
276
|
+
"pseudo",
|
277
|
+
"attribute_id",
|
278
|
+
"eql_incl_dash",
|
279
|
+
"negation_arg" ]
|
280
|
+
|
281
|
+
Racc_debug_parser = false
|
282
|
+
|
283
|
+
##### State transition tables end #####
|
284
|
+
|
285
|
+
# reduce 0 omitted
|
286
|
+
|
287
|
+
def _reduce_1(val, _values, result)
|
288
|
+
result = [val.first, val.last].flatten
|
289
|
+
|
290
|
+
result
|
291
|
+
end
|
292
|
+
|
293
|
+
def _reduce_2(val, _values, result)
|
294
|
+
result = val.flatten
|
295
|
+
result
|
296
|
+
end
|
297
|
+
|
298
|
+
def _reduce_3(val, _values, result)
|
299
|
+
result = :DIRECT_ADJACENT_SELECTOR
|
300
|
+
result
|
301
|
+
end
|
302
|
+
|
303
|
+
def _reduce_4(val, _values, result)
|
304
|
+
result = :CHILD_SELECTOR
|
305
|
+
result
|
306
|
+
end
|
307
|
+
|
308
|
+
def _reduce_5(val, _values, result)
|
309
|
+
result = :PRECEDING_SELECTOR
|
310
|
+
result
|
311
|
+
end
|
312
|
+
|
313
|
+
def _reduce_6(val, _values, result)
|
314
|
+
result = :DESCENDANT_SELECTOR
|
315
|
+
result
|
316
|
+
end
|
317
|
+
|
318
|
+
def _reduce_7(val, _values, result)
|
319
|
+
result = :DESCENDANT_SELECTOR
|
320
|
+
result
|
321
|
+
end
|
322
|
+
|
323
|
+
def _reduce_8(val, _values, result)
|
324
|
+
result = :CHILD_SELECTOR
|
325
|
+
result
|
326
|
+
end
|
327
|
+
|
328
|
+
def _reduce_9(val, _values, result)
|
329
|
+
result = if val[1].nil?
|
330
|
+
val.first
|
331
|
+
else
|
332
|
+
Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
|
333
|
+
end
|
334
|
+
|
335
|
+
result
|
336
|
+
end
|
337
|
+
|
338
|
+
def _reduce_10(val, _values, result)
|
339
|
+
result = Node.new(:CONDITIONAL_SELECTOR,
|
340
|
+
[
|
341
|
+
val.first,
|
342
|
+
Node.new(:COMBINATOR, [val[1], val.last])
|
343
|
+
]
|
344
|
+
)
|
345
|
+
|
346
|
+
result
|
347
|
+
end
|
348
|
+
|
349
|
+
def _reduce_11(val, _values, result)
|
350
|
+
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
351
|
+
|
352
|
+
result
|
353
|
+
end
|
354
|
+
|
355
|
+
# reduce 12 omitted
|
356
|
+
|
357
|
+
def _reduce_13(val, _values, result)
|
358
|
+
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
359
|
+
|
360
|
+
result
|
361
|
+
end
|
362
|
+
|
363
|
+
def _reduce_14(val, _values, result)
|
364
|
+
result = Node.new(:CONDITIONAL_SELECTOR,
|
365
|
+
[
|
366
|
+
Node.new(:ELEMENT_NAME, ['*']),
|
367
|
+
Node.new(:COMBINATOR, val)
|
368
|
+
]
|
369
|
+
)
|
370
|
+
|
371
|
+
result
|
372
|
+
end
|
373
|
+
|
374
|
+
def _reduce_15(val, _values, result)
|
375
|
+
result = Node.new(:CONDITIONAL_SELECTOR,
|
376
|
+
[Node.new(:ELEMENT_NAME, ['*']), val.first]
|
377
|
+
)
|
378
|
+
|
379
|
+
result
|
380
|
+
end
|
381
|
+
|
382
|
+
def _reduce_16(val, _values, result)
|
383
|
+
result = Node.new(val[1], [val.first, val.last])
|
384
|
+
|
385
|
+
result
|
386
|
+
end
|
387
|
+
|
388
|
+
# reduce 17 omitted
|
389
|
+
|
390
|
+
def _reduce_18(val, _values, result)
|
391
|
+
result = Node.new(:CLASS_CONDITION, [val[1]])
|
392
|
+
result
|
393
|
+
end
|
394
|
+
|
395
|
+
def _reduce_19(val, _values, result)
|
396
|
+
result = Node.new(:ELEMENT_NAME,
|
397
|
+
[[val.first, val.last].compact.join(':')]
|
398
|
+
)
|
399
|
+
|
400
|
+
result
|
401
|
+
end
|
402
|
+
|
403
|
+
def _reduce_20(val, _values, result)
|
404
|
+
name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
|
405
|
+
result = Node.new(:ELEMENT_NAME, [name])
|
406
|
+
|
407
|
+
result
|
408
|
+
end
|
409
|
+
|
410
|
+
def _reduce_21(val, _values, result)
|
411
|
+
result = Node.new(:ELEMENT_NAME, val)
|
412
|
+
result
|
413
|
+
end
|
414
|
+
|
415
|
+
def _reduce_22(val, _values, result)
|
416
|
+
result = val[0]
|
417
|
+
result
|
418
|
+
end
|
419
|
+
|
420
|
+
# reduce 23 omitted
|
421
|
+
|
422
|
+
def _reduce_24(val, _values, result)
|
423
|
+
result = Node.new(:ATTRIBUTE_CONDITION,
|
424
|
+
[Node.new(:ELEMENT_NAME, [val[1]])] + (val[2] || [])
|
425
|
+
)
|
426
|
+
|
427
|
+
result
|
428
|
+
end
|
429
|
+
|
430
|
+
def _reduce_25(val, _values, result)
|
431
|
+
result = Node.new(:ATTRIBUTE_CONDITION,
|
432
|
+
[val[1]] + (val[2] || [])
|
433
|
+
)
|
434
|
+
|
435
|
+
result
|
436
|
+
end
|
437
|
+
|
438
|
+
def _reduce_26(val, _values, result)
|
439
|
+
# Non standard, but hpricot supports it.
|
440
|
+
result = Node.new(:PSEUDO_CLASS,
|
441
|
+
[Node.new(:FUNCTION, ['nth-child(', val[1]])]
|
442
|
+
)
|
443
|
+
|
444
|
+
result
|
445
|
+
end
|
446
|
+
|
447
|
+
def _reduce_27(val, _values, result)
|
448
|
+
result = Node.new(:FUNCTION, [val.first.strip])
|
449
|
+
|
450
|
+
result
|
451
|
+
end
|
452
|
+
|
453
|
+
def _reduce_28(val, _values, result)
|
454
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
455
|
+
|
456
|
+
result
|
457
|
+
end
|
458
|
+
|
459
|
+
def _reduce_29(val, _values, result)
|
460
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
461
|
+
|
462
|
+
result
|
463
|
+
end
|
464
|
+
|
465
|
+
def _reduce_30(val, _values, result)
|
466
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
467
|
+
|
468
|
+
result
|
469
|
+
end
|
470
|
+
|
471
|
+
def _reduce_31(val, _values, result)
|
472
|
+
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
473
|
+
|
474
|
+
result
|
475
|
+
end
|
476
|
+
|
477
|
+
def _reduce_32(val, _values, result)
|
478
|
+
result = [val.first, val.last]
|
479
|
+
result
|
480
|
+
end
|
481
|
+
|
482
|
+
def _reduce_33(val, _values, result)
|
483
|
+
result = [val.first, val.last]
|
484
|
+
result
|
485
|
+
end
|
486
|
+
|
487
|
+
def _reduce_34(val, _values, result)
|
488
|
+
result = [val.first, val.last]
|
489
|
+
result
|
490
|
+
end
|
491
|
+
|
492
|
+
# reduce 35 omitted
|
493
|
+
|
494
|
+
# reduce 36 omitted
|
495
|
+
|
496
|
+
def _reduce_37(val, _values, result)
|
497
|
+
if val[0] == 'even'
|
498
|
+
val = ["2","n","+","0"]
|
499
|
+
result = Node.new(:AN_PLUS_B, val)
|
500
|
+
elsif val[0] == 'odd'
|
501
|
+
val = ["2","n","+","1"]
|
502
|
+
result = Node.new(:AN_PLUS_B, val)
|
503
|
+
else
|
504
|
+
# This is not CSS standard. It allows us to support this:
|
505
|
+
# assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
|
506
|
+
# assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
|
507
|
+
# assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
|
508
|
+
result = val
|
509
|
+
end
|
510
|
+
|
511
|
+
result
|
512
|
+
end
|
513
|
+
|
514
|
+
def _reduce_38(val, _values, result)
|
515
|
+
if val[1] == 'n'
|
516
|
+
result = Node.new(:AN_PLUS_B, val)
|
517
|
+
else
|
518
|
+
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
519
|
+
end
|
520
|
+
|
521
|
+
result
|
522
|
+
end
|
523
|
+
|
524
|
+
def _reduce_39(val, _values, result)
|
525
|
+
# n+3, -n+3
|
526
|
+
if val[0] == 'n'
|
527
|
+
val.unshift("1")
|
528
|
+
result = Node.new(:AN_PLUS_B, val)
|
529
|
+
elsif val[0] == '-n'
|
530
|
+
val[0] = 'n'
|
531
|
+
val.unshift("-1")
|
532
|
+
result = Node.new(:AN_PLUS_B, val)
|
533
|
+
else
|
534
|
+
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
535
|
+
end
|
536
|
+
|
537
|
+
result
|
538
|
+
end
|
539
|
+
|
540
|
+
def _reduce_40(val, _values, result)
|
541
|
+
if val[1] == 'n'
|
542
|
+
val << "+"
|
543
|
+
val << "0"
|
544
|
+
result = Node.new(:AN_PLUS_B, val)
|
545
|
+
else
|
546
|
+
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
547
|
+
end
|
548
|
+
|
549
|
+
result
|
550
|
+
end
|
551
|
+
|
552
|
+
def _reduce_41(val, _values, result)
|
553
|
+
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
554
|
+
|
555
|
+
result
|
556
|
+
end
|
557
|
+
|
558
|
+
def _reduce_42(val, _values, result)
|
559
|
+
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
560
|
+
result
|
561
|
+
end
|
562
|
+
|
563
|
+
# reduce 43 omitted
|
564
|
+
|
565
|
+
# reduce 44 omitted
|
566
|
+
|
567
|
+
def _reduce_45(val, _values, result)
|
568
|
+
result = Node.new(:COMBINATOR, val)
|
569
|
+
|
570
|
+
result
|
571
|
+
end
|
572
|
+
|
573
|
+
def _reduce_46(val, _values, result)
|
574
|
+
result = Node.new(:COMBINATOR, val)
|
575
|
+
|
576
|
+
result
|
577
|
+
end
|
578
|
+
|
579
|
+
def _reduce_47(val, _values, result)
|
580
|
+
result = Node.new(:COMBINATOR, val)
|
581
|
+
|
582
|
+
result
|
583
|
+
end
|
584
|
+
|
585
|
+
def _reduce_48(val, _values, result)
|
586
|
+
result = Node.new(:COMBINATOR, val)
|
587
|
+
|
588
|
+
result
|
589
|
+
end
|
590
|
+
|
591
|
+
# reduce 49 omitted
|
592
|
+
|
593
|
+
# reduce 50 omitted
|
594
|
+
|
595
|
+
# reduce 51 omitted
|
596
|
+
|
597
|
+
# reduce 52 omitted
|
598
|
+
|
599
|
+
def _reduce_53(val, _values, result)
|
600
|
+
result = Node.new(:ID, val)
|
601
|
+
result
|
602
|
+
end
|
603
|
+
|
604
|
+
def _reduce_54(val, _values, result)
|
605
|
+
result = [val.first, val[1]]
|
606
|
+
result
|
607
|
+
end
|
608
|
+
|
609
|
+
def _reduce_55(val, _values, result)
|
610
|
+
result = [val.first, val[1]]
|
611
|
+
result
|
612
|
+
end
|
613
|
+
|
614
|
+
# reduce 56 omitted
|
615
|
+
|
616
|
+
def _reduce_57(val, _values, result)
|
617
|
+
result = :equal
|
618
|
+
result
|
619
|
+
end
|
620
|
+
|
621
|
+
def _reduce_58(val, _values, result)
|
622
|
+
result = :prefix_match
|
623
|
+
result
|
624
|
+
end
|
625
|
+
|
626
|
+
def _reduce_59(val, _values, result)
|
627
|
+
result = :suffix_match
|
628
|
+
result
|
629
|
+
end
|
630
|
+
|
631
|
+
def _reduce_60(val, _values, result)
|
632
|
+
result = :substring_match
|
633
|
+
result
|
634
|
+
end
|
635
|
+
|
636
|
+
def _reduce_61(val, _values, result)
|
637
|
+
result = :not_equal
|
638
|
+
result
|
639
|
+
end
|
640
|
+
|
641
|
+
def _reduce_62(val, _values, result)
|
642
|
+
result = :includes
|
643
|
+
result
|
644
|
+
end
|
645
|
+
|
646
|
+
def _reduce_63(val, _values, result)
|
647
|
+
result = :dash_match
|
648
|
+
result
|
649
|
+
end
|
650
|
+
|
651
|
+
def _reduce_64(val, _values, result)
|
652
|
+
result = Node.new(:NOT, [val[1]])
|
653
|
+
|
654
|
+
result
|
655
|
+
end
|
656
|
+
|
657
|
+
# reduce 65 omitted
|
658
|
+
|
659
|
+
# reduce 66 omitted
|
660
|
+
|
661
|
+
# reduce 67 omitted
|
662
|
+
|
663
|
+
def _reduce_none(val, _values, result)
|
664
|
+
val[0]
|
665
|
+
end
|
666
|
+
|
667
|
+
end # class GeneratedParser
|
668
|
+
end # module CSS
|
669
|
+
end # module Nokogiri
|