diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-11-08 15:15:37 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-11-09 11:29:32 +0800 |
| commit | bd10e55e72cfd588d3ed1ef6330bc138a3fe8eff (patch) | |
| tree | 058f5cededdbef0c5152a06dcb10da96f5895c8a | |
| parent | b9b1cf94e1324e344df6f7204c8d479329c56718 (diff) | |
| download | yuescript-bd10e55e72cfd588d3ed1ef6330bc138a3fe8eff.tar.gz yuescript-bd10e55e72cfd588d3ed1ef6330bc138a3fe8eff.tar.bz2 yuescript-bd10e55e72cfd588d3ed1ef6330bc138a3fe8eff.zip | |
added indentation error messages.
Diffstat (limited to '')
| -rw-r--r-- | spec/inputs/try-catch.yue | 4 | ||||
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 2 | ||||
| -rw-r--r-- | src/yuescript/yue_parser.cpp | 9 | ||||
| -rw-r--r-- | src/yuescript/yue_parser.h | 1 |
4 files changed, 11 insertions, 5 deletions
diff --git a/spec/inputs/try-catch.yue b/spec/inputs/try-catch.yue index f5cb97e..7287c33 100644 --- a/spec/inputs/try-catch.yue +++ b/spec/inputs/try-catch.yue | |||
| @@ -34,8 +34,8 @@ catch err | |||
| 34 | 34 | ||
| 35 | if try func 1 | 35 | if try func 1 |
| 36 | catch err | 36 | catch err |
| 37 | print err | 37 | print err |
| 38 | print "OK" | 38 | print "OK" |
| 39 | 39 | ||
| 40 | do | 40 | do |
| 41 | if success, result = try func "abc", 123 | 41 | if success, result = try func "abc", 123 |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index d0f2dbb..45a9bf6 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -59,7 +59,7 @@ namespace yue { | |||
| 59 | 59 | ||
| 60 | typedef std::list<std::string> str_list; | 60 | typedef std::list<std::string> str_list; |
| 61 | 61 | ||
| 62 | const std::string_view version = "0.15.9"sv; | 62 | const std::string_view version = "0.15.10"sv; |
| 63 | const std::string_view extension = "yue"sv; | 63 | const std::string_view extension = "yue"sv; |
| 64 | 64 | ||
| 65 | class YueCompilerImpl { | 65 | class YueCompilerImpl { |
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index e4de0b5..e755fb2 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
| @@ -679,10 +679,15 @@ YueParser::YueParser() { | |||
| 679 | advance >> ensure(MultiLineComment >> Space | Comment, PopIndent) | | 679 | advance >> ensure(MultiLineComment >> Space | Comment, PopIndent) | |
| 680 | plain_space) >> and_(Break); | 680 | plain_space) >> and_(Break); |
| 681 | 681 | ||
| 682 | indentation_error = pl::user(not_(PipeOperator), [](const item_t& item) { | ||
| 683 | throw ParserError("unexpected indent", *item.begin, *item.end); | ||
| 684 | return false; | ||
| 685 | }); | ||
| 686 | |||
| 682 | Line = | 687 | Line = |
| 683 | CheckIndent >> Statement | | 688 | CheckIndent >> Statement | |
| 684 | Advance >> ensure(Space >> and_(PipeOperator) >> Statement, PopIndent) | | 689 | empty_line_break | |
| 685 | empty_line_break; | 690 | Advance >> ensure(Space >> (indentation_error | Statement), PopIndent); |
| 686 | Block = Seperator >> Line >> *(+Break >> Line); | 691 | Block = Seperator >> Line >> *(+Break >> Line); |
| 687 | 692 | ||
| 688 | Shebang = expr("#!") >> *(not_(Stop) >> Any); | 693 | Shebang = expr("#!") >> *(not_(Stop) >> Any); |
diff --git a/src/yuescript/yue_parser.h b/src/yuescript/yue_parser.h index 9e2a621..74281fb 100644 --- a/src/yuescript/yue_parser.h +++ b/src/yuescript/yue_parser.h | |||
| @@ -117,6 +117,7 @@ private: | |||
| 117 | 117 | ||
| 118 | rule empty_block_error; | 118 | rule empty_block_error; |
| 119 | rule leading_spaces_error; | 119 | rule leading_spaces_error; |
| 120 | rule indentation_error; | ||
| 120 | 121 | ||
| 121 | rule num_char; | 122 | rule num_char; |
| 122 | rule num_char_hex; | 123 | rule num_char_hex; |
