@@ -69,11 +69,7 @@ impl<'a> Cursor<'a> {
69
69
70
70
pub ( crate ) type PResult < ' a , O > = Result < ( Cursor < ' a > , O ) , LexError > ;
71
71
72
- pub ( crate ) fn whitespace ( input : Cursor ) -> PResult < ( ) > {
73
- if input. is_empty ( ) {
74
- return Err ( LexError ) ;
75
- }
76
-
72
+ pub ( crate ) fn skip_whitespace ( input : Cursor ) -> Cursor {
77
73
let bytes = input. as_bytes ( ) ;
78
74
let mut i = 0 ;
79
75
while i < bytes. len ( ) {
@@ -95,9 +91,13 @@ pub(crate) fn whitespace(input: Cursor) -> PResult<()> {
95
91
&& ( !s. starts_with ( "/**" ) || s. starts_with ( "/***" ) )
96
92
&& !s. starts_with ( "/*!" )
97
93
{
98
- let ( _, com) = block_comment ( s) ?;
99
- i += com. len ( ) ;
100
- continue ;
94
+ match block_comment ( s) {
95
+ Ok ( ( _, com) ) => {
96
+ i += com. len ( ) ;
97
+ continue ;
98
+ }
99
+ Err ( LexError ) => return input,
100
+ }
101
101
}
102
102
}
103
103
match bytes[ i] {
@@ -114,9 +114,9 @@ pub(crate) fn whitespace(input: Cursor) -> PResult<()> {
114
114
}
115
115
}
116
116
}
117
- return if i > 0 { Ok ( ( s , ( ) ) ) } else { Err ( LexError ) } ;
117
+ return s ;
118
118
}
119
- Ok ( ( input. advance ( input. len ( ) ) , ( ) ) )
119
+ input. advance ( input. len ( ) )
120
120
}
121
121
122
122
pub ( crate ) fn block_comment ( input : Cursor ) -> PResult < & str > {
@@ -144,13 +144,6 @@ pub(crate) fn block_comment(input: Cursor) -> PResult<&str> {
144
144
Err ( LexError )
145
145
}
146
146
147
- pub ( crate ) fn skip_whitespace ( input : Cursor ) -> Cursor {
148
- match whitespace ( input) {
149
- Ok ( ( rest, _) ) => rest,
150
- Err ( LexError ) => input,
151
- }
152
- }
153
-
154
147
fn is_whitespace ( ch : char ) -> bool {
155
148
// Rust treats left-to-right mark and right-to-left mark as whitespace
156
149
ch. is_whitespace ( ) || ch == '\u{200e}' || ch == '\u{200f}'
0 commit comments