diff options
author | Damien Doligez <damien.doligez@inria.fr> | 2023-04-25 15:25:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 16:25:52 +0200 |
commit | 0a7c5fe35f4be2ea5c834b586fb5e947bd952377 (patch) | |
tree | 0d66e63cda683098b81ef07f2dad09e9a9c85477 /ocamltest/tsl_lexer.mll | |
parent | 6be361ffd75a2fce5f4daa21fd5073b9a18ce31c (diff) | |
download | ocaml-0a7c5fe35f4be2ea5c834b586fb5e947bd952377.tar.gz |
New script language for ocamltest (#12185)
New test script language, all tests translated automatically (see `tools/translate-all-tests`).
Diffstat (limited to 'ocamltest/tsl_lexer.mll')
-rw-r--r-- | ocamltest/tsl_lexer.mll | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/ocamltest/tsl_lexer.mll b/ocamltest/tsl_lexer.mll index 2c40753747..b643509eca 100644 --- a/ocamltest/tsl_lexer.mll +++ b/ocamltest/tsl_lexer.mll @@ -20,6 +20,7 @@ open Tsl_parser let comment_start_pos = ref [] +let has_comments = ref false let lexer_error message = failwith (Printf.sprintf "Tsl lexer: %s" message) @@ -43,11 +44,19 @@ rule is_test = parse and token = parse | blank * { token lexbuf } | newline { Lexing.new_line lexbuf; token lexbuf } - | "/*" blank* "TEST" { TSL_BEGIN_C_STYLE } - | "/*" blank* "TEST_BELOW" _ * "/*" blank* "TEST" { TSL_BEGIN_C_STYLE } + | "/*" blank* "TEST" { TSL_BEGIN_C_STYLE `Above } + | "/*" blank* "TEST_BELOW" _ * "/*" blank* "TEST" { + let s = Lexing.lexeme lexbuf in + String.iter (fun c -> if c = '\n' then Lexing.new_line lexbuf) s; + TSL_BEGIN_C_STYLE `Below + } | "*/" { TSL_END_C_STYLE } - | "(*" blank* "TEST" { TSL_BEGIN_OCAML_STYLE } - | "(*" blank* "TEST_BELOW" _ * "(*" blank* "TEST" { TSL_BEGIN_OCAML_STYLE } + | "(*" blank* "TEST" { TSL_BEGIN_OCAML_STYLE `Above } + | "(*" blank* "TEST_BELOW" _ * "(*" blank* "TEST" { + let s = Lexing.lexeme lexbuf in + String.iter (fun c -> if c = '\n' then Lexing.new_line lexbuf) s; + TSL_BEGIN_OCAML_STYLE `Below + } | "*)" { TSL_END_OCAML_STYLE } | "," { COMMA } | '*'+ { TEST_DEPTH (String.length (Lexing.lexeme lexbuf)) } @@ -63,9 +72,13 @@ and token = parse | "with" -> WITH | _ -> IDENTIFIER s } + | "{" { LEFT_BRACE } + | "}" { RIGHT_BRACE } + | ";" { SEMI } | "(*" { comment_start_pos := [Lexing.lexeme_start_p lexbuf]; + has_comments := true; comment lexbuf } | '"' |