fix numeric parsing
This commit is contained in:
parent
a82a5fa1c6
commit
2b116296bc
3 changed files with 3 additions and 5 deletions
1
examples/a.talc
Normal file
1
examples/a.talc
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -373,9 +373,6 @@ impl<'s> Lexer<'s> {
|
|||
|
||||
fn next_number(&mut self) -> Result<Token<'s>> {
|
||||
if self.next()? == '0' {
|
||||
while self.peek()? == '_' {
|
||||
self.next()?;
|
||||
}
|
||||
match self.peek()? {
|
||||
'x' => {
|
||||
self.next()?;
|
||||
|
@ -393,7 +390,7 @@ impl<'s> Lexer<'s> {
|
|||
self.next()?;
|
||||
return self.next_int_base(2)
|
||||
}
|
||||
'0'..='9' | '.' | 'e' | 'i' => (),
|
||||
'0'..='9' | '_' | '.' | 'e' | 'i' => (),
|
||||
c if is_xid_start(c) => return self.unexpected(),
|
||||
_ => return self.emit(K::Integer),
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ pub fn parse_int<'a, S: Into<&'a LStr>>(f: S, radix: u32) -> Result<i64, ParseIn
|
|||
|
||||
pub fn parse_int_literal<'a, S: Into<&'a LStr>>(f: S) -> Result<i64, ParseIntError> {
|
||||
let f = f.into();
|
||||
match f.chars().nth(2) {
|
||||
match f.chars().nth(1) {
|
||||
Some('x') => parse_int(&f[2..], 16),
|
||||
Some('o') => parse_int(&f[2..], 8),
|
||||
Some('s') => parse_int(&f[2..], 6),
|
||||
|
|
Loading…
Reference in a new issue