From 736456d9952c1d58008f4ca5755913dfff7a32b8 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Tue, 17 Oct 2023 19:49:48 +0200 Subject: New message for error --- lib/qparser/expression_parser.messages | 4 ++++ test/syntax_error.ml | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/qparser/expression_parser.messages b/lib/qparser/expression_parser.messages index eb13846..4f99943 100644 --- a/lib/qparser/expression_parser.messages +++ b/lib/qparser/expression_parser.messages @@ -307,3 +307,7 @@ main: LOCATION_START EOL IF STAR main: LOCATION_START EOL IDENT DECR STAR Missing operand + +main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF IDENT COLUMN STAR + +Mix between IF block and inline ELIF diff --git a/test/syntax_error.ml b/test/syntax_error.ml index d395dba..6c28f0f 100644 --- a/test/syntax_error.ml +++ b/test/syntax_error.ml @@ -1,4 +1,3 @@ -module Parser = Qparser.Parser.Make (Qsp_syntax.Tree) module Ast = Qsp_syntax.Tree.Ast module S = Qsp_syntax.S @@ -109,6 +108,17 @@ let unknow_function () = _test_instruction "a = ran(1, 2)" { level = Error; loc = _position; message = "Unexpected expression here." } +let inline_elif () = + _test_instruction {| + if a = 1: + elseif a = 1: a = 1 + end|} + { + level = Error; + loc = _position; + message = "Mix between IF block and inline ELIF"; + } + let test = ( "Syntax Errors", [ @@ -121,4 +131,5 @@ let test = Alcotest.test_case "Syntax error $" `Quick syntax_error; Alcotest.test_case "Missing operand" `Quick missing_operand; Alcotest.test_case "Unknown function" `Quick unknow_function; + Alcotest.test_case "Inline elif" `Quick inline_elif; ] ) -- cgit v1.2.3