diff options
Diffstat (limited to '')
| -rw-r--r-- | src/MoonP/moon_compiler.cpp | 2 | ||||
| -rw-r--r-- | src/MoonP/moon_parser.cpp | 21 | ||||
| -rw-r--r-- | src/MoonP/moon_parser.h | 1 |
3 files changed, 13 insertions, 11 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index cac4ad0..2f16fff 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp | |||
| @@ -49,7 +49,7 @@ inline std::string s(std::string_view sv) { | |||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | const std::string_view version() { | 51 | const std::string_view version() { |
| 52 | return "0.4.9"sv; | 52 | return "0.4.10"sv; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | // name of table stored in lua registry | 55 | // name of table stored in lua registry |
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index d30d6b5..a13a779 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp | |||
| @@ -43,7 +43,8 @@ MoonParser::MoonParser() { | |||
| 43 | multi_line_close = expr("]]"); | 43 | multi_line_close = expr("]]"); |
| 44 | multi_line_content = *(not_(multi_line_close) >> Any); | 44 | multi_line_content = *(not_(multi_line_close) >> Any); |
| 45 | MultiLineComment = multi_line_open >> multi_line_content >> multi_line_close; | 45 | MultiLineComment = multi_line_open >> multi_line_content >> multi_line_close; |
| 46 | space_one = set(" \t") | MultiLineComment; | 46 | EscapeNewLine = expr('\\') >> *(set(" \t") | MultiLineComment) >> -Comment >> Break; |
| 47 | space_one = set(" \t") | and_(set("-\\")) >> (MultiLineComment | EscapeNewLine); | ||
| 47 | Space = *space_one >> -Comment; | 48 | Space = *space_one >> -Comment; |
| 48 | SpaceBreak = Space >> Break; | 49 | SpaceBreak = Space >> Break; |
| 49 | White = Space >> *(Break >> Space); | 50 | White = Space >> *(Break >> Space); |
| @@ -241,8 +242,8 @@ MoonParser::MoonParser() { | |||
| 241 | While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; | 242 | While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; |
| 242 | Repeat = key("repeat") >> Body >> Break >> *EmptyLine >> CheckIndent >> key("until") >> Exp; | 243 | Repeat = key("repeat") >> Body >> Break >> *EmptyLine >> CheckIndent >> key("until") >> Exp; |
| 243 | 244 | ||
| 244 | for_step_value = sym(',') >> White >> Exp; | 245 | for_step_value = sym(',') >> Exp; |
| 245 | for_args = Space >> Variable >> sym('=') >> Exp >> sym(',') >> White >> Exp >> -for_step_value; | 246 | for_args = Space >> Variable >> sym('=') >> Exp >> sym(',') >> Exp >> -for_step_value; |
| 246 | 247 | ||
| 247 | For = key("for") >> DisableDo >> | 248 | For = key("for") >> DisableDo >> |
| 248 | ensure(for_args, PopDo) >> | 249 | ensure(for_args, PopDo) >> |
| @@ -250,7 +251,7 @@ MoonParser::MoonParser() { | |||
| 250 | 251 | ||
| 251 | for_in = star_exp | ExpList; | 252 | for_in = star_exp | ExpList; |
| 252 | 253 | ||
| 253 | ForEach = key("for") >> AssignableNameList >> White >> key("in") >> | 254 | ForEach = key("for") >> AssignableNameList >> key("in") >> |
| 254 | DisableDo >> ensure(for_in, PopDo) >> | 255 | DisableDo >> ensure(for_in, PopDo) >> |
| 255 | -key("do") >> Body; | 256 | -key("do") >> Body; |
| 256 | 257 | ||
| @@ -278,10 +279,10 @@ MoonParser::MoonParser() { | |||
| 278 | CompInner = Seperator >> (CompForEach | CompFor) >> *CompClause; | 279 | CompInner = Seperator >> (CompForEach | CompFor) >> *CompClause; |
| 279 | star_exp = sym('*') >> Exp; | 280 | star_exp = sym('*') >> Exp; |
| 280 | CompForEach = key("for") >> AssignableNameList >> key("in") >> (star_exp | Exp); | 281 | CompForEach = key("for") >> AssignableNameList >> key("in") >> (star_exp | Exp); |
| 281 | CompFor = key("for") >> Space >> Variable >> sym('=') >> Exp >> sym(',') >> White >> Exp >> -for_step_value; | 282 | CompFor = key("for") >> Space >> Variable >> sym('=') >> Exp >> sym(',') >> Exp >> -for_step_value; |
| 282 | CompClause = CompFor | CompForEach | key("when") >> Exp; | 283 | CompClause = CompFor | CompForEach | key("when") >> Exp; |
| 283 | 284 | ||
| 284 | Assign = sym('=') >> Seperator >> (With | If | Switch | TableBlock | Exp >> *(White >> set(",;") >> White >> Exp)); | 285 | Assign = sym('=') >> Seperator >> (With | If | Switch | TableBlock | Exp >> *(Space >> set(",;") >> Exp)); |
| 285 | 286 | ||
| 286 | update_op = | 287 | update_op = |
| 287 | expr("..") | | 288 | expr("..") | |
| @@ -514,15 +515,15 @@ MoonParser::MoonParser() { | |||
| 514 | MacroLit = -macro_args_def >> Space >> expr("->") >> Body; | 515 | MacroLit = -macro_args_def >> Space >> expr("->") >> Body; |
| 515 | Macro = key("macro") >> Space >> macro_type >> Space >> Name >> sym('=') >> MacroLit; | 516 | Macro = key("macro") >> Space >> macro_type >> Space >> Name >> sym('=') >> MacroLit; |
| 516 | 517 | ||
| 517 | NameList = Seperator >> Space >> Variable >> *(sym(',') >> White >> Variable); | 518 | NameList = Seperator >> Space >> Variable >> *(sym(',') >> Space >> Variable); |
| 518 | NameOrDestructure = Space >> Variable | TableLit; | 519 | NameOrDestructure = Space >> Variable | TableLit; |
| 519 | AssignableNameList = Seperator >> NameOrDestructure >> *(sym(',') >> White >> NameOrDestructure); | 520 | AssignableNameList = Seperator >> NameOrDestructure >> *(sym(',') >> NameOrDestructure); |
| 520 | 521 | ||
| 521 | fn_arrow_back = expr('<') >> set("-="); | 522 | fn_arrow_back = expr('<') >> set("-="); |
| 522 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; | 523 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; |
| 523 | 524 | ||
| 524 | ExpList = Seperator >> Exp >> *(White >> expr(',') >> White >> Exp); | 525 | ExpList = Seperator >> Exp >> *(sym(',') >> Exp); |
| 525 | ExpListLow = Seperator >> Exp >> *(White >> set(",;") >> White >> Exp); | 526 | ExpListLow = Seperator >> Exp >> *(Space >> set(",;") >> Exp); |
| 526 | 527 | ||
| 527 | ArgLine = CheckIndent >> Exp >> *(sym(',') >> Exp); | 528 | ArgLine = CheckIndent >> Exp >> *(sym(',') >> Exp); |
| 528 | ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; | 529 | ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; |
diff --git a/src/MoonP/moon_parser.h b/src/MoonP/moon_parser.h index d7fa24b..c6a03f8 100644 --- a/src/MoonP/moon_parser.h +++ b/src/MoonP/moon_parser.h | |||
| @@ -111,6 +111,7 @@ private: | |||
| 111 | rule multi_line_content; | 111 | rule multi_line_content; |
| 112 | rule MultiLineComment; | 112 | rule MultiLineComment; |
| 113 | rule Indent; | 113 | rule Indent; |
| 114 | rule EscapeNewLine; | ||
| 114 | rule space_one; | 115 | rule space_one; |
| 115 | rule Space; | 116 | rule Space; |
| 116 | rule SpaceBreak; | 117 | rule SpaceBreak; |
