Debian Codegraph @

vendor/opam/src/format/opamInterpLexer.mll

raw
1 (**************************************************************************)
2 (* *)
3 (* Copyright 2016 MetaStack Solutions Ltd. *)
4 (* *)
5 (* All rights reserved. This file is distributed under the terms of the *)
6 (* GNU Lesser General Public License version 2.1, with the special *)
7 (* exception on linking described in the file LICENSE. *)
8 (* *)
9 (**************************************************************************)
10
11 rule main unquoted quoted = parse
12 | [^ '"' '\n' ]+
13 { unquoted @@ Lexing.lexeme lexbuf;
14 main unquoted quoted lexbuf }
15 | ("\"\"\"" | '"') as quote
16 { unquoted quote;
17 let triple = String.length quote = 3 in
18 string triple unquoted quoted lexbuf }
19 | '\n' { Lexing.new_line lexbuf;
20 unquoted "\n";
21 main unquoted quoted lexbuf }
22 | eof { () }
23
24
25 and string triple unquoted quoted = parse
26 | ( [^ '"' '\\' '\n' ]+ | '\\' [^ '\n' ]? )+
27 { quoted @@ Lexing.lexeme lexbuf;
28 string triple unquoted quoted lexbuf }
29 | "\"\"\""
30 { unquoted "\"\"\"";
31 main unquoted quoted lexbuf }
32 | '"' { if triple then begin
33 quoted "\"";
34 string triple unquoted quoted lexbuf
35 end else begin
36 unquoted "\"";
37 main unquoted quoted lexbuf
38 end }
39 | '\n' { Lexing.new_line lexbuf;
40 unquoted "\n";
41 string triple unquoted quoted lexbuf}
42 | eof { () }