aboutsummaryrefslogtreecommitdiff
path: root/lib/qparser/lexer.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/lexer.ml
parent4f5e33ef7b96d6daee29ff1088ea381b9302f846 (diff)
Updated the way to process the strings
Diffstat (limited to 'lib/qparser/lexer.ml')
-rw-r--r--lib/qparser/lexer.ml13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml
index abe47ac..7878299 100644
--- a/lib/qparser/lexer.ml
+++ b/lib/qparser/lexer.ml
@@ -63,6 +63,14 @@ let location_ident = [%sedlex.regexp? letters | digit]
let location_prefix = [%sedlex.regexp? '!' | '$' | '#' | '^']
let location = [%sedlex.regexp? Opt location_prefix, Plus location_ident]
+(** Change the state when we are ending a string. Send the text marker to the
+ parser in order to tell the string is over.
+
+ This can work because the state EndString is only raised when the same
+ token is fetched inside the appropriate sting method lexer. The
+ [Lexbuf.rollback] function is called in order to let the same token occur
+ again.
+ *)
let end_string : Lexbuf.t -> token =
fun buffer ->
let lexbuf = Lexbuf.buffer buffer in
@@ -92,6 +100,7 @@ let rec read_long_string level buf buffer =
Lexbuf.rollback buffer;
LITERAL (Buffer.contents buf)
| _ ->
+ (* We have nested strings. Do not terminate end *)
Buffer.add_string buf (Sedlexing.Utf8.lexeme lexbuf);
read_long_string (level - 1) buf buffer)
| eol ->
@@ -204,11 +213,11 @@ let rec token : Lexbuf.t -> token =
| ')' ->
Lexbuf.leave_state buffer;
R_PAREN
- | '<' -> LT
- | '>' -> GT
| ">>" ->
Lexbuf.leave_state buffer;
token buffer
+ | '<' -> LT
+ | '>' -> GT
| coma -> COMA
| '=' ->
Lexbuf.enter_state buffer Lexbuf.Expression;