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