diff options
author | Chimrod <> | 2024-12-14 23:06:12 +0100 |
---|---|---|
committer | Chimrod <> | 2025-01-03 15:05:00 +0100 |
commit | 75f3eabb46eded01460f7700a75d094100047438 (patch) | |
tree | 4dcee7d2fc9310ff41776d9df8986f5efa0db229 /lib/qparser/lexbuf.mli | |
parent | 289dc576624d4233116806e566bb791fee1de178 (diff) |
Diffstat (limited to 'lib/qparser/lexbuf.mli')
-rw-r--r-- | lib/qparser/lexbuf.mli | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/qparser/lexbuf.mli b/lib/qparser/lexbuf.mli index 4283db1..d656642 100644 --- a/lib/qparser/lexbuf.mli +++ b/lib/qparser/lexbuf.mli @@ -3,8 +3,11 @@ type t (** The state of the buffer *) -val from_lexbuf : ?reset_line:bool -> Sedlexing.lexbuf -> t -(** Create a new buffer *) +val from_lexbuf : + ?position:Lexing.position -> ?reset_line:bool -> Sedlexing.lexbuf -> t +(** Create a new buffer. + + If a position is given, start from this position in the file. *) val start : t -> unit (** Intialize a new run. *) @@ -13,11 +16,10 @@ val buffer : t -> Sedlexing.lexbuf (** Extract the sedlex buffer. Required in each rule. *) val positions : t -> Lexing.position * Lexing.position -(** Extract the starting and ending position for the matched token. +(** Extract the starting and ending position for the matched token. - This function is used outside of the parser, in order to get the position - of the latest token in the case of an error. - *) + This function is used outside of the parser, in order to get the position of + the latest token in the case of an error. *) val content : t -> string (** Extract the token matched by the rule *) @@ -33,15 +35,14 @@ val tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position val rollback : t -> unit (** Rollback the latest token matched *) -(** {1 State in expressions} +(** {1 State in expressions} - The comment system is terrible. The same symbol can be used for : - - starting a comment - - inequality operation + The comment system is terrible. The same symbol can be used for : + - starting a comment + - inequality operation - In order to manage this, I try to identify the context in a very basic way, - using a stack for determining the token to send. -*) + In order to manage this, I try to identify the context in a very basic way, + using a stack for determining the token to send. *) type lexer = t -> Tokens.token and buffer_builder = ?nested:bool -> Buffer.t -> t -> Tokens.token @@ -64,14 +65,14 @@ type state = | String of stringWraper (** String enclosed by [''] *) | MString of int (** String enclosed by [{}]*) | EndString of stringWraper - (** State raised just before closing the string. - The buffer is rollbacked and the position is the closing symbol. *) + (** State raised just before closing the string. The buffer is rollbacked + and the position is the closing symbol. *) | Expression (** Expression where [!] is an operator *) val pp_state : Format.formatter -> state -> unit val state : t -> state option -(** Get the current state for the lexer. +(** Get the current state for the lexer. @return [None] when in the default state *) @@ -84,8 +85,8 @@ val leave_state : t -> unit val overlay : t -> lexer -> lexer val start_recovery : t -> unit -(** Set the lexer in recovery mode, the lexer raise this mode after an error, - in order to ignore the further errors until a new location *) +(** Set the lexer in recovery mode, the lexer raise this mode after an error, in + order to ignore the further errors until a new location *) val is_recovery : t -> bool (** Check if the lexer is in recovery mode *) |