nokogiri 1.5.3.rc3-java → 1.5.3.rc4-java

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.

@@ -255,6 +255,7 @@ public class NokogiriHelpers {
255
255
  * this for us.
256
256
  */
257
257
  public static String rubyStringToString(IRubyObject str) {
258
+ if (str.isNil()) return null;
258
259
  //return rubyStringToString(str.convertToString());
259
260
  return toJavaString(str.convertToString());
260
261
  }
@@ -25,7 +25,7 @@ int io_read_callback(void * ctx, char * buffer, int len) {
25
25
  safe_len = str_len > (size_t)len ? (size_t)len : str_len;
26
26
  memcpy(buffer, StringValuePtr(string), safe_len);
27
27
 
28
- return safe_len;
28
+ return (int)safe_len;
29
29
  }
30
30
 
31
31
  VALUE write_check(VALUE *args) {
@@ -11,13 +11,10 @@ VALUE cNokogiriXmlNamespace ;
11
11
  static VALUE prefix(VALUE self)
12
12
  {
13
13
  xmlNsPtr ns;
14
- xmlDocPtr doc;
15
14
 
16
15
  Data_Get_Struct(self, xmlNs, ns);
17
16
  if(!ns->prefix) return Qnil;
18
17
 
19
- Data_Get_Struct(rb_iv_get(self, "@document"), xmlDoc, doc);
20
-
21
18
  return NOKOGIRI_STR_NEW2(ns->prefix);
22
19
  }
23
20
 
@@ -30,13 +27,10 @@ static VALUE prefix(VALUE self)
30
27
  static VALUE href(VALUE self)
31
28
  {
32
29
  xmlNsPtr ns;
33
- xmlDocPtr doc;
34
30
 
35
31
  Data_Get_Struct(self, xmlNs, ns);
36
32
  if(!ns->href) return Qnil;
37
33
 
38
- Data_Get_Struct(rb_iv_get(self, "@document"), xmlDoc, doc);
39
-
40
34
  return NOKOGIRI_STR_NEW2(ns->href);
41
35
  }
42
36
 
@@ -1,6 +1,8 @@
1
1
  module Nokogiri
2
2
  module CSS
3
3
  class Node
4
+ ALLOW_COMBINATOR_ON_SELF = [:DIRECT_ADJACENT_SELECTOR, :FOLLOWING_SELECTOR, :CHILD_SELECTOR]
5
+
4
6
  # Get the type of this node
5
7
  attr_accessor :type
6
8
  # Get the value of this node
@@ -21,6 +23,7 @@ module Nokogiri
21
23
  # Convert this CSS node to xpath with +prefix+ using +visitor+
22
24
  def to_xpath prefix = '//', visitor = XPathVisitor.new
23
25
  self.preprocess!
26
+ prefix = '.' if ALLOW_COMBINATOR_ON_SELF.include?(type) && value.first.nil?
24
27
  prefix + visitor.accept(self)
25
28
  end
26
29
 
@@ -14,172 +14,180 @@ module Nokogiri
14
14
  ##### State transition tables begin ###
15
15
 
16
16
  racc_action_table = [
17
- 5, 59, 28, 23, 12, 25, 63, 60, 5, 1,
18
- 6, 62, 12, 60, 69, 24, 17, 1, 86, 20,
19
- 98, 97, 6, 12, 9, 10, 14, 20, 17, 70,
20
- 6, 5, 9, 10, 14, 12, 17, -24, 44, 5,
21
- 1, 6, 44, 12, 10, 64, 65, 17, 1, 68,
22
- 20, 5, 67, 6, 62, 9, 10, 14, 20, 17,
23
- 29, 6, 31, 9, 10, 14, 12, 17, 12, 65,
24
- 20, 1, 87, 12, 88, 9, 66, 12, 12, 61,
25
- 28, 56, 12, 57, 6, 91, 6, 10, 14, 10,
26
- 17, 6, 17, 92, 10, 6, 6, 17, 10, 10,
27
- 6, 17, 17, 10, 5, 44, 17, 72, 75, 28,
28
- 56, 46, 57, 52, 28, 56, 95, 57, 73, 76,
29
- 77, 96, 78, 20, 72, 75, 71, 22, 9, 99,
30
- -24, 101, 36, 38, 40, 73, 76, 77, 102, 78,
31
- nil, nil, 35, 71, 37, 39, 28, 56, nil, 57 ]
17
+ 6, 62, 7, 63, 14, 19, 23, 26, 20, 2,
18
+ 71, 14, 6, 63, 85, 17, 14, 22, 25, 28,
19
+ 83, 2, 7, 72, 11, 13, 15, -26, 20, 7,
20
+ 49, 28, 13, 70, 7, 20, 11, 13, 15, 6,
21
+ 20, 64, 65, 14, 19, 23, 26, 64, 2, 36,
22
+ 59, 6, 60, 67, 17, 14, 22, 25, 28, 90,
23
+ 2, 7, 6, 11, 13, 15, 14, 20, 66, 67,
24
+ 28, 2, 91, 7, 14, 11, 13, 15, 14, 20,
25
+ 69, 28, 6, 2, 7, 68, 11, 13, 15, 14,
26
+ 20, 37, 7, 39, 94, 13, 7, 14, 20, 13,
27
+ 15, 28, 20, 6, 49, 14, 11, 7, 36, 59,
28
+ 13, 60, 53, 20, 14, 7, 36, 59, 13, 60,
29
+ 95, 20, 28, 7, 101, 100, 13, 11, 49, 20,
30
+ 74, 76, 7, 36, 31, 13, 33, 50, 20, 74,
31
+ 76, 75, 77, 79, 98, 80, 32, 99, 42, 73,
32
+ 75, 77, 79, 102, 80, 19, 23, 26, 73, 36,
33
+ 59, -26, 60, 104, 105, 17, nil, 22, 25 ]
32
34
 
33
35
  racc_action_check = [
34
- 0, 21, 5, 5, 0, 5, 23, 45, 9, 0,
35
- 15, 23, 9, 21, 30, 5, 15, 9, 45, 0,
36
- 79, 79, 0, 8, 0, 0, 0, 9, 0, 31,
37
- 9, 34, 9, 9, 9, 34, 9, 29, 8, 60,
38
- 34, 8, 42, 60, 8, 25, 25, 8, 60, 28,
39
- 34, 6, 27, 34, 56, 34, 34, 34, 60, 34,
40
- 6, 60, 6, 60, 60, 60, 44, 60, 83, 57,
41
- 6, 44, 58, 19, 59, 6, 26, 18, 13, 22,
42
- 62, 62, 16, 62, 44, 63, 83, 44, 44, 83,
43
- 44, 19, 83, 64, 19, 18, 13, 19, 18, 13,
44
- 16, 18, 13, 16, 17, 11, 16, 32, 32, 20,
45
- 20, 10, 20, 17, 65, 65, 69, 65, 32, 32,
46
- 32, 74, 32, 17, 33, 33, 32, 4, 17, 80,
47
- 1, 85, 7, 7, 7, 33, 33, 33, 92, 33,
48
- nil, nil, 7, 33, 7, 7, 68, 68, nil, 68 ]
36
+ 0, 29, 21, 45, 0, 0, 0, 0, 21, 0,
37
+ 38, 24, 63, 29, 45, 0, 63, 0, 0, 0,
38
+ 42, 63, 0, 39, 0, 0, 0, 37, 0, 24,
39
+ 47, 63, 24, 36, 63, 24, 63, 63, 63, 11,
40
+ 63, 59, 31, 11, 11, 11, 11, 31, 11, 70,
41
+ 70, 9, 70, 60, 11, 9, 11, 11, 11, 61,
42
+ 9, 11, 44, 11, 11, 11, 44, 11, 33, 33,
43
+ 9, 44, 62, 9, 87, 9, 9, 9, 49, 9,
44
+ 35, 44, 7, 49, 44, 34, 44, 44, 44, 12,
45
+ 44, 7, 87, 7, 65, 87, 49, 27, 87, 49,
46
+ 49, 7, 49, 20, 12, 18, 7, 12, 64, 64,
47
+ 12, 64, 20, 12, 1, 27, 28, 28, 27, 28,
48
+ 66, 27, 20, 18, 81, 81, 18, 20, 16, 18,
49
+ 41, 41, 1, 6, 6, 1, 6, 13, 1, 40,
50
+ 40, 41, 41, 41, 71, 41, 6, 78, 8, 41,
51
+ 40, 40, 40, 82, 40, 10, 10, 10, 40, 67,
52
+ 67, 2, 67, 89, 95, 10, nil, 10, 10 ]
49
53
 
50
54
  racc_action_pointer = [
51
- -2, 101, nil, nil, 98, -8, 49, 125, 17, 6,
52
- 100, 84, nil, 72, nil, -14, 76, 102, 71, 67,
53
- 99, 1, 68, -1, nil, 34, 53, 29, 37, 8,
54
- -15, 4, 104, 121, 29, nil, nil, nil, nil, nil,
55
- nil, nil, 21, nil, 60, -5, nil, nil, nil, nil,
56
- nil, nil, nil, nil, nil, nil, 42, 57, 49, 74,
57
- 37, nil, 70, 72, 86, 104, nil, nil, 136, 105,
58
- nil, nil, nil, nil, 96, nil, nil, nil, nil, 10,
59
- 104, nil, nil, 62, nil, 108, nil, nil, nil, nil,
60
- nil, nil, 125, nil, nil, nil, nil, nil, nil, nil,
61
- nil, nil, nil ]
55
+ -2, 108, 132, nil, nil, nil, 123, 80, 119, 49,
56
+ 148, 37, 83, 126, nil, nil, 107, nil, 99, nil,
57
+ 101, -22, nil, nil, 5, nil, nil, 91, 106, 1,
58
+ nil, 35, nil, 57, 62, 57, 21, -2, -19, -2,
59
+ 136, 127, 9, nil, 60, -9, nil, 9, nil, 72,
60
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, 29,
61
+ 41, 36, 72, 10, 98, 81, 113, 149, nil, nil,
62
+ 39, 133, nil, nil, nil, nil, nil, nil, 122, nil,
63
+ nil, 114, 128, nil, nil, nil, nil, 68, nil, 140,
64
+ nil, nil, nil, nil, nil, 151, nil, nil, nil, nil,
65
+ nil, nil, nil, nil, nil, nil ]
62
66
 
63
67
  racc_action_default = [
64
- -25, -23, -20, -2, -72, -72, -25, -18, -48, -25,
65
- -72, -16, -57, -53, -21, -12, -56, -72, -55, -54,
66
- -72, -72, -72, -41, -31, -39, -72, -72, -40, -30,
67
- -72, -72, -60, -60, -25, -5, -3, -8, -4, -7,
68
- -6, -9, -47, -11, -25, -72, -19, -15, -49, -13,
69
- -14, -52, -46, -45, -51, -50, -41, -39, -72, -72,
70
- -25, -22, -72, -72, -44, -72, -32, -33, -72, -72,
71
- -28, -61, -66, -62, -72, -67, -63, -64, -65, -72,
72
- -72, -17, -10, -69, -71, -72, -35, -34, 103, -1,
73
- -38, -43, -72, -36, -37, -29, -26, -58, -59, -27,
74
- -70, -68, -42 ]
68
+ -27, -56, -25, -3, -22, -2, -74, -27, -74, -27,
69
+ -20, -27, -50, -74, -59, -23, -17, -6, -55, -4,
70
+ -74, -13, -9, -5, -58, -8, -7, -57, -74, -74,
71
+ -52, -43, -33, -41, -74, -74, -42, -32, -74, -74,
72
+ -62, -62, -74, -18, -27, -74, -10, -49, -12, -27,
73
+ -21, -16, -51, -48, -47, -14, -15, -54, -53, -43,
74
+ -41, -74, -74, -27, -74, -74, -46, -74, -34, -35,
75
+ -74, -74, -30, -63, -68, -64, -69, -65, -74, -66,
76
+ -67, -74, -74, -24, -19, -37, -11, -71, -73, -74,
77
+ -36, 106, -1, -40, -45, -74, -38, -39, -31, -28,
78
+ -60, -61, -29, -72, -70, -44 ]
75
79
 
76
80
  racc_goto_table = [
77
- 42, 26, 81, 43, 33, 48, 47, 49, 51, 21,
78
- 54, 55, 74, 80, 41, 53, 58, 50, 45, 30,
79
- 32, 83, 34, 27, 85, nil, nil, nil, 89, nil,
80
- nil, nil, nil, nil, nil, nil, 84, 82, nil, nil,
81
+ 30, 43, 34, 48, 29, 41, 55, 51, 78, 82,
82
+ 46, 47, 56, 38, 40, 45, 87, 52, 54, 44,
83
+ 35, 89, nil, 57, 61, nil, 58, nil, nil, nil,
84
+ nil, nil, nil, nil, nil, nil, 84, nil, 86, nil,
85
+ nil, nil, nil, nil, nil, nil, nil, nil, 88, nil,
86
+ nil, nil, nil, nil, nil, 92, nil, nil, nil, nil,
87
+ 93, nil, nil, 96, nil, nil, 97, nil, nil, nil,
81
88
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
82
- nil, nil, nil, nil, nil, nil, nil, nil, 90, nil,
83
- nil, 93, nil, nil, 94, nil, nil, nil, nil, nil,
84
- nil, nil, nil, nil, nil, 100 ]
89
+ nil, nil, nil, nil, nil, nil, 103 ]
85
90
 
86
91
  racc_goto_check = [
87
- 7, 17, 2, 8, 9, 7, 8, 10, 7, 1,
88
- 7, 7, 16, 16, 6, 9, 17, 11, 1, 14,
89
- 15, 5, 3, 18, 21, nil, nil, nil, 2, nil,
90
- nil, nil, nil, nil, nil, nil, 7, 8, nil, nil,
92
+ 8, 2, 18, 9, 1, 10, 11, 9, 17, 17,
93
+ 7, 8, 12, 15, 16, 1, 6, 8, 10, 4,
94
+ 19, 22, nil, 8, 18, nil, 8, nil, nil, nil,
95
+ nil, nil, nil, nil, nil, nil, 2, nil, 9, nil,
96
+ nil, nil, nil, nil, nil, nil, nil, nil, 8, nil,
97
+ nil, nil, nil, nil, nil, 2, nil, nil, nil, nil,
98
+ 18, nil, nil, 18, nil, nil, 18, nil, nil, nil,
91
99
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
92
- nil, nil, nil, nil, nil, nil, nil, nil, 17, nil,
93
- nil, 17, nil, nil, 17, nil, nil, nil, nil, nil,
94
- nil, nil, nil, nil, nil, 7 ]
100
+ nil, nil, nil, nil, nil, nil, 8 ]
95
101
 
96
102
  racc_goto_pointer = [
97
- nil, 9, -32, 15, nil, -23, 6, -8, -5, -2,
98
- -8, 2, nil, nil, 13, 14, -20, -4, 18, nil,
99
- nil, -20 ]
103
+ nil, 4, -8, nil, 9, nil, -33, -2, -1, -9,
104
+ -2, -15, -9, nil, nil, 6, 7, -32, -4, 14,
105
+ nil, nil, -28 ]
100
106
 
101
107
  racc_goto_default = [
102
- nil, nil, 3, nil, 7, 8, nil, 11, nil, 15,
103
- 16, 18, 19, 2, 4, nil, nil, nil, nil, 13,
104
- 79, nil ]
108
+ nil, nil, 3, 5, 9, 10, 12, nil, 16, nil,
109
+ 21, 24, 27, 1, 4, 8, nil, nil, nil, nil,
110
+ 18, 81, nil ]
105
111
 
106
112
  racc_reduce_table = [
107
113
  0, 0, :racc_error,
108
114
  3, 32, :_reduce_1,
109
115
  1, 32, :_reduce_2,
110
- 1, 34, :_reduce_3,
111
- 1, 34, :_reduce_4,
112
- 1, 34, :_reduce_5,
113
- 1, 34, :_reduce_6,
114
- 1, 34, :_reduce_7,
115
- 1, 34, :_reduce_8,
116
- 2, 35, :_reduce_9,
117
- 3, 35, :_reduce_10,
118
- 2, 35, :_reduce_11,
119
- 1, 35, :_reduce_none,
120
- 2, 35, :_reduce_13,
121
- 2, 35, :_reduce_14,
122
- 2, 35, :_reduce_15,
123
- 1, 35, :_reduce_16,
124
- 3, 33, :_reduce_17,
125
- 1, 33, :_reduce_none,
126
- 2, 43, :_reduce_19,
116
+ 1, 32, :_reduce_3,
117
+ 1, 35, :_reduce_4,
118
+ 1, 35, :_reduce_5,
119
+ 1, 35, :_reduce_6,
120
+ 1, 35, :_reduce_7,
121
+ 1, 35, :_reduce_8,
122
+ 1, 35, :_reduce_9,
123
+ 2, 36, :_reduce_10,
124
+ 3, 36, :_reduce_11,
125
+ 2, 36, :_reduce_12,
127
126
  1, 36, :_reduce_none,
128
- 1, 36, :_reduce_21,
129
- 3, 44, :_reduce_22,
130
- 1, 44, :_reduce_23,
131
- 1, 45, :_reduce_24,
132
- 0, 45, :_reduce_none,
133
- 4, 42, :_reduce_26,
134
- 4, 42, :_reduce_27,
135
- 3, 42, :_reduce_28,
136
- 3, 46, :_reduce_29,
137
- 1, 46, :_reduce_30,
138
- 2, 40, :_reduce_31,
139
- 3, 40, :_reduce_32,
140
- 3, 40, :_reduce_33,
141
- 3, 40, :_reduce_34,
142
- 3, 40, :_reduce_35,
143
- 3, 48, :_reduce_36,
144
- 3, 48, :_reduce_37,
145
- 3, 48, :_reduce_38,
146
- 1, 48, :_reduce_none,
147
- 1, 48, :_reduce_none,
148
- 1, 48, :_reduce_41,
149
- 4, 49, :_reduce_42,
150
- 3, 49, :_reduce_43,
151
- 2, 49, :_reduce_44,
152
- 2, 41, :_reduce_45,
153
- 2, 41, :_reduce_46,
127
+ 2, 36, :_reduce_14,
128
+ 2, 36, :_reduce_15,
129
+ 2, 36, :_reduce_16,
130
+ 1, 36, :_reduce_17,
131
+ 2, 34, :_reduce_18,
132
+ 3, 33, :_reduce_19,
133
+ 1, 33, :_reduce_none,
134
+ 2, 44, :_reduce_21,
154
135
  1, 37, :_reduce_none,
155
- 0, 37, :_reduce_none,
156
- 2, 38, :_reduce_49,
157
- 2, 38, :_reduce_50,
158
- 2, 38, :_reduce_51,
159
- 2, 38, :_reduce_52,
160
- 1, 38, :_reduce_none,
161
- 1, 38, :_reduce_none,
136
+ 1, 37, :_reduce_23,
137
+ 3, 45, :_reduce_24,
138
+ 1, 45, :_reduce_25,
139
+ 1, 46, :_reduce_26,
140
+ 0, 46, :_reduce_none,
141
+ 4, 43, :_reduce_28,
142
+ 4, 43, :_reduce_29,
143
+ 3, 43, :_reduce_30,
144
+ 3, 47, :_reduce_31,
145
+ 1, 47, :_reduce_32,
146
+ 2, 41, :_reduce_33,
147
+ 3, 41, :_reduce_34,
148
+ 3, 41, :_reduce_35,
149
+ 3, 41, :_reduce_36,
150
+ 3, 41, :_reduce_37,
151
+ 3, 49, :_reduce_38,
152
+ 3, 49, :_reduce_39,
153
+ 3, 49, :_reduce_40,
154
+ 1, 49, :_reduce_none,
155
+ 1, 49, :_reduce_none,
156
+ 1, 49, :_reduce_43,
157
+ 4, 50, :_reduce_44,
158
+ 3, 50, :_reduce_45,
159
+ 2, 50, :_reduce_46,
160
+ 2, 42, :_reduce_47,
161
+ 2, 42, :_reduce_48,
162
162
  1, 38, :_reduce_none,
163
- 1, 38, :_reduce_none,
164
- 1, 50, :_reduce_57,
165
- 2, 47, :_reduce_58,
166
- 2, 47, :_reduce_59,
167
- 0, 47, :_reduce_none,
168
- 1, 51, :_reduce_61,
169
- 1, 51, :_reduce_62,
170
- 1, 51, :_reduce_63,
171
- 1, 51, :_reduce_64,
172
- 1, 51, :_reduce_65,
173
- 1, 51, :_reduce_66,
174
- 1, 51, :_reduce_67,
175
- 3, 39, :_reduce_68,
176
- 1, 52, :_reduce_none,
177
- 2, 52, :_reduce_none,
178
- 1, 52, :_reduce_none ]
179
-
180
- racc_reduce_n = 72
181
-
182
- racc_shift_n = 103
163
+ 0, 38, :_reduce_none,
164
+ 2, 39, :_reduce_51,
165
+ 2, 39, :_reduce_52,
166
+ 2, 39, :_reduce_53,
167
+ 2, 39, :_reduce_54,
168
+ 1, 39, :_reduce_none,
169
+ 1, 39, :_reduce_none,
170
+ 1, 39, :_reduce_none,
171
+ 1, 39, :_reduce_none,
172
+ 1, 51, :_reduce_59,
173
+ 2, 48, :_reduce_60,
174
+ 2, 48, :_reduce_61,
175
+ 0, 48, :_reduce_none,
176
+ 1, 52, :_reduce_63,
177
+ 1, 52, :_reduce_64,
178
+ 1, 52, :_reduce_65,
179
+ 1, 52, :_reduce_66,
180
+ 1, 52, :_reduce_67,
181
+ 1, 52, :_reduce_68,
182
+ 1, 52, :_reduce_69,
183
+ 3, 40, :_reduce_70,
184
+ 1, 53, :_reduce_none,
185
+ 2, 53, :_reduce_none,
186
+ 1, 53, :_reduce_none ]
187
+
188
+ racc_reduce_n = 74
189
+
190
+ racc_shift_n = 106
183
191
 
184
192
  racc_token_table = {
185
193
  false => 0,
@@ -269,6 +277,7 @@ Racc_token_to_s_table = [
269
277
  "$start",
270
278
  "selector",
271
279
  "simple_selector_1toN",
280
+ "prefixless_combinator_selector",
272
281
  "combinator",
273
282
  "simple_selector",
274
283
  "element_name",
@@ -307,22 +316,22 @@ def _reduce_2(val, _values, result)
307
316
  end
308
317
 
309
318
  def _reduce_3(val, _values, result)
310
- result = :DIRECT_ADJACENT_SELECTOR
319
+ result = val.flatten
311
320
  result
312
321
  end
313
322
 
314
323
  def _reduce_4(val, _values, result)
315
- result = :CHILD_SELECTOR
324
+ result = :DIRECT_ADJACENT_SELECTOR
316
325
  result
317
326
  end
318
327
 
319
328
  def _reduce_5(val, _values, result)
320
- result = :PRECEDING_SELECTOR
329
+ result = :CHILD_SELECTOR
321
330
  result
322
331
  end
323
332
 
324
333
  def _reduce_6(val, _values, result)
325
- result = :DESCENDANT_SELECTOR
334
+ result = :FOLLOWING_SELECTOR
326
335
  result
327
336
  end
328
337
 
@@ -332,11 +341,16 @@ def _reduce_7(val, _values, result)
332
341
  end
333
342
 
334
343
  def _reduce_8(val, _values, result)
335
- result = :CHILD_SELECTOR
344
+ result = :DESCENDANT_SELECTOR
336
345
  result
337
346
  end
338
347
 
339
348
  def _reduce_9(val, _values, result)
349
+ result = :CHILD_SELECTOR
350
+ result
351
+ end
352
+
353
+ def _reduce_10(val, _values, result)
340
354
  result = if val[1].nil?
341
355
  val.first
342
356
  else
@@ -346,7 +360,7 @@ def _reduce_9(val, _values, result)
346
360
  result
347
361
  end
348
362
 
349
- def _reduce_10(val, _values, result)
363
+ def _reduce_11(val, _values, result)
350
364
  result = Node.new(:CONDITIONAL_SELECTOR,
351
365
  [
352
366
  val.first,
@@ -357,27 +371,27 @@ def _reduce_10(val, _values, result)
357
371
  result
358
372
  end
359
373
 
360
- def _reduce_11(val, _values, result)
374
+ def _reduce_12(val, _values, result)
361
375
  result = Node.new(:CONDITIONAL_SELECTOR, val)
362
376
 
363
377
  result
364
378
  end
365
379
 
366
- # reduce 12 omitted
380
+ # reduce 13 omitted
367
381
 
368
- def _reduce_13(val, _values, result)
382
+ def _reduce_14(val, _values, result)
369
383
  result = Node.new(:CONDITIONAL_SELECTOR, val)
370
384
 
371
385
  result
372
386
  end
373
387
 
374
- def _reduce_14(val, _values, result)
388
+ def _reduce_15(val, _values, result)
375
389
  result = Node.new(:CONDITIONAL_SELECTOR, val)
376
390
 
377
391
  result
378
392
  end
379
393
 
380
- def _reduce_15(val, _values, result)
394
+ def _reduce_16(val, _values, result)
381
395
  result = Node.new(:CONDITIONAL_SELECTOR,
382
396
  [
383
397
  Node.new(:ELEMENT_NAME, ['*']),
@@ -388,7 +402,7 @@ def _reduce_15(val, _values, result)
388
402
  result
389
403
  end
390
404
 
391
- def _reduce_16(val, _values, result)
405
+ def _reduce_17(val, _values, result)
392
406
  result = Node.new(:CONDITIONAL_SELECTOR,
393
407
  [Node.new(:ELEMENT_NAME, ['*']), val.first]
394
408
  )
@@ -396,27 +410,33 @@ def _reduce_16(val, _values, result)
396
410
  result
397
411
  end
398
412
 
399
- def _reduce_17(val, _values, result)
400
- result = Node.new(val[1], [val.first, val.last])
413
+ def _reduce_18(val, _values, result)
414
+ result = Node.new(val.first, [nil, val.last])
401
415
 
402
416
  result
403
417
  end
404
418
 
405
- # reduce 18 omitted
406
-
407
419
  def _reduce_19(val, _values, result)
408
- result = Node.new(:CLASS_CONDITION, [val[1]])
420
+ result = Node.new(val[1], [val.first, val.last])
421
+
409
422
  result
410
423
  end
411
424
 
412
425
  # reduce 20 omitted
413
426
 
414
427
  def _reduce_21(val, _values, result)
428
+ result = Node.new(:CLASS_CONDITION, [val[1]])
429
+ result
430
+ end
431
+
432
+ # reduce 22 omitted
433
+
434
+ def _reduce_23(val, _values, result)
415
435
  result = Node.new(:ELEMENT_NAME, val)
416
436
  result
417
437
  end
418
438
 
419
- def _reduce_22(val, _values, result)
439
+ def _reduce_24(val, _values, result)
420
440
  result = Node.new(:ELEMENT_NAME,
421
441
  [[val.first, val.last].compact.join(':')]
422
442
  )
@@ -424,21 +444,21 @@ def _reduce_22(val, _values, result)
424
444
  result
425
445
  end
426
446
 
427
- def _reduce_23(val, _values, result)
447
+ def _reduce_25(val, _values, result)
428
448
  name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
429
449
  result = Node.new(:ELEMENT_NAME, [name])
430
450
 
431
451
  result
432
452
  end
433
453
 
434
- def _reduce_24(val, _values, result)
454
+ def _reduce_26(val, _values, result)
435
455
  result = val[0]
436
456
  result
437
457
  end
438
458
 
439
- # reduce 25 omitted
459
+ # reduce 27 omitted
440
460
 
441
- def _reduce_26(val, _values, result)
461
+ def _reduce_28(val, _values, result)
442
462
  result = Node.new(:ATTRIBUTE_CONDITION,
443
463
  [val[1]] + (val[2] || [])
444
464
  )
@@ -446,7 +466,7 @@ def _reduce_26(val, _values, result)
446
466
  result
447
467
  end
448
468
 
449
- def _reduce_27(val, _values, result)
469
+ def _reduce_29(val, _values, result)
450
470
  result = Node.new(:ATTRIBUTE_CONDITION,
451
471
  [val[1]] + (val[2] || [])
452
472
  )
@@ -454,7 +474,7 @@ def _reduce_27(val, _values, result)
454
474
  result
455
475
  end
456
476
 
457
- def _reduce_28(val, _values, result)
477
+ def _reduce_30(val, _values, result)
458
478
  # Non standard, but hpricot supports it.
459
479
  result = Node.new(:PSEUDO_CLASS,
460
480
  [Node.new(:FUNCTION, ['nth-child(', val[1]])]
@@ -463,7 +483,7 @@ def _reduce_28(val, _values, result)
463
483
  result
464
484
  end
465
485
 
466
- def _reduce_29(val, _values, result)
486
+ def _reduce_31(val, _values, result)
467
487
  result = Node.new(:ELEMENT_NAME,
468
488
  [[val.first, val.last].compact.join(':')]
469
489
  )
@@ -471,7 +491,7 @@ def _reduce_29(val, _values, result)
471
491
  result
472
492
  end
473
493
 
474
- def _reduce_30(val, _values, result)
494
+ def _reduce_32(val, _values, result)
475
495
  # Default namespace is not applied to attributes.
476
496
  # So we don't add prefix "xmlns:" as in namespaced_ident.
477
497
  result = Node.new(:ELEMENT_NAME, [val.first])
@@ -479,56 +499,56 @@ def _reduce_30(val, _values, result)
479
499
  result
480
500
  end
481
501
 
482
- def _reduce_31(val, _values, result)
502
+ def _reduce_33(val, _values, result)
483
503
  result = Node.new(:FUNCTION, [val.first.strip])
484
504
 
485
505
  result
486
506
  end
487
507
 
488
- def _reduce_32(val, _values, result)
508
+ def _reduce_34(val, _values, result)
489
509
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
490
510
 
491
511
  result
492
512
  end
493
513
 
494
- def _reduce_33(val, _values, result)
514
+ def _reduce_35(val, _values, result)
495
515
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
496
516
 
497
517
  result
498
518
  end
499
519
 
500
- def _reduce_34(val, _values, result)
520
+ def _reduce_36(val, _values, result)
501
521
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
502
522
 
503
523
  result
504
524
  end
505
525
 
506
- def _reduce_35(val, _values, result)
526
+ def _reduce_37(val, _values, result)
507
527
  result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
508
528
 
509
529
  result
510
530
  end
511
531
 
512
- def _reduce_36(val, _values, result)
532
+ def _reduce_38(val, _values, result)
513
533
  result = [val.first, val.last]
514
534
  result
515
535
  end
516
536
 
517
- def _reduce_37(val, _values, result)
537
+ def _reduce_39(val, _values, result)
518
538
  result = [val.first, val.last]
519
539
  result
520
540
  end
521
541
 
522
- def _reduce_38(val, _values, result)
542
+ def _reduce_40(val, _values, result)
523
543
  result = [val.first, val.last]
524
544
  result
525
545
  end
526
546
 
527
- # reduce 39 omitted
547
+ # reduce 41 omitted
528
548
 
529
- # reduce 40 omitted
549
+ # reduce 42 omitted
530
550
 
531
- def _reduce_41(val, _values, result)
551
+ def _reduce_43(val, _values, result)
532
552
  if val[0] == 'even'
533
553
  val = ["2","n","+","0"]
534
554
  result = Node.new(:AN_PLUS_B, val)
@@ -546,7 +566,7 @@ def _reduce_41(val, _values, result)
546
566
  result
547
567
  end
548
568
 
549
- def _reduce_42(val, _values, result)
569
+ def _reduce_44(val, _values, result)
550
570
  if val[1] == 'n'
551
571
  result = Node.new(:AN_PLUS_B, val)
552
572
  else
@@ -556,7 +576,7 @@ def _reduce_42(val, _values, result)
556
576
  result
557
577
  end
558
578
 
559
- def _reduce_43(val, _values, result)
579
+ def _reduce_45(val, _values, result)
560
580
  # n+3, -n+3
561
581
  if val[0] == 'n'
562
582
  val.unshift("1")
@@ -572,7 +592,7 @@ def _reduce_43(val, _values, result)
572
592
  result
573
593
  end
574
594
 
575
- def _reduce_44(val, _values, result)
595
+ def _reduce_46(val, _values, result)
576
596
  if val[1] == 'n'
577
597
  val << "+"
578
598
  val << "0"
@@ -584,116 +604,116 @@ def _reduce_44(val, _values, result)
584
604
  result
585
605
  end
586
606
 
587
- def _reduce_45(val, _values, result)
607
+ def _reduce_47(val, _values, result)
588
608
  result = Node.new(:PSEUDO_CLASS, [val[1]])
589
609
 
590
610
  result
591
611
  end
592
612
 
593
- def _reduce_46(val, _values, result)
613
+ def _reduce_48(val, _values, result)
594
614
  result = Node.new(:PSEUDO_CLASS, [val[1]])
595
615
  result
596
616
  end
597
617
 
598
- # reduce 47 omitted
618
+ # reduce 49 omitted
599
619
 
600
- # reduce 48 omitted
620
+ # reduce 50 omitted
601
621
 
602
- def _reduce_49(val, _values, result)
622
+ def _reduce_51(val, _values, result)
603
623
  result = Node.new(:COMBINATOR, val)
604
624
 
605
625
  result
606
626
  end
607
627
 
608
- def _reduce_50(val, _values, result)
628
+ def _reduce_52(val, _values, result)
609
629
  result = Node.new(:COMBINATOR, val)
610
630
 
611
631
  result
612
632
  end
613
633
 
614
- def _reduce_51(val, _values, result)
634
+ def _reduce_53(val, _values, result)
615
635
  result = Node.new(:COMBINATOR, val)
616
636
 
617
637
  result
618
638
  end
619
639
 
620
- def _reduce_52(val, _values, result)
640
+ def _reduce_54(val, _values, result)
621
641
  result = Node.new(:COMBINATOR, val)
622
642
 
623
643
  result
624
644
  end
625
645
 
626
- # reduce 53 omitted
627
-
628
- # reduce 54 omitted
629
-
630
646
  # reduce 55 omitted
631
647
 
632
648
  # reduce 56 omitted
633
649
 
634
- def _reduce_57(val, _values, result)
650
+ # reduce 57 omitted
651
+
652
+ # reduce 58 omitted
653
+
654
+ def _reduce_59(val, _values, result)
635
655
  result = Node.new(:ID, val)
636
656
  result
637
657
  end
638
658
 
639
- def _reduce_58(val, _values, result)
659
+ def _reduce_60(val, _values, result)
640
660
  result = [val.first, val[1]]
641
661
  result
642
662
  end
643
663
 
644
- def _reduce_59(val, _values, result)
664
+ def _reduce_61(val, _values, result)
645
665
  result = [val.first, val[1]]
646
666
  result
647
667
  end
648
668
 
649
- # reduce 60 omitted
669
+ # reduce 62 omitted
650
670
 
651
- def _reduce_61(val, _values, result)
671
+ def _reduce_63(val, _values, result)
652
672
  result = :equal
653
673
  result
654
674
  end
655
675
 
656
- def _reduce_62(val, _values, result)
676
+ def _reduce_64(val, _values, result)
657
677
  result = :prefix_match
658
678
  result
659
679
  end
660
680
 
661
- def _reduce_63(val, _values, result)
681
+ def _reduce_65(val, _values, result)
662
682
  result = :suffix_match
663
683
  result
664
684
  end
665
685
 
666
- def _reduce_64(val, _values, result)
686
+ def _reduce_66(val, _values, result)
667
687
  result = :substring_match
668
688
  result
669
689
  end
670
690
 
671
- def _reduce_65(val, _values, result)
691
+ def _reduce_67(val, _values, result)
672
692
  result = :not_equal
673
693
  result
674
694
  end
675
695
 
676
- def _reduce_66(val, _values, result)
696
+ def _reduce_68(val, _values, result)
677
697
  result = :includes
678
698
  result
679
699
  end
680
700
 
681
- def _reduce_67(val, _values, result)
701
+ def _reduce_69(val, _values, result)
682
702
  result = :dash_match
683
703
  result
684
704
  end
685
705
 
686
- def _reduce_68(val, _values, result)
706
+ def _reduce_70(val, _values, result)
687
707
  result = Node.new(:NOT, [val[1]])
688
708
 
689
709
  result
690
710
  end
691
711
 
692
- # reduce 69 omitted
712
+ # reduce 71 omitted
693
713
 
694
- # reduce 70 omitted
714
+ # reduce 72 omitted
695
715
 
696
- # reduce 71 omitted
716
+ # reduce 73 omitted
697
717
 
698
718
  def _reduce_none(val, _values, result)
699
719
  val[0]