Revision e1d133e434f05b050d2db8d69281231d86ffabfe authored by Marge Bot on 13 September 2022, 15:23:52 UTC, committed by Marge Bot on 13 September 2022, 15:23:52 UTC
Co-authored-by: Rémy El Sibaïe <remy.el-sibaie@nomadic-labs.com>

Approved-by: Andrea Cerone <andrea.cerone@trili.tech>
Approved-by: François Thiré <francois.thire@nomadic-labs.com>
Approved-by: Raphaël Proust <code@bnwr.net>

See merge request https://gitlab.com/tezos/tezos/-/merge_requests/6284
2 parent s 413d6e5 + 0c6f7f8
Raw File
JSON_lexer.mll
{
  open JSON_parser
}

(* NOTE: This rule does not follow the JSON spec. In particular it does
   not correctly handle backslash characters in strings. If it becomes
   necessary to support it, we could consider vendoring a json library. *)
rule token = parse
  | [' ' '\t' '\r' '\n']+ { token lexbuf }
  | '-'? ['0'-'9']+ ('.' ['0'-'9']+)? as x
      { (* TODO: this regexp probably doesn't exactly match the spec *)
        FLOAT (float_of_string x) }
  | '"' ([^'"' '\\']* as x) '"'
      { STRING x }
  | '{' { LBRACE }
  | '}' { RBRACE }
  | '[' { LBRACKET }
  | ']' { RBRACKET }
  | ',' { COMMA }
  | ':' { COLON }
  | ['a'-'z']+ as x
      { match x with
          | "true" -> BOOL true
          | "false" -> BOOL false
          | "null" -> NULL
          | _ -> failwith "parse error" }
  | eof { EOF }
back to top