Skip to content

Commit

Permalink
fix the wrong regex pattern of scientific notation (vesoft-inc#794)
Browse files Browse the repository at this point in the history
Co-authored-by: jie.wang <[email protected]>
  • Loading branch information
nebula-bots and jievince authored Apr 12, 2022
1 parent e897ad6 commit 4e12d32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/parser/scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,8 @@ LABEL_FULL_WIDTH {CN_EN_FULL_WIDTH}{CN_EN_NUM_FULL_WIDTH}*
return parseDecimal();
}

{DEC}*\.{DEC}+ |
{DEC}+\.{DEC}* |
{DEC}*\.{DEC}*{EXP} |
{DEC}*\.{DEC}+{EXP}? |
{DEC}+\.{DEC}*{EXP}? |
{DEC}+{EXP} {
return parseDouble();
}
Expand Down
3 changes: 3 additions & 0 deletions src/parser/test/ScannerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@ TEST(Scanner, Basic) {
CHECK_SEMANTIC_VALUE("123.", TokenType::DOUBLE, 123.),
CHECK_SEMANTIC_VALUE(".123", TokenType::DOUBLE, 0.123),
CHECK_SEMANTIC_VALUE("123.456", TokenType::DOUBLE, 123.456),
CHECK_SEMANTIC_VALUE("1.2e1", TokenType::DOUBLE, 12.0),
CHECK_SEMANTIC_VALUE("1.e2", TokenType::DOUBLE, 100.0),
CHECK_SEMANTIC_VALUE(".2e3", TokenType::DOUBLE, 200.0),

CHECK_SEMANTIC_VALUE("0x7FFFFFFFFFFFFFFF", TokenType::INTEGER, 0x7FFFFFFFFFFFFFFFL),
CHECK_SEMANTIC_VALUE("0x007FFFFFFFFFFFFFFF", TokenType::INTEGER, 0x007FFFFFFFFFFFFFFFL),
Expand Down

0 comments on commit 4e12d32

Please sign in to comment.