From f75ebb80a6154840feabe6f91bb2d753c68555d2 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Thu, 24 Jan 2013 15:20:06 -0800 Subject: [PATCH] numbers can start with . --- moonscript/parse.lua | 5 ++++- tests/inputs/literals.moon | 4 ++++ tests/outputs/literals.lua | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/moonscript/parse.lua b/moonscript/parse.lua index 6a506cc..37f15b7 100644 --- a/moonscript/parse.lua +++ b/moonscript/parse.lua @@ -52,7 +52,10 @@ local _Name = C(R("az", "AZ", "__") * AlphaNum^0) local Name = Space * _Name local Num = P"0x" * R("09", "af", "AF")^1 + - R"09"^1 * (P"." * R"09"^1)^-1 * (S"eE" * P"-"^-1 * R"09"^1)^-1 + ( + R"09"^1 * (P"." * R"09"^1)^-1 + + P"." * R"09"^1 + ) * (S"eE" * P"-"^-1 * R"09"^1)^-1 Num = Space * (Num / function(value) return {"number", value} end) diff --git a/tests/inputs/literals.moon b/tests/inputs/literals.moon index ef80828..125b494 100644 --- a/tests/inputs/literals.moon +++ b/tests/inputs/literals.moon @@ -11,6 +11,10 @@ 0xabcdef 0xABCDEF +.2323 +.2323e-1 +.2323e13434 + [[ hello world ]] [=[ hello world ]=] diff --git a/tests/outputs/literals.lua b/tests/outputs/literals.lua index 69609c5..93c0629 100644 --- a/tests/outputs/literals.lua +++ b/tests/outputs/literals.lua @@ -7,6 +7,9 @@ _ = 0x12323 _ = 0xfF2323 _ = 0xabcdef _ = 0xABCDEF +_ = .2323 +_ = .2323e-1 +_ = .2323e13434 _ = [[ hello world ]] _ = [=[ hello world ]=] _ = [====[ hello world ]====]