Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix signed integers in exponents beginning with 0.

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...
commit 6f80eb4220a1c58383ce3ea494bf14b87034e96b 1 parent 864e762
aszlig aszlig authored
Showing with 6 additions and 5 deletions.
  1. +1 −0  runtests.hs
  2. +5 −5 src-dev/Language/JavaScript/Parser/Lexer.x
1  runtests.hs
View
@@ -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\")")
10 src-dev/Language/JavaScript/Parser/Lexer.x
View
@@ -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*
Please sign in to comment.
Something went wrong with that request. Please try again.