From 8a7bdc73a7c65d23c79e1c470ba0fbff975b59a5 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Fri, 27 Oct 2023 09:59:28 +0200 Subject: Updated the way to process the strings --- lib/qparser/lexer.ml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/qparser/lexer.ml') diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml index abe47ac..7878299 100644 --- a/lib/qparser/lexer.ml +++ b/lib/qparser/lexer.ml @@ -63,6 +63,14 @@ let location_ident = [%sedlex.regexp? letters | digit] let location_prefix = [%sedlex.regexp? '!' | '$' | '#' | '^'] let location = [%sedlex.regexp? Opt location_prefix, Plus location_ident] +(** Change the state when we are ending a string. Send the text marker to the + parser in order to tell the string is over. + + This can work because the state EndString is only raised when the same + token is fetched inside the appropriate sting method lexer. The + [Lexbuf.rollback] function is called in order to let the same token occur + again. + *) let end_string : Lexbuf.t -> token = fun buffer -> let lexbuf = Lexbuf.buffer buffer in @@ -92,6 +100,7 @@ let rec read_long_string level buf buffer = Lexbuf.rollback buffer; LITERAL (Buffer.contents buf) | _ -> + (* We have nested strings. Do not terminate end *) Buffer.add_string buf (Sedlexing.Utf8.lexeme lexbuf); read_long_string (level - 1) buf buffer) | eol -> @@ -204,11 +213,11 @@ let rec token : Lexbuf.t -> token = | ')' -> Lexbuf.leave_state buffer; R_PAREN - | '<' -> LT - | '>' -> GT | ">>" -> Lexbuf.leave_state buffer; token buffer + | '<' -> LT + | '>' -> GT | coma -> COMA | '=' -> Lexbuf.enter_state buffer Lexbuf.Expression; -- cgit v1.2.3