aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChimrod <>2024-01-15 10:45:16 +0100
committerChimrod <>2024-01-15 10:45:16 +0100
commitc48740e598132261e20260678ff2feb3b398d913 (patch)
tree08b34440bd4cc5cf663da87343dbb409cb579c4e
parent6c7c12803b3c17027309071a749939e0c8bb476c (diff)
Updated the code used to read the location name
-rw-r--r--lib/qparser/lexer.ml2
-rw-r--r--test/syntax.ml9
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml
index 5741b7a..da8acce 100644
--- a/lib/qparser/lexer.ml
+++ b/lib/qparser/lexer.ml
@@ -10,7 +10,7 @@ exception LexError of string
exception EOF
(* Extract the location name from the pattern *)
-let location_name = Str.regexp {|.* \(.*\)|}
+let location_name = Str.regexp {|# *\(.*\)|}
(** Remove all the expression state when we are leaving the expression itself. *)
let rec leave_expression buffer =
diff --git a/test/syntax.ml b/test/syntax.ml
index e81bf3d..126d323 100644
--- a/test/syntax.ml
+++ b/test/syntax.ml
@@ -48,6 +48,14 @@ let test_empty_location () =
Alcotest.(check' location ~msg ~expected ~actual)
+let test_location_without_space () =
+ let expected = (_position, [])
+ and actual = get_location @@ parse {|#Location
+------- |}
+ and msg = "Empty location" in
+
+ Alcotest.(check' location ~msg ~expected ~actual)
+
let test_location_without_database () =
let expected = (_position, [])
and actual = get_location @@ parse {|# $Location
@@ -855,6 +863,7 @@ let test =
( "Syntax",
[
Alcotest.test_case "Location" `Quick test_empty_location;
+ Alcotest.test_case "Location" `Quick test_location_without_space;
Alcotest.test_case "Location" `Quick test_location_without_database;
Alcotest.test_case " Numeric expression" `Quick test_numeric_expression;
Alcotest.test_case "-Numeric expression" `Quick