aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChimrod <>2023-10-15 18:23:01 +0200
committerChimrod <>2023-10-15 19:04:36 +0200
commita7e382aa2b31a4ec044bda12155818c22b33d989 (patch)
tree2aa25c8ba2d5653c677ce62c5515cc5c0c98ff6f
parent617d2ee554ccf502c718391aa05b7b72668b83e7 (diff)
New errors reported
-rw-r--r--lib/qparser/expression_parser.messages5
-rw-r--r--test/syntax_error.ml43
2 files changed, 27 insertions, 21 deletions
diff --git a/lib/qparser/expression_parser.messages b/lib/qparser/expression_parser.messages
index a493067..eb13846 100644
--- a/lib/qparser/expression_parser.messages
+++ b/lib/qparser/expression_parser.messages
@@ -302,3 +302,8 @@ main: LOCATION_START EOL SET IDENT DECR INTEGER SET
main: LOCATION_START EOL LET IDENT DECR INTEGER SET
Missing separator between instructions
+
+main: LOCATION_START EOL IF STAR
+main: LOCATION_START EOL IDENT DECR STAR
+
+Missing operand
diff --git a/test/syntax_error.ml b/test/syntax_error.ml
index e9e3fca..fed43a7 100644
--- a/test/syntax_error.ml
+++ b/test/syntax_error.ml
@@ -75,29 +75,18 @@ let act_no_column () =
message = "Invalid `ACT` label. You probably missed a ':'";
}
-let missing_ampersand_1 () =
- _test_instruction "b = 1 a = 2"
- {
- level = Error;
- loc = _position;
- message = "Missing separator between instructions";
- }
-
-let missing_ampersand_2 () =
- _test_instruction "let b = 1 a = 2"
- {
- level = Error;
- loc = _position;
- message = "Missing separator between instructions";
- }
-
-let missing_ampersand_3 () =
- _test_instruction "set b = 1 a = 2"
+let missing_ampersand () =
+ let result =
{
level = Error;
loc = _position;
message = "Missing separator between instructions";
}
+ in
+ let () = _test_instruction "b = 1 a = 2" result
+ and () = _test_instruction "let b = 1 a = 2" result
+ and () = _test_instruction "set b = 1 a = 2" result in
+ ()
let unclose_comment () =
_test_instruction {| ! that's it|}
@@ -107,6 +96,18 @@ let syntax_error () =
_test_instruction {|*clr $ cla|}
{ level = Error; loc = _position; message = "Unexpected character \"\"" }
+let missing_operand () =
+ let result =
+ { level = Error; loc = _position; message = "Missing operand" }
+ in
+ let () = _test_instruction {|if and other: 1|} result
+ and () = _test_instruction {|a = and other: 1|} result in
+ ()
+
+let unknow_function () =
+ _test_instruction "a = ran(1, 2)"
+ { level = Error; loc = _position; message = "Unexpected expression here." }
+
let test =
( "Syntax Errors",
[
@@ -114,9 +115,9 @@ let test =
Alcotest.test_case "elseif" `Quick elseif_no_column;
Alcotest.test_case "(1" `Quick unclosed_paren;
Alcotest.test_case "act 1" `Quick act_no_column;
- Alcotest.test_case "no &" `Quick missing_ampersand_1;
- Alcotest.test_case "no &" `Quick missing_ampersand_2;
- Alcotest.test_case "no &" `Quick missing_ampersand_3;
+ Alcotest.test_case "no &" `Quick missing_ampersand;
Alcotest.test_case "unclose_comment" `Quick unclose_comment;
Alcotest.test_case "Syntax error $" `Quick syntax_error;
+ Alcotest.test_case "Missing operand" `Quick missing_operand;
+ Alcotest.test_case "Unknown function" `Quick unknow_function;
] )