aboutsummaryrefslogtreecommitdiff
path: root/lib/qparser/lexbuf.ml
diff options
context:
space:
mode:
authorChimrod <>2023-10-27 09:59:28 +0200
committerChimrod <>2023-11-02 11:06:12 +0100
commit8a7bdc73a7c65d23c79e1c470ba0fbff975b59a5 (patch)
tree2057dce34911c78046ce93469856ae2a0913c2ce /lib/qparser/lexbuf.ml
parent4f5e33ef7b96d6daee29ff1088ea381b9302f846 (diff)
Updated the way to process the strings
Diffstat (limited to 'lib/qparser/lexbuf.ml')
-rw-r--r--lib/qparser/lexbuf.ml15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/qparser/lexbuf.ml b/lib/qparser/lexbuf.ml
index af8c48a..9498f4a 100644
--- a/lib/qparser/lexbuf.ml
+++ b/lib/qparser/lexbuf.ml
@@ -13,6 +13,9 @@ type t = {
reset_line : bool;
}
+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)
let buffer : t -> Sedlexing.lexbuf = fun t -> t.buffer
let start : t -> unit =
@@ -22,6 +25,7 @@ let start : t -> unit =
if not t.reset_line then
Sedlexing.set_position t.buffer { end_pos with Lexing.pos_lnum = 1 }
in
+ Stack.clear t.state;
t.start_p <- None
let positions : t -> Lexing.position * Lexing.position =
@@ -61,14 +65,3 @@ let tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position
lexer
let rollback : t -> unit = fun t -> Sedlexing.rollback t.buffer
-
-(** 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 counter for determining the token to send.
-*)
-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)