summaryrefslogtreecommitdiff
path: root/ocamltest/tsl_lexer.mll
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez@inria.fr>2023-04-22 15:59:51 +0100
committerGitHub <noreply@github.com>2023-04-22 16:59:51 +0200
commit44febc5fd6613c40cdc022ca04a813272de29ffd (patch)
tree3188278f8717df5c64e665c1aceb26f5fb1d20a3 /ocamltest/tsl_lexer.mll
parent518e6912cac994f81a99e978f4dfed7dfb087aaa (diff)
downloadocaml-44febc5fd6613c40cdc022ca04a813272de29ffd.tar.gz
Check for syntax errors in test scripts instead of ignoring them. (#12194)
check that anything that starts with `(* TEST` is indeed a test script
Diffstat (limited to 'ocamltest/tsl_lexer.mll')
-rw-r--r--ocamltest/tsl_lexer.mll12
1 files changed, 11 insertions, 1 deletions
diff --git a/ocamltest/tsl_lexer.mll b/ocamltest/tsl_lexer.mll
index 8ec1674a26..2c40753747 100644
--- a/ocamltest/tsl_lexer.mll
+++ b/ocamltest/tsl_lexer.mll
@@ -30,7 +30,17 @@ let blank = [' ' '\009' '\012']
let identchar = ['A'-'Z' 'a'-'z' '_' '.' '-' '\'' '0'-'9']
let num = ['0'-'9']
-rule token = parse
+rule is_test = parse
+ | blank * { is_test lexbuf }
+ | newline { Lexing.new_line lexbuf; is_test lexbuf }
+ | "/*" blank* "TEST" { true }
+ | "/*" blank* "TEST_BELOW" { true }
+ | "(*" blank* "TEST" { true }
+ | "(*" blank* "TEST_BELOW" { true }
+ | _ { false }
+ | eof { false }
+
+and token = parse
| blank * { token lexbuf }
| newline { Lexing.new_line lexbuf; token lexbuf }
| "/*" blank* "TEST" { TSL_BEGIN_C_STYLE }