@@ -30,8 +30,12 @@ use self::value::{
30
30
value_expression,
31
31
} ;
32
32
use crate :: input:: { SourceFile , SourceName , SourcePos } ;
33
- use crate :: sass:: parser:: { variable_declaration2, variable_declaration_mod} ;
34
- use crate :: sass:: { Callable , FormalArgs , Item , Name , Selectors , Value } ;
33
+ use crate :: sass:: parser:: {
34
+ src_range, variable_declaration2, variable_declaration_mod,
35
+ } ;
36
+ use crate :: sass:: {
37
+ Callable , FormalArgs , Item , Name , Selectors , SrcValue , Value ,
38
+ } ;
35
39
use crate :: value:: ListSeparator ;
36
40
#[ cfg( test) ]
37
41
use crate :: value:: { Numeric , Unit } ;
@@ -387,27 +391,18 @@ fn each_loop2(input: Span) -> PResult<Item> {
387
391
/// A for loop after the initial `@for`.
388
392
fn for_loop2 ( input : Span ) -> PResult < Item > {
389
393
let ( input, name) = delimited ( tag ( "$" ) , name, ignore_comments) ( input) ?;
390
- let ( input, from) = delimited (
391
- terminated ( tag ( "from" ) , ignore_comments) ,
392
- single_value,
393
- ignore_comments,
394
- ) ( input) ?;
395
- let ( input, inclusive) = terminated (
396
- alt ( ( value ( true , tag ( "through" ) ) , value ( false , tag ( "to" ) ) ) ) ,
397
- ignore_comments,
398
- ) ( input) ?;
399
- let ( input, to) = terminated ( single_value, ignore_comments) ( input) ?;
394
+ let ( input, range) = src_range ( input) ?;
400
395
let ( input, body) = body_block ( input) ?;
401
- Ok ( (
402
- input ,
403
- Item :: For {
404
- name : name . into ( ) ,
405
- from : Box :: new ( from ) ,
406
- to : Box :: new ( to ) ,
407
- inclusive ,
408
- body ,
409
- } ,
410
- ) )
396
+ Ok ( ( input , Item :: For ( name . into ( ) , range , body ) ) )
397
+ }
398
+
399
+ /// A single `SrcValue`.
400
+ ///
401
+ /// That is, a single sass value with source position.
402
+ pub fn single_value_p ( input : Span ) -> PResult < SrcValue > {
403
+ let ( rest , value ) = single_value ( input ) ? ;
404
+ let pos = input . up_to ( & rest ) . to_owned ( ) ;
405
+ Ok ( ( rest , SrcValue :: new ( value , pos ) ) )
411
406
}
412
407
413
408
fn while_loop2 ( input : Span ) -> PResult < Item > {
0 commit comments