aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/qparser/lexer.ml3
-rw-r--r--test/syntax.ml26
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml
index da8acce..30d151b 100644
--- a/lib/qparser/lexer.ml
+++ b/lib/qparser/lexer.ml
@@ -198,6 +198,9 @@ let rec parse_token : Lexbuf.t -> token =
Lexbuf.start buffer;
LOCATION_START ident
+ | '_', Star space, eol, Star space ->
+ (* The _ character can be used to break lines *)
+ parse_token buffer
| '-', Plus '-', Star (Sub (any, ('\r' | '\n'))) ->
leave_expression buffer;
LOCATION_END
diff --git a/test/syntax.ml b/test/syntax.ml
index 126d323..f64129f 100644
--- a/test/syntax.ml
+++ b/test/syntax.ml
@@ -594,6 +594,31 @@ let test_if_inline_act () =
};
]
+let test_if_multiline () =
+ _test_instruction {|if 1 _
+ and hour >= 8: 1|}
+ [
+ Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Ast.BinaryOp
+ ( _position,
+ Qsp_syntax.T.And,
+ Ast.Integer (_position, "1"),
+ Ast.BinaryOp
+ ( _position,
+ Qsp_syntax.T.Gte,
+ Ast.Ident
+ { Ast.pos = _position; name = "HOUR"; index = None },
+ Ast.Integer (_position, "8") ) ),
+ [ Tree.Ast.Expression (Tree.Ast.Integer (_position, "1")) ] );
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
let test_if_inline_act2 () =
_test_instruction "if 1: act 'go': gt 'go' &! comment "
[
@@ -907,6 +932,7 @@ let test =
Alcotest.test_case "If inline &!" `Quick test_if_inline_comment;
Alcotest.test_case "If inline & !!" `Quick test_if_inline_comment2;
Alcotest.test_case "If : act" `Quick test_if_inline_act;
+ Alcotest.test_case "If _ and " `Quick test_if_multiline;
Alcotest.test_case "If : act: &!" `Quick test_if_inline_act2;
Alcotest.test_case "Precedence1" `Quick test_precedence;
Alcotest.test_case "Precedence2" `Quick test_precedence2;