@@ -64,8 +64,8 @@ pub fn parse_one_rule<T: Iterator<Node>>(iter: T) -> Result<Rule, ErrorReason> {
64
64
pub fn parse_one_declaration < T : Iterator < Node > > ( mut iter : T ) -> Result < Declaration , ErrorReason > {
65
65
match next_non_whitespace ( & mut iter) {
66
66
None => Err ( ErrEmptyInput ) ,
67
- Some ( item ) => {
68
- let result = parse_declaration ( & mut iter, item ) ;
67
+ Some ( ( component_value , location ) ) => {
68
+ let result = parse_declaration ( & mut iter, component_value , location ) ;
69
69
if result. is_err ( ) || next_non_whitespace ( & mut iter) . is_none ( ) { result }
70
70
else { Err ( ErrExtraInput ) }
71
71
}
@@ -113,7 +113,7 @@ impl<T: Iterator<Node>> Iterator<Result<Rule, ErrorReason>> for StylesheetParser
113
113
match component_value {
114
114
WhiteSpace | CDO | CDC => ( ) ,
115
115
AtKeyword ( name) => return Some ( Ok ( AtRule ( parse_at_rule( iter, name, location) ) ) ) ,
116
- _ => return Some ( match parse_qualified_rule( iter, ( component_value, location) ) {
116
+ _ => return Some ( match parse_qualified_rule( iter, component_value, location) {
117
117
Ok ( rule) => Ok ( QualifiedRule ( rule) ) ,
118
118
Err ( reason) => Err ( reason) ,
119
119
} ) ,
@@ -131,7 +131,7 @@ impl<T: Iterator<Node>> Iterator<Result<Rule, ErrorReason>> for RuleListParser<T
131
131
match component_value {
132
132
WhiteSpace => ( ) ,
133
133
AtKeyword ( name) => return Some ( Ok ( AtRule ( parse_at_rule( iter, name, location) ) ) ) ,
134
- _ => return Some ( match parse_qualified_rule( iter, ( component_value, location) ) {
134
+ _ => return Some ( match parse_qualified_rule( iter, component_value, location) {
135
135
Ok ( rule) => Ok ( QualifiedRule ( rule) ) ,
136
136
Err ( reason) => Err ( reason) ,
137
137
} ) ,
@@ -151,7 +151,7 @@ for DeclarationListParser<T> {
151
151
WhiteSpace | Semicolon => ( ) ,
152
152
AtKeyword ( name)
153
153
=> return Some ( Ok ( Decl_AtRule ( parse_at_rule( iter, name, location) ) ) ) ,
154
- _ => return Some ( match parse_declaration( iter, ( component_value, location) ) {
154
+ _ => return Some ( match parse_declaration( iter, component_value, location) {
155
155
Ok ( declaration) => Ok ( Declaration ( declaration) ) ,
156
156
Err ( reason) => {
157
157
// Find the end of the declaration
@@ -170,40 +170,42 @@ fn parse_at_rule<T: Iterator<Node>>(iter: &mut T, name: ~str, location: SourceLo
170
170
-> AtRule {
171
171
let mut prelude = ~[ ] ;
172
172
let mut block = None ;
173
- for_iter ! ( iter, ( component_value, location ) , {
173
+ for_iter ! ( iter, ( component_value, _location ) , {
174
174
match component_value {
175
175
CurlyBracketBlock ( content) => { block = Some ( content) ; break } ,
176
176
Semicolon => break ,
177
- component_value => prelude. push( ( component_value, location ) ) ,
177
+ component_value => prelude. push( component_value) ,
178
178
}
179
179
} )
180
180
AtRule { location : location, name : name, prelude : prelude, block : block}
181
181
}
182
182
183
183
184
- fn parse_qualified_rule < T : Iterator < Node > > ( iter : & mut T , first : Node )
185
- -> Result < QualifiedRule , ErrorReason > {
184
+ fn parse_qualified_rule < T : Iterator < Node > > ( iter : & mut T , first : ComponentValue ,
185
+ location : SourceLocation )
186
+ -> Result < QualifiedRule , ErrorReason > {
186
187
match first {
187
- ( CurlyBracketBlock ( content) , location )
188
+ CurlyBracketBlock ( content)
188
189
=> return Ok ( QualifiedRule { location : location, prelude : ~[ ] , block : content } ) ,
189
190
_ => ( ) ,
190
191
}
191
192
let mut prelude = ~[ first] ;
192
- for_iter ! ( iter, ( component_value, location ) , {
193
+ for_iter ! ( iter, ( component_value, _location ) , {
193
194
match component_value {
194
195
CurlyBracketBlock ( content)
195
196
=> return Ok ( QualifiedRule { location: location, prelude: prelude, block: content} ) ,
196
- component_value => prelude. push( ( component_value, location ) ) ,
197
+ component_value => prelude. push( component_value) ,
197
198
}
198
199
} )
199
200
Err ( ErrMissingQualifiedRuleBlock )
200
201
}
201
202
202
203
203
- fn parse_declaration < T : Iterator < Node > > ( iter : & mut T , first : Node )
204
- -> Result < Declaration , ErrorReason > {
205
- let ( name, location) = match first {
206
- ( Ident ( name) , location) => ( name, location) ,
204
+ fn parse_declaration < T : Iterator < Node > > ( iter : & mut T , first : ComponentValue ,
205
+ location : SourceLocation )
206
+ -> Result < Declaration , ErrorReason > {
207
+ let name = match first {
208
+ Ident ( name) => name,
207
209
_ => return Err ( ErrInvalidDeclarationSyntax )
208
210
} ;
209
211
match next_non_whitespace ( iter) {
@@ -212,7 +214,7 @@ fn parse_declaration<T: Iterator<Node>>(iter: &mut T, first: Node)
212
214
}
213
215
let mut value = ~[ ] ;
214
216
let mut important = false ;
215
- for_iter ! ( iter, ( component_value, location ) , {
217
+ for_iter ! ( iter, ( component_value, _location ) , {
216
218
match component_value {
217
219
Semicolon => break ,
218
220
Delim ( '!' ) => if parse_declaration_important( iter) {
@@ -221,7 +223,7 @@ fn parse_declaration<T: Iterator<Node>>(iter: &mut T, first: Node)
221
223
} else {
222
224
return Err ( ErrInvalidBangImportantSyntax )
223
225
} ,
224
- component_value => value. push( ( component_value, location ) ) ,
226
+ component_value => value. push( component_value) ,
225
227
}
226
228
} )
227
229
Ok ( Declaration { location : location, name : name, value : value, important : important} )
0 commit comments