diff options
Diffstat (limited to '')
-rwxr-xr-x | src/yuescript/yue_parser.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 3d12190..8325366 100755 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -29,7 +29,8 @@ std::unordered_set<std::string> Keywords = { | |||
29 | "until", "while", // Lua keywords | 29 | "until", "while", // Lua keywords |
30 | "as", "class", "continue", "export", "extends", | 30 | "as", "class", "continue", "export", "extends", |
31 | "from", "global", "import", "is", "macro", | 31 | "from", "global", "import", "is", "macro", |
32 | "switch", "unless", "using", "when", "with" // Yue keywords | 32 | "switch", "try", "unless", "using", "when", |
33 | "with" // Yue keywords | ||
33 | }; | 34 | }; |
34 | 35 | ||
35 | YueParser::YueParser() { | 36 | YueParser::YueParser() { |
@@ -229,8 +230,8 @@ YueParser::YueParser() { | |||
229 | SwitchBlock = *EmptyLine >> | 230 | SwitchBlock = *EmptyLine >> |
230 | Advance >> Seperator >> | 231 | Advance >> Seperator >> |
231 | SwitchCase >> | 232 | SwitchCase >> |
232 | *(+SpaceBreak >> SwitchCase) >> | 233 | *(Break >> *EmptyLine >> CheckIndent >> SwitchCase) >> |
233 | -(+SpaceBreak >> SwitchElse) >> | 234 | -(Break >> *EmptyLine >> CheckIndent >> SwitchElse) >> |
234 | PopIndent; | 235 | PopIndent; |
235 | 236 | ||
236 | Switch = Space >> key("switch") >> disable_do(Exp) >> -(Space >> key("do")) | 237 | Switch = Space >> key("switch") >> disable_do(Exp) >> -(Space >> key("do")) |
@@ -299,6 +300,9 @@ YueParser::YueParser() { | |||
299 | return true; | 300 | return true; |
300 | }); | 301 | }); |
301 | 302 | ||
303 | catch_block = Break >> *EmptyLine >> CheckIndent >> Space >> key("catch") >> Space >> Variable >> InBlock; | ||
304 | Try = Space >> key("try") >> (InBlock | Exp) >> -catch_block; | ||
305 | |||
302 | Comprehension = sym('[') >> Exp >> Space >> CompInner >> sym(']'); | 306 | Comprehension = sym('[') >> Exp >> Space >> CompInner >> sym(']'); |
303 | comp_value = sym(',') >> Exp; | 307 | comp_value = sym(',') >> Exp; |
304 | TblComprehension = sym('{') >> Exp >> -comp_value >> Space >> CompInner >> sym('}'); | 308 | TblComprehension = sym('{') >> Exp >> -comp_value >> Space >> CompInner >> sym('}'); |
@@ -609,7 +613,7 @@ YueParser::YueParser() { | |||
609 | const_value = (expr("nil") | expr("true") | expr("false")) >> not_(AlphaNum); | 613 | const_value = (expr("nil") | expr("true") | expr("false")) >> not_(AlphaNum); |
610 | 614 | ||
611 | SimpleValue = Space >> (const_value | | 615 | SimpleValue = Space >> (const_value | |
612 | If | Switch | With | ClassDecl | ForEach | For | While | Do | | 616 | If | Switch | Try | With | ClassDecl | ForEach | For | While | Do | |
613 | unary_value | TblComprehension | TableLit | Comprehension | | 617 | unary_value | TblComprehension | TableLit | Comprehension | |
614 | FunLit | Num); | 618 | FunLit | Num); |
615 | 619 | ||