@@ -8,8 +8,6 @@ use nom_locate::LocatedSpan;
8
8
pub ( crate ) type StrSpan < ' a > = LocatedSpan < CompleteStr < ' a > > ;
9
9
10
10
11
- named ! ( pub space<StrSpan , StrSpan >, eat_separator!( & b" \t " [ ..] ) ) ;
12
-
13
11
/// Like `ws!()`, but does not allow newlines.
14
12
#[ macro_export]
15
13
macro_rules! ws2 (
@@ -18,10 +16,10 @@ macro_rules! ws2 (
18
16
use nom:: Convert ;
19
17
use nom:: Err ;
20
18
21
- match sep!( $i, $crate:: helpers:: space , $( $args) * ) {
19
+ match sep!( $i, $crate:: helpers:: spaces2 , $( $args) * ) {
22
20
Err ( e) => Err ( e) ,
23
21
Ok ( ( i1, o) ) => {
24
- match $crate:: helpers:: space ( i1) {
22
+ match $crate:: helpers:: spaces2 ( i1) {
25
23
Err ( e) => Err ( Err :: convert( e) ) ,
26
24
Ok ( ( i2, _) ) => Ok ( ( i2, o) )
27
25
}
@@ -52,20 +50,24 @@ macro_rules! ws4 (
52
50
)
53
51
) ;
54
52
53
+ named ! ( escaped_newline<StrSpan , ( ) >,
54
+ map!( terminated!( char !( '\\' ) , char !( '\n' ) ) , |_| ( ) )
55
+ ) ;
56
+
55
57
named ! ( pub spaces<StrSpan , ( ) >,
56
- map!( many0!( alt!( map! ( one_of!( " \t " ) , |_|( ) ) | newline) ) , |_| ( ) )
58
+ map!( many0!( alt!( one_of!( " \t " ) => { |_|( ) } | escaped_newline | newline) ) , |_| ( ) )
57
59
) ;
58
60
59
61
named ! ( pub spaces2<StrSpan , ( ) >,
60
- map!( many0!( one_of!( " \t " ) ) , |_| ( ) )
62
+ map!( many0!( alt! ( one_of!( " \t " ) => { |_| ( ) } |escaped_newline ) ) , |_| ( ) )
61
63
) ;
62
64
63
65
named ! ( pub space_sep<StrSpan , ( ) >,
64
- map!( many1!( alt!( map! ( one_of!( " \t " ) , |_|( ) ) | newline) ) , |_| ( ) )
66
+ map!( many1!( alt!( one_of!( " \t " ) => { |_|( ) } | escaped_newline | newline) ) , |_| ( ) )
65
67
) ;
66
68
67
69
named ! ( pub space_sep2<StrSpan , ( ) >,
68
- map!( many1!( one_of!( " \t " ) ) , |_| ( ) )
70
+ map!( many1!( alt! ( one_of!( " \t " ) => { |_| ( ) } | escaped_newline ) ) , |_| ( ) )
69
71
) ;
70
72
71
73
// Let me explain this ugliness.
@@ -128,7 +130,7 @@ named!(pub newline<StrSpan, ()>,
128
130
map!(
129
131
many1!(
130
132
tuple!(
131
- space ,
133
+ spaces2 ,
132
134
opt!( preceded!( char !( '#' ) , many0!( none_of!( "\n " ) ) ) ) ,
133
135
char !( '\n' )
134
136
)
0 commit comments