diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-24 08:56:46 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-24 08:56:46 +0800 |
| commit | c2a34e380b7ff57b071f8081e1cac589eab664d3 (patch) | |
| tree | 5f83de9255913d96dc4e5de12f9e49ff742e5daf /src | |
| parent | 50221313c577a2e9f01a3a6b12c8e54594f13126 (diff) | |
| download | yuescript-c2a34e380b7ff57b071f8081e1cac589eab664d3.tar.gz yuescript-c2a34e380b7ff57b071f8081e1cac589eab664d3.tar.bz2 yuescript-c2a34e380b7ff57b071f8081e1cac589eab664d3.zip | |
Fixed issue #245.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 2 | ||||
| -rw-r--r-- | src/yuescript/yue_parser.cpp | 17 | ||||
| -rw-r--r-- | src/yuescript/yue_parser.h | 1 |
3 files changed, 9 insertions, 11 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 840ef3e..7624d81 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -78,7 +78,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 78 | "close"s // Lua 5.4 | 78 | "close"s // Lua 5.4 |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | const std::string_view version = "0.33.2"sv; | 81 | const std::string_view version = "0.33.3"sv; |
| 82 | const std::string_view extension = "yue"sv; | 82 | const std::string_view extension = "yue"sv; |
| 83 | 83 | ||
| 84 | class CompileError : public std::logic_error { | 84 | class CompileError : public std::logic_error { |
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index c5c3ef7..421acee 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
| @@ -905,21 +905,18 @@ YueParser::YueParser() { | |||
| 905 | white >> '}' | 905 | white >> '}' |
| 906 | ); | 906 | ); |
| 907 | 907 | ||
| 908 | table_block_inner = Seperator >> key_value_line >> *(line_break >> key_value_line); | 908 | table_block_inner = Seperator >> key_value_line >> *(+plain_space_break >> key_value_line); |
| 909 | TableBlock = +plain_space_break >> advance_match >> ensure(table_block_inner, pop_indent); | 909 | TableBlock = +plain_space_break >> advance_match >> ensure(table_block_inner, pop_indent); |
| 910 | TableBlockIndent = ('*' | '-' >> space_one) >> Seperator >> disable_arg_table_block_rule( | 910 | TableBlockIndent = ('*' | '-' >> space_one) >> Seperator >> disable_arg_table_block_rule( |
| 911 | space >> key_value_list >> -(space >> ',') >> | 911 | space >> key_value_list >> -(space >> ',') >> |
| 912 | -(plain_space_break >> advance_match >> space >> ensure(key_value_list >> -(space >> ',') >> *(plain_space_break >> key_value_line), pop_indent))); | 912 | -(plain_space_break >> advance_match >> space >> ensure(key_value_list >> -(space >> ',') >> *(plain_space_break >> key_value_line), pop_indent))); |
| 913 | 913 | ||
| 914 | ClassMemberList = Seperator >> key_value >> *(space >> ',' >> space >> key_value); | 914 | ClassMemberList = Seperator >> key_value >> *(space >> ',' >> space >> key_value); |
| 915 | class_line = -EmptyLine >> ( | 915 | class_line = -yue_comment_block >> check_indent_match >> space >> (ClassMemberList | Statement) >> -(space >> ',') >> space; |
| 916 | YueComment | | ||
| 917 | check_indent_match >> space >> (ClassMemberList | Statement) >> -(space >> ',') | ||
| 918 | ) >> space; | ||
| 919 | ClassBlock = | 916 | ClassBlock = |
| 920 | +plain_space_break >> | 917 | +plain_space_break >> |
| 921 | advance_match >> Seperator >> | 918 | advance_match >> Seperator >> |
| 922 | class_line >> *(plain_space_break >> class_line) >> | 919 | class_line >> *(+plain_space_break >> class_line) >> |
| 923 | pop_indent; | 920 | pop_indent; |
| 924 | 921 | ||
| 925 | ClassDecl = | 922 | ClassDecl = |
| @@ -1010,20 +1007,20 @@ YueParser::YueParser() { | |||
| 1010 | MetaNormalPairDef = MetaNormalPair >> destruct_def; | 1007 | MetaNormalPairDef = MetaNormalPair >> destruct_def; |
| 1011 | NormalDef = Exp >> Seperator >> destruct_def; | 1008 | NormalDef = Exp >> Seperator >> destruct_def; |
| 1012 | 1009 | ||
| 1010 | yue_comment_block = -EmptyLine >> YueComment >> *(line_break >> -EmptyLine >> YueComment) >> line_break; | ||
| 1011 | |||
| 1013 | key_value = | 1012 | key_value = |
| 1014 | VariablePair | | 1013 | VariablePair | |
| 1015 | NormalPair | | 1014 | NormalPair | |
| 1016 | MetaVariablePair | | 1015 | MetaVariablePair | |
| 1017 | MetaNormalPair; | 1016 | MetaNormalPair; |
| 1018 | key_value_list = key_value >> *(space >> ',' >> space >> key_value); | 1017 | key_value_list = key_value >> *(space >> ',' >> space >> key_value); |
| 1019 | key_value_line = -EmptyLine >> ( | 1018 | key_value_line = -yue_comment_block >> |
| 1020 | YueComment | | ||
| 1021 | check_indent_match >> space >> ( | 1019 | check_indent_match >> space >> ( |
| 1022 | key_value_list >> -(space >> ',') | | 1020 | key_value_list >> -(space >> ',') | |
| 1023 | TableBlockIndent | | 1021 | TableBlockIndent | |
| 1024 | ('*' | '-' >> space_one) >> space >> (SpreadExp | Exp | TableBlock) | 1022 | ('*' | '-' >> space_one) >> space >> (SpreadExp | Exp | TableBlock) |
| 1025 | ) >> space | 1023 | ) >> space; |
| 1026 | ); | ||
| 1027 | 1024 | ||
| 1028 | fn_arg_def_list = FnArgDef >> *(space >> ',' >> space >> FnArgDef); | 1025 | fn_arg_def_list = FnArgDef >> *(space >> ',' >> space >> FnArgDef); |
| 1029 | 1026 | ||
diff --git a/src/yuescript/yue_parser.h b/src/yuescript/yue_parser.h index 12b19ac..07153fb 100644 --- a/src/yuescript/yue_parser.h +++ b/src/yuescript/yue_parser.h | |||
| @@ -318,6 +318,7 @@ private: | |||
| 318 | NONE_AST_RULE(comment_line); | 318 | NONE_AST_RULE(comment_line); |
| 319 | NONE_AST_RULE(yue_line_comment); | 319 | NONE_AST_RULE(yue_line_comment); |
| 320 | NONE_AST_RULE(yue_multiline_comment); | 320 | NONE_AST_RULE(yue_multiline_comment); |
| 321 | NONE_AST_RULE(yue_comment_block); | ||
| 321 | NONE_AST_RULE(line); | 322 | NONE_AST_RULE(line); |
| 322 | NONE_AST_RULE(shebang); | 323 | NONE_AST_RULE(shebang); |
| 323 | NONE_AST_RULE(is_lax); | 324 | NONE_AST_RULE(is_lax); |
