This commit is contained in:
Shunsuke Shibayama 2022-10-10 11:51:47 +09:00
commit c5a3886d65

View file

@ -461,6 +461,7 @@ impl Lexer /*<'a>*/ {
let mut num = mantissa;
debug_power_assert!(self.peek_cur_ch(), ==, Some('e'));
num.push(self.consume().unwrap()); // e
if self.peek_cur_ch().is_some() {
num.push(self.consume().unwrap()); // + | -
while let Some(cur) = self.peek_cur_ch() {
if cur.is_ascii_digit() || cur == '_' {
@ -470,6 +471,20 @@ impl Lexer /*<'a>*/ {
}
}
Ok(self.emit_token(RatioLit, &num))
} else {
let token = self.emit_token(RatioLit, &num);
Err(LexError::syntax_error(
0,
token.loc(),
switch_lang!(
"japanese" => format!("`{}`は無効な十進数リテラルです", &token.content),
"simplified_chinese" => format!("`{}`是无效的十进制字词", &token.content),
"traditional_chinese" => format!("`{}`是無效的十進製文字", &token.content),
"english" => format!("`{}` is invalid decimal literal", &token.content),
),
None,
))
}
}
/// `_` will be removed at compiletime