diff options
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
| -rw-r--r-- | src/yuescript/yue_parser.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index cacfebe..a7feb83 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
| @@ -66,6 +66,7 @@ YueParser::YueParser() { | |||
| 66 | space = -(and_(set(" \t-\\")) >> *space_one >> -comment); | 66 | space = -(and_(set(" \t-\\")) >> *space_one >> -comment); |
| 67 | space_break = space >> line_break; | 67 | space_break = space >> line_break; |
| 68 | white = space >> *(line_break >> space); | 68 | white = space >> *(line_break >> space); |
| 69 | plain_white = plain_space >> *(line_break >> plain_space); | ||
| 69 | alpha_num = range('a', 'z') | range('A', 'Z') | range('0', '9') | '_'; | 70 | alpha_num = range('a', 'z') | range('A', 'Z') | range('0', '9') | '_'; |
| 70 | not_alpha_num = not_(alpha_num); | 71 | not_alpha_num = not_(alpha_num); |
| 71 | Name = (range('a', 'z') | range('A', 'Z') | '_') >> *alpha_num >> not_(larger(255)); | 72 | Name = (range('a', 'z') | range('A', 'Z') | '_') >> *alpha_num >> not_(larger(255)); |
| @@ -1109,15 +1110,16 @@ YueParser::YueParser() { | |||
| 1109 | yue_line_comment; | 1110 | yue_line_comment; |
| 1110 | YueComment = | 1111 | YueComment = |
| 1111 | check_indent >> comment_line >> and_(stop) | | 1112 | check_indent >> comment_line >> and_(stop) | |
| 1112 | advance >> ensure(comment_line, pop_indent) >> and_(stop) | | 1113 | advance >> ensure(comment_line, pop_indent) >> and_(stop); |
| 1113 | plain_space >> and_(stop); | 1114 | |
| 1115 | EmptyLine = plain_space >> and_(stop); | ||
| 1114 | 1116 | ||
| 1115 | indentation_error = pl::user(not_(pipe_operator | eof()), [](const item_t& item) { | 1117 | indentation_error = pl::user(not_(pipe_operator | eof()), [](const item_t& item) { |
| 1116 | RaiseError("unexpected indent"sv, item); | 1118 | RaiseError("unexpected indent"sv, item); |
| 1117 | return false; | 1119 | return false; |
| 1118 | }); | 1120 | }); |
| 1119 | 1121 | ||
| 1120 | line = ( | 1122 | line = *(EmptyLine >> line_break) >> ( |
| 1121 | check_indent_match >> space >> Statement | | 1123 | check_indent_match >> space >> Statement | |
| 1122 | YueComment | | 1124 | YueComment | |
| 1123 | advance_match >> ensure(space >> (indentation_error | Statement), pop_indent) | 1125 | advance_match >> ensure(space >> (indentation_error | Statement), pop_indent) |
| @@ -1128,8 +1130,8 @@ YueParser::YueParser() { | |||
| 1128 | }) >> lax_line >> *(line_break >> lax_line) | line >> *(line_break >> line)); | 1130 | }) >> lax_line >> *(line_break >> lax_line) | line >> *(line_break >> line)); |
| 1129 | 1131 | ||
| 1130 | shebang = "#!" >> *(not_(stop) >> any_char); | 1132 | shebang = "#!" >> *(not_(stop) >> any_char); |
| 1131 | BlockEnd = Block >> stop; | 1133 | BlockEnd = Block >> plain_white >> stop; |
| 1132 | File = -shebang >> -Block >> stop; | 1134 | File = -shebang >> -Block >> plain_white >> stop; |
| 1133 | 1135 | ||
| 1134 | lax_line = advance_match >> ensure(*(not_(stop) >> any()), pop_indent) | line >> and_(stop) | check_indent_match >> *(not_(stop) >> any()); | 1136 | lax_line = advance_match >> ensure(*(not_(stop) >> any()), pop_indent) | line >> and_(stop) | check_indent_match >> *(not_(stop) >> any()); |
| 1135 | } | 1137 | } |
