aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/qparser/expression_parser.messages29
-rw-r--r--test/syntax_error.ml42
2 files changed, 48 insertions, 23 deletions
diff --git a/lib/qparser/expression_parser.messages b/lib/qparser/expression_parser.messages
index 4f99943..23d0dc3 100644
--- a/lib/qparser/expression_parser.messages
+++ b/lib/qparser/expression_parser.messages
@@ -138,7 +138,7 @@ main: LOCATION_START EOL IF IDENT COLUMN EOL IDENT AMPERSAND LOCATION_END
## In state 146, spurious reduction of production list(line_statement) -> line_statement list(line_statement)
##
-Unclosed `IF` block.
+Unclosed `IF` block. Another block ends before the `END` instruction.
main: LOCATION_START EOL IF IDENT COLUMN EOL ELSE EOL LOCATION_END
##
@@ -251,27 +251,8 @@ main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF INTEGER SET
The `ELIF` expression does not end properly. A `:` is expected before any instruction.
main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF IDENT COLUMN EOL IDENT AMPERSAND LOCATION_END
-##
-## Ends in an error in state: 173.
-##
-## list(elif) -> elif . list(elif) [ END ELSE ]
-##
-## The known suffix of the stack is as follows:
-## elif
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 117, spurious reduction of production nonempty_list(AMPERSAND) -> AMPERSAND
-## In state 149, spurious reduction of production list(EOL) ->
-## In state 150, spurious reduction of production line_statement -> instruction nonempty_list(AMPERSAND) list(EOL)
-## In state 145, spurious reduction of production list(line_statement) ->
-## In state 146, spurious reduction of production list(line_statement) -> line_statement list(line_statement)
-## In state 160, spurious reduction of production elif -> ELIF expression COLUMN nonempty_list(EOL) list(line_statement)
-##
-Unclosed `ELIF` block.
+Unclosed `ELIF` block. Another block ends before the `END` instruction.
main: EOL STAR
##
@@ -310,4 +291,8 @@ Missing operand
main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF IDENT COLUMN STAR
-Mix between IF block and inline ELIF
+Mix between `IF` block and inline `ELIF`
+
+main: LOCATION_START EOL IF IDENT COLUMN EOL ELSE EOL IDENT AMPERSAND LOCATION_END
+
+Unclosed `ELSE` block. Another block ends before the `END` instruction.
diff --git a/test/syntax_error.ml b/test/syntax_error.ml
index 6c28f0f..08de384 100644
--- a/test/syntax_error.ml
+++ b/test/syntax_error.ml
@@ -116,7 +116,46 @@ let inline_elif () =
{
level = Error;
loc = _position;
- message = "Mix between IF block and inline ELIF";
+ message = "Mix between `IF` block and inline `ELIF`";
+ }
+
+let unclosed_block () =
+ _test_instruction {|
+if $ARGS[0] = 'arg':
+ act'action':
+end|}
+ {
+ level = Error;
+ loc = _position;
+ message =
+ "Unclosed `IF` block. Another block ends before the `END` instruction.";
+ };
+
+ _test_instruction
+ {|
+IF 1:
+ELSE
+ 0
+ |}
+ {
+ level = Error;
+ loc = _position;
+ message =
+ "Unclosed `ELSE` block. Another block ends before the `END` \
+ instruction.";
+ };
+ _test_instruction
+ {|
+IF 1:
+ELSEIF 0:
+ 0
+ |}
+ {
+ level = Error;
+ loc = _position;
+ message =
+ "Unclosed `ELIF` block. Another block ends before the `END` \
+ instruction.";
}
let test =
@@ -132,4 +171,5 @@ let test =
Alcotest.test_case "Missing operand" `Quick missing_operand;
Alcotest.test_case "Unknown function" `Quick unknow_function;
Alcotest.test_case "Inline elif" `Quick inline_elif;
+ Alcotest.test_case "Unclosed block" `Quick unclosed_block;
] )