mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:57:42 +00:00
LibJS: Hack the lexer to allow numbers with decimals
This is very hackish and should definitely be improved. :^)
This commit is contained in:
parent
3a026a1ede
commit
a860a3f793
2 changed files with 2 additions and 4 deletions
|
@ -229,7 +229,7 @@ Token Lexer::next()
|
|||
}
|
||||
} else if (isdigit(m_current_char)) {
|
||||
consume();
|
||||
while (isdigit(m_current_char)) {
|
||||
while (m_current_char == '.' || isdigit(m_current_char)) {
|
||||
consume();
|
||||
}
|
||||
token_type = TokenType::NumericLiteral;
|
||||
|
|
|
@ -52,9 +52,7 @@ const char* Token::name() const
|
|||
double Token::double_value() const
|
||||
{
|
||||
ASSERT(type() == TokenType::NumericLiteral);
|
||||
// FIXME: need to parse double instead of int
|
||||
bool ok;
|
||||
return m_value.to_int(ok);
|
||||
return strtod(String(m_value).characters(), nullptr);
|
||||
}
|
||||
|
||||
String Token::string_value() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue