diff options
author | Chimrod <> | 2023-10-27 09:59:28 +0200 |
---|---|---|
committer | Chimrod <> | 2023-11-02 11:06:12 +0100 |
commit | 8a7bdc73a7c65d23c79e1c470ba0fbff975b59a5 (patch) | |
tree | 2057dce34911c78046ce93469856ae2a0913c2ce /lib/qparser/lexbuf.mli | |
parent | 4f5e33ef7b96d6daee29ff1088ea381b9302f846 (diff) |
Updated the way to process the strings
Diffstat (limited to 'lib/qparser/lexbuf.mli')
-rw-r--r-- | lib/qparser/lexbuf.mli | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/qparser/lexbuf.mli b/lib/qparser/lexbuf.mli index ec94d1b..5fda8ff 100644 --- a/lib/qparser/lexbuf.mli +++ b/lib/qparser/lexbuf.mli @@ -13,7 +13,11 @@ 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. + *) val content : t -> string (** Extract the token matched by the rule *) @@ -29,18 +33,28 @@ 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 + + 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 state = - | Token - | String - | DString - | MString of int - | EndString - | Expression + | Token (** Default state, parsing the tokens *) + | String (** String enclosed by [''] *) + | DString (** String enclosed by [""] *) + | MString of int (** String enclosed by [{}]*) + | EndString (** State raised just before closing the string *) + | Expression (** Expression where [!] is an operator *) 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 *) val enter_state : t -> state -> unit (** Enter into a new state *) |