let rec token c lexbuf =
(lexbuf.Lexing.lex_mem <- Array.create 12 (-1);
__ocaml_lex_token_rec c lexbuf 0)
and __ocaml_lex_token_rec c lexbuf __ocaml_lex_state =
match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state
lexbuf
with
| 0 -> (update_loc c None 1 false 0; NEWLINE)
| 1 ->
let x =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in BLANKS x
| 2 ->
let x =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
(lexbuf.Lexing.lex_curr_pos + (-1))
in LABEL x
| 3 ->
let x =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
(lexbuf.Lexing.lex_curr_pos + (-1))
in OPTLABEL x
| 4 ->
let x =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in LIDENT x
| 5 ->
let x =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in UIDENT x
| 6 ->
let i =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in
(try INT ((int_of_string i), i)
with
| Failure _ ->
err (Literal_overflow "int") (Loc.of_lexbuf lexbuf))
| 7 ->
let f =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in
(try FLOAT ((float_of_string f), f)
with
| Failure _ ->
err (Literal_overflow "float")
(Loc.of_lexbuf lexbuf))
| 8 ->
let i =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
(lexbuf.Lexing.lex_curr_pos + (-1))
in
(try INT32 ((Int32.of_string i), i)
with
| Failure _ ->
err (Literal_overflow "int32")
(Loc.of_lexbuf lexbuf))
| 9 ->
let i =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
(lexbuf.Lexing.lex_curr_pos + (-1))
in
(try INT64 ((Int64.of_string i), i)
with
| Failure _ ->
err (Literal_overflow "int64")
(Loc.of_lexbuf lexbuf))
| 10 ->
let i =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
(lexbuf.Lexing.lex_curr_pos + (-1))
in
(try NATIVEINT ((Nativeint.of_string i), i)
with
| Failure _ ->
err (Literal_overflow "nativeint")
(Loc.of_lexbuf lexbuf))
| 11 ->
(with_curr_loc string c;
let s = buff_contents c
in STRING ((TokenEval.string s), s))
| 12 ->
let x =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
(lexbuf.Lexing.lex_curr_pos + (-1))
in
(update_loc c None 1 false 1;
CHAR ((TokenEval.char x), x))
| 13 ->
let x =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
(lexbuf.Lexing.lex_curr_pos + (-1))
in CHAR ((TokenEval.char x), x)
| 14 ->
let c =
Lexing.sub_lexeme_char lexbuf
(lexbuf.Lexing.lex_start_pos + 2)
in
err (Illegal_escape (String.make 1 c))
(Loc.of_lexbuf lexbuf)
| 15 ->
(store c; COMMENT (parse_nested comment (in_comment c)))
| 16 ->
(warn Comment_start (Loc.of_lexbuf lexbuf);
parse comment (in_comment c);
COMMENT (buff_contents c))
| 17 ->
(warn Comment_not_end (Loc.of_lexbuf lexbuf);
move_start_p (-1) c;
SYMBOL "*")
| 18 ->
let beginning =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 2)
lexbuf.Lexing.lex_curr_pos
in
if quotations c
then
(move_start_p (- (String.length beginning));
mk_quotation quotation c "" "" 2)
else parse (symbolchar_star ("<<" ^ beginning)) c
| 19 ->
if quotations c
then
QUOTATION
{
q_name = "";
q_loc = "";
q_shift = 2;
q_contents = "";
}
else parse (symbolchar_star "<<>>") c
| 20 ->
if quotations c
then with_curr_loc maybe_quotation_at c
else parse (symbolchar_star "<@") c
| 21 ->
if quotations c
then with_curr_loc maybe_quotation_colon c
else parse (symbolchar_star "<:") c
| 22 ->
let num =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0)
lexbuf.Lexing.lex_mem.(1)
and name =
Lexing.sub_lexeme_opt lexbuf lexbuf.Lexing.lex_mem.(3)
lexbuf.Lexing.lex_mem.(2) in
let inum = int_of_string num
in
(update_loc c name inum true 0;
LINE_DIRECTIVE (inum, name))
| 23 ->
let op =
Lexing.sub_lexeme_char lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
in ESCAPED_IDENT (String.make 1 op)
| 24 ->
let op =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
(lexbuf.Lexing.lex_curr_pos + (-1))
in ESCAPED_IDENT op
| 25 ->
let op =
Lexing.sub_lexeme lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
lexbuf.Lexing.lex_mem.(0)
in ESCAPED_IDENT op
| 26 ->
let op =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0)
(lexbuf.Lexing.lex_curr_pos + (-1))
in ESCAPED_IDENT op
| 27 ->
let op =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0)
lexbuf.Lexing.lex_mem.(1)
in ESCAPED_IDENT op
| 28 ->
let x =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in SYMBOL x
| 29 ->
if antiquots c
then with_curr_loc dollar (shift 1 c)
else parse (symbolchar_star "$") c
| 30 ->
let x =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in SYMBOL x
| 31 ->
let pos = lexbuf.lex_curr_p
in
(lexbuf.lex_curr_p <-
{
(pos)
with
pos_bol = pos.pos_bol + 1;
pos_cnum = pos.pos_cnum + 1;
};
EOI)
| 32 ->
let c =
Lexing.sub_lexeme_char lexbuf lexbuf.Lexing.lex_start_pos
in err (Illegal_character c) (Loc.of_lexbuf lexbuf)
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_token_rec c lexbuf __ocaml_lex_state)
and comment c lexbuf = __ocaml_lex_comment_rec c lexbuf 123
and __ocaml_lex_comment_rec c lexbuf __ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf
with
| 0 -> (store c; with_curr_loc comment c; parse comment c)
| 1 -> store c
| 2 ->
(store c;
if quotations c then with_curr_loc quotation c else ();
parse comment c)
| 3 -> store_parse comment c
| 4 ->
(store c;
(try with_curr_loc string c
with
| Loc.Exc_located (_, (Error.E Unterminated_string)) ->
err Unterminated_string_in_comment (loc c));
Buffer.add_char c.buffer '"';
parse comment c)
| 5 -> store_parse comment c
| 6 -> store_parse comment c
| 7 -> (update_loc c None 1 false 1; store_parse comment c)
| 8 -> store_parse comment c
| 9 -> store_parse comment c
| 10 -> store_parse comment c
| 11 -> store_parse comment c
| 12 -> err Unterminated_comment (loc c)
| 13 -> (update_loc c None 1 false 0; store_parse comment c)
| 14 -> store_parse comment c
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_comment_rec c lexbuf __ocaml_lex_state)
and string c lexbuf =
(lexbuf.Lexing.lex_mem <- Array.create 2 (-1);
__ocaml_lex_string_rec c lexbuf 159)
and __ocaml_lex_string_rec c lexbuf __ocaml_lex_state =
match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state
lexbuf
with
| 0 -> set_start_p c
| 1 ->
let space =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0)
lexbuf.Lexing.lex_curr_pos
in
(update_loc c None 1 false (String.length space);
store_parse string c)
| 2 -> store_parse string c
| 3 -> store_parse string c
| 4 -> store_parse string c
| 5 ->
let x =
Lexing.sub_lexeme_char lexbuf
(lexbuf.Lexing.lex_start_pos + 1)
in
if is_in_comment c
then store_parse string c
else
(warn (Illegal_escape (String.make 1 x))
(Loc.of_lexbuf lexbuf);
store_parse string c)
| 6 -> (update_loc c None 1 false 0; store_parse string c)
| 7 -> err Unterminated_string (loc c)
| 8 -> store_parse string c
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_string_rec c lexbuf __ocaml_lex_state)
and symbolchar_star beginning c lexbuf =
__ocaml_lex_symbolchar_star_rec beginning c lexbuf 176
and
__ocaml_lex_symbolchar_star_rec beginning c lexbuf
__ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf
with
| 0 ->
let tok =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in
(move_start_p (- (String.length beginning)) c;
SYMBOL (beginning ^ tok))
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_symbolchar_star_rec beginning c lexbuf
__ocaml_lex_state)
and maybe_quotation_at c lexbuf =
__ocaml_lex_maybe_quotation_at_rec c lexbuf 177
and
__ocaml_lex_maybe_quotation_at_rec c lexbuf __ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf
with
| 0 ->
let loc =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
(lexbuf.Lexing.lex_curr_pos + (-1))
in
mk_quotation quotation c "" loc (1 + (String.length loc))
| 1 ->
let tok =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in SYMBOL ("<@" ^ tok)
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_maybe_quotation_at_rec c lexbuf
__ocaml_lex_state)
and maybe_quotation_colon c lexbuf =
(lexbuf.Lexing.lex_mem <- Array.create 2 (-1);
__ocaml_lex_maybe_quotation_colon_rec c lexbuf 181)
and
__ocaml_lex_maybe_quotation_colon_rec c lexbuf
__ocaml_lex_state =
match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state
lexbuf
with
| 0 ->
let name =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
(lexbuf.Lexing.lex_curr_pos + (-1))
in
mk_quotation quotation c name ""
(1 + (String.length name))
| 1 ->
let name =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_mem.(0)
and loc =
Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_mem.(0) + 1)
(lexbuf.Lexing.lex_curr_pos + (-1))
in
mk_quotation quotation c name loc
((2 + (String.length loc)) + (String.length name))
| 2 ->
let tok =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
lexbuf.Lexing.lex_curr_pos
in SYMBOL ("<:" ^ tok)
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_maybe_quotation_colon_rec c lexbuf
__ocaml_lex_state)
and quotation c lexbuf = __ocaml_lex_quotation_rec c lexbuf 188
and __ocaml_lex_quotation_rec c lexbuf __ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf
with
| 0 -> (store c; with_curr_loc quotation c; parse quotation c)
| 1 -> store c
| 2 -> err Unterminated_quotation (loc c)
| 3 -> (update_loc c None 1 false 0; store_parse quotation c)
| 4 -> store_parse quotation c
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_quotation_rec c lexbuf __ocaml_lex_state)
and dollar c lexbuf = __ocaml_lex_dollar_rec c lexbuf 201
and __ocaml_lex_dollar_rec c lexbuf __ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf
with
| 0 -> (set_start_p c; ANTIQUOT ("", ""))
| 1 ->
let name =
Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos
(lexbuf.Lexing.lex_curr_pos + (-1))
in
with_curr_loc (antiquot name)
(shift (1 + (String.length name)) c)
| 2 -> store_parse (antiquot "") c
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_dollar_rec c lexbuf __ocaml_lex_state)
and antiquot name c lexbuf =
__ocaml_lex_antiquot_rec name c lexbuf 210
and __ocaml_lex_antiquot_rec name c lexbuf __ocaml_lex_state =
match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf
with
| 0 -> (set_start_p c; ANTIQUOT (name, (buff_contents c)))
| 1 -> err Unterminated_antiquot (loc c)
| 2 ->
(update_loc c None 1 false 0;
store_parse (antiquot name) c)
| 3 ->
(store c;
with_curr_loc quotation c;
parse (antiquot name) c)
| 4 -> store_parse (antiquot name) c
| __ocaml_lex_state ->
(lexbuf.Lexing.refill_buff lexbuf;
__ocaml_lex_antiquot_rec name c lexbuf __ocaml_lex_state)