@@ -110,9 +110,9 @@ pub struct BaseLexer<
110
110
}
111
111
112
112
#[ derive( Debug ) ]
113
- crate struct LexerPosition {
114
- crate line : Cell < isize > ,
115
- crate char_position_in_line : Cell < isize > ,
113
+ pub ( crate ) struct LexerPosition {
114
+ pub ( crate ) line : Cell < isize > ,
115
+ pub ( crate ) char_position_in_line : Cell < isize > ,
116
116
}
117
117
118
118
impl < ' input , T , Input , TF > Deref for BaseLexer < ' input , T , Input , TF >
@@ -123,7 +123,9 @@ where
123
123
{
124
124
type Target = T ;
125
125
126
- fn deref ( & self ) -> & Self :: Target { & self . recog }
126
+ fn deref ( & self ) -> & Self :: Target {
127
+ & self . recog
128
+ }
127
129
}
128
130
129
131
impl < ' input , T , Input , TF > DerefMut for BaseLexer < ' input , T , Input , TF >
@@ -132,7 +134,9 @@ where
132
134
Input : CharStream < TF :: From > ,
133
135
TF : TokenFactory < ' input > ,
134
136
{
135
- fn deref_mut ( & mut self ) -> & mut Self :: Target { & mut self . recog }
137
+ fn deref_mut ( & mut self ) -> & mut Self :: Target {
138
+ & mut self . recog
139
+ }
136
140
}
137
141
138
142
impl < ' input , T , Input , TF > Recognizer < ' input > for BaseLexer < ' input , T , Input , TF >
@@ -178,16 +182,18 @@ pub use super::token::TOKEN_DEFAULT_CHANNEL as LEXER_DEFAULT_TOKEN_CHANNEL;
178
182
#[ doc( inline) ]
179
183
pub use super :: token:: TOKEN_HIDDEN_CHANNEL as LEXER_HIDDEN ;
180
184
181
- crate const LEXER_MIN_CHAR_VALUE : isize = 0x0000 ;
182
- crate const LEXER_MAX_CHAR_VALUE : isize = 0x10FFFF ;
185
+ pub ( crate ) const LEXER_MIN_CHAR_VALUE : isize = 0x0000 ;
186
+ pub ( crate ) const LEXER_MAX_CHAR_VALUE : isize = 0x10FFFF ;
183
187
184
188
impl < ' input , T , Input , TF > BaseLexer < ' input , T , Input , TF >
185
189
where
186
190
T : LexerRecog < ' input , Self > + ' static ,
187
191
Input : CharStream < TF :: From > ,
188
192
TF : TokenFactory < ' input > ,
189
193
{
190
- fn emit_token ( & mut self , token : TF :: Tok ) { self . token = Some ( token) ; }
194
+ fn emit_token ( & mut self , token : TF :: Tok ) {
195
+ self . token = Some ( token) ;
196
+ }
191
197
192
198
fn emit ( & mut self ) {
193
199
<T as LexerRecog < Self > >:: before_emit ( self ) ;
@@ -220,7 +226,9 @@ where
220
226
}
221
227
222
228
/// Current position in input stream
223
- pub fn get_char_index ( & self ) -> isize { self . input . as_ref ( ) . unwrap ( ) . index ( ) }
229
+ pub fn get_char_index ( & self ) -> isize {
230
+ self . input . as_ref ( ) . unwrap ( ) . index ( )
231
+ }
224
232
225
233
/// Current token text
226
234
pub fn get_text < ' a > ( & ' a self ) -> Cow < ' a , TF :: Data >
@@ -242,7 +250,9 @@ where
242
250
}
243
251
244
252
/// Used from lexer actions to override text of the token that will be emitted next
245
- pub fn set_text ( & mut self , _text : <TF :: Data as ToOwned >:: Owned ) { self . text = Some ( _text) ; }
253
+ pub fn set_text ( & mut self , _text : <TF :: Data as ToOwned >:: Owned ) {
254
+ self . text = Some ( _text) ;
255
+ }
246
256
247
257
// fn get_all_tokens(&mut self) -> Vec<TF::Tok> { unimplemented!() }
248
258
@@ -254,7 +264,9 @@ where
254
264
}
255
265
256
266
/// Remove and drop all error listeners
257
- pub fn remove_error_listeners ( & mut self ) { self . error_listeners . borrow_mut ( ) . clear ( ) ; }
267
+ pub fn remove_error_listeners ( & mut self ) {
268
+ self . error_listeners . borrow_mut ( ) . clear ( ) ;
269
+ }
258
270
259
271
/// Creates new lexer instance
260
272
pub fn new_base_lexer (
@@ -375,9 +387,13 @@ where
375
387
self . token . take ( ) . unwrap ( )
376
388
}
377
389
378
- fn get_line ( & self ) -> isize { self . current_pos . line . get ( ) }
390
+ fn get_line ( & self ) -> isize {
391
+ self . current_pos . line . get ( )
392
+ }
379
393
380
- fn get_char_position_in_line ( & self ) -> isize { self . current_pos . char_position_in_line . get ( ) }
394
+ fn get_char_position_in_line ( & self ) -> isize {
395
+ self . current_pos . char_position_in_line . get ( )
396
+ }
381
397
382
398
fn get_input_stream ( & mut self ) -> Option < & mut dyn IntStream > {
383
399
match & mut self . input {
@@ -397,7 +413,9 @@ where
397
413
// self.factory = f;
398
414
// }
399
415
400
- fn get_token_factory ( & self ) -> & ' input TF { self . factory }
416
+ fn get_token_factory ( & self ) -> & ' input TF {
417
+ self . factory
418
+ }
401
419
}
402
420
403
421
#[ cold]
@@ -440,9 +458,13 @@ where
440
458
{
441
459
type Input = Input ;
442
460
443
- fn input ( & mut self ) -> & mut Self :: Input { self . input . as_mut ( ) . unwrap ( ) }
461
+ fn input ( & mut self ) -> & mut Self :: Input {
462
+ self . input . as_mut ( ) . unwrap ( )
463
+ }
444
464
445
- fn set_channel ( & mut self , v : isize ) { self . channel = v; }
465
+ fn set_channel ( & mut self , v : isize ) {
466
+ self . channel = v;
467
+ }
446
468
447
469
fn push_mode ( & mut self , m : usize ) {
448
470
self . mode_stack . push ( self . mode ) ;
@@ -456,15 +478,27 @@ where
456
478
} )
457
479
}
458
480
459
- fn set_type ( & mut self , t : isize ) { self . token_type = t; }
481
+ fn set_type ( & mut self , t : isize ) {
482
+ self . token_type = t;
483
+ }
460
484
461
- fn set_mode ( & mut self , m : usize ) { self . mode = m; }
485
+ fn set_mode ( & mut self , m : usize ) {
486
+ self . mode = m;
487
+ }
462
488
463
- fn more ( & mut self ) { self . set_type ( LEXER_MORE ) }
489
+ fn more ( & mut self ) {
490
+ self . set_type ( LEXER_MORE )
491
+ }
464
492
465
- fn skip ( & mut self ) { self . set_type ( LEXER_SKIP ) }
493
+ fn skip ( & mut self ) {
494
+ self . set_type ( LEXER_SKIP )
495
+ }
466
496
467
- fn reset ( & mut self ) { unimplemented ! ( ) }
497
+ fn reset ( & mut self ) {
498
+ unimplemented ! ( )
499
+ }
468
500
469
- fn get_interpreter ( & self ) -> Option < & LexerATNSimulator > { self . interpreter . as_deref ( ) }
501
+ fn get_interpreter ( & self ) -> Option < & LexerATNSimulator > {
502
+ self . interpreter . as_deref ( )
503
+ }
470
504
}
0 commit comments