2017-09-29 18:20:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2017-09-29 18:20:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
open Error_monad
|
|
|
|
|
2017-11-04 03:16:05 +04:00
|
|
|
type 'a parsing_result = 'a * error list
|
|
|
|
|
|
|
|
val no_parsing_error : 'a parsing_result -> 'a tzresult
|
|
|
|
|
2017-09-29 18:20:10 +04:00
|
|
|
type point =
|
|
|
|
{ point : int ;
|
|
|
|
byte : int ;
|
|
|
|
line : int ;
|
|
|
|
column : int }
|
|
|
|
|
|
|
|
val point_zero : point
|
|
|
|
|
|
|
|
type location =
|
|
|
|
{ start : point ;
|
|
|
|
stop : point }
|
|
|
|
|
|
|
|
val location_zero : location
|
|
|
|
|
|
|
|
val point_encoding : point Data_encoding.encoding
|
|
|
|
|
|
|
|
val location_encoding : location Data_encoding.encoding
|
|
|
|
|
|
|
|
type token_value =
|
|
|
|
| String of string
|
|
|
|
| Int of string
|
|
|
|
| Ident of string
|
|
|
|
| Annot of string
|
|
|
|
| Comment of string
|
|
|
|
| Eol_comment of string
|
|
|
|
| Semi
|
|
|
|
| Open_paren | Close_paren
|
|
|
|
| Open_brace | Close_brace
|
|
|
|
|
|
|
|
type token =
|
|
|
|
{ token : token_value ;
|
|
|
|
loc : location }
|
|
|
|
|
2017-11-04 03:16:05 +04:00
|
|
|
val tokenize : string -> token list parsing_result
|
2017-09-29 18:20:10 +04:00
|
|
|
|
|
|
|
type node = (location, string) Micheline.node
|
|
|
|
|
|
|
|
(** Beginning of a sequence of consecutive primitives *)
|
|
|
|
val min_point : node list -> point
|
|
|
|
|
|
|
|
(** End of a sequence of consecutive primitives *)
|
|
|
|
val max_point : node list -> point
|
|
|
|
|
|
|
|
val node_encoding : node Data_encoding.encoding
|
|
|
|
|
|
|
|
type error += Invalid_utf8_sequence of point * string
|
|
|
|
type error += Unexpected_character of point * string
|
|
|
|
type error += Undefined_escape_sequence of point * string
|
|
|
|
type error += Missing_break_after_number of point
|
|
|
|
type error += Unterminated_string of location
|
|
|
|
type error += Unterminated_integer of location
|
|
|
|
type error += Unterminated_comment of location
|
|
|
|
type error += Unclosed of token
|
|
|
|
type error += Unexpected of token
|
|
|
|
type error += Extra of token
|
|
|
|
type error += Misaligned of node
|
|
|
|
type error += Empty
|
|
|
|
|
2017-11-04 03:16:05 +04:00
|
|
|
val parse_toplevel : ?check:bool -> token list -> node list parsing_result
|
2017-09-29 18:20:10 +04:00
|
|
|
|
2017-11-04 03:16:05 +04:00
|
|
|
val parse_expression : ?check:bool -> token list -> node parsing_result
|
2017-09-29 18:20:10 +04:00
|
|
|
|
|
|
|
val print_location : Format.formatter -> location -> unit
|
|
|
|
|
|
|
|
val print_point : Format.formatter -> point -> unit
|