diff options
| author | Li Jin <dragon-fly@qq.com> | 2023-12-11 09:40:29 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2023-12-11 09:40:29 +0800 |
| commit | a6dc9009035113858acac32cd083983c42bc9de6 (patch) | |
| tree | eeaeac744046a3e07c0ff0d6bb6f6ffc79374f36 | |
| parent | 514b9f97febe8920a78d6078b092fe84b859a963 (diff) | |
| download | yuescript-a6dc9009035113858acac32cd083983c42bc9de6.tar.gz yuescript-a6dc9009035113858acac32cd083983c42bc9de6.tar.bz2 yuescript-a6dc9009035113858acac32cd083983c42bc9de6.zip | |
fix empty block ends with eof issue.
Diffstat (limited to '')
| -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); |
