File tree 1 file changed +8
-1
lines changed 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ pub use super::token::Tok;
8
8
use crate :: error:: { LexicalError , LexicalErrorType } ;
9
9
use crate :: location:: Location ;
10
10
use num_bigint:: BigInt ;
11
+ use num_traits:: identities:: Zero ;
11
12
use num_traits:: Num ;
12
13
use std:: cmp:: Ordering ;
13
14
use std:: collections:: HashMap ;
@@ -352,7 +353,7 @@ where
352
353
/// Lex a normal number, that is, no octal, hex or binary number.
353
354
fn lex_normal_number ( & mut self ) -> LexResult {
354
355
let start_pos = self . get_pos ( ) ;
355
-
356
+ let start_is_zero = self . chr0 == Some ( '0' ) ;
356
357
// Normal number:
357
358
let mut value_text = self . radix_run ( 10 ) ;
358
359
@@ -403,6 +404,12 @@ where
403
404
} else {
404
405
let end_pos = self . get_pos ( ) ;
405
406
let value = value_text. parse :: < BigInt > ( ) . unwrap ( ) ;
407
+ if start_is_zero && !value. is_zero ( ) {
408
+ return Err ( LexicalError {
409
+ error : LexicalErrorType :: OtherError ( "Invalid Token" . to_string ( ) ) ,
410
+ location : self . get_pos ( ) ,
411
+ } ) ;
412
+ }
406
413
Ok ( ( start_pos, Tok :: Int { value } , end_pos) )
407
414
}
408
415
}
You can’t perform that action at this time.
0 commit comments