From dd060261e35fcb8a57f03b01dbe84ab772a2a199 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Sat, 28 Oct 2023 16:47:23 +0200 Subject: Set up a context for parsing the literal strings --- lib/qparser/lexbuf.mli | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/qparser/lexbuf.mli') diff --git a/lib/qparser/lexbuf.mli b/lib/qparser/lexbuf.mli index 5fda8ff..dd13da4 100644 --- a/lib/qparser/lexbuf.mli +++ b/lib/qparser/lexbuf.mli @@ -43,12 +43,28 @@ val rollback : t -> unit using a stack for determining the token to send. *) +type lexer = t -> Tokens.token +type buffer_builder = Buffer.t -> lexer + +type stringWraper = { + start_string : lexer -> lexer; + (** Start a new string. This function is used insed the token lexer, in + order to identify how to start a new string *) + wrap : buffer_builder -> buffer_builder; + (** function used to escape the character and add it to the buffer. This + function is used inside the string lexer. *) + end_string : lexer; + (** Function used to match the end of the string. This function is used + after the string lexer, in order to identify the end patten for a + string *) +} + type state = - | Token (** Default state, parsing the tokens *) - | String (** String enclosed by [''] *) - | DString (** String enclosed by [""] *) + | Token of stringWraper (** Default state, parsing the tokens *) + | String of stringWraper (** String enclosed by [''] *) | MString of int (** String enclosed by [{}]*) - | EndString (** State raised just before closing the string *) + | EndString of stringWraper + (** State raised just before closing the string *) | Expression (** Expression where [!] is an operator *) val state : t -> state option -- cgit v1.2.3