diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-06-03 23:14:45 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-06-03 23:14:45 +0800 |
| commit | 8e546a5d26a6a19192caa4b56f3c0348e67bde2b (patch) | |
| tree | 25d0115421fdb950da96c209630c4b4a5fae5ff8 | |
| parent | c06dde519a8da2be72bdf5a5d450d637f388ae83 (diff) | |
| download | yuescript-8e546a5d26a6a19192caa4b56f3c0348e67bde2b.tar.gz yuescript-8e546a5d26a6a19192caa4b56f3c0348e67bde2b.tar.bz2 yuescript-8e546a5d26a6a19192caa4b56f3c0348e67bde2b.zip | |
fix issue #104.
| -rw-r--r-- | spec/inputs/string.yue | 2 | ||||
| -rw-r--r-- | spec/outputs/string.lua | 1 | ||||
| -rwxr-xr-x | src/yuescript/yue_compiler.cpp | 2 | ||||
| -rwxr-xr-x | src/yuescript/yue_parser.cpp | 10 |
4 files changed, 9 insertions, 6 deletions
diff --git a/spec/inputs/string.yue b/spec/inputs/string.yue index e21ae84..201e60d 100644 --- a/spec/inputs/string.yue +++ b/spec/inputs/string.yue | |||
| @@ -33,6 +33,8 @@ nil | |||
| 33 | Fail to compile | 33 | Fail to compile |
| 34 | ]] | 34 | ]] |
| 35 | 35 | ||
| 36 | txt[ [[abc]]] = [["#{i}" for i = 1, 10] for i = 1, 10]] | ||
| 37 | |||
| 36 | oo = "" | 38 | oo = "" |
| 37 | 39 | ||
| 38 | x = "\\" | 40 | x = "\\" |
diff --git a/spec/outputs/string.lua b/spec/outputs/string.lua index 84b6700..87ecf2c 100644 --- a/spec/outputs/string.lua +++ b/spec/outputs/string.lua | |||
| @@ -17,6 +17,7 @@ local txt = [[ | |||
| 17 | nil | 17 | nil |
| 18 | Fail to compile | 18 | Fail to compile |
| 19 | ]] | 19 | ]] |
| 20 | txt[ [[abc]]] = [["#{i}" for i = 1, 10] for i = 1, 10]] | ||
| 20 | local oo = "" | 21 | local oo = "" |
| 21 | local x = "\\" | 22 | local x = "\\" |
| 22 | x = "a\\b" | 23 | x = "a\\b" |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index b9b51bf..d270455 100755 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -56,7 +56,7 @@ using namespace parserlib; | |||
| 56 | 56 | ||
| 57 | typedef std::list<std::string> str_list; | 57 | typedef std::list<std::string> str_list; |
| 58 | 58 | ||
| 59 | const std::string_view version = "0.10.25"sv; | 59 | const std::string_view version = "0.11.0"sv; |
| 60 | const std::string_view extension = "yue"sv; | 60 | const std::string_view extension = "yue"sv; |
| 61 | 61 | ||
| 62 | class YueCompilerImpl { | 62 | class YueCompilerImpl { |
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index ef414d4..54dd174 100755 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
| @@ -305,7 +305,7 @@ YueParser::YueParser() { | |||
| 305 | catch_block = Break >> *EmptyLine >> CheckIndent >> Space >> key("catch") >> Space >> Variable >> InBlock; | 305 | catch_block = Break >> *EmptyLine >> CheckIndent >> Space >> key("catch") >> Space >> Variable >> InBlock; |
| 306 | Try = Space >> key("try") >> (InBlock | Exp) >> -catch_block; | 306 | Try = Space >> key("try") >> (InBlock | Exp) >> -catch_block; |
| 307 | 307 | ||
| 308 | Comprehension = sym('[') >> Exp >> Space >> CompInner >> sym(']'); | 308 | Comprehension = sym('[') >> not_('[') >> Exp >> Space >> CompInner >> sym(']'); |
| 309 | comp_value = sym(',') >> Exp; | 309 | comp_value = sym(',') >> Exp; |
| 310 | TblComprehension = sym('{') >> Exp >> -comp_value >> Space >> CompInner >> sym('}'); | 310 | TblComprehension = sym('{') >> Exp >> -comp_value >> Space >> CompInner >> sym('}'); |
| 311 | 311 | ||
| @@ -446,7 +446,7 @@ YueParser::YueParser() { | |||
| 446 | chain_with_colon = +ChainItem >> -ColonChain; | 446 | chain_with_colon = +ChainItem >> -ColonChain; |
| 447 | ChainItems = chain_with_colon | ColonChain; | 447 | ChainItems = chain_with_colon | ColonChain; |
| 448 | 448 | ||
| 449 | Index = symx('[') >> Exp >> sym(']'); | 449 | Index = symx('[') >> not_('[') >> Exp >> sym(']'); |
| 450 | ChainItem = Invoke >> -existential_op | DotChainItem >> -existential_op | Slice | Index >> -existential_op; | 450 | ChainItem = Invoke >> -existential_op | DotChainItem >> -existential_op | Slice | Index >> -existential_op; |
| 451 | DotChainItem = symx('.') >> (Name >> not_('#') | Metatable | Metamethod); | 451 | DotChainItem = symx('.') >> (Name >> not_('#') | Metatable | Metamethod); |
| 452 | ColonChainItem = (expr('\\') | expr("::")) >> ((LuaKeyword | Name) >> not_('#') | Metamethod); | 452 | ColonChainItem = (expr('\\') | expr("::")) >> ((LuaKeyword | Name) >> not_('#') | Metamethod); |
| @@ -455,7 +455,7 @@ YueParser::YueParser() { | |||
| 455 | 455 | ||
| 456 | default_value = true_(); | 456 | default_value = true_(); |
| 457 | Slice = | 457 | Slice = |
| 458 | symx('[') >> | 458 | symx('[') >> not_('[') >> |
| 459 | (Exp | default_value) >> | 459 | (Exp | default_value) >> |
| 460 | sym(',') >> | 460 | sym(',') >> |
| 461 | (Exp | default_value) >> | 461 | (Exp | default_value) >> |
| @@ -537,7 +537,7 @@ YueParser::YueParser() { | |||
| 537 | 537 | ||
| 538 | normal_pair = ( | 538 | normal_pair = ( |
| 539 | KeyName | | 539 | KeyName | |
| 540 | sym('[') >> Exp >> sym(']') | | 540 | sym('[') >> not_('[') >> Exp >> sym(']') | |
| 541 | Space >> DoubleString | | 541 | Space >> DoubleString | |
| 542 | Space >> SingleString | | 542 | Space >> SingleString | |
| 543 | Space >> LuaString | 543 | Space >> LuaString |
| @@ -549,7 +549,7 @@ YueParser::YueParser() { | |||
| 549 | 549 | ||
| 550 | meta_variable_pair = sym(':') >> Variable >> expr('#'); | 550 | meta_variable_pair = sym(':') >> Variable >> expr('#'); |
| 551 | 551 | ||
| 552 | meta_normal_pair = Space >> -(Name | symx('[') >> Exp >> sym(']')) >> expr("#:") >> | 552 | meta_normal_pair = Space >> -(Name | symx('[') >> not_('[') >> Exp >> sym(']')) >> expr("#:") >> |
| 553 | (Exp | TableBlock | +(SpaceBreak) >> Exp); | 553 | (Exp | TableBlock | +(SpaceBreak) >> Exp); |
| 554 | 554 | ||
| 555 | meta_default_pair = (sym(':') >> Variable >> expr('#') >> Seperator | Space >> -Name >> expr("#:") >> Seperator >> Exp) >> sym('=') >> Exp; | 555 | meta_default_pair = (sym(':') >> Variable >> expr('#') >> Seperator | Space >> -Name >> expr("#:") >> Seperator >> Exp) >> sym('=') >> Exp; |
