Simple_utils is now used as a library by the local builds.
Preprocessor is now a library installed by opam. Replaced ligolang@gmail.com by contact@ligolang.org in opam files. Reformatted some opam files. Removed #line directive from preprocessor. Added to the interface of ParserUnit. Script messages.sh now checks the identity of .msg and .msg.old to avoid undue warning about possibly different LR items.
This commit is contained in:
parent
1941f9ae4b
commit
c0ee726fb2
@ -1,6 +1,6 @@
|
|||||||
name: "ligo"
|
name: "ligo"
|
||||||
opam-version: "2.0"
|
opam-version: "2.0"
|
||||||
maintainer: "ligolang@gmail.com"
|
maintainer: "Galfour <contact@ligolang.org>"
|
||||||
authors: [ "Galfour" ]
|
authors: [ "Galfour" ]
|
||||||
homepage: "https://gitlab.com/ligolang/tezos"
|
homepage: "https://gitlab.com/ligolang/tezos"
|
||||||
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
|
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
|
||||||
|
@ -131,12 +131,12 @@ let apply parser =
|
|||||||
|
|
||||||
(* Parsing a contract in a file *)
|
(* Parsing a contract in a file *)
|
||||||
|
|
||||||
let parse_file source = apply (fun () -> Unit.parse_file source)
|
let parse_file source = apply (fun () -> Unit.contract_in_file source)
|
||||||
|
|
||||||
(* Parsing a contract in a string *)
|
(* Parsing a contract in a string *)
|
||||||
|
|
||||||
let parse_string source = apply (fun () -> Unit.parse_string source)
|
let parse_string source = apply (fun () -> Unit.contract_in_string source)
|
||||||
|
|
||||||
(* Parsing an expression in a string *)
|
(* Parsing an expression in a string *)
|
||||||
|
|
||||||
let parse_expression source = apply (fun () -> Unit.parse_expression source)
|
let parse_expression source = apply (fun () -> Unit.expr_in_string source)
|
||||||
|
@ -1,20 +1,5 @@
|
|||||||
$HOME/git/OCaml-build/Makefile
|
$HOME/git/OCaml-build/Makefile
|
||||||
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.ml
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
|
|
||||||
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_AST.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Lexer.mll
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/Preproc.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/Preproc.mll
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Lexer.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Parser.mly
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/.E_Parser.mly.tag
|
|
||||||
|
|
||||||
../shared/Lexer.mli
|
../shared/Lexer.mli
|
||||||
../shared/Lexer.mll
|
../shared/Lexer.mll
|
||||||
../shared/EvalOpt.ml
|
../shared/EvalOpt.ml
|
||||||
@ -34,7 +19,4 @@ $HOME/git/ligo/vendors/Preprocessor/.E_Parser.mly.tag
|
|||||||
../shared/ParserUnit.mli
|
../shared/ParserUnit.mli
|
||||||
../shared/ParserUnit.ml
|
../shared/ParserUnit.ml
|
||||||
|
|
||||||
Stubs/Simple_utils.ml
|
|
||||||
Stubs/Preprocessor.ml
|
|
||||||
|
|
||||||
$HOME/git/ligo/_build/default/src/passes/1-parser/cameligo/ParErr.ml
|
$HOME/git/ligo/_build/default/src/passes/1-parser/cameligo/ParErr.ml
|
@ -19,6 +19,8 @@ open Utils
|
|||||||
denoting the _region_ of the occurrence of the keyword "and".
|
denoting the _region_ of the occurrence of the keyword "and".
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
|
||||||
type 'a reg = 'a Region.reg
|
type 'a reg = 'a Region.reg
|
||||||
|
|
||||||
(* Keywords of OCaml *)
|
(* Keywords of OCaml *)
|
||||||
|
@ -4,7 +4,7 @@ module Region = Simple_utils.Region
|
|||||||
|
|
||||||
module IO =
|
module IO =
|
||||||
struct
|
struct
|
||||||
let options = EvalOpt.(read ~lang:CameLIGO ~ext:".mligo")
|
let options = EvalOpt.(read ~lang:`CameLIGO ~ext:".mligo")
|
||||||
end
|
end
|
||||||
|
|
||||||
module M = LexerUnit.Make (IO) (Lexer.Make (LexToken))
|
module M = LexerUnit.Make (IO) (Lexer.Make (LexToken))
|
||||||
|
@ -2,4 +2,4 @@ SHELL := dash
|
|||||||
BFLAGS := -strict-sequence -w +A-48-4 -g
|
BFLAGS := -strict-sequence -w +A-48-4 -g
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
> rm -f Parser.msg Parser.msg.map Parser.msg.states Version.ml
|
> \rm -f Parser.msg.map Parser.msg.states Version.ml
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
[@@@warning "-42"]
|
[@@@warning "-42"]
|
||||||
|
|
||||||
open Region
|
open Simple_utils.Region
|
||||||
open AST
|
open AST
|
||||||
|
|
||||||
(* END HEADER *)
|
(* END HEADER *)
|
||||||
|
3969
src/passes/1-parser/cameligo/Parser.msg
Normal file
3969
src/passes/1-parser/cameligo/Parser.msg
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
|||||||
[@@@coverage exclude_file]
|
[@@@coverage exclude_file]
|
||||||
|
|
||||||
open AST
|
open AST
|
||||||
|
module Region = Simple_utils.Region
|
||||||
open! Region
|
open! Region
|
||||||
|
|
||||||
let sprintf = Printf.sprintf
|
let sprintf = Printf.sprintf
|
||||||
|
@ -1,8 +1,47 @@
|
|||||||
(** Driver for the CameLIGO parser *)
|
(* Driver for the CameLIGO parser *)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
module SSet = Set.Make (String)
|
||||||
|
|
||||||
module IO =
|
module IO =
|
||||||
struct
|
struct
|
||||||
let options = EvalOpt.(read ~lang:CameLIGO ~ext:".mligo")
|
let options = EvalOpt.(read ~lang:`CameLIGO ~ext:".mligo")
|
||||||
|
end
|
||||||
|
|
||||||
|
module SubIO =
|
||||||
|
struct
|
||||||
|
type options = <
|
||||||
|
libs : string list;
|
||||||
|
verbose : SSet.t;
|
||||||
|
offsets : bool;
|
||||||
|
lang : EvalOpt.language;
|
||||||
|
ext : string;
|
||||||
|
mode : [`Byte | `Point];
|
||||||
|
cmd : EvalOpt.command;
|
||||||
|
mono : bool
|
||||||
|
>
|
||||||
|
|
||||||
|
let options : options =
|
||||||
|
object
|
||||||
|
method libs = IO.options#libs
|
||||||
|
method verbose = IO.options#verbose
|
||||||
|
method offsets = IO.options#offsets
|
||||||
|
method lang = IO.options#lang
|
||||||
|
method ext = IO.options#ext
|
||||||
|
method mode = IO.options#mode
|
||||||
|
method cmd = IO.options#cmd
|
||||||
|
method mono = IO.options#mono
|
||||||
|
end
|
||||||
|
|
||||||
|
let make =
|
||||||
|
EvalOpt.make ~libs:options#libs
|
||||||
|
~verbose:options#verbose
|
||||||
|
~offsets:options#offsets
|
||||||
|
~lang:options#lang
|
||||||
|
~ext:options#ext
|
||||||
|
~mode:options#mode
|
||||||
|
~cmd:options#cmd
|
||||||
|
~mono:options#mono
|
||||||
end
|
end
|
||||||
|
|
||||||
module Parser =
|
module Parser =
|
||||||
@ -22,118 +61,18 @@ module ParserLog =
|
|||||||
module Lexer = Lexer.Make (LexToken)
|
module Lexer = Lexer.Make (LexToken)
|
||||||
|
|
||||||
module Unit =
|
module Unit =
|
||||||
ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)(IO)
|
ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)(SubIO)
|
||||||
|
|
||||||
(* Main *)
|
(* Main *)
|
||||||
|
|
||||||
let issue_error error : ('a, string Region.reg) Stdlib.result =
|
let wrap = function
|
||||||
Stdlib.Error (Unit.format_error ~offsets:IO.options#offsets
|
Stdlib.Ok _ -> flush_all ()
|
||||||
IO.options#mode error)
|
| Error msg ->
|
||||||
|
(flush_all (); Printf.eprintf "\027[31m%s\027[0m%!" msg.Region.value)
|
||||||
let parse parser : ('a, string Region.reg) Stdlib.result =
|
|
||||||
try parser () with
|
|
||||||
(* Scoping errors *)
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Reserved_name name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
issue_error
|
|
||||||
("Reserved name.\nHint: Change the name.\n", None, invalid))
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_variant name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_constr name.Region.value name.Region.region in
|
|
||||||
let point = "Duplicate constructor in this sum type declaration.\n\
|
|
||||||
Hint: Change the constructor.\n",
|
|
||||||
None, token
|
|
||||||
in issue_error point
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Non_linear_pattern var) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident var.Region.value var.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [var] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
let point = "Repeated variable in this pattern.\n\
|
|
||||||
Hint: Change the name.\n",
|
|
||||||
None, invalid
|
|
||||||
in issue_error point)
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_field name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
let point = "Duplicate field name in this record declaration.\n\
|
|
||||||
Hint: Change the name.\n",
|
|
||||||
None, invalid
|
|
||||||
in issue_error point)
|
|
||||||
|
|
||||||
(* Preprocessing the input source with CPP *)
|
|
||||||
|
|
||||||
module SSet = Utils.String.Set
|
|
||||||
let sprintf = Printf.sprintf
|
|
||||||
|
|
||||||
(* Path for CPP inclusions (#include) *)
|
|
||||||
|
|
||||||
let lib_path =
|
|
||||||
match IO.options#libs with
|
|
||||||
[] -> ""
|
|
||||||
| libs -> let mk_I dir path = sprintf " -I %s%s" dir path
|
|
||||||
in List.fold_right mk_I libs ""
|
|
||||||
|
|
||||||
let prefix =
|
|
||||||
match IO.options#input with
|
|
||||||
None | Some "-" -> "temp"
|
|
||||||
| Some file -> Filename.(file |> basename |> remove_extension)
|
|
||||||
|
|
||||||
let suffix = ".pp" ^ IO.options#ext
|
|
||||||
|
|
||||||
let pp_input =
|
|
||||||
if SSet.mem "cpp" IO.options#verbose
|
|
||||||
then prefix ^ suffix
|
|
||||||
else let pp_input, pp_out =
|
|
||||||
Filename.open_temp_file prefix suffix
|
|
||||||
in close_out pp_out; pp_input
|
|
||||||
|
|
||||||
let cpp_cmd =
|
|
||||||
match IO.options#input with
|
|
||||||
None | Some "-" ->
|
|
||||||
sprintf "cpp -traditional-cpp%s - > %s"
|
|
||||||
lib_path pp_input
|
|
||||||
| Some file ->
|
|
||||||
sprintf "cpp -traditional-cpp%s %s > %s"
|
|
||||||
lib_path file pp_input
|
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
if Sys.command cpp_cmd <> 0 then
|
match IO.options#input with
|
||||||
Printf.eprintf "External error: \"%s\" failed." cpp_cmd
|
Some "-" | None ->
|
||||||
|
Unit.contract_in_stdin () |> wrap
|
||||||
(* Instantiating the lexer and calling the parser *)
|
| Some file_path ->
|
||||||
|
Unit.contract_in_file file_path |> wrap
|
||||||
let lexer_inst =
|
|
||||||
match Lexer.open_token_stream (Lexer.File pp_input) with
|
|
||||||
Ok instance ->
|
|
||||||
if IO.options#expr
|
|
||||||
then
|
|
||||||
match parse (fun () -> Unit.apply instance Unit.parse_expr) with
|
|
||||||
Stdlib.Ok _ -> ()
|
|
||||||
| Error Region.{value; _} ->
|
|
||||||
Printf.eprintf "\027[31m%s\027[0m%!" value
|
|
||||||
else
|
|
||||||
(match parse (fun () -> Unit.apply instance Unit.parse_contract) with
|
|
||||||
Stdlib.Ok _ -> ()
|
|
||||||
| Error Region.{value; _} ->
|
|
||||||
Printf.eprintf "\027[31m%s\027[0m%!" value)
|
|
||||||
| Stdlib.Error (Lexer.File_opening msg) ->
|
|
||||||
Printf.eprintf "\027[31m%s\027[0m%!" msg
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
[@@@warning "-42"]
|
[@@@warning "-42"]
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
Reserved_name of AST.variable
|
Reserved_name of AST.variable
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
(* This module exports checks on scoping, called from the parser. *)
|
(* This module exports checks on scoping, called from the parser. *)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
Reserved_name of AST.variable
|
Reserved_name of AST.variable
|
||||||
| Duplicate_variant of AST.variable
|
| Duplicate_variant of AST.variable
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
module Region = Region
|
|
||||||
module Pos = Pos
|
|
@ -143,12 +143,12 @@ let apply parser =
|
|||||||
|
|
||||||
(* Parsing a contract in a file *)
|
(* Parsing a contract in a file *)
|
||||||
|
|
||||||
let parse_file source = apply (fun () -> Unit.parse_file source)
|
let parse_file source = apply (fun () -> Unit.contract_in_file source)
|
||||||
|
|
||||||
(* Parsing a contract in a string *)
|
(* Parsing a contract in a string *)
|
||||||
|
|
||||||
let parse_string source = apply (fun () -> Unit.parse_string source)
|
let parse_string source = apply (fun () -> Unit.contract_in_string source)
|
||||||
|
|
||||||
(* Parsing an expression in a string *)
|
(* Parsing an expression in a string *)
|
||||||
|
|
||||||
let parse_expression source = apply (fun () -> Unit.parse_expression source)
|
let parse_expression source = apply (fun () -> Unit.expr_in_string source)
|
||||||
|
@ -1,22 +1,5 @@
|
|||||||
$HOME/git/OCaml-build/Makefile
|
$HOME/git/OCaml-build/Makefile
|
||||||
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.ml
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
|
|
||||||
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.mli PP_EvalOpt.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.ml PP_EvalOpt.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_AST.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Lexer.mll
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/Preproc.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/Preproc.mll
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Lexer.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Parser.mly
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/.E_Parser.mly.tag
|
|
||||||
|
|
||||||
../shared/Lexer.mli
|
../shared/Lexer.mli
|
||||||
../shared/Lexer.mll
|
../shared/Lexer.mll
|
||||||
../shared/EvalOpt.ml
|
../shared/EvalOpt.ml
|
||||||
@ -36,7 +19,4 @@ $HOME/git/ligo/vendors/Preprocessor/.E_Parser.mly.tag
|
|||||||
../shared/ParserUnit.mli
|
../shared/ParserUnit.mli
|
||||||
../shared/ParserUnit.ml
|
../shared/ParserUnit.ml
|
||||||
|
|
||||||
Stubs/Simple_utils.ml
|
|
||||||
Stubs/Preprocessor.ml
|
|
||||||
|
|
||||||
$HOME/git/ligo/_build/default/src/passes/1-parser/pascaligo/ParErr.ml
|
$HOME/git/ligo/_build/default/src/passes/1-parser/pascaligo/ParErr.ml
|
||||||
|
@ -19,6 +19,8 @@ open Utils
|
|||||||
denoting the _region_ of the occurrence of the keyword "and".
|
denoting the _region_ of the occurrence of the keyword "and".
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
|
||||||
type 'a reg = 'a Region.reg
|
type 'a reg = 'a Region.reg
|
||||||
|
|
||||||
(* Keywords of LIGO *)
|
(* Keywords of LIGO *)
|
||||||
|
@ -2,4 +2,4 @@ SHELL := dash
|
|||||||
BFLAGS := -strict-sequence -w +A-48-4 -g
|
BFLAGS := -strict-sequence -w +A-48-4 -g
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
> rm -f Parser.msg Parser.msg.map Parser.msg.states Version.ml
|
> \rm -f Parser.msg.map Parser.msg.states Version.ml
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
[@@@warning "-42"]
|
[@@@warning "-42"]
|
||||||
|
|
||||||
open Region
|
open Simple_utils.Region
|
||||||
open AST
|
open AST
|
||||||
|
|
||||||
(* END HEADER *)
|
(* END HEADER *)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
[@@@coverage exclude_file]
|
[@@@coverage exclude_file]
|
||||||
|
|
||||||
open AST
|
open AST
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
open! Region
|
open! Region
|
||||||
|
|
||||||
let sprintf = Printf.sprintf
|
let sprintf = Printf.sprintf
|
||||||
|
@ -1,10 +1,49 @@
|
|||||||
(* Driver for the PascaLIGO parser *)
|
(* Driver for the PascaLIGO parser *)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
module SSet = Set.Make (String)
|
||||||
|
|
||||||
module IO =
|
module IO =
|
||||||
struct
|
struct
|
||||||
let options = EvalOpt.(read ~lang:`PascaLIGO ~ext:".ligo")
|
let options = EvalOpt.(read ~lang:`PascaLIGO ~ext:".ligo")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module SubIO =
|
||||||
|
struct
|
||||||
|
type options = <
|
||||||
|
libs : string list;
|
||||||
|
verbose : SSet.t;
|
||||||
|
offsets : bool;
|
||||||
|
lang : EvalOpt.language;
|
||||||
|
ext : string;
|
||||||
|
mode : [`Byte | `Point];
|
||||||
|
cmd : EvalOpt.command;
|
||||||
|
mono : bool
|
||||||
|
>
|
||||||
|
|
||||||
|
let options : options =
|
||||||
|
object
|
||||||
|
method libs = IO.options#libs
|
||||||
|
method verbose = IO.options#verbose
|
||||||
|
method offsets = IO.options#offsets
|
||||||
|
method lang = IO.options#lang
|
||||||
|
method ext = IO.options#ext
|
||||||
|
method mode = IO.options#mode
|
||||||
|
method cmd = IO.options#cmd
|
||||||
|
method mono = IO.options#mono
|
||||||
|
end
|
||||||
|
|
||||||
|
let make =
|
||||||
|
EvalOpt.make ~libs:options#libs
|
||||||
|
~verbose:options#verbose
|
||||||
|
~offsets:options#offsets
|
||||||
|
~lang:options#lang
|
||||||
|
~ext:options#ext
|
||||||
|
~mode:options#mode
|
||||||
|
~cmd:options#cmd
|
||||||
|
~mono:options#mono
|
||||||
|
end
|
||||||
|
|
||||||
module Parser =
|
module Parser =
|
||||||
struct
|
struct
|
||||||
type ast = AST.t
|
type ast = AST.t
|
||||||
@ -22,119 +61,18 @@ module ParserLog =
|
|||||||
module Lexer = Lexer.Make (LexToken)
|
module Lexer = Lexer.Make (LexToken)
|
||||||
|
|
||||||
module Unit =
|
module Unit =
|
||||||
ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)(IO)
|
ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)(SubIO)
|
||||||
|
|
||||||
module SSet = Set.Make (String)
|
|
||||||
|
|
||||||
(* Main *)
|
(* Main *)
|
||||||
|
|
||||||
let issue_error error : ('a, string Region.reg) Stdlib.result =
|
let wrap = function
|
||||||
Stdlib.Error (Unit.format_error ~offsets:IO.options#offsets
|
Stdlib.Ok _ -> flush_all ()
|
||||||
IO.options#mode error)
|
| Error msg ->
|
||||||
|
(flush_all (); Printf.eprintf "\027[31m%s\027[0m%!" msg.Region.value)
|
||||||
let parse parser : ('a, string Region.reg) Stdlib.result =
|
|
||||||
try parser () with
|
|
||||||
(* Scoping errors *)
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_parameter name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is not a reserved name for the
|
|
||||||
lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
issue_error ("Duplicate parameter.\nHint: Change the name.\n",
|
|
||||||
None, invalid))
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Reserved_name name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is not a reserved name for the
|
|
||||||
lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
issue_error
|
|
||||||
("Reserved name.\nHint: Change the name.\n", None, invalid))
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_variant name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_constr name.Region.value name.Region.region in
|
|
||||||
let point = "Duplicate constructor in this sum type declaration.\n\
|
|
||||||
Hint: Change the constructor.\n",
|
|
||||||
None, token
|
|
||||||
in issue_error point
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Non_linear_pattern var) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident var.Region.value var.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [var] is not a reserved name for the
|
|
||||||
lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
let point = "Repeated variable in this pattern.\n\
|
|
||||||
Hint: Change the name.\n",
|
|
||||||
None, invalid
|
|
||||||
in issue_error point)
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_field name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
let point =
|
|
||||||
"Duplicate field name in this record declaration.\n\
|
|
||||||
Hint: Change the name.\n",
|
|
||||||
None, invalid
|
|
||||||
in issue_error point)
|
|
||||||
|
|
||||||
(* Preprocessing the input source *)
|
|
||||||
|
|
||||||
let preproc cin : unit =
|
|
||||||
let close () = flush_all (); close_in cin in
|
|
||||||
let buffer = Lexing.from_channel cin in
|
|
||||||
let open Lexing in
|
|
||||||
let () =
|
|
||||||
match IO.options#input with
|
|
||||||
None | Some "-" -> ()
|
|
||||||
| Some pos_fname ->
|
|
||||||
buffer.lex_curr_p <- {buffer.lex_curr_p with pos_fname} in
|
|
||||||
match Preproc.lex IO.options buffer with
|
|
||||||
Stdlib.Error (pp_buffer, err) ->
|
|
||||||
if SSet.mem "preproc" IO.options#verbose then
|
|
||||||
Printf.printf "%s\n%!" (Buffer.contents pp_buffer);
|
|
||||||
let Region.{value; _} =
|
|
||||||
Preproc.format ~offsets:IO.options#offsets ~file:true err
|
|
||||||
in close (); Printf.eprintf "\027[31m%s\027[0m%!" value
|
|
||||||
| Stdlib.Ok pp_buffer ->
|
|
||||||
(* Running the lexer and the parser on the preprocessed input *)
|
|
||||||
|
|
||||||
let source = Lexer.String (Buffer.contents pp_buffer) in
|
|
||||||
match Lexer.open_token_stream source with
|
|
||||||
Stdlib.Ok instance ->
|
|
||||||
if IO.options#expr
|
|
||||||
then
|
|
||||||
match parse (fun () -> Unit.apply instance Unit.parse_expr) with
|
|
||||||
Stdlib.Ok _ -> ()
|
|
||||||
| Error Region.{value; _} ->
|
|
||||||
close (); Printf.eprintf "\027[31m%s\027[0m%!" value
|
|
||||||
else
|
|
||||||
(match parse (fun () -> Unit.apply instance Unit.parse_contract) with
|
|
||||||
Stdlib.Ok _ -> ()
|
|
||||||
| Error Region.{value; _} ->
|
|
||||||
close (); Printf.eprintf "\027[31m%s\027[0m%!" value)
|
|
||||||
| Stdlib.Error (Lexer.File_opening msg) ->
|
|
||||||
flush_all (); Printf.eprintf "\027[31m%s\027[0m%!" msg
|
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
match IO.options#input with
|
match IO.options#input with
|
||||||
Some "-" | None -> preproc stdin
|
Some "-" | None ->
|
||||||
| Some file_path ->
|
Unit.contract_in_stdin () |> wrap
|
||||||
try open_in file_path |> preproc with
|
| Some file_path ->
|
||||||
Sys_error msg ->
|
Unit.contract_in_file file_path |> wrap
|
||||||
(flush_all (); Printf.eprintf "\027[31m%s\027[0m%!" msg)
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
[@@@warning "-42"]
|
[@@@warning "-42"]
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
Reserved_name of AST.variable
|
Reserved_name of AST.variable
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
(* This module exports checks on scoping, called from the parser. *)
|
(* This module exports checks on scoping, called from the parser. *)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
Reserved_name of AST.variable
|
Reserved_name of AST.variable
|
||||||
| Duplicate_parameter of AST.variable
|
| Duplicate_parameter of AST.variable
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
module Preproc = Preproc
|
|
||||||
module EvalOpt = PP_EvalOpt
|
|
@ -1,2 +0,0 @@
|
|||||||
module Region = Region
|
|
||||||
module Pos = Pos
|
|
@ -149,12 +149,12 @@ let apply parser =
|
|||||||
|
|
||||||
(* Parsing a contract in a file *)
|
(* Parsing a contract in a file *)
|
||||||
|
|
||||||
let parse_file source = apply (fun () -> Unit.parse_file source)
|
let parse_file source = apply (fun () -> Unit.contract_in_file source)
|
||||||
|
|
||||||
(* Parsing a contract in a string *)
|
(* Parsing a contract in a string *)
|
||||||
|
|
||||||
let parse_string source = apply (fun () -> Unit.parse_string source)
|
let parse_string source = apply (fun () -> Unit.contract_in_string source)
|
||||||
|
|
||||||
(* Parsing an expression in a string *)
|
(* Parsing an expression in a string *)
|
||||||
|
|
||||||
let parse_expression source = apply (fun () -> Unit.parse_expression source)
|
let parse_expression source = apply (fun () -> Unit.expr_in_string source)
|
||||||
|
@ -1,20 +1,5 @@
|
|||||||
$HOME/git/OCaml-build/Makefile
|
$HOME/git/OCaml-build/Makefile
|
||||||
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.ml
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
|
|
||||||
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_AST.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Lexer.mll
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.ml
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/Preproc.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/EvalOpt.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/Preproc.mll
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Lexer.mli
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/E_Parser.mly
|
|
||||||
$HOME/git/ligo/vendors/Preprocessor/.E_Parser.mly.tag
|
|
||||||
|
|
||||||
../shared/Lexer.mli
|
../shared/Lexer.mli
|
||||||
../shared/Lexer.mll
|
../shared/Lexer.mll
|
||||||
../shared/EvalOpt.ml
|
../shared/EvalOpt.ml
|
||||||
@ -34,9 +19,7 @@ $HOME/git/ligo/vendors/Preprocessor/.E_Parser.mly.tag
|
|||||||
../shared/ParserUnit.mli
|
../shared/ParserUnit.mli
|
||||||
../shared/ParserUnit.ml
|
../shared/ParserUnit.ml
|
||||||
|
|
||||||
Stubs/Simple_utils.ml
|
|
||||||
Stubs/Parser_cameligo.ml
|
Stubs/Parser_cameligo.ml
|
||||||
Stubs/Preprocessor.ml
|
|
||||||
|
|
||||||
../cameligo/AST.ml
|
../cameligo/AST.ml
|
||||||
../cameligo/ParserLog.mli
|
../cameligo/ParserLog.mli
|
||||||
|
@ -4,7 +4,7 @@ module Region = Simple_utils.Region
|
|||||||
|
|
||||||
module IO =
|
module IO =
|
||||||
struct
|
struct
|
||||||
let options = EvalOpt.(read ~lang:ReasonLIGO ~ext:".religo")
|
let options = EvalOpt.(read ~lang:`ReasonLIGO ~ext:".religo")
|
||||||
end
|
end
|
||||||
|
|
||||||
module M = LexerUnit.Make (IO) (Lexer.Make (LexToken))
|
module M = LexerUnit.Make (IO) (Lexer.Make (LexToken))
|
||||||
|
@ -2,4 +2,4 @@ SHELL := dash
|
|||||||
BFLAGS := -strict-sequence -w +A-48-4 -g
|
BFLAGS := -strict-sequence -w +A-48-4 -g
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
> rm -f Parser.msg Parser.msg.map Parser.msg.states Version.ml
|
> \rm -f Parser.msg.map Parser.msg.states Version.ml
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
[@@@warning "-42"]
|
[@@@warning "-42"]
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
open Region
|
open Region
|
||||||
module AST = Parser_cameligo.AST
|
module AST = Parser_cameligo.AST
|
||||||
open! AST
|
open! AST
|
||||||
|
4148
src/passes/1-parser/reasonligo/Parser.msg
Normal file
4148
src/passes/1-parser/reasonligo/Parser.msg
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,47 @@
|
|||||||
(** Driver for the ReasonLIGO parser *)
|
(* Driver for the ReasonLIGO parser *)
|
||||||
|
|
||||||
|
module Region = Simple_utils.Region
|
||||||
|
module SSet = Set.Make (String)
|
||||||
|
|
||||||
module IO =
|
module IO =
|
||||||
struct
|
struct
|
||||||
let options = EvalOpt.(read ~lang:ReasonLIGO ~ext:".religo")
|
let options = EvalOpt.(read ~lang:`ReasonLIGO ~ext:".religo")
|
||||||
|
end
|
||||||
|
|
||||||
|
module SubIO =
|
||||||
|
struct
|
||||||
|
type options = <
|
||||||
|
libs : string list;
|
||||||
|
verbose : SSet.t;
|
||||||
|
offsets : bool;
|
||||||
|
lang : EvalOpt.language;
|
||||||
|
ext : string;
|
||||||
|
mode : [`Byte | `Point];
|
||||||
|
cmd : EvalOpt.command;
|
||||||
|
mono : bool
|
||||||
|
>
|
||||||
|
|
||||||
|
let options : options =
|
||||||
|
object
|
||||||
|
method libs = IO.options#libs
|
||||||
|
method verbose = IO.options#verbose
|
||||||
|
method offsets = IO.options#offsets
|
||||||
|
method lang = IO.options#lang
|
||||||
|
method ext = IO.options#ext
|
||||||
|
method mode = IO.options#mode
|
||||||
|
method cmd = IO.options#cmd
|
||||||
|
method mono = IO.options#mono
|
||||||
|
end
|
||||||
|
|
||||||
|
let make =
|
||||||
|
EvalOpt.make ~libs:options#libs
|
||||||
|
~verbose:options#verbose
|
||||||
|
~offsets:options#offsets
|
||||||
|
~lang:options#lang
|
||||||
|
~ext:options#ext
|
||||||
|
~mode:options#mode
|
||||||
|
~cmd:options#cmd
|
||||||
|
~mono:options#mono
|
||||||
end
|
end
|
||||||
|
|
||||||
module Parser =
|
module Parser =
|
||||||
@ -22,133 +61,18 @@ module ParserLog =
|
|||||||
module Lexer = Lexer.Make (LexToken)
|
module Lexer = Lexer.Make (LexToken)
|
||||||
|
|
||||||
module Unit =
|
module Unit =
|
||||||
ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)(IO)
|
ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog)(SubIO)
|
||||||
|
|
||||||
(* Main *)
|
(* Main *)
|
||||||
|
|
||||||
let issue_error error : ('a, string Region.reg) Stdlib.result =
|
let wrap = function
|
||||||
Stdlib.Error (Unit.format_error ~offsets:IO.options#offsets
|
Stdlib.Ok _ -> flush_all ()
|
||||||
IO.options#mode error)
|
| Error msg ->
|
||||||
|
(flush_all (); Printf.eprintf "\027[31m%s\027[0m%!" msg.Region.value)
|
||||||
let parse parser : ('a, string Region.reg) Stdlib.result =
|
|
||||||
try parser () with
|
|
||||||
(* Ad hoc errors from the parser *)
|
|
||||||
|
|
||||||
SyntaxError.Error (SyntaxError.WrongFunctionArguments expr) ->
|
|
||||||
let msg = "It looks like you are defining a function, \
|
|
||||||
however we do not\n\
|
|
||||||
understand the parameters declaration.\n\
|
|
||||||
Examples of valid functions:\n\
|
|
||||||
let x = (a: string, b: int) : int => 3;\n\
|
|
||||||
let x = (a: string) : string => \"Hello, \" ++ a;\n"
|
|
||||||
and region = AST.expr_to_region expr in
|
|
||||||
let error = Unit.short_error ~offsets:IO.options#offsets
|
|
||||||
IO.options#mode msg region
|
|
||||||
in Stdlib.Error Region.{value=error; region}
|
|
||||||
|
|
||||||
(* Scoping errors *)
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Reserved_name name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
issue_error
|
|
||||||
("Reserved name.\nHint: Change the name.\n", None, invalid))
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_variant name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_constr name.Region.value name.Region.region in
|
|
||||||
let point = "Duplicate constructor in this sum type declaration.\n\
|
|
||||||
Hint: Change the constructor.\n",
|
|
||||||
None, token
|
|
||||||
in issue_error point
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Non_linear_pattern var) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident var.Region.value var.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [var] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
let point = "Repeated variable in this pattern.\n\
|
|
||||||
Hint: Change the name.\n",
|
|
||||||
None, invalid
|
|
||||||
in issue_error point)
|
|
||||||
|
|
||||||
| Scoping.Error (Scoping.Duplicate_field name) ->
|
|
||||||
let token =
|
|
||||||
Lexer.Token.mk_ident name.Region.value name.Region.region in
|
|
||||||
(match token with
|
|
||||||
(* Cannot fail because [name] is a not a
|
|
||||||
reserved name for the lexer. *)
|
|
||||||
Stdlib.Error _ -> assert false
|
|
||||||
| Ok invalid ->
|
|
||||||
let point =
|
|
||||||
"Duplicate field name in this record declaration.\n\
|
|
||||||
Hint: Change the name.\n",
|
|
||||||
None, invalid
|
|
||||||
in issue_error point)
|
|
||||||
|
|
||||||
(* Preprocessing the input source with CPP *)
|
|
||||||
|
|
||||||
module SSet = Utils.String.Set
|
|
||||||
let sprintf = Printf.sprintf
|
|
||||||
|
|
||||||
(* Path for CPP inclusions (#include) *)
|
|
||||||
|
|
||||||
let lib_path =
|
|
||||||
match IO.options#libs with
|
|
||||||
[] -> ""
|
|
||||||
| libs -> let mk_I dir path = sprintf " -I %s%s" dir path
|
|
||||||
in List.fold_right mk_I libs ""
|
|
||||||
|
|
||||||
let prefix =
|
|
||||||
match IO.options#input with
|
|
||||||
None | Some "-" -> "temp"
|
|
||||||
| Some file -> Filename.(file |> basename |> remove_extension)
|
|
||||||
|
|
||||||
let suffix = ".pp" ^ IO.options#ext
|
|
||||||
|
|
||||||
let pp_input =
|
|
||||||
if SSet.mem "cpp" IO.options#verbose
|
|
||||||
then prefix ^ suffix
|
|
||||||
else let pp_input, pp_out =
|
|
||||||
Filename.open_temp_file prefix suffix
|
|
||||||
in close_out pp_out; pp_input
|
|
||||||
|
|
||||||
let cpp_cmd =
|
|
||||||
match IO.options#input with
|
|
||||||
None | Some "-" ->
|
|
||||||
sprintf "cpp -traditional-cpp%s - > %s"
|
|
||||||
lib_path pp_input
|
|
||||||
| Some file ->
|
|
||||||
sprintf "cpp -traditional-cpp%s %s > %s"
|
|
||||||
lib_path file pp_input
|
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
if Sys.command cpp_cmd <> 0 then
|
match IO.options#input with
|
||||||
Printf.eprintf "External error: \"%s\" failed." cpp_cmd
|
Some "-" | None ->
|
||||||
|
Unit.contract_in_stdin () |> wrap
|
||||||
(* Instantiating the lexer and calling the parser *)
|
| Some file_path ->
|
||||||
|
Unit.contract_in_file file_path |> wrap
|
||||||
let lexer_inst =
|
|
||||||
match Lexer.open_token_stream (Lexer.File pp_input) with
|
|
||||||
Ok instance ->
|
|
||||||
if IO.options#expr
|
|
||||||
then
|
|
||||||
match parse (fun () -> Unit.apply instance Unit.parse_expr) with
|
|
||||||
Stdlib.Ok _ -> ()
|
|
||||||
| Error Region.{value; _} ->
|
|
||||||
Printf.eprintf "\027[31m%s\027[0m%!" value
|
|
||||||
else
|
|
||||||
(match parse (fun () -> Unit.apply instance Unit.parse_contract) with
|
|
||||||
Stdlib.Ok _ -> ()
|
|
||||||
| Error Region.{value; _} ->
|
|
||||||
Printf.eprintf "\027[31m%s\027[0m%!" value)
|
|
||||||
| Stdlib.Error (Lexer.File_opening msg) ->
|
|
||||||
Printf.eprintf "\027[31m%s\027[0m%!" msg
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
module Preproc = Preproc
|
|
@ -1,2 +0,0 @@
|
|||||||
module Region = Region
|
|
||||||
module Pos = Pos
|
|
@ -241,20 +241,32 @@ module Make (Lexer: Lexer.S)
|
|||||||
|
|
||||||
(* Parsing a contract in a file *)
|
(* Parsing a contract in a file *)
|
||||||
|
|
||||||
let parse_file (source : string) =
|
let contract_in_file (source : string) =
|
||||||
let options = SubIO.make ~input:(Some source) ~expr:false
|
let options = SubIO.make ~input:(Some source) ~expr:false
|
||||||
in gen_parser options (Lexer.File source) parse_contract
|
in gen_parser options (Lexer.File source) parse_contract
|
||||||
|
|
||||||
(* Parsing a contract in a string *)
|
(* Parsing a contract in a string *)
|
||||||
|
|
||||||
let parse_string (source : string) =
|
let contract_in_string (source : string) =
|
||||||
let options = SubIO.make ~input:None ~expr:false in
|
let options = SubIO.make ~input:None ~expr:false in
|
||||||
gen_parser options (Lexer.String source) parse_contract
|
gen_parser options (Lexer.String source) parse_contract
|
||||||
|
|
||||||
|
(* Parsing a contract in stdin *)
|
||||||
|
|
||||||
|
let contract_in_stdin () =
|
||||||
|
let options = SubIO.make ~input:None ~expr:false in
|
||||||
|
gen_parser options Lexer.Stdin parse_contract
|
||||||
|
|
||||||
(* Parsing an expression in a string *)
|
(* Parsing an expression in a string *)
|
||||||
|
|
||||||
let parse_expression (source : string) =
|
let expr_in_string (source : string) =
|
||||||
let options = SubIO.make ~input:None ~expr:true in
|
let options = SubIO.make ~input:None ~expr:true in
|
||||||
gen_parser options (Lexer.String source) parse_expr
|
gen_parser options (Lexer.String source) parse_expr
|
||||||
|
|
||||||
|
(* Parsing an expression in stdin *)
|
||||||
|
|
||||||
|
let expr_in_stdin () =
|
||||||
|
let options = SubIO.make ~input:None ~expr:true in
|
||||||
|
gen_parser options Lexer.Stdin parse_expr
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -65,12 +65,18 @@ module Make (Lexer : Lexer.S)
|
|||||||
|
|
||||||
(* Parsers *)
|
(* Parsers *)
|
||||||
|
|
||||||
val parse_file :
|
val contract_in_file :
|
||||||
string -> (AST.t, message Region.reg) Stdlib.result
|
string -> (AST.t, message Region.reg) Stdlib.result
|
||||||
|
|
||||||
val parse_string :
|
val contract_in_string :
|
||||||
string -> (AST.t, message Region.reg) Stdlib.result
|
string -> (AST.t, message Region.reg) Stdlib.result
|
||||||
|
|
||||||
val parse_expression :
|
val contract_in_stdin :
|
||||||
|
unit -> (AST.t, message Region.reg) Stdlib.result
|
||||||
|
|
||||||
|
val expr_in_string :
|
||||||
string -> (AST.expr, message Region.reg) Stdlib.result
|
string -> (AST.expr, message Region.reg) Stdlib.result
|
||||||
end
|
|
||||||
|
val expr_in_stdin :
|
||||||
|
unit -> (AST.expr, message Region.reg) Stdlib.result
|
||||||
|
end
|
||||||
|
4
vendors/Preprocessor/.links
vendored
4
vendors/Preprocessor/.links
vendored
@ -1,5 +1 @@
|
|||||||
$HOME/git/OCaml-build/Makefile
|
$HOME/git/OCaml-build/Makefile
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/pos.ml
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
|
|
||||||
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
|
|
||||||
|
3
vendors/Preprocessor/LICENSE
vendored
3
vendors/Preprocessor/LICENSE
vendored
@ -1,6 +1,7 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018 Christian Rinderknecht
|
Copyright (c) 2018, 2019, 2020 Christian Rinderknecht,
|
||||||
|
2020 LigoLANG
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
5
vendors/Preprocessor/Makefile.cfg
vendored
5
vendors/Preprocessor/Makefile.cfg
vendored
@ -1,4 +1,5 @@
|
|||||||
SHELL := dash
|
SHELL := dash
|
||||||
BFLAGS := -strict-sequence -w +A-48-4
|
BFLAGS := -strict-sequence -w +A-48-4
|
||||||
#OCAMLC := ocamlcp
|
|
||||||
#OCAMLOPT := ocamloptp
|
clean::
|
||||||
|
> \rm -f Version.ml
|
||||||
|
8
vendors/Preprocessor/Preproc.mll
vendored
8
vendors/Preprocessor/Preproc.mll
vendored
@ -331,7 +331,7 @@ let expr state buffer : mode =
|
|||||||
|
|
||||||
let directives = [
|
let directives = [
|
||||||
"define"; "elif"; "else"; "endif"; "endregion"; "error";
|
"define"; "elif"; "else"; "endif"; "endregion"; "error";
|
||||||
"if"; "include"; "line"; "region"; "undef" (* "warning" *)
|
"if"; "include"; (*"line";*) "region"; "undef" (* "; warning" *)
|
||||||
]
|
]
|
||||||
|
|
||||||
(* END OF HEADER *)
|
(* END OF HEADER *)
|
||||||
@ -572,12 +572,13 @@ rule scan state = parse
|
|||||||
in expand_offset state;
|
in expand_offset state;
|
||||||
print state ("#" ^ space ^ "endregion" ^ msg ^ "\n");
|
print state ("#" ^ space ^ "endregion" ^ msg ^ "\n");
|
||||||
scan (reduce_region state region) lexbuf
|
scan (reduce_region state region) lexbuf
|
||||||
|
(*
|
||||||
| "line" ->
|
| "line" ->
|
||||||
expand_offset state;
|
expand_offset state;
|
||||||
print state ("#" ^ space ^ "line");
|
print state ("#" ^ space ^ "line");
|
||||||
line_ind state lexbuf;
|
line_ind state lexbuf;
|
||||||
scan {state with offset = Prefix 0} lexbuf
|
scan {state with offset = Prefix 0} lexbuf
|
||||||
(*
|
|
||||||
| "warning" ->
|
| "warning" ->
|
||||||
let start_p, end_p = region in
|
let start_p, end_p = region in
|
||||||
let msg = message [] lexbuf in
|
let msg = message [] lexbuf in
|
||||||
@ -643,7 +644,7 @@ and symbol state = parse
|
|||||||
ident as id { id, mk_reg lexbuf }
|
ident as id { id, mk_reg lexbuf }
|
||||||
| _ { fail Invalid_symbol state lexbuf }
|
| _ { fail Invalid_symbol state lexbuf }
|
||||||
|
|
||||||
|
(*
|
||||||
(* Line indicator (#line) *)
|
(* Line indicator (#line) *)
|
||||||
|
|
||||||
and line_ind state = parse
|
and line_ind state = parse
|
||||||
@ -674,6 +675,7 @@ and opt_line_com state = parse
|
|||||||
| eof { copy state lexbuf }
|
| eof { copy state lexbuf }
|
||||||
| blank+ { copy state lexbuf; opt_line_com state lexbuf }
|
| blank+ { copy state lexbuf; opt_line_com state lexbuf }
|
||||||
| "//" { print state ("//" ^ message [] lexbuf) }
|
| "//" { print state ("//" ^ message [] lexbuf) }
|
||||||
|
*)
|
||||||
|
|
||||||
(* New lines and verbatim sequence of characters *)
|
(* New lines and verbatim sequence of characters *)
|
||||||
|
|
||||||
|
35
vendors/Preprocessor/Preprocessor.install
vendored
Normal file
35
vendors/Preprocessor/Preprocessor.install
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
lib: [
|
||||||
|
"_build/install/default/lib/Preprocessor/META"
|
||||||
|
"_build/install/default/lib/Preprocessor/E_Lexer.mli"
|
||||||
|
"_build/install/default/lib/Preprocessor/E_Lexer.mll"
|
||||||
|
"_build/install/default/lib/Preprocessor/EvalOpt.mli"
|
||||||
|
"_build/install/default/lib/Preprocessor/EvalOpt.ml"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preproc.mli"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preproc.mll"
|
||||||
|
"_build/install/default/lib/Preprocessor/E_AST.ml"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.a"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.cma"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.cmxa"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.cmxs"
|
||||||
|
"_build/install/default/lib/Preprocessor/dune-package"
|
||||||
|
"_build/install/default/lib/Preprocessor/opam"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.cmi"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.cmt"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor.cmx"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__E_Lexer.cmi"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__E_Lexer.cmt"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__E_Lexer.cmx"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__EvalOpt.cmi"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__EvalOpt.cmt"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__EvalOpt.cmx"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__Preproc.cmi"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__Preproc.cmt"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__Preproc.cmx"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__E_AST.cmi"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__E_AST.cmt"
|
||||||
|
"_build/install/default/lib/Preprocessor/Preprocessor__E_AST.cmx"
|
||||||
|
]
|
||||||
|
doc: [
|
||||||
|
"_build/install/default/doc/Preprocessor/LICENSE"
|
||||||
|
"_build/install/default/doc/Preprocessor/README.md"
|
||||||
|
]
|
@ -1 +1,2 @@
|
|||||||
module Preproc = Preproc
|
module Preproc = Preproc
|
||||||
|
module EvalOpt = EvalOpt
|
15
vendors/Preprocessor/Preprocessor.opam
vendored
Normal file
15
vendors/Preprocessor/Preprocessor.opam
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
opam-version : "2.0"
|
||||||
|
name : "Preprocessor"
|
||||||
|
version : "1.0"
|
||||||
|
synopsis : "A C#-like preprocessor for LIGO"
|
||||||
|
description : "The following preprocessing directives are supported: #define, #elif, #else, #endif, #endregion, #error, #if, #include, #region, #undef."
|
||||||
|
maintainer : "rinderknecht@free.fr"
|
||||||
|
authors : "Christian Rinderknecht"
|
||||||
|
license : "MIT"
|
||||||
|
homepage : "https://gitlab.com/ligolang/Preprocessor"
|
||||||
|
bug-reports : "https://gitlab.com/ligolang/ligo-utils/issues"
|
||||||
|
depends : ["dune" "base" "ocaml" "simple-utils"]
|
||||||
|
build : [
|
||||||
|
[ "sh" "-c" "printf 'let version = \"%s\"' \"$(git describe --always --dirty --abbrev=0)\" > Version.ml" ]
|
||||||
|
[ "dune" "build" "-p" name "-j" jobs ]
|
||||||
|
]
|
21
vendors/Preprocessor/README.md
vendored
Normal file
21
vendors/Preprocessor/README.md
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# A preprocessor a la C# in OCaml
|
||||||
|
|
||||||
|
The following preprocessing directives are supported
|
||||||
|
* #define
|
||||||
|
* #elif
|
||||||
|
* #else
|
||||||
|
* #endif
|
||||||
|
* #endregion
|
||||||
|
* #error
|
||||||
|
* #if
|
||||||
|
* #include
|
||||||
|
* #region
|
||||||
|
* #undef
|
||||||
|
|
||||||
|
Note: Because it is meant for LIGO, there is no error raised for
|
||||||
|
invalid preprocessing directives, as the symbol `#` is valid in
|
||||||
|
PascaLIGO (cons operator for lists). Also, the preprocessor may report an error on some weird but valid PascaLIGO contracts, like
|
||||||
|
|
||||||
|
const include : list (int) = list [1]
|
||||||
|
const l : list (int) = 0
|
||||||
|
# include
|
34
vendors/Preprocessor/dune
vendored
34
vendors/Preprocessor/dune
vendored
@ -1,19 +1,27 @@
|
|||||||
|
;; Building the preprocessor as a library
|
||||||
|
|
||||||
|
(library
|
||||||
|
(name Preprocessor)
|
||||||
|
(public_name Preprocessor)
|
||||||
|
(wrapped true)
|
||||||
|
(libraries
|
||||||
|
getopt
|
||||||
|
simple-utils)
|
||||||
|
(modules EvalOpt E_Parser E_Lexer E_AST Preproc)
|
||||||
|
(preprocess
|
||||||
|
(pps bisect_ppx --conditional)))
|
||||||
|
|
||||||
|
;; Building the lexers of the preprocessor
|
||||||
|
|
||||||
(ocamllex
|
(ocamllex
|
||||||
E_Lexer Preproc)
|
E_Lexer Preproc)
|
||||||
|
|
||||||
|
;; Building the parser of the preprocessor (for boolean expressions)
|
||||||
|
|
||||||
(menhir
|
(menhir
|
||||||
(modules E_Parser))
|
(modules E_Parser))
|
||||||
|
|
||||||
(library
|
;; Building PreprocMain.exe for a standalone preprocessor
|
||||||
(name Preprocessor)
|
|
||||||
(public_name ligo.preproc)
|
|
||||||
(libraries
|
|
||||||
getopt
|
|
||||||
simple-utils)
|
|
||||||
(wrapped true)
|
|
||||||
(modules EvalOpt E_Parser E_Lexer E_AST Preproc)
|
|
||||||
(preprocess
|
|
||||||
(pps bisect_ppx --conditional)))
|
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name PreprocMain)
|
(name PreprocMain)
|
||||||
@ -22,6 +30,9 @@
|
|||||||
(preprocess
|
(preprocess
|
||||||
(pps bisect_ppx --conditional)))
|
(pps bisect_ppx --conditional)))
|
||||||
|
|
||||||
|
;; Building E_LexerMain.exe for a standalone lexer of boolean
|
||||||
|
;; expressions
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name E_LexerMain)
|
(name E_LexerMain)
|
||||||
(modules E_LexerMain)
|
(modules E_LexerMain)
|
||||||
@ -29,6 +40,9 @@
|
|||||||
(preprocess
|
(preprocess
|
||||||
(pps bisect_ppx --conditional)))
|
(pps bisect_ppx --conditional)))
|
||||||
|
|
||||||
|
;; Building E_ParserMain.exe for a standalone parser of boolean
|
||||||
|
;; expressions
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(name E_ParserMain)
|
(name E_ParserMain)
|
||||||
(modules E_ParserMain)
|
(modules E_ParserMain)
|
||||||
|
2
vendors/Preprocessor/dune-project
vendored
Normal file
2
vendors/Preprocessor/dune-project
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
(lang dune 1.7)
|
||||||
|
(using menhir 2.0)
|
12
vendors/UnionFind/UnionFind.opam
vendored
12
vendors/UnionFind/UnionFind.opam
vendored
@ -1,10 +1,12 @@
|
|||||||
opam-version : "2.0"
|
opam-version : "2.0"
|
||||||
version : "1.0"
|
version : "1.0"
|
||||||
maintainer : "rinderknecht@free.fr"
|
synopsis : "A Some implementations in OCaml of the Union/Find algorithm"
|
||||||
authors : [ "Christian Rinderknecht" ]
|
description : "All modules implementing Union/Find can be coerced by the same signature [Partition.S]. Note the function [alias] which is equivalent to [equiv], but not symmetric: [alias x y] means that [x] is an alias of y, which translates in the present context as [x] not being the representative of the equivalence class containing the equivalence between [x] and [y]. The function [alias] is useful when managing aliases during the static analyses of programming languages, so the representatives of the classes are always the original object."
|
||||||
homepage : "https://gitlab.com/rinderknecht/UnionFind"
|
maintainer : "Christian Rinderknecht <rinderknecht@free.fr>"
|
||||||
bug-reports : "https://gitlab.com/rinderknecht/UnionFind/issues"
|
authors : "Christian Rinderknecht"
|
||||||
dev-repo : "git+https://gitlab.com/rinderknecht/UnionFind.git"
|
homepage : "https://github.com/rinderknecht/UnionFind"
|
||||||
|
bug-reports : "https://github.com/rinderknecht/UnionFind/issues"
|
||||||
|
dev-repo : "git+https://github.com/rinderknecht/UnionFind.git"
|
||||||
license : "MIT"
|
license : "MIT"
|
||||||
|
|
||||||
depends : [ "dune" ]
|
depends : [ "dune" ]
|
||||||
|
@ -2,8 +2,8 @@ opam-version: "2.0"
|
|||||||
name: "memory-proto-alpha"
|
name: "memory-proto-alpha"
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
synopsis: "Tezos Protocol Alpha in memory"
|
synopsis: "Tezos Protocol Alpha in memory"
|
||||||
maintainer: "Galfour <ligolang@gmail.com>"
|
maintainer: "Galfour <contact@ligolang.org>"
|
||||||
authors: "Galfour <ligolang@gmail.com>"
|
authors: "Galfour <contact@ligolang.org>"
|
||||||
license: "MIT"
|
license: "MIT"
|
||||||
homepage: "https://gitlab.com/ligolang/tezos"
|
homepage: "https://gitlab.com/ligolang/tezos"
|
||||||
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
|
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
|
||||||
|
@ -2,8 +2,8 @@ opam-version: "2.0"
|
|||||||
name: "proto-alpha-utils"
|
name: "proto-alpha-utils"
|
||||||
version: "dev"
|
version: "dev"
|
||||||
synopsis: "LIGO Proto Alpha-specific Utilities, to be used by other libraries"
|
synopsis: "LIGO Proto Alpha-specific Utilities, to be used by other libraries"
|
||||||
maintainer: "Galfour <ligolang@gmail.com>"
|
maintainer: "Galfour <contact@ligolang.org>"
|
||||||
authors: "Galfour <ligolang@gmail.com>"
|
authors: "Galfour <contact@ligolang.org>"
|
||||||
license: "MIT"
|
license: "MIT"
|
||||||
homepage: "https://gitlab.com/ligolang/ligo-utils"
|
homepage: "https://gitlab.com/ligolang/ligo-utils"
|
||||||
bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues"
|
bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues"
|
||||||
|
10
vendors/ligo-utils/simple-utils/messages.sh
vendored
10
vendors/ligo-utils/simple-utils/messages.sh
vendored
@ -196,9 +196,13 @@ if test "$?" = "0"; then
|
|||||||
menhir --update-errors $msg.old \
|
menhir --update-errors $msg.old \
|
||||||
$flags $mly > $msg 2> $err
|
$flags $mly > $msg 2> $err
|
||||||
if test "$?" = "0"; then
|
if test "$?" = "0"; then
|
||||||
printf "done:\n"
|
if $(diff $msg $msg.old 2>&1 > /dev/null); then
|
||||||
emphasise "Warning: The LR items may have changed."
|
echo "done."
|
||||||
emphasise "> Check your error messages again."
|
else
|
||||||
|
printf "done:\n"
|
||||||
|
emphasise "Warning: The LR items may have changed."
|
||||||
|
emphasise "> Check your error messages again."
|
||||||
|
fi
|
||||||
rm -f $err
|
rm -f $err
|
||||||
else failed "."
|
else failed "."
|
||||||
touch $err
|
touch $err
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
opam-version: "2.0"
|
opam-version : "2.0"
|
||||||
name: "simple-utils"
|
name : "simple-utils"
|
||||||
version: "dev"
|
version : "dev"
|
||||||
synopsis: "LIGO Utilities, to be used by other libraries"
|
synopsis : "LIGO utilities, to be used by other libraries"
|
||||||
maintainer: "Galfour <ligolang@gmail.com>"
|
maintainer : "Galfour <contact@ligolang.org>"
|
||||||
authors: "Galfour <ligolang@gmail.com>"
|
authors : "Galfour"
|
||||||
license: "MIT"
|
license : "MIT"
|
||||||
homepage: "https://gitlab.com/ligolang/ligo-utils"
|
homepage: "https://gitlab.com/ligolang/ligo-utils"
|
||||||
bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues"
|
bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues"
|
||||||
depends: [
|
depends: [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: "michelson-parser"
|
name: "michelson-parser"
|
||||||
opam-version: "2.0"
|
opam-version: "2.0"
|
||||||
maintainer: "ligolang@gmail.com"
|
maintainer: "contact@ligolang.org"
|
||||||
authors: [ "Galfour" ]
|
authors: [ "Galfour" ]
|
||||||
homepage: "https://gitlab.com/ligolang/tezos"
|
homepage: "https://gitlab.com/ligolang/tezos"
|
||||||
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
|
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
|
||||||
|
@ -2,15 +2,14 @@ opam-version: "2.0"
|
|||||||
name: "tezos-utils"
|
name: "tezos-utils"
|
||||||
version: "dev"
|
version: "dev"
|
||||||
synopsis: "LIGO Tezos specific Utilities, to be used by other libraries"
|
synopsis: "LIGO Tezos specific Utilities, to be used by other libraries"
|
||||||
maintainer: "Galfour <ligolang@gmail.com>"
|
maintainer: "Galfour <contact@ligolang.org>"
|
||||||
authors: "Galfour <ligolang@gmail.com>"
|
authors: "Galfour <contact@ligolang.org>"
|
||||||
license: "MIT"
|
license: "MIT"
|
||||||
homepage: "https://gitlab.com/ligolang/ligo-utils"
|
homepage: "https://gitlab.com/ligolang/ligo-utils"
|
||||||
bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues"
|
bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues"
|
||||||
depends: [
|
depends: [
|
||||||
"dune"
|
"dune"
|
||||||
"base"
|
"base"
|
||||||
"base"
|
|
||||||
"bigstring"
|
"bigstring"
|
||||||
"calendar"
|
"calendar"
|
||||||
"cohttp-lwt-unix"
|
"cohttp-lwt-unix"
|
||||||
|
Loading…
Reference in New Issue
Block a user