Skip to content

Commit

Permalink
Fix signed integers in exponents beginning with 0.
Browse files Browse the repository at this point in the history
I don't really know if this behaviour is according to the standard, but all
other parsers I tested seem to accept it and parse it as integer, not octal.
  • Loading branch information
aszlig committed Apr 23, 2012
1 parent 864e762 commit 6f80eb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions runtests.hs
Expand Up @@ -64,6 +64,7 @@ testSuite = testGroup "Parser"
, testCase "LiteralDecimal13" (testLiteral "1e18" "Right (JSDecimal \"1e18\")")
, testCase "LiteralDecimal14" (testLiteral "1e+18" "Right (JSDecimal \"1e+18\")")
, testCase "LiteralDecimal15" (testLiteral "1e-18" "Right (JSDecimal \"1e-18\")")
, testCase "LiteralDecimal16" (testLiteral "1E-01" "Right (JSDecimal \"1E-01\")")

, testCase "LiteralString1" (testLiteral "\"hello\\nworld\"" "Right (JSStringLiteral '\"' \"hello\\\\nworld\")")
, testCase "LiteralString2" (testLiteral "'hello\\nworld'" "Right (JSStringLiteral '\\'' \"hello\\\\nworld\")")
Expand Down
10 changes: 5 additions & 5 deletions src-dev/Language/JavaScript/Parser/Lexer.x
Expand Up @@ -238,11 +238,11 @@ tokens :-
-- | "0"
-- | "0." $digit+ { mkString decimalToken }

<reg,divide> "0" "." $digit* ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
| $non_zero_digit $digit* "." $digit* ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
| "." $digit+ ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
| "0" ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
| $non_zero_digit $digit* ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
<reg,divide> "0" "." $digit* ("e"|"E") ("+"|"-")? $digit+
| $non_zero_digit $digit* "." $digit* ("e"|"E") ("+"|"-")? $digit+
| "." $digit+ ("e"|"E") ("+"|"-")? $digit+
| "0" ("e"|"E") ("+"|"-")? $digit+
| $non_zero_digit $digit* ("e"|"E") ("+"|"-")? $digit+
-- ++FOO++
| "0" "." $digit*
| $non_zero_digit $digit* "." $digit*
Expand Down

0 comments on commit 6f80eb4

Please sign in to comment.