2020-01-04 19:49:22 +01:00
|
|
|
(* Generic parser API for LIGO *)
|
|
|
|
|
2020-01-08 16:39:52 +01:00
|
|
|
module Region = Simple_utils.Region
|
|
|
|
|
2020-01-20 10:57:07 +01:00
|
|
|
(* The signature generated by Menhir with additional type definitions
|
|
|
|
for [ast] and [expr]. *)
|
|
|
|
|
2020-01-04 19:49:22 +01:00
|
|
|
module type PARSER =
|
|
|
|
sig
|
|
|
|
(* The type of tokens. *)
|
|
|
|
|
|
|
|
type token
|
|
|
|
type ast
|
|
|
|
type expr
|
|
|
|
|
|
|
|
(* This exception is raised by the monolithic API functions. *)
|
|
|
|
|
|
|
|
exception Error
|
|
|
|
|
|
|
|
(* The monolithic API. *)
|
|
|
|
|
2020-01-14 01:27:35 +01:00
|
|
|
val interactive_expr :
|
|
|
|
(Lexing.lexbuf -> token) -> Lexing.lexbuf -> expr
|
|
|
|
val contract :
|
|
|
|
(Lexing.lexbuf -> token) -> Lexing.lexbuf -> ast
|
2020-01-04 19:49:22 +01:00
|
|
|
|
|
|
|
(* The incremental API. *)
|
|
|
|
|
|
|
|
module MenhirInterpreter :
|
|
|
|
sig
|
|
|
|
include MenhirLib.IncrementalEngine.INCREMENTAL_ENGINE
|
|
|
|
with type token = token
|
|
|
|
end
|
|
|
|
|
|
|
|
(* The entry point(s) to the incremental API. *)
|
|
|
|
|
|
|
|
module Incremental :
|
|
|
|
sig
|
|
|
|
val interactive_expr :
|
|
|
|
Lexing.position -> expr MenhirInterpreter.checkpoint
|
|
|
|
val contract :
|
|
|
|
Lexing.position -> ast MenhirInterpreter.checkpoint
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Make (Lexer: Lexer.S)
|
|
|
|
(Parser: PARSER with type token = Lexer.Token.token)
|
|
|
|
(ParErr: sig val message : int -> string end) :
|
|
|
|
sig
|
2020-01-20 10:57:07 +01:00
|
|
|
(* The monolithic API of Menhir with memos *)
|
2020-01-04 19:49:22 +01:00
|
|
|
|
|
|
|
val mono_contract :
|
2020-01-20 10:57:07 +01:00
|
|
|
(Lexing.lexbuf -> Lexer.token) ->
|
|
|
|
Lexing.lexbuf ->
|
|
|
|
(Parser.ast, string) Stdlib.result
|
2020-01-04 19:49:22 +01:00
|
|
|
|
2020-01-14 01:27:35 +01:00
|
|
|
val mono_expr :
|
2020-01-20 10:57:07 +01:00
|
|
|
(Lexing.lexbuf -> Lexer.token) ->
|
|
|
|
Lexing.lexbuf ->
|
|
|
|
(Parser.expr, string) Stdlib.result
|
2020-01-04 19:49:22 +01:00
|
|
|
|
2020-01-20 10:57:07 +01:00
|
|
|
(* Incremental API of Menhir with memos *)
|
2020-01-04 19:49:22 +01:00
|
|
|
|
2020-01-20 10:57:07 +01:00
|
|
|
val incr_contract :
|
|
|
|
Lexer.instance -> (Parser.ast, string) Stdlib.result
|
2020-01-08 16:39:52 +01:00
|
|
|
|
2020-01-20 10:57:07 +01:00
|
|
|
val incr_expr :
|
|
|
|
Lexer.instance ->
|
|
|
|
(Parser.expr, string) Stdlib.result
|
2020-01-04 19:49:22 +01:00
|
|
|
end
|