diff options
author | Li Jin <dragon-fly@qq.com> | 2023-01-22 07:15:02 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-01-22 07:15:02 +0800 |
commit | 3f881ba631a935b6d5ac2e4fc3fec9f08e498542 (patch) | |
tree | 39699f72f9258341a2890efd48741c0072060ba2 | |
parent | 89b606df6303a44f121be8ff0f4458c97f93d9df (diff) | |
download | yuescript-3f881ba631a935b6d5ac2e4fc3fec9f08e498542.tar.gz yuescript-3f881ba631a935b6d5ac2e4fc3fec9f08e498542.tar.bz2 yuescript-3f881ba631a935b6d5ac2e4fc3fec9f08e498542.zip |
fixing issue #120 again.
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 2 | ||||
-rw-r--r-- | src/yuescript/yue_parser.cpp | 7 | ||||
-rw-r--r-- | src/yuescript/yue_parser.h | 1 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 6fd43d0..5443c61 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
@@ -71,7 +71,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
71 | "close"s // Lua 5.4 | 71 | "close"s // Lua 5.4 |
72 | }; | 72 | }; |
73 | 73 | ||
74 | const std::string_view version = "0.15.22"sv; | 74 | const std::string_view version = "0.15.23"sv; |
75 | const std::string_view extension = "yue"sv; | 75 | const std::string_view extension = "yue"sv; |
76 | 76 | ||
77 | class YueCompilerImpl { | 77 | class YueCompilerImpl { |
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 4532d21..2fc1333 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -387,7 +387,7 @@ YueParser::YueParser() { | |||
387 | 387 | ||
388 | Comprehension = '[' >> not_('[') >> space >> Exp >> space >> CompInner >> space >> ']'; | 388 | Comprehension = '[' >> not_('[') >> space >> Exp >> space >> CompInner >> space >> ']'; |
389 | CompValue = ',' >> space >> Exp; | 389 | CompValue = ',' >> space >> Exp; |
390 | TblComprehension = '{' >> space >> Exp >> space >> -(CompValue >> space) >> CompInner >> space >> '}'; | 390 | TblComprehension = '{' >> (space >> Exp >> space >> -(CompValue >> space) >> CompInner >> space >> '}' | braces_expression_error); |
391 | 391 | ||
392 | CompInner = Seperator >> (CompForEach | CompFor) >> *(space >> comp_clause); | 392 | CompInner = Seperator >> (CompForEach | CompFor) >> *(space >> comp_clause); |
393 | StarExp = '*' >> space >> Exp; | 393 | StarExp = '*' >> space >> Exp; |
@@ -736,6 +736,11 @@ YueParser::YueParser() { | |||
736 | 736 | ||
737 | ConstValue = (expr("nil") | "true" | "false") >> not_alpha_num; | 737 | ConstValue = (expr("nil") | "true" | "false") >> not_alpha_num; |
738 | 738 | ||
739 | braces_expression_error = pl::user("{", [](const item_t& item) { | ||
740 | throw ParserError("invalid brace expression", *item.begin, *item.end); | ||
741 | return false; | ||
742 | }); | ||
743 | |||
739 | SimpleValue = | 744 | SimpleValue = |
740 | TableLit | ConstValue | If | Switch | Try | With | | 745 | TableLit | ConstValue | If | Switch | Try | With | |
741 | ClassDecl | ForEach | For | While | Do | | 746 | ClassDecl | ForEach | For | While | Do | |
diff --git a/src/yuescript/yue_parser.h b/src/yuescript/yue_parser.h index da25d3d..c8fc17e 100644 --- a/src/yuescript/yue_parser.h +++ b/src/yuescript/yue_parser.h | |||
@@ -118,6 +118,7 @@ private: | |||
118 | rule empty_block_error; | 118 | rule empty_block_error; |
119 | rule leading_spaces_error; | 119 | rule leading_spaces_error; |
120 | rule indentation_error; | 120 | rule indentation_error; |
121 | rule braces_expression_error; | ||
121 | 122 | ||
122 | rule num_char; | 123 | rule num_char; |
123 | rule num_char_hex; | 124 | rule num_char_hex; |