diff options
Diffstat (limited to 'lib/qparser/lexbuf.ml')
-rw-r--r-- | lib/qparser/lexbuf.ml | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/qparser/lexbuf.ml b/lib/qparser/lexbuf.ml index 9498f4a..2433ea5 100644 --- a/lib/qparser/lexbuf.ml +++ b/lib/qparser/lexbuf.ml @@ -1,11 +1,3 @@ -type state = - | Token - | String - | DString - | MString of int - | EndString - | Expression - type t = { buffer : Sedlexing.lexbuf; mutable start_p : Lexing.position option; @@ -13,6 +5,29 @@ type t = { reset_line : bool; } +and lexer = t -> Tokens.token +and buffer_builder = Buffer.t -> lexer + +and 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 *) +} + +and state = + | Token of stringWraper + | String of stringWraper + | MString of int + | EndString of stringWraper + | Expression + let state : t -> state option = fun t -> Stack.top_opt t.state let enter_state : t -> state -> unit = fun t state -> Stack.push state t.state let leave_state : t -> unit = fun t -> ignore (Stack.pop_opt t.state) |