1
1
use { SyntaxKind , TextUnit , Token } ;
2
2
use super :: Event ;
3
3
use super :: super :: is_insignificant;
4
- use SyntaxKind :: { EOF , ERROR , L_CURLY , R_CURLY , TOMBSTONE } ;
4
+ use SyntaxKind :: { EOF , TOMBSTONE } ;
5
5
6
6
pub ( crate ) struct Marker {
7
7
pos : u32 ,
@@ -106,9 +106,6 @@ pub(crate) struct Parser<'t> {
106
106
107
107
pos : usize ,
108
108
events : Vec < Event > ,
109
-
110
- curly_level : i32 ,
111
- curly_limit : Option < i32 > ,
112
109
}
113
110
114
111
impl < ' t > Parser < ' t > {
@@ -131,13 +128,10 @@ impl<'t> Parser<'t> {
131
128
132
129
pos : 0 ,
133
130
events : Vec :: new ( ) ,
134
- curly_level : 0 ,
135
- curly_limit : None ,
136
131
}
137
132
}
138
133
139
134
pub ( crate ) fn into_events ( self ) -> Vec < Event > {
140
- assert ! ( self . curly_limit. is_none( ) ) ;
141
135
assert_eq ! ( self . current( ) , EOF ) ;
142
136
self . events
143
137
}
@@ -146,13 +140,7 @@ impl<'t> Parser<'t> {
146
140
if self . pos == self . tokens . len ( ) {
147
141
return EOF ;
148
142
}
149
- let token = self . tokens [ self . pos ] ;
150
- if let Some ( limit) = self . curly_limit {
151
- if limit == self . curly_level && token. kind == R_CURLY {
152
- return EOF ;
153
- }
154
- }
155
- token. kind
143
+ self . tokens [ self . pos ] . kind
156
144
}
157
145
158
146
pub ( crate ) fn start ( & mut self ) -> Marker {
@@ -172,11 +160,8 @@ impl<'t> Parser<'t> {
172
160
173
161
pub ( crate ) fn bump ( & mut self ) -> SyntaxKind {
174
162
let kind = self . current ( ) ;
175
- match kind {
176
- L_CURLY => self . curly_level += 1 ,
177
- R_CURLY => self . curly_level -= 1 ,
178
- EOF => return EOF ,
179
- _ => ( ) ,
163
+ if kind == EOF {
164
+ return EOF ;
180
165
}
181
166
self . pos += 1 ;
182
167
self . event ( Event :: Token {
@@ -190,28 +175,6 @@ impl<'t> Parser<'t> {
190
175
self . tokens . get ( self . pos + n) . map ( |t| t. kind ) . unwrap_or ( EOF )
191
176
}
192
177
193
- pub ( crate ) fn curly_block < F : FnOnce ( & mut Parser ) > ( & mut self , f : F ) -> bool {
194
- let old_level = self . curly_level ;
195
- let old_limit = self . curly_limit ;
196
- if !self . expect ( L_CURLY ) {
197
- return false ;
198
- }
199
- self . curly_limit = Some ( self . curly_level ) ;
200
- f ( self ) ;
201
- assert ! ( self . curly_level > old_level) ;
202
- self . curly_limit = old_limit;
203
- if !self . expect ( R_CURLY ) {
204
- let err = self . start ( ) ;
205
- while self . curly_level > old_level {
206
- if self . bump ( ) == EOF {
207
- break ;
208
- }
209
- }
210
- err. complete ( self , ERROR ) ;
211
- }
212
- true
213
- }
214
-
215
178
fn event ( & mut self , event : Event ) {
216
179
self . events . push ( event)
217
180
}
0 commit comments