diff options
Diffstat (limited to 'lib/qparser/lexer.ml')
-rw-r--r-- | lib/qparser/lexer.ml | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml index 814c97f..470cdc7 100644 --- a/lib/qparser/lexer.ml +++ b/lib/qparser/lexer.ml @@ -1,6 +1,4 @@ -(** - Lexer using sedlex - *) +(** Lexer using sedlex *) open Tokens open StdLabels @@ -12,7 +10,8 @@ exception EOF (* Extract the location name from the pattern *) let location_name = Str.regexp {|# *\(.*\)|} -(** Remove all the expression state when we are leaving the expression itself. *) +(** Remove all the expression state when we are leaving the expression itself. +*) let rec leave_expression buffer = match Lexbuf.state buffer with | Some Lexbuf.Expression -> @@ -21,7 +20,7 @@ let rec leave_expression buffer = | _ -> () (** Try to read the identifier and check if this is a function, a keyword, or - just a variable. + just a variable. See the tests [Syntax.Operator2] and [Syntax.Call Nl] for two cases. *) let build_ident buffer = @@ -124,8 +123,7 @@ let rec read_long_string : ?nested:bool -> int -> Buffer.t -> Lexbuf.t -> token rollbacked, leaving the state in [Lexbuf.EndString _]. The next call to [main] will call the associated function, effectively - leaving the string mode in the parser. - *) + leaving the string mode in the parser. *) let rec read_quoted_string : Lexbuf.stringWraper -> Lexbuf.buffer_builder = fun f ?(nested = false) buf buffer -> let lexbuf = Lexbuf.buffer buffer in @@ -153,11 +151,9 @@ let rec read_quoted_string : Lexbuf.stringWraper -> Lexbuf.buffer_builder = (f.wrap ~nested (read_quoted_string f)) buf buffer | _ -> raise Not_found -(** Track the kind of nested string inside a multiline string inside a - comment. +(** Track the kind of nested string inside a multiline string inside a comment. - Some constructions are not allowed in this specific case (see later) -*) + Some constructions are not allowed in this specific case (see later) *) type commentedString = None | Quote | DQuote let rec skip_comment buffer = @@ -333,6 +329,10 @@ let main buffer = in parser buffer +(** Function used inside the dynamics expressions. Here, we give the EOF token + to the parser. *) +let dynamics buffer = try main buffer with EOF -> Tokens.EOF + let rec discard buffer = let () = Lexbuf.start_recovery buffer in let lexbuf = Lexbuf.buffer buffer in |