package jsonxt

  1. Overview
  2. Docs

Source file parser_tools.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

let token_error tok =
  let open Tokens in
  let err = match tok with
    | STRING s -> "unexpected string '" ^ s ^ "'"
    | OS -> "unexpected '{'"
    | OE -> "unexpected '}'"
    | NULL -> "unexpected null value"
    | NEGINFINITY -> "unexpected negative infinity"
    | NAN -> "unexpected Not-a-Number"
    | LEX_ERROR s -> s
    | LARGEINT s -> "unexpected large integer '" ^ s ^ "'"
    | INT i -> "unexpected integer '" ^ (string_of_int i) ^ "'"
    | INFINITY -> "unexpected infinity"
    | FLOAT f -> "unexpected float '" ^ (string_of_float f) ^ "'"
    | EOF -> "unexpected end-of-input"
    | COMPLIANCE_ERROR s -> "compliance error '" ^ s ^ "'"
    | COMMA -> "unexpected ','"
    | COLON -> "unexpected ':'"
    | BOOL b -> "unexpected boolean '" ^ (if b then "true" else "false") ^ "'"
    | AS -> "unexpected '['"
    | AE -> "unexpected ']'"
    | TS -> "unexpected '('"
    | TE -> "unexpected ')'"
    | VS -> "unexpected '<'"
    | VE -> "unexpected '>'"
  in
    `Syntax_error err