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>> {
|
fn next_number(&mut self) -> Result<Token<'s>> {
|
||||||
if self.next()? == '0' {
|
if self.next()? == '0' {
|
||||||
while self.peek()? == '_' {
|
|
||||||
self.next()?;
|
|
||||||
}
|
|
||||||
match self.peek()? {
|
match self.peek()? {
|
||||||
'x' => {
|
'x' => {
|
||||||
self.next()?;
|
self.next()?;
|
||||||
|
@ -393,7 +390,7 @@ impl<'s> Lexer<'s> {
|
||||||
self.next()?;
|
self.next()?;
|
||||||
return self.next_int_base(2)
|
return self.next_int_base(2)
|
||||||
}
|
}
|
||||||
'0'..='9' | '.' | 'e' | 'i' => (),
|
'0'..='9' | '_' | '.' | 'e' | 'i' => (),
|
||||||
c if is_xid_start(c) => return self.unexpected(),
|
c if is_xid_start(c) => return self.unexpected(),
|
||||||
_ => return self.emit(K::Integer),
|
_ => 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> {
|
pub fn parse_int_literal<'a, S: Into<&'a LStr>>(f: S) -> Result<i64, ParseIntError> {
|
||||||
let f = f.into();
|
let f = f.into();
|
||||||
match f.chars().nth(2) {
|
match f.chars().nth(1) {
|
||||||
Some('x') => parse_int(&f[2..], 16),
|
Some('x') => parse_int(&f[2..], 16),
|
||||||
Some('o') => parse_int(&f[2..], 8),
|
Some('o') => parse_int(&f[2..], 8),
|
||||||
Some('s') => parse_int(&f[2..], 6),
|
Some('s') => parse_int(&f[2..], 6),
|
||||||
|
|
Loading…
Reference in a new issue