diff options
author | Chimrod <> | 2023-10-26 09:44:53 +0200 |
---|---|---|
committer | Chimrod <> | 2023-10-26 09:44:53 +0200 |
commit | 09f12acfb6d40f1b0b29625e87c2df58ecf9f275 (patch) | |
tree | 864e212f10dee0740646559fd92f85f321268419 | |
parent | fc235a1d2b7f10e6b5b1d7ed4328e2f9f7714171 (diff) |
Update the documentation in the parser
-rw-r--r-- | lib/qparser/lexbuf.mli | 18 | ||||
-rw-r--r-- | lib/qparser/lexer.ml | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/qparser/lexbuf.mli b/lib/qparser/lexbuf.mli index 97a4d65..5a0bbcd 100644 --- a/lib/qparser/lexbuf.mli +++ b/lib/qparser/lexbuf.mli @@ -1,4 +1,7 @@ +(** Lexing buffer. *) + type t +(** The state of the buffer *) val from_lexbuf : ?reset_line:bool -> Sedlexing.lexbuf -> t (** Create a new buffer *) @@ -16,12 +19,21 @@ val content : t -> string (** Extract the token matched by the rule *) val set_start_position : t -> Lexing.position -> unit +(** Reset the starting position. Used while parsing the string to keep the + begining of the whole string. *) + val tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position +(** Function to use in the parser in order to extract the token match, and the + starting and ending position. *) + +val level : t -> int +(** The state track the nesting level in the expression. Depending of the + level, the token [!] will be considered as a comment or a boolean + operation. *) + val incr_level : t -> unit val decr_level : t -> unit val reset_level : t -> unit -val level : t -> int -(** Return the nested expression level *) - val rollback : t -> unit +(** Rollback the latest token matched *) diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml index 383d6a3..f2d04bf 100644 --- a/lib/qparser/lexer.ml +++ b/lib/qparser/lexer.ml @@ -43,11 +43,11 @@ let wait_balance : (Buffer.t -> Lexbuf.t -> 'a) -> Lexbuf.t -> 'a = with Not_found -> raise UnclosedQuote let space = [%sedlex.regexp? ' ' | '\t'] +let spaces = [%sedlex.regexp? Plus space] let eol = [%sedlex.regexp? '\r' | '\n' | "\r\n"] let coma = [%sedlex.regexp? ','] let digit = [%sedlex.regexp? '0' .. '9'] let letters = [%sedlex.regexp? 'a' .. 'z' | 'A' .. 'Z' | '_'] -let spaces = [%sedlex.regexp? Plus space] let ident = [%sedlex.regexp? Opt ('$' | '*'), letters, Star (digit | letters)] let location_ident = [%sedlex.regexp? letters | digit] let location_prefix = [%sedlex.regexp? '!' | '$' | '#' | '^'] |