From ca50603a7c24365ced7728bd95c5c34e12d7f7ca Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Sat, 4 Jul 2020 14:38:47 +0200 Subject: [PATCH] Added to the scanning of verbatim strings: new line and preprocessor line directive. --- src/passes/01-parsing/shared/Lexer.mll | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/passes/01-parsing/shared/Lexer.mll b/src/passes/01-parsing/shared/Lexer.mll index 787a21a9b..13a840218 100644 --- a/src/passes/01-parsing/shared/Lexer.mll +++ b/src/passes/01-parsing/shared/Lexer.mll @@ -516,11 +516,22 @@ and scan_string thread state = parse scan_string (thread#push_char c) state lexbuf } and scan_verbatim thread state = parse -| eof { fail thread#opening Unterminated_verbatim} -| "|}" { let _, _, state = state#sync lexbuf - in thread, state } -| _ as c { let _, _, state = state#sync lexbuf in - scan_verbatim (thread#push_char c) state lexbuf } + nl as nl { let () = Lexing.new_line lexbuf + and state = state#set_pos (state#pos#new_line nl) + in scan_verbatim (thread#push_string nl) state lexbuf } +| '#' blank* (natural as line) blank+ '"' (string as file) '"' { + let _, _, state = state#sync lexbuf in + let flags, state = scan_flags state [] lexbuf in + let () = ignore flags in + let line = int_of_string line + and file = Filename.basename file in + let pos = state#pos#set ~file ~line ~offset:0 in + let state = state#set_pos pos in + scan_verbatim thread state lexbuf } +| eof { fail thread#opening Unterminated_verbatim } +| "|}" { let _, _, state = state#sync lexbuf in thread, state } +| _ as c { let _, _, state = state#sync lexbuf in + scan_verbatim (thread#push_char c) state lexbuf } (* Finishing a block comment