Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

driver_lexer.mll 4.25 KB
Newer Older
1 2
(**************************************************************************)
(*                                                                        *)
MARCHE Claude's avatar
MARCHE Claude committed
3
(*  Copyright (C) 2010-2012                                               *)
4 5 6
(*    François Bobot                                                      *)
(*    Jean-Christophe Filliâtre                                           *)
(*    Claude Marché                                                       *)
MARCHE Claude's avatar
MARCHE Claude committed
7
(*    Guillaume Melquiond                                                 *)
8 9 10 11 12 13 14 15 16 17 18 19 20 21
(*    Andrei Paskevich                                                    *)
(*                                                                        *)
(*  This software is free software; you can redistribute it and/or        *)
(*  modify it under the terms of the GNU Library General Public           *)
(*  License version 2.1, with the special exception on linking            *)
(*  described in file LICENSE.                                            *)
(*                                                                        *)
(*  This software is distributed in the hope that it will be useful,      *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *)
(*                                                                        *)
(**************************************************************************)

{
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
22
  open Format
23 24
  open Lexing
  open Driver_parser
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
25
  open Lexer
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
26

27 28 29 30 31 32
  exception IllegalCharacter of char

  let () = Exn_printer.register (fun fmt e -> match e with
    | IllegalCharacter c -> fprintf fmt "illegal character %c" c
    | _ -> raise e)

Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
33
  let keywords = Hashtbl.create 97
34 35
  let () =
    List.iter
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
36 37
      (fun (x,y) -> Hashtbl.add keywords x y)
      [ "theory", THEORY;
38 39 40 41 42 43 44 45 46
        "end", END;
        "syntax", SYNTAX;
        "remove", REMOVE;
        "meta", META;
        "cloned", CLONED;
        "prelude", PRELUDE;
        "printer", PRINTER;
        "valid", VALID;
        "invalid", INVALID;
47
        "timeout", TIMEOUT;
48
        "outofmemory", OUTOFMEMORY;
49
        "time",    TIME;
50 51
        "unknown", UNKNOWN;
        "fail", FAIL;
52 53
        "function", FUNCTION;
        "predicate", PREDICATE;
54 55
        "type", TYPE;
        "prop", PROP;
56
        "filename", FILENAME;
57
        "transformation", TRANSFORM;
58
        "plugin", PLUGIN
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
59 60
      ]

61 62
}

Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
63 64 65 66 67
let space = [' ' '\t' '\r']
let alpha = ['a'-'z' 'A'-'Z' '_']
let digit = ['0'-'9']
let ident = alpha (alpha | digit | '\'')*

68 69 70
let op_char = ['=' '<' '>' '~' '+' '-' '*' '/' '%'
               '!' '$' '&' '?' '@' '^' '.' ':' '|' '#']

71
rule token = parse
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
72 73
  | '\n'
      { newline lexbuf; token lexbuf }
74
  | space+
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
75
      { token lexbuf }
76 77
  | "(*)"
      { LEFTPAR_STAR_RIGHTPAR }
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
78 79
  | "(*"
      { comment lexbuf; token lexbuf }
80
  | '_'
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
81 82 83
      { UNDERSCORE }
  | ident as id
      { try Hashtbl.find keywords id with Not_found -> IDENT id }
84 85
  | digit+ as i
      { INTEGER (int_of_string i) }
86 87 88 89 90 91
  | "<-"
      { LARROW }
  | "["
      { LEFTSQ }
  | "]"
      { RIGHTSQ }
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
92 93 94 95 96 97
  | "("
      { LEFTPAR }
  | ")"
      { RIGHTPAR }
  | "."
      { DOT }
98 99 100 101
  | ","
      { COMMA }
  | op_char+ as op
      { OPERATOR op }
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
102
  | "\""
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
103
      { STRING (string lexbuf) }
104 105
  | "import" space*  "\""
      { INPUT (string lexbuf) }
106
  | eof
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
107 108
      { EOF }
  | _ as c
109
      { raise (IllegalCharacter c) }
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
110 111

{
112
  let loc lb = Loc.extract (lexeme_start_p lb, lexeme_end_p lb)
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
113 114 115 116

  let with_location f lb =
    try f lb with e -> raise (Loc.Located (loc lb, e))

117 118 119 120 121 122 123 124 125
  let parse_file input_lexbuf lexbuf =
    let s = Stack.create () in
    Stack.push lexbuf s;
    let rec multifile lex_dumb =
      let lexbuf = Stack.top s in
      let tok = token lexbuf in
      Loc.transfer_loc lexbuf lex_dumb;
      match tok with
        | INPUT filename ->
126 127
          let dirname = Filename.dirname lexbuf.lex_curr_p.pos_fname in
          let filename = Sysutil.absolutize_filename dirname filename in
128 129 130 131 132 133 134 135
          Stack.push (input_lexbuf filename) s;
          multifile lex_dumb
        | EOF -> ignore (Stack.pop s);
          if Stack.is_empty s then EOF else multifile lex_dumb
        | _ -> tok in
    let lex_dumb = Lexing.from_function (fun _ _ -> assert false) in
    Loc.transfer_loc lexbuf lex_dumb;
    with_location (Driver_parser.file multifile) lex_dumb
Jean-Christophe Filliâtre's avatar
drivers  
Jean-Christophe Filliâtre committed
136
}