diff options
-rw-r--r-- | spec/inputs/syntax.yue | 18 | ||||
-rw-r--r-- | spec/outputs/syntax.lua | 16 | ||||
-rw-r--r-- | src/yuescript/yue_parser.cpp | 2 |
3 files changed, 35 insertions, 1 deletions
diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue index d60a145..271f43f 100644 --- a/spec/inputs/syntax.yue +++ b/spec/inputs/syntax.yue | |||
@@ -460,5 +460,23 @@ do | |||
460 | ) | 460 | ) |
461 | f ! | 461 | f ! |
462 | 462 | ||
463 | do | ||
464 | if cond | ||
465 | -- | ||
466 | else | ||
467 | -- | ||
468 | |||
469 | switch cond | ||
470 | when 1 | ||
471 | -- | ||
472 | when 2 | ||
473 | -- | ||
474 | else | ||
475 | -- | ||
476 | |||
477 | f1 = -> -- | ||
478 | f2 = -> | ||
479 | -- | ||
480 | |||
463 | nil | 481 | nil |
464 | 482 | ||
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 2afadbb..20b8469 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua | |||
@@ -412,4 +412,20 @@ do | |||
412 | f(a, b) | 412 | f(a, b) |
413 | f() | 413 | f() |
414 | end | 414 | end |
415 | do | ||
416 | if cond then | ||
417 | else | ||
418 | end | ||
419 | do | ||
420 | local _exp_0 = cond | ||
421 | if 1 == _exp_0 then | ||
422 | elseif 2 == _exp_0 then | ||
423 | else | ||
424 | end | ||
425 | end | ||
426 | local f1 | ||
427 | f1 = function() end | ||
428 | local f2 | ||
429 | f2 = function() end | ||
430 | end | ||
415 | return nil | 431 | return nil |
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 5b97a25..4b865f5 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -958,7 +958,7 @@ YueParser::YueParser() { | |||
958 | check_indent >> (multi_line_comment >> space | comment) | | 958 | check_indent >> (multi_line_comment >> space | comment) | |
959 | advance >> ensure(multi_line_comment >> space | comment, pop_indent) | | 959 | advance >> ensure(multi_line_comment >> space | comment, pop_indent) | |
960 | plain_space | 960 | plain_space |
961 | ) >> and_(line_break); | 961 | ) >> and_(stop); |
962 | 962 | ||
963 | indentation_error = pl::user(not_(pipe_operator | eof()), [](const item_t& item) { | 963 | indentation_error = pl::user(not_(pipe_operator | eof()), [](const item_t& item) { |
964 | throw ParserError("unexpected indent"sv, item.begin); | 964 | throw ParserError("unexpected indent"sv, item.begin); |