From a6a65ba26a9d320611abcbfba49fa724edfb4dad Mon Sep 17 00:00:00 2001
From: Li Jin <dragon-fly@qq.com>
Date: Fri, 2 Dec 2022 10:15:09 +0800
Subject: add more num lit specs.

---
 spec/inputs/literals.yue       |  3 +++
 spec/outputs/literals.lua      |  3 +++
 src/yuescript/yue_compiler.cpp |  2 +-
 src/yuescript/yue_parser.cpp   | 20 +++++++++++---------
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/spec/inputs/literals.yue b/spec/inputs/literals.yue
index 8b81fde..ef8b5f1 100644
--- a/spec/inputs/literals.yue
+++ b/spec/inputs/literals.yue
@@ -10,6 +10,9 @@ _ = {
 	0xfF2323
 	0xabcdef
 	0xABCDEF
+	0x123p-123
+	0xABCP+321
+	0x.1p-111
 
 	.2323
 	.2323e-1
diff --git a/spec/outputs/literals.lua b/spec/outputs/literals.lua
index 4495725..0d4d8b8 100644
--- a/spec/outputs/literals.lua
+++ b/spec/outputs/literals.lua
@@ -8,6 +8,9 @@ local _ = {
 	0xfF2323,
 	0xabcdef,
 	0xABCDEF,
+	0x123p-123,
+	0xABCP+321,
+	0x.1p-111,
 	.2323,
 	.2323e-1,
 	.2323e13434,
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 3e58305..0d674f8 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -60,7 +60,7 @@ namespace yue {
 
 typedef std::list<std::string> str_list;
 
-const std::string_view version = "0.15.17"sv;
+const std::string_view version = "0.15.18"sv;
 const std::string_view extension = "yue"sv;
 
 class YueCompilerImpl {
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 63c9162..acdc343 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -57,16 +57,16 @@ YueParser::YueParser() {
 	num_char_hex = range('0', '9') | range('a', 'f') | range('A', 'F');
 	num_lit = num_char_hex >> *(num_char_hex | expr('_') >> and_(num_char_hex));
 	Num = (
-		"0x." >> +num_lit >> -num_expo_hex
-	) | (
-		"0x" >> +num_lit >> (
-			'.' >> +num_lit >> -num_expo_hex |
-			num_expo_hex |
-			lj_num |
-			true_()
+		"0x" >> (
+			+num_lit >> (
+				'.' >> +num_lit >> -num_expo_hex |
+				num_expo_hex |
+				lj_num |
+				true_()
+			) | (
+				'.' >> +num_lit >> -num_expo_hex
+			)
 		)
-	) | (
-		'.' >> +num_char >> -num_expo
 	) | (
 		+num_char >> (
 			'.' >> +num_char >> -num_expo |
@@ -74,6 +74,8 @@ YueParser::YueParser() {
 			lj_num |
 			true_()
 		)
+	) | (
+		'.' >> +num_char >> -num_expo
 	);
 
 	Cut = false_();
-- 
cgit v1.2.3-55-g6feb