From d1b738855058e44689199cccb773df5154bd4fac Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Tue, 30 Jun 2020 14:34:15 +0200 Subject: [PATCH] Refactoring of the dune files, minimised dependencies. --- src/passes/01-parsing/cameligo.ml | 5 +- src/passes/01-parsing/cameligo/.links | 15 +- src/passes/01-parsing/cameligo/LexToken.mli | 7 +- src/passes/01-parsing/cameligo/LexToken.mll | 16 +- src/passes/01-parsing/cameligo/LexerMain.ml | 10 +- src/passes/01-parsing/cameligo/ParToken.mly | 1 + src/passes/01-parsing/cameligo/Parser.mly | 4 +- src/passes/01-parsing/cameligo/ParserMain.ml | 29 ++- src/passes/01-parsing/cameligo/Pretty.ml | 2 +- src/passes/01-parsing/cameligo/README.txt | 2 + src/passes/01-parsing/cameligo/Scoping.ml | 6 +- src/passes/01-parsing/cameligo/Stubs/Cst.ml | 1 + .../01-parsing/cameligo/Stubs/Cst_cameligo.ml | 1 + .../cameligo/Stubs/Lexer_cameligo.ml | 1 + .../01-parsing/cameligo/Stubs/Lexer_shared.ml | 6 + .../cameligo/Stubs/Parser_cameligo.ml | 2 + .../cameligo/Stubs/Parser_shared.ml | 1 + src/passes/01-parsing/cameligo/cameligo.ml | 3 - src/passes/01-parsing/cameligo/dune | 192 +++++++++-------- src/passes/01-parsing/parser.ml | 2 +- src/passes/01-parsing/pascaligo.ml | 7 +- src/passes/01-parsing/pascaligo/.links | 15 +- src/passes/01-parsing/pascaligo/LexToken.mli | 7 +- src/passes/01-parsing/pascaligo/LexToken.mll | 13 +- src/passes/01-parsing/pascaligo/LexerMain.ml | 14 +- src/passes/01-parsing/pascaligo/ParToken.mly | 1 + src/passes/01-parsing/pascaligo/Parser.mly | 9 +- src/passes/01-parsing/pascaligo/ParserMain.ml | 29 ++- src/passes/01-parsing/pascaligo/Scoping.ml | 10 +- src/passes/01-parsing/pascaligo/Scoping.mli | 6 +- src/passes/01-parsing/pascaligo/Stubs/Cst.ml | 1 + .../pascaligo/Stubs/Cst_pascaligo.ml | 1 + .../pascaligo/Stubs/Lexer_pascaligo.ml | 1 + .../pascaligo/Stubs/Lexer_shared.ml | 6 + .../pascaligo/Stubs/Parser_pascaligo.ml | 2 + .../pascaligo/Stubs/Parser_shared.ml | 1 + src/passes/01-parsing/pascaligo/dune | 188 ++++++++-------- src/passes/01-parsing/pascaligo/pascaligo.ml | 3 - src/passes/01-parsing/reasonligo.ml | 5 +- src/passes/01-parsing/reasonligo/.links | 19 +- src/passes/01-parsing/reasonligo/LexToken.mli | 7 +- src/passes/01-parsing/reasonligo/LexToken.mll | 16 +- src/passes/01-parsing/reasonligo/LexerMain.ml | 10 +- src/passes/01-parsing/reasonligo/ParToken.mly | 1 + .../01-parsing/reasonligo/ParserMain.ml | 29 ++- src/passes/01-parsing/reasonligo/Scoping.ml | 1 + src/passes/01-parsing/reasonligo/Scoping.mli | 1 + src/passes/01-parsing/reasonligo/Stubs/Cst.ml | 1 + .../reasonligo/Stubs/Cst_cameligo.ml | 1 + .../reasonligo/Stubs/Lexer_reasonligo.ml | 1 + .../reasonligo/Stubs/Lexer_shared.ml | 6 + .../reasonligo/Stubs/Parser_cameligo.ml | 1 - .../reasonligo/Stubs/Parser_reasonligo.ml | 2 + .../reasonligo/Stubs/Parser_shared.ml | 1 + .../01-parsing/reasonligo/SyntaxError.ml | 2 +- src/passes/01-parsing/reasonligo/dune | 200 ++++++++++-------- .../01-parsing/reasonligo/reasonligo.ml | 4 - src/passes/01-parsing/shared/LexerLib.ml | 5 +- src/passes/01-parsing/shared/LexerLib.mli | 3 +- .../01-parsing/shared/{ => Misc}/Memo.ml | 0 .../01-parsing/shared/{ => Misc}/Memo.mli | 0 .../shared/{Doc => Misc}/shared.txt | 0 src/passes/01-parsing/shared/ParserAPI.ml | 10 +- src/passes/01-parsing/shared/ParserAPI.mli | 9 +- src/passes/01-parsing/shared/ParserUnit.ml | 14 +- src/passes/01-parsing/shared/ParserUnit.mli | 8 +- src/passes/01-parsing/shared/dune | 56 +++-- .../03-tree_abstraction/pascaligo/errors.ml | 2 +- src/stages/1-cst/cameligo/CST.ml | 13 +- src/stages/1-cst/cameligo/cameligo.ml | 1 - src/stages/1-cst/cameligo/dune | 13 +- src/stages/1-cst/dune | 10 +- src/stages/1-cst/pascaligo/CST.ml | 33 +-- src/stages/1-cst/pascaligo/dune | 13 +- src/stages/1-cst/pascaligo/pascaligo.ml | 1 - vendors/Preprocessor/dune | 14 +- .../ligo-utils/simple-utils}/FQueue.ml | 0 .../ligo-utils/simple-utils}/FQueue.mli | 0 .../ligo-utils/simple-utils}/Utils.ml | 0 .../ligo-utils/simple-utils}/Utils.mli | 0 vendors/ligo-utils/simple-utils/dune | 7 +- .../ligo-utils/simple-utils/simple-utils.opam | 28 ++- .../ligo-utils/simple-utils/simple_utils.ml | 8 +- 83 files changed, 717 insertions(+), 459 deletions(-) create mode 100644 src/passes/01-parsing/cameligo/README.txt create mode 100644 src/passes/01-parsing/cameligo/Stubs/Cst.ml create mode 100644 src/passes/01-parsing/cameligo/Stubs/Cst_cameligo.ml create mode 100644 src/passes/01-parsing/cameligo/Stubs/Lexer_cameligo.ml create mode 100644 src/passes/01-parsing/cameligo/Stubs/Lexer_shared.ml create mode 100644 src/passes/01-parsing/cameligo/Stubs/Parser_cameligo.ml create mode 100644 src/passes/01-parsing/cameligo/Stubs/Parser_shared.ml delete mode 100644 src/passes/01-parsing/cameligo/cameligo.ml create mode 100644 src/passes/01-parsing/pascaligo/Stubs/Cst.ml create mode 100644 src/passes/01-parsing/pascaligo/Stubs/Cst_pascaligo.ml create mode 100644 src/passes/01-parsing/pascaligo/Stubs/Lexer_pascaligo.ml create mode 100644 src/passes/01-parsing/pascaligo/Stubs/Lexer_shared.ml create mode 100644 src/passes/01-parsing/pascaligo/Stubs/Parser_pascaligo.ml create mode 100644 src/passes/01-parsing/pascaligo/Stubs/Parser_shared.ml delete mode 100644 src/passes/01-parsing/pascaligo/pascaligo.ml create mode 120000 src/passes/01-parsing/reasonligo/Scoping.ml create mode 120000 src/passes/01-parsing/reasonligo/Scoping.mli create mode 100644 src/passes/01-parsing/reasonligo/Stubs/Cst.ml create mode 100644 src/passes/01-parsing/reasonligo/Stubs/Cst_cameligo.ml create mode 100644 src/passes/01-parsing/reasonligo/Stubs/Lexer_reasonligo.ml create mode 100644 src/passes/01-parsing/reasonligo/Stubs/Lexer_shared.ml delete mode 100644 src/passes/01-parsing/reasonligo/Stubs/Parser_cameligo.ml create mode 100644 src/passes/01-parsing/reasonligo/Stubs/Parser_reasonligo.ml create mode 100644 src/passes/01-parsing/reasonligo/Stubs/Parser_shared.ml delete mode 100644 src/passes/01-parsing/reasonligo/reasonligo.ml rename src/passes/01-parsing/shared/{ => Misc}/Memo.ml (100%) rename src/passes/01-parsing/shared/{ => Misc}/Memo.mli (100%) rename src/passes/01-parsing/shared/{Doc => Misc}/shared.txt (100%) delete mode 100644 src/stages/1-cst/cameligo/cameligo.ml delete mode 100644 src/stages/1-cst/pascaligo/pascaligo.ml rename {src/passes/01-parsing/shared => vendors/ligo-utils/simple-utils}/FQueue.ml (100%) rename {src/passes/01-parsing/shared => vendors/ligo-utils/simple-utils}/FQueue.mli (100%) rename {src/passes/01-parsing/shared => vendors/ligo-utils/simple-utils}/Utils.ml (100%) rename {src/passes/01-parsing/shared => vendors/ligo-utils/simple-utils}/Utils.mli (100%) diff --git a/src/passes/01-parsing/cameligo.ml b/src/passes/01-parsing/cameligo.ml index 69af2bd6e..5bc39fcca 100644 --- a/src/passes/01-parsing/cameligo.ml +++ b/src/passes/01-parsing/cameligo.ml @@ -1,11 +1,12 @@ module CST = Cst.Cameligo -module LexToken = Parser_cameligo.LexToken -module Lexer = Lexer.Make(LexToken) +module LexToken = Lexer_cameligo.LexToken +module Lexer = Lexer_shared.Lexer.Make (LexToken) module Scoping = Parser_cameligo.Scoping module Region = Simple_utils.Region module ParErr = Parser_cameligo.ParErr module SSet = Set.Make (String) module Pretty = Parser_cameligo.Pretty +module EvalOpt = Lexer_shared.EvalOpt (* Mock IOs TODO: Fill them with CLI options *) diff --git a/src/passes/01-parsing/cameligo/.links b/src/passes/01-parsing/cameligo/.links index 8dcc06146..c4aeb0081 100644 --- a/src/passes/01-parsing/cameligo/.links +++ b/src/passes/01-parsing/cameligo/.links @@ -5,17 +5,24 @@ $HOME/git/OCaml-build/Makefile ../shared/LexerLib.ml ../shared/EvalOpt.ml ../shared/EvalOpt.mli -../shared/FQueue.ml -../shared/FQueue.mli ../shared/LexerLog.mli ../shared/LexerLog.ml ../shared/Markup.ml ../shared/Markup.mli -../shared/Utils.mli -../shared/Utils.ml ../shared/ParserAPI.mli ../shared/ParserAPI.ml ../shared/LexerUnit.mli ../shared/LexerUnit.ml ../shared/ParserUnit.mli ../shared/ParserUnit.ml + +./Stubs/Lexer_shared.ml +./Stubs/Lexer_cameligo.ml +./Stubs/Parser_shared.ml +./Stubs/Parser_cameligo.ml +./Stubs/Cst.ml +./Stubs/Cst_cameligo.ml + +$HOME/git/ligo/src/stages/1-cst/cameligo/CST.ml +$HOME/git/ligo/src/stages/1-cst/cameligo/ParserLog.mli +$HOME/git/ligo/src/stages/1-cst/cameligo/ParserLog.ml diff --git a/src/passes/01-parsing/cameligo/LexToken.mli b/src/passes/01-parsing/cameligo/LexToken.mli index b05b94318..0746a301e 100644 --- a/src/passes/01-parsing/cameligo/LexToken.mli +++ b/src/passes/01-parsing/cameligo/LexToken.mli @@ -21,13 +21,16 @@ aliased to [token]. *) +(* Dependencies *) + module Region = Simple_utils.Region module Pos = Simple_utils.Pos - -type lexeme = string +module Markup = Lexer_shared.Markup (* TOKENS *) +type lexeme = string + type t = (* Identifiers, labels, numbers and strings *) diff --git a/src/passes/01-parsing/cameligo/LexToken.mll b/src/passes/01-parsing/cameligo/LexToken.mll index 1c0bc389a..9c4378c82 100644 --- a/src/passes/01-parsing/cameligo/LexToken.mll +++ b/src/passes/01-parsing/cameligo/LexToken.mll @@ -1,17 +1,19 @@ +(* ocamlex specification for CameLIGO *) { - (* START HEADER *) +(* START HEADER *) -type lexeme = string - -let sprintf = Printf.sprintf +(* Dependencies *) module Region = Simple_utils.Region module Pos = Simple_utils.Pos -module SMap = Utils.String.Map -module SSet = Utils.String.Set +module Markup = Lexer_shared.Markup +module SMap = Map.Make (String) +module SSet = Set.Make (String) (* TOKENS *) +type lexeme = string + type t = (* Identifiers, labels, numbers and strings *) @@ -107,6 +109,8 @@ type t = (* Projections *) +let sprintf = Printf.sprintf + type token = t let proj_token = function diff --git a/src/passes/01-parsing/cameligo/LexerMain.ml b/src/passes/01-parsing/cameligo/LexerMain.ml index 498098035..071f6a07a 100644 --- a/src/passes/01-parsing/cameligo/LexerMain.ml +++ b/src/passes/01-parsing/cameligo/LexerMain.ml @@ -1,6 +1,14 @@ (* Driver for the CameLIGO lexer *) -module Region = Simple_utils.Region +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module LexerUnit = Lexer_shared.LexerUnit +module LexToken = Lexer_cameligo.LexToken + +(* Input/Output *) module IO = struct diff --git a/src/passes/01-parsing/cameligo/ParToken.mly b/src/passes/01-parsing/cameligo/ParToken.mly index 093968ee4..86ad6fb1e 100644 --- a/src/passes/01-parsing/cameligo/ParToken.mly +++ b/src/passes/01-parsing/cameligo/ParToken.mly @@ -1,4 +1,5 @@ %{ +module LexToken = Lexer_cameligo.LexToken %} (* Tokens (mirroring thise defined in module LexToken) *) diff --git a/src/passes/01-parsing/cameligo/Parser.mly b/src/passes/01-parsing/cameligo/Parser.mly index de0251a89..28b8f43a3 100644 --- a/src/passes/01-parsing/cameligo/Parser.mly +++ b/src/passes/01-parsing/cameligo/Parser.mly @@ -15,8 +15,8 @@ open CST (* Entry points *) %start contract interactive_expr -%type contract -%type interactive_expr +%type contract +%type interactive_expr %% diff --git a/src/passes/01-parsing/cameligo/ParserMain.ml b/src/passes/01-parsing/cameligo/ParserMain.ml index 0ccb71a01..0f2e547c1 100644 --- a/src/passes/01-parsing/cameligo/ParserMain.ml +++ b/src/passes/01-parsing/cameligo/ParserMain.ml @@ -1,7 +1,16 @@ (* Driver for the CameLIGO parser *) -module Region = Simple_utils.Region -module SSet = Set.Make (String) +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module LexToken = Lexer_cameligo.LexToken +module CST = Cst.Cameligo +module SSet = Set.Make (String) +module ParserUnit = Parser_shared.ParserUnit +module Pretty = Parser_cameligo.Pretty + +(* Input/Output *) module IO = struct @@ -55,22 +64,22 @@ module SubIO = module Parser = struct - type ast = AST.t - type expr = AST.expr - include Parser + type ast = CST.t + type expr = CST.expr + include Parser_cameligo.Parser end module ParserLog = struct - type ast = AST.t - type expr = AST.expr - include ParserLog + type ast = CST.t + type expr = CST.expr + include Cst_cameligo.ParserLog end -module Lexer = Lexer.Make (LexToken) +module Lexer = Lexer_shared.Lexer.Make (LexToken) module Unit = - ParserUnit.Make (Lexer)(AST)(Parser)(Parser_msg)(ParserLog)(SubIO) + ParserUnit.Make (Lexer)(CST)(Parser)(Parser_msg)(ParserLog)(SubIO) (* Main *) diff --git a/src/passes/01-parsing/cameligo/Pretty.ml b/src/passes/01-parsing/cameligo/Pretty.ml index 1eec2dc69..2129fe5fe 100644 --- a/src/passes/01-parsing/cameligo/Pretty.ml +++ b/src/passes/01-parsing/cameligo/Pretty.ml @@ -1,6 +1,6 @@ [@@@warning "-42"] -module CST=Cst.Cameligo +module CST = Cst.Cameligo open CST module Region = Simple_utils.Region open! Region diff --git a/src/passes/01-parsing/cameligo/README.txt b/src/passes/01-parsing/cameligo/README.txt new file mode 100644 index 000000000..4b332db99 --- /dev/null +++ b/src/passes/01-parsing/cameligo/README.txt @@ -0,0 +1,2 @@ +Note: The files Scoping.mli and Scoping.ml are the destination of +symbolic links from ../reasonligo. diff --git a/src/passes/01-parsing/cameligo/Scoping.ml b/src/passes/01-parsing/cameligo/Scoping.ml index 5b9820132..a409a8f80 100644 --- a/src/passes/01-parsing/cameligo/Scoping.ml +++ b/src/passes/01-parsing/cameligo/Scoping.ml @@ -1,7 +1,9 @@ [@@@warning "-42"] +(* Dependencies *) + module Region = Simple_utils.Region -module CST = Cst.Cameligo +module CST = Cst.Cameligo type t = Reserved_name of CST.variable @@ -17,7 +19,7 @@ open Region (* Useful modules *) -module SSet = Utils.String.Set +module SSet = Set.Make (String) module Ord = struct diff --git a/src/passes/01-parsing/cameligo/Stubs/Cst.ml b/src/passes/01-parsing/cameligo/Stubs/Cst.ml new file mode 100644 index 000000000..fcd70f2bb --- /dev/null +++ b/src/passes/01-parsing/cameligo/Stubs/Cst.ml @@ -0,0 +1 @@ +module Cameligo = CST diff --git a/src/passes/01-parsing/cameligo/Stubs/Cst_cameligo.ml b/src/passes/01-parsing/cameligo/Stubs/Cst_cameligo.ml new file mode 100644 index 000000000..011ad3f5e --- /dev/null +++ b/src/passes/01-parsing/cameligo/Stubs/Cst_cameligo.ml @@ -0,0 +1 @@ +module ParserLog = ParserLog diff --git a/src/passes/01-parsing/cameligo/Stubs/Lexer_cameligo.ml b/src/passes/01-parsing/cameligo/Stubs/Lexer_cameligo.ml new file mode 100644 index 000000000..0b6aa4f73 --- /dev/null +++ b/src/passes/01-parsing/cameligo/Stubs/Lexer_cameligo.ml @@ -0,0 +1 @@ +module LexToken = LexToken diff --git a/src/passes/01-parsing/cameligo/Stubs/Lexer_shared.ml b/src/passes/01-parsing/cameligo/Stubs/Lexer_shared.ml new file mode 100644 index 000000000..71d9cc522 --- /dev/null +++ b/src/passes/01-parsing/cameligo/Stubs/Lexer_shared.ml @@ -0,0 +1,6 @@ +module EvalOpt = EvalOpt +module Markup = Markup +module Lexer = Lexer +module LexerUnit = LexerUnit +module LexerLog = LexerLog +module LexerLib = LexerLib diff --git a/src/passes/01-parsing/cameligo/Stubs/Parser_cameligo.ml b/src/passes/01-parsing/cameligo/Stubs/Parser_cameligo.ml new file mode 100644 index 000000000..9479f6e5f --- /dev/null +++ b/src/passes/01-parsing/cameligo/Stubs/Parser_cameligo.ml @@ -0,0 +1,2 @@ +module Pretty = Pretty +module Parser = Parser diff --git a/src/passes/01-parsing/cameligo/Stubs/Parser_shared.ml b/src/passes/01-parsing/cameligo/Stubs/Parser_shared.ml new file mode 100644 index 000000000..f1e238ebf --- /dev/null +++ b/src/passes/01-parsing/cameligo/Stubs/Parser_shared.ml @@ -0,0 +1 @@ +module ParserUnit = ParserUnit diff --git a/src/passes/01-parsing/cameligo/cameligo.ml b/src/passes/01-parsing/cameligo/cameligo.ml deleted file mode 100644 index d85ec4700..000000000 --- a/src/passes/01-parsing/cameligo/cameligo.ml +++ /dev/null @@ -1,3 +0,0 @@ -module Parser = Parser -module Lexer = Lexer -module LexToken = LexToken diff --git a/src/passes/01-parsing/cameligo/dune b/src/passes/01-parsing/cameligo/dune index 197c92f69..552860c01 100644 --- a/src/passes/01-parsing/cameligo/dune +++ b/src/passes/01-parsing/cameligo/dune @@ -1,13 +1,48 @@ +;; -------------------------------------------------------------------- +;; LEXING + ;; Build of the lexer (ocamllex LexToken) +;; Build of the lexer as a library + +(library + (name lexer_cameligo) + (public_name ligo.lexer.cameligo) + (modules LexToken) + (libraries + ;; Ligo + lexer_shared + ;; Third party + hex) + (preprocess + (pps bisect_ppx --conditional))) + +;; Build of a standalone lexer + +(executable + (name LexerMain) + (libraries + ;; Ligo + lexer_shared + lexer_cameligo + ;; Third party + hex) + (modules LexerMain) + (preprocess + (pps bisect_ppx --conditional))) + +;; -------------------------------------------------------------------- +;; PARSING + ;; Build of the parser (menhir (merge_into Parser) (modules ParToken Parser) - (flags -la 1 --table --strict --explain --external-tokens LexToken)) + (flags -la 1 --table --strict --explain + --external-tokens Lexer_cameligo.LexToken)) ;; Build of the parser as a library @@ -15,50 +50,47 @@ (name parser_cameligo) (public_name ligo.parser.cameligo) (modules - Scoping cameligo Parser LexToken ParErr Pretty) + Scoping Parser ParErr Pretty) (libraries - pprint - terminal_size - menhirLib - parser_shared - str - simple-utils - tezos-utils - cst - ) + ;; Ligo + lexer_cameligo + parser_shared + cst + ;; Vendors + simple-utils + ;; Third party + pprint + terminal_size + menhirLib + hex) (preprocess (pps bisect_ppx --conditional)) - (flags (:standard -open Parser_shared -open Simple_utils))) + (flags (:standard -open Cst_cameligo))) ;; For CST in Parser.mli -;; Build of the unlexer (for covering the error states of the LR -;; automaton) +;; Build of the unlexer (for covering the +;; error states of the LR automaton) (executable (name Unlexer) (libraries str) + (modules Unlexer) (preprocess - (pps bisect_ppx --conditional)) - (modules Unlexer)) - -;; Local build of a standalone lexer - -(executable - (name LexerMain) - (libraries parser_cameligo) - (modules LexerMain) - (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Parser_shared -open Parser_cameligo))) + (pps bisect_ppx --conditional))) ;; Local build of a standalone parser (executable (name ParserMain) - (libraries parser_cameligo) + (libraries + ;; Ligo + parser_shared + parser_cameligo + cst + ;; Third party + hex) (modules ParserMain Parser_msg) (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Simple_utils -open Parser_shared -open Parser_cameligo))) + (pps bisect_ppx --conditional))) ;; Build of the covering of error states in the LR automaton @@ -85,7 +117,14 @@ (rule (targets all.mligo) (deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe) - (action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=mligo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly ))) + (action (run %{script_cover} + --lex-tokens=LexToken.mli + --par-tokens=ParToken.mly + --ext=mligo + --unlexer=./Unlexer.exe + --messages=Parser.msg + --dir=. + --concatenate Parser.mly))) ;; Error messages @@ -95,60 +134,45 @@ (deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli) (action (with-stdout-to %{targets} - (run - menhir - --unused-tokens - --update-errors error.messages.checked-in - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - ) - )) -) + (run menhir + --unused-tokens + --update-errors error.messages.checked-in + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly)))) (rule (target error.messages.new) (mode (promote (until-clean) (only *))) (action (with-stdout-to %{target} - (run - menhir - --unused-tokens - --list-errors - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - ) - ) - ) -) + (run menhir + --unused-tokens + --list-errors + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly)))) (alias (name runtest) (deps error.messages error.messages.new) (action - (run - menhir - --unused-tokens - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - --compare-errors error.messages.new - --compare-errors error.messages - ) - ) - ) - - + (run menhir + --unused-tokens + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly + --compare-errors error.messages.new + --compare-errors error.messages))) (rule (targets ParErr.ml) @@ -156,16 +180,12 @@ (deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli) (action (with-stdout-to %{targets} - (run - menhir - --unused-tokens - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - --compile-errors error.messages.checked-in - ) - )) -) + (run menhir + --unused-tokens + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly + --compile-errors error.messages.checked-in)))) diff --git a/src/passes/01-parsing/parser.ml b/src/passes/01-parsing/parser.ml index ba2c27cb6..5d66daa7d 100644 --- a/src/passes/01-parsing/parser.ml +++ b/src/passes/01-parsing/parser.ml @@ -2,4 +2,4 @@ module Pascaligo = Pascaligo module Cameligo = Cameligo module Reasonligo = Reasonligo module Errors = Errors -module Formatter = Formatter \ No newline at end of file +module Formatter = Formatter diff --git a/src/passes/01-parsing/pascaligo.ml b/src/passes/01-parsing/pascaligo.ml index 2f79b07e2..dc9f9f235 100644 --- a/src/passes/01-parsing/pascaligo.ml +++ b/src/passes/01-parsing/pascaligo.ml @@ -1,6 +1,9 @@ +(* Dependencies *) + +module EvalOpt = Lexer_shared.EvalOpt module CST = Cst.Pascaligo -module LexToken = Parser_pascaligo.LexToken -module Lexer = Lexer.Make(LexToken) +module LexToken = Lexer_pascaligo.LexToken +module Lexer = Lexer_shared.Lexer.Make (LexToken) module Scoping = Parser_pascaligo.Scoping module Region = Simple_utils.Region module ParErr = Parser_pascaligo.ParErr diff --git a/src/passes/01-parsing/pascaligo/.links b/src/passes/01-parsing/pascaligo/.links index aca47d8ff..ac3ad0e4c 100644 --- a/src/passes/01-parsing/pascaligo/.links +++ b/src/passes/01-parsing/pascaligo/.links @@ -6,14 +6,10 @@ $HOME/git/OCaml-build/Makefile ../shared/LexerLib.ml ../shared/EvalOpt.ml ../shared/EvalOpt.mli -../shared/FQueue.ml -../shared/FQueue.mli ../shared/LexerLog.mli ../shared/LexerLog.ml ../shared/Markup.ml ../shared/Markup.mli -../shared/Utils.mli -../shared/Utils.ml ../shared/ParserAPI.mli ../shared/ParserAPI.ml ../shared/LexerUnit.mli @@ -21,3 +17,14 @@ $HOME/git/OCaml-build/Makefile ../shared/ParserUnit.mli ../shared/ParserUnit.ml ../shared/LexerLib.ml + +./Stubs/Lexer_shared.ml +./Stubs/Lexer_pascaligo.ml +./Stubs/Parser_shared.ml +./Stubs/Parser_pascaligo.ml +./Stubs/Cst.ml +./Stubs/Cst_pascaligo.ml + +$HOME/git/ligo/src/stages/1-cst/pascaligo/CST.ml +$HOME/git/ligo/src/stages/1-cst/pascaligo/ParserLog.mli +$HOME/git/ligo/src/stages/1-cst/pascaligo/ParserLog.ml diff --git a/src/passes/01-parsing/pascaligo/LexToken.mli b/src/passes/01-parsing/pascaligo/LexToken.mli index 6c445e4b9..505c46425 100644 --- a/src/passes/01-parsing/pascaligo/LexToken.mli +++ b/src/passes/01-parsing/pascaligo/LexToken.mli @@ -21,13 +21,16 @@ aliased to [token]. *) +(* Dependencies *) + module Region = Simple_utils.Region module Pos = Simple_utils.Pos - -type lexeme = string +module Markup = Lexer_shared.Markup (* TOKENS *) +type lexeme = string + type attribute = { header : string; string : lexeme Region.reg diff --git a/src/passes/01-parsing/pascaligo/LexToken.mll b/src/passes/01-parsing/pascaligo/LexToken.mll index e037f252e..1c68e21f7 100644 --- a/src/passes/01-parsing/pascaligo/LexToken.mll +++ b/src/passes/01-parsing/pascaligo/LexToken.mll @@ -1,21 +1,20 @@ -(* Lexer specification for LIGO, to be processed by [ocamllex] *) +(* ocamlex specification for PascaLIGO *) { (* START HEADER *) -(* Shorthands *) +(* Dependencies *) module Region = Simple_utils.Region module Pos = Simple_utils.Pos +module Markup = Lexer_shared.Markup module SMap = Map.Make (String) module SSet = Set.Make (String) -type lexeme = string - -let sprintf = Printf.sprintf - (* TOKENS *) +type lexeme = string + type attribute = { header : string; string : lexeme Region.reg @@ -117,6 +116,8 @@ type t = (* Projections *) +let sprintf = Printf.sprintf + type token = t let proj_token = function diff --git a/src/passes/01-parsing/pascaligo/LexerMain.ml b/src/passes/01-parsing/pascaligo/LexerMain.ml index a497df466..1365531ba 100644 --- a/src/passes/01-parsing/pascaligo/LexerMain.ml +++ b/src/passes/01-parsing/pascaligo/LexerMain.ml @@ -1,6 +1,14 @@ (* Driver for the PascaLIGO lexer *) -module Region = Simple_utils.Region +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module LexerUnit = Lexer_shared.LexerUnit +module LexToken = Lexer_pascaligo.LexToken + +(* Input/Output *) module IO = struct @@ -10,8 +18,12 @@ module IO = in read ~block ~line:"//" ".ligo" end +(* Instantiating the standalone lexer *) + module M = LexerUnit.Make (IO) (Lexer.Make (LexToken)) +(* Tracing all tokens in the source *) + let () = match M.trace () with Stdlib.Ok () -> () diff --git a/src/passes/01-parsing/pascaligo/ParToken.mly b/src/passes/01-parsing/pascaligo/ParToken.mly index 2ed734bb7..cbd994c45 100644 --- a/src/passes/01-parsing/pascaligo/ParToken.mly +++ b/src/passes/01-parsing/pascaligo/ParToken.mly @@ -1,4 +1,5 @@ %{ +module LexToken = Lexer_pascaligo.LexToken %} (* Tokens (mirroring thise defined in module LexToken) *) diff --git a/src/passes/01-parsing/pascaligo/Parser.mly b/src/passes/01-parsing/pascaligo/Parser.mly index 37c172b4f..c0cfeff6b 100644 --- a/src/passes/01-parsing/pascaligo/Parser.mly +++ b/src/passes/01-parsing/pascaligo/Parser.mly @@ -1,10 +1,13 @@ +(* Menhir specification of the parsing of PascaLIGO *) %{ (* START HEADER *) [@@@warning "-42"] +(* Dependencies *) + open Simple_utils.Region -module CST = Cst.Pascaligo +module CST = Cst.Pascaligo open CST (* END HEADER *) @@ -15,8 +18,8 @@ open CST (* Entry points *) %start contract interactive_expr -%type contract -%type interactive_expr +%type contract +%type interactive_expr %% diff --git a/src/passes/01-parsing/pascaligo/ParserMain.ml b/src/passes/01-parsing/pascaligo/ParserMain.ml index 6158dc5da..8a91d8c42 100644 --- a/src/passes/01-parsing/pascaligo/ParserMain.ml +++ b/src/passes/01-parsing/pascaligo/ParserMain.ml @@ -1,7 +1,16 @@ (* Driver for the PascaLIGO parser *) -module Region = Simple_utils.Region -module SSet = Set.Make (String) +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module LexToken = Lexer_pascaligo.LexToken +module CST = Cst.Pascaligo +module SSet = Set.Make (String) +module ParserUnit = Parser_shared.ParserUnit +module Pretty = Parser_pascaligo.Pretty + +(* Input/Output *) module IO = struct @@ -55,22 +64,22 @@ module SubIO = module Parser = struct - type ast = AST.t - type expr = AST.expr - include Parser + type ast = CST.t + type expr = CST.expr + include Parser_pascaligo.Parser end module ParserLog = struct - type ast = AST.t - type expr = AST.expr - include ParserLog + type ast = CST.t + type expr = CST.expr + include Cst_pascaligo.ParserLog end -module Lexer = Lexer.Make (LexToken) +module Lexer = Lexer_shared.Lexer.Make (LexToken) module Unit = - ParserUnit.Make (Lexer)(AST)(Parser)(Parser_msg)(ParserLog)(SubIO) + ParserUnit.Make (Lexer)(CST)(Parser)(Parser_msg)(ParserLog)(SubIO) (* Main *) diff --git a/src/passes/01-parsing/pascaligo/Scoping.ml b/src/passes/01-parsing/pascaligo/Scoping.ml index 300abbfc7..ad2224053 100644 --- a/src/passes/01-parsing/pascaligo/Scoping.ml +++ b/src/passes/01-parsing/pascaligo/Scoping.ml @@ -1,7 +1,13 @@ +(* This module exports checks on scoping, called from the parser. *) + [@@@warning "-42"] +(* Dependencies *) + module Region = Simple_utils.Region -module CST = Cst.Pascaligo +module CST = Cst.Pascaligo + +(* Errors *) type t = Reserved_name of CST.variable @@ -18,7 +24,7 @@ open Region (* Useful modules *) -module SSet = Utils.String.Set +module SSet = Set.Make (String) module Ord = struct diff --git a/src/passes/01-parsing/pascaligo/Scoping.mli b/src/passes/01-parsing/pascaligo/Scoping.mli index 7cf0f176e..2a38309c6 100644 --- a/src/passes/01-parsing/pascaligo/Scoping.mli +++ b/src/passes/01-parsing/pascaligo/Scoping.mli @@ -1,7 +1,11 @@ (* This module exports checks on scoping, called from the parser. *) +(* Dependencies *) + module Region = Simple_utils.Region -module CST = Cst.Pascaligo +module CST = Cst.Pascaligo + +(* Errors *) type t = Reserved_name of CST.variable diff --git a/src/passes/01-parsing/pascaligo/Stubs/Cst.ml b/src/passes/01-parsing/pascaligo/Stubs/Cst.ml new file mode 100644 index 000000000..23b6f9878 --- /dev/null +++ b/src/passes/01-parsing/pascaligo/Stubs/Cst.ml @@ -0,0 +1 @@ +module Pascaligo = CST diff --git a/src/passes/01-parsing/pascaligo/Stubs/Cst_pascaligo.ml b/src/passes/01-parsing/pascaligo/Stubs/Cst_pascaligo.ml new file mode 100644 index 000000000..011ad3f5e --- /dev/null +++ b/src/passes/01-parsing/pascaligo/Stubs/Cst_pascaligo.ml @@ -0,0 +1 @@ +module ParserLog = ParserLog diff --git a/src/passes/01-parsing/pascaligo/Stubs/Lexer_pascaligo.ml b/src/passes/01-parsing/pascaligo/Stubs/Lexer_pascaligo.ml new file mode 100644 index 000000000..0b6aa4f73 --- /dev/null +++ b/src/passes/01-parsing/pascaligo/Stubs/Lexer_pascaligo.ml @@ -0,0 +1 @@ +module LexToken = LexToken diff --git a/src/passes/01-parsing/pascaligo/Stubs/Lexer_shared.ml b/src/passes/01-parsing/pascaligo/Stubs/Lexer_shared.ml new file mode 100644 index 000000000..71d9cc522 --- /dev/null +++ b/src/passes/01-parsing/pascaligo/Stubs/Lexer_shared.ml @@ -0,0 +1,6 @@ +module EvalOpt = EvalOpt +module Markup = Markup +module Lexer = Lexer +module LexerUnit = LexerUnit +module LexerLog = LexerLog +module LexerLib = LexerLib diff --git a/src/passes/01-parsing/pascaligo/Stubs/Parser_pascaligo.ml b/src/passes/01-parsing/pascaligo/Stubs/Parser_pascaligo.ml new file mode 100644 index 000000000..9479f6e5f --- /dev/null +++ b/src/passes/01-parsing/pascaligo/Stubs/Parser_pascaligo.ml @@ -0,0 +1,2 @@ +module Pretty = Pretty +module Parser = Parser diff --git a/src/passes/01-parsing/pascaligo/Stubs/Parser_shared.ml b/src/passes/01-parsing/pascaligo/Stubs/Parser_shared.ml new file mode 100644 index 000000000..f1e238ebf --- /dev/null +++ b/src/passes/01-parsing/pascaligo/Stubs/Parser_shared.ml @@ -0,0 +1 @@ +module ParserUnit = ParserUnit diff --git a/src/passes/01-parsing/pascaligo/dune b/src/passes/01-parsing/pascaligo/dune index 4851e927c..5cc2a75d0 100644 --- a/src/passes/01-parsing/pascaligo/dune +++ b/src/passes/01-parsing/pascaligo/dune @@ -1,13 +1,48 @@ +;; -------------------------------------------------------------------- +;; LEXING + ;; Build of the lexer (ocamllex LexToken) +;; Build of the lexer as a library + +(library + (name lexer_pascaligo) + (public_name ligo.lexer.pascaligo) + (modules LexToken) + (libraries + ;; Ligo + lexer_shared + ;; Third party + hex) + (preprocess + (pps bisect_ppx --conditional))) + +;; Build of a standalone lexer + +(executable + (name LexerMain) + (libraries + ;; Ligo + lexer_shared + lexer_pascaligo + ;; Third party + hex) + (modules LexerMain) + (preprocess + (pps bisect_ppx --conditional))) + +;; -------------------------------------------------------------------- +;; PARSING + ;; Build of the parser (menhir (merge_into Parser) (modules ParToken Parser) - (flags -la 1 --table --strict --explain --external-tokens LexToken)) + (flags -la 1 --table --strict --explain + --external-tokens Lexer_pascaligo.LexToken)) ;; Build of the parser as a library @@ -15,19 +50,22 @@ (name parser_pascaligo) (public_name ligo.parser.pascaligo) (modules - Scoping pascaligo Parser LexToken ParErr Pretty) + Scoping Parser ParErr Pretty) (libraries - pprint - terminal_size - menhirLib - parser_shared - hex - Preprocessor - simple-utils - cst) + ;; Ligo + lexer_pascaligo + parser_shared + cst + ;; Vendors + simple-utils + ;; Third party + pprint + terminal_size + menhirLib + hex) (preprocess (pps bisect_ppx --conditional)) - (flags (:standard -open Parser_shared -open Simple_utils))) + (flags (:standard -open Cst_pascaligo))) ;; For CST in Parser.mli ;; Build of the unlexer (for covering the ;; error states of the LR automaton) @@ -35,30 +73,24 @@ (executable (name Unlexer) (libraries str) + (modules Unlexer) (preprocess - (pps bisect_ppx --conditional)) - (modules Unlexer)) - -;; Local build of a standalone lexer - -(executable - (name LexerMain) - (libraries - hex simple-utils tezos-utils parser_pascaligo) - (modules LexerMain) - (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Parser_shared -open Parser_pascaligo))) + (pps bisect_ppx --conditional))) ;; Local build of a standalone parser (executable (name ParserMain) - (libraries parser_pascaligo) - (modules ParserMain) + (libraries + ;; Ligo + parser_shared + parser_pascaligo + cst + ;; Third party + hex) + (modules ParserMain Parser_msg) (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Simple_utils -open Parser_shared -open Parser_pascaligo))) + (pps bisect_ppx --conditional))) ;; Build of the covering of error states in the LR automaton @@ -85,7 +117,14 @@ (rule (targets all.ligo) (deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe) - (action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=ligo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly))) + (action (run %{script_cover} + --lex-tokens=LexToken.mli + --par-tokens=ParToken.mly + --ext=ligo + --unlexer=./Unlexer.exe + --messages=Parser.msg + --dir=. + --concatenate Parser.mly))) ;; Error messages @@ -95,58 +134,45 @@ (deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli) (action (with-stdout-to %{targets} - (run - menhir - --unused-tokens - --update-errors error.messages.checked-in - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - ) - )) -) + (run menhir + --unused-tokens + --update-errors error.messages.checked-in + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly)))) (rule (target error.messages.new) (mode (promote (until-clean) (only *))) (action (with-stdout-to %{target} - (run - menhir - --unused-tokens - --list-errors - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - ) - ) - ) -) + (run menhir + --unused-tokens + --list-errors + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly)))) (alias (name runtest) (deps error.messages error.messages.new) (action - (run - menhir - --unused-tokens - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - --compare-errors error.messages.new - --compare-errors error.messages - ) - ) - ) + (run menhir + --unused-tokens + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly + --compare-errors error.messages.new + --compare-errors error.messages))) (rule (targets ParErr.ml) @@ -154,16 +180,12 @@ (deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli) (action (with-stdout-to %{targets} - (run - menhir - --unused-tokens - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - --compile-errors error.messages.checked-in - ) - )) -) + (run menhir + --unused-tokens + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly + --compile-errors error.messages.checked-in)))) diff --git a/src/passes/01-parsing/pascaligo/pascaligo.ml b/src/passes/01-parsing/pascaligo/pascaligo.ml deleted file mode 100644 index 2421f543f..000000000 --- a/src/passes/01-parsing/pascaligo/pascaligo.ml +++ /dev/null @@ -1,3 +0,0 @@ -module Lexer = Lexer -module LexToken = LexToken -module Parser = Parser diff --git a/src/passes/01-parsing/reasonligo.ml b/src/passes/01-parsing/reasonligo.ml index 5bbed6c0c..cfd87761b 100644 --- a/src/passes/01-parsing/reasonligo.ml +++ b/src/passes/01-parsing/reasonligo.ml @@ -1,12 +1,13 @@ module CST = Cst.Cameligo -module LexToken = Parser_reasonligo.LexToken -module Lexer = Lexer.Make (LexToken) +module LexToken = Lexer_reasonligo.LexToken +module Lexer = Lexer_shared.Lexer.Make (LexToken) module Scoping = Parser_cameligo.Scoping module Region = Simple_utils.Region module ParErr = Parser_reasonligo.ParErr module SyntaxError = Parser_reasonligo.SyntaxError module SSet = Set.Make (String) module Pretty = Parser_reasonligo.Pretty +module EvalOpt = Lexer_shared.EvalOpt (* Mock IOs TODO: Fill them with CLI options *) diff --git a/src/passes/01-parsing/reasonligo/.links b/src/passes/01-parsing/reasonligo/.links index e85766c2b..d8ba17996 100644 --- a/src/passes/01-parsing/reasonligo/.links +++ b/src/passes/01-parsing/reasonligo/.links @@ -5,14 +5,10 @@ $HOME/git/OCaml-build/Makefile ../shared/LexerLib.ml ../shared/EvalOpt.ml ../shared/EvalOpt.mli -../shared/FQueue.ml -../shared/FQueue.mli ../shared/LexerLog.mli ../shared/LexerLog.ml ../shared/Markup.ml ../shared/Markup.mli -../shared/Utils.mli -../shared/Utils.ml ../shared/ParserAPI.mli ../shared/ParserAPI.ml ../shared/LexerUnit.mli @@ -20,10 +16,13 @@ $HOME/git/OCaml-build/Makefile ../shared/ParserUnit.mli ../shared/ParserUnit.ml -Stubs/Parser_cameligo.ml +./Stubs/Lexer_shared.ml +./Stubs/Lexer_reasonligo.ml +./Stubs/Parser_shared.ml +./Stubs/Parser_reasonligo.ml +./Stubs/Cst.ml +./Stubs/Cst_cameligo.ml -../cameligo/AST.ml -../cameligo/ParserLog.mli -../cameligo/ParserLog.ml -../cameligo/Scoping.mli -../cameligo/Scoping.ml +$HOME/git/ligo/src/stages/1-cst/cameligo/CST.ml +$HOME/git/ligo/src/stages/1-cst/cameligo/ParserLog.mli +$HOME/git/ligo/src/stages/1-cst/cameligo/ParserLog.ml diff --git a/src/passes/01-parsing/reasonligo/LexToken.mli b/src/passes/01-parsing/reasonligo/LexToken.mli index 3f91a0f71..0368aff6e 100644 --- a/src/passes/01-parsing/reasonligo/LexToken.mli +++ b/src/passes/01-parsing/reasonligo/LexToken.mli @@ -21,13 +21,16 @@ aliased to [token]. *) +(* Dependencies *) + module Region = Simple_utils.Region module Pos = Simple_utils.Pos - -type lexeme = string +module Markup = Lexer_shared.Markup (* TOKENS *) +type lexeme = string + type t = (* Identifiers, labels, numbers and strings *) diff --git a/src/passes/01-parsing/reasonligo/LexToken.mll b/src/passes/01-parsing/reasonligo/LexToken.mll index 4e7fa6079..737fdb797 100644 --- a/src/passes/01-parsing/reasonligo/LexToken.mll +++ b/src/passes/01-parsing/reasonligo/LexToken.mll @@ -1,19 +1,19 @@ +(* ocamlex specification for ReasonLIGO *) { (* START OF HEADER *) -(* Shorthands *) +(* Dependencies *) module Region = Simple_utils.Region module Pos = Simple_utils.Pos -module SMap = Utils.String.Map -module SSet = Utils.String.Set - -type lexeme = string - -let sprintf = Printf.sprintf +module Markup = Lexer_shared.Markup +module SMap = Map.Make (String) +module SSet = Set.Make (String) (* TOKENS *) +type lexeme = string + type t = (* Identifiers, labels, numbers and strings *) @@ -103,6 +103,8 @@ type t = (* Projections *) +let sprintf = Printf.sprintf + type token = t let proj_token = function diff --git a/src/passes/01-parsing/reasonligo/LexerMain.ml b/src/passes/01-parsing/reasonligo/LexerMain.ml index f0d6fdfa1..69b9d40e2 100644 --- a/src/passes/01-parsing/reasonligo/LexerMain.ml +++ b/src/passes/01-parsing/reasonligo/LexerMain.ml @@ -1,6 +1,14 @@ (* Driver for the ReasonLIGO lexer *) -module Region = Simple_utils.Region +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module LexerUnit = Lexer_shared.LexerUnit +module LexToken = Lexer_reasonligo.LexToken + +(* Input/Output *) module IO = struct diff --git a/src/passes/01-parsing/reasonligo/ParToken.mly b/src/passes/01-parsing/reasonligo/ParToken.mly index 01bbc839c..337a8d7e8 100644 --- a/src/passes/01-parsing/reasonligo/ParToken.mly +++ b/src/passes/01-parsing/reasonligo/ParToken.mly @@ -1,4 +1,5 @@ %{ +module LexToken = Lexer_reasonligo.LexToken %} (* Tokens (mirroring those defined in module LexToken) *) diff --git a/src/passes/01-parsing/reasonligo/ParserMain.ml b/src/passes/01-parsing/reasonligo/ParserMain.ml index 3dd94d37e..30d71deb5 100644 --- a/src/passes/01-parsing/reasonligo/ParserMain.ml +++ b/src/passes/01-parsing/reasonligo/ParserMain.ml @@ -1,7 +1,16 @@ (* Driver for the ReasonLIGO parser *) -module Region = Simple_utils.Region -module SSet = Set.Make (String) +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module LexToken = Lexer_reasonligo.LexToken +module CST = Cst.Cameligo +module SSet = Set.Make (String) +module ParserUnit = Parser_shared.ParserUnit +module Pretty = Parser_reasonligo.Pretty + +(* Input/Output *) module IO = struct @@ -55,22 +64,22 @@ module SubIO = module Parser = struct - type ast = AST.t - type expr = AST.expr - include Parser + type ast = CST.t + type expr = CST.expr + include Parser_reasonligo.Parser end module ParserLog = struct - type ast = AST.t - type expr = AST.expr - include ParserLog + type ast = CST.t + type expr = CST.expr + include Cst_cameligo.ParserLog end -module Lexer = Lexer.Make (LexToken) +module Lexer = Lexer_shared.Lexer.Make (LexToken) module Unit = - ParserUnit.Make (Lexer)(AST)(Parser)(Parser_msg)(ParserLog)(SubIO) + ParserUnit.Make (Lexer)(CST)(Parser)(Parser_msg)(ParserLog)(SubIO) (* Main *) diff --git a/src/passes/01-parsing/reasonligo/Scoping.ml b/src/passes/01-parsing/reasonligo/Scoping.ml new file mode 120000 index 000000000..f89a36ef0 --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Scoping.ml @@ -0,0 +1 @@ +../cameligo/Scoping.ml \ No newline at end of file diff --git a/src/passes/01-parsing/reasonligo/Scoping.mli b/src/passes/01-parsing/reasonligo/Scoping.mli new file mode 120000 index 000000000..5e0c71af4 --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Scoping.mli @@ -0,0 +1 @@ +../cameligo/Scoping.mli \ No newline at end of file diff --git a/src/passes/01-parsing/reasonligo/Stubs/Cst.ml b/src/passes/01-parsing/reasonligo/Stubs/Cst.ml new file mode 100644 index 000000000..fcd70f2bb --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Stubs/Cst.ml @@ -0,0 +1 @@ +module Cameligo = CST diff --git a/src/passes/01-parsing/reasonligo/Stubs/Cst_cameligo.ml b/src/passes/01-parsing/reasonligo/Stubs/Cst_cameligo.ml new file mode 100644 index 000000000..011ad3f5e --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Stubs/Cst_cameligo.ml @@ -0,0 +1 @@ +module ParserLog = ParserLog diff --git a/src/passes/01-parsing/reasonligo/Stubs/Lexer_reasonligo.ml b/src/passes/01-parsing/reasonligo/Stubs/Lexer_reasonligo.ml new file mode 100644 index 000000000..0b6aa4f73 --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Stubs/Lexer_reasonligo.ml @@ -0,0 +1 @@ +module LexToken = LexToken diff --git a/src/passes/01-parsing/reasonligo/Stubs/Lexer_shared.ml b/src/passes/01-parsing/reasonligo/Stubs/Lexer_shared.ml new file mode 100644 index 000000000..71d9cc522 --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Stubs/Lexer_shared.ml @@ -0,0 +1,6 @@ +module EvalOpt = EvalOpt +module Markup = Markup +module Lexer = Lexer +module LexerUnit = LexerUnit +module LexerLog = LexerLog +module LexerLib = LexerLib diff --git a/src/passes/01-parsing/reasonligo/Stubs/Parser_cameligo.ml b/src/passes/01-parsing/reasonligo/Stubs/Parser_cameligo.ml deleted file mode 100644 index bf4e0962a..000000000 --- a/src/passes/01-parsing/reasonligo/Stubs/Parser_cameligo.ml +++ /dev/null @@ -1 +0,0 @@ -module AST = AST diff --git a/src/passes/01-parsing/reasonligo/Stubs/Parser_reasonligo.ml b/src/passes/01-parsing/reasonligo/Stubs/Parser_reasonligo.ml new file mode 100644 index 000000000..9479f6e5f --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Stubs/Parser_reasonligo.ml @@ -0,0 +1,2 @@ +module Pretty = Pretty +module Parser = Parser diff --git a/src/passes/01-parsing/reasonligo/Stubs/Parser_shared.ml b/src/passes/01-parsing/reasonligo/Stubs/Parser_shared.ml new file mode 100644 index 000000000..f1e238ebf --- /dev/null +++ b/src/passes/01-parsing/reasonligo/Stubs/Parser_shared.ml @@ -0,0 +1 @@ +module ParserUnit = ParserUnit diff --git a/src/passes/01-parsing/reasonligo/SyntaxError.ml b/src/passes/01-parsing/reasonligo/SyntaxError.ml index cab81f352..434625931 100644 --- a/src/passes/01-parsing/reasonligo/SyntaxError.ml +++ b/src/passes/01-parsing/reasonligo/SyntaxError.ml @@ -1,6 +1,6 @@ module CST = Cst.Cameligo -type error = +type error = | WrongFunctionArguments of CST.expr | InvalidWild of CST.expr diff --git a/src/passes/01-parsing/reasonligo/dune b/src/passes/01-parsing/reasonligo/dune index 38170a812..b0c88b150 100644 --- a/src/passes/01-parsing/reasonligo/dune +++ b/src/passes/01-parsing/reasonligo/dune @@ -1,30 +1,71 @@ +;; -------------------------------------------------------------------- +;; LEXING + ;; Build of the lexer (ocamllex LexToken) +;; Build of the lexer as a library + +(library + (name lexer_reasonligo) + (public_name ligo.lexer.reasonligo) + (modules LexToken) + (libraries + ;; Ligo + lexer_shared + ;; Third party + hex) + (preprocess + (pps bisect_ppx --conditional))) + +;; Build of a standalone lexer + +(executable + (name LexerMain) + (libraries + ;; Ligo + lexer_shared + lexer_reasonligo + ;; Third party + hex) + (modules LexerMain) + (preprocess + (pps bisect_ppx --conditional))) + +;; -------------------------------------------------------------------- +;; PARSING + ;; Build of the parser (menhir (merge_into Parser) (modules ParToken Parser) - (flags -la 1 --table --strict --explain --external-tokens LexToken)) + (flags -la 1 --table --strict --explain + --external-tokens Lexer_reasonligo.LexToken)) ;; Build of the parser as a library (library - (name parser_reasonligo) - (public_name ligo.parser.reasonligo) - (modules - SyntaxError reasonligo LexToken ParErr Parser Pretty) - (libraries - menhirLib + (name parser_reasonligo) + (public_name ligo.parser.reasonligo) + (modules + SyntaxError Scoping Parser ParErr Pretty) + (libraries + ;; Ligo + lexer_reasonligo parser_shared - parser_cameligo - str - simple-utils) - (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Parser_shared -open Simple_utils -open Parser_cameligo))) + cst + ;; Vendors + simple-utils + ;; Third party + pprint + terminal_size + menhirLib + hex) + (preprocess + (pps bisect_ppx --conditional)) + (flags (:standard -open Cst_cameligo))) ;; For CST in Parser.mli ;; Build of the unlexer (for covering the ;; error states of the LR automaton) @@ -32,38 +73,31 @@ (executable (name Unlexer) (libraries str) + (modules Unlexer) (preprocess - (pps bisect_ppx --conditional)) - (modules Unlexer)) - -;; Local build of a standalone lexer - -(executable - (name LexerMain) - (libraries parser_reasonligo) - (modules LexerMain) - (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Parser_shared -open Parser_reasonligo))) + (pps bisect_ppx --conditional))) ;; Local build of a standalone parser (executable (name ParserMain) (libraries - parser_reasonligo - parser_cameligo) - (modules ParserMain) + ;; Ligo + parser_shared + parser_reasonligo + cst + ;; Third party + hex) + (modules ParserMain Parser_msg) (preprocess - (pps bisect_ppx --conditional)) - (flags (:standard -open Simple_utils -open Parser_cameligo -open Parser_shared -open Parser_reasonligo))) + (pps bisect_ppx --conditional))) ;; Build of the covering of error states in the LR automaton (rule (targets Parser.msg) (deps (:script_messages ../../../../vendors/ligo-utils/simple-utils/messages.sh) Parser.mly LexToken.mli ParToken.mly) - (action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly ))) + (action (run %{script_messages} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly Parser.mly))) (rule (targets Parser_msg.ml) @@ -83,7 +117,16 @@ (rule (targets all.religo) (deps (:script_cover ../../../../vendors/ligo-utils/simple-utils/cover.sh) Parser.mly LexToken.mli ParToken.mly Parser.msg Unlexer.exe) - (action (run %{script_cover} --lex-tokens=LexToken.mli --par-tokens=ParToken.mly --ext=religo --unlexer=./Unlexer.exe --messages=Parser.msg --dir=. --concatenate Parser.mly ))) + (action (run %{script_cover} + --lex-tokens=LexToken.mli + --par-tokens=ParToken.mly + --ext=religo + --unlexer=./Unlexer.exe + --messages=Parser.msg + --dir=. + --concatenate Parser.mly))) + +;; Error messages (rule (targets error.messages) @@ -91,60 +134,45 @@ (deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli) (action (with-stdout-to %{targets} - (run - menhir - --unused-tokens - --update-errors error.messages.checked-in - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - ) - )) -) + (run menhir + --unused-tokens + --update-errors error.messages.checked-in + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly)))) (rule (target error.messages.new) (mode (promote (until-clean) (only *))) (action (with-stdout-to %{target} - (run - menhir - --unused-tokens - --list-errors - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - ) - ) - ) -) + (run menhir + --unused-tokens + --list-errors + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly)))) (alias (name runtest) (deps error.messages error.messages.new) (action - (run - menhir - --unused-tokens - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - --compare-errors error.messages.new - --compare-errors error.messages - ) - ) - ) - - + (run menhir + --unused-tokens + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly + --compare-errors error.messages.new + --compare-errors error.messages))) (rule (targets ParErr.ml) @@ -152,16 +180,12 @@ (deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli) (action (with-stdout-to %{targets} - (run - menhir - --unused-tokens - --table - --strict - --external-tokens LexToken.mli - --base Parser.mly - ParToken.mly - Parser.mly - --compile-errors error.messages.checked-in - ) - )) -) + (run menhir + --unused-tokens + --table + --strict + --external-tokens LexToken.mli + --base Parser.mly + ParToken.mly + Parser.mly + --compile-errors error.messages.checked-in)))) diff --git a/src/passes/01-parsing/reasonligo/reasonligo.ml b/src/passes/01-parsing/reasonligo/reasonligo.ml deleted file mode 100644 index 8ac1f47fa..000000000 --- a/src/passes/01-parsing/reasonligo/reasonligo.ml +++ /dev/null @@ -1,4 +0,0 @@ -module Parser = Parser -module Lexer = Lexer -module LexToken = LexToken -module SyntaxError = SyntaxError diff --git a/src/passes/01-parsing/shared/LexerLib.ml b/src/passes/01-parsing/shared/LexerLib.ml index 850c71a57..86cae1f2c 100644 --- a/src/passes/01-parsing/shared/LexerLib.ml +++ b/src/passes/01-parsing/shared/LexerLib.ml @@ -1,5 +1,8 @@ +(* A library for writing UTF8-aware lexers *) + module Region = Simple_utils.Region -module Pos = Simple_utils.Pos +module Pos = Simple_utils.Pos +module FQueue = Simple_utils.FQueue (* LEXER ENGINE *) diff --git a/src/passes/01-parsing/shared/LexerLib.mli b/src/passes/01-parsing/shared/LexerLib.mli index bddc1b2e7..1af30a058 100644 --- a/src/passes/01-parsing/shared/LexerLib.mli +++ b/src/passes/01-parsing/shared/LexerLib.mli @@ -1,7 +1,8 @@ (* A library for writing UTF8-aware lexers *) module Region = Simple_utils.Region -module Pos = Simple_utils.Pos +module Pos = Simple_utils.Pos +module FQueue = Simple_utils.FQueue (* The function [rollback] resets the lexing buffer to the state it was when it matched the last regular expression. This function is diff --git a/src/passes/01-parsing/shared/Memo.ml b/src/passes/01-parsing/shared/Misc/Memo.ml similarity index 100% rename from src/passes/01-parsing/shared/Memo.ml rename to src/passes/01-parsing/shared/Misc/Memo.ml diff --git a/src/passes/01-parsing/shared/Memo.mli b/src/passes/01-parsing/shared/Misc/Memo.mli similarity index 100% rename from src/passes/01-parsing/shared/Memo.mli rename to src/passes/01-parsing/shared/Misc/Memo.mli diff --git a/src/passes/01-parsing/shared/Doc/shared.txt b/src/passes/01-parsing/shared/Misc/shared.txt similarity index 100% rename from src/passes/01-parsing/shared/Doc/shared.txt rename to src/passes/01-parsing/shared/Misc/shared.txt diff --git a/src/passes/01-parsing/shared/ParserAPI.ml b/src/passes/01-parsing/shared/ParserAPI.ml index 73b384302..a93f5dff2 100644 --- a/src/passes/01-parsing/shared/ParserAPI.ml +++ b/src/passes/01-parsing/shared/ParserAPI.ml @@ -1,6 +1,14 @@ (* Generic parser for LIGO *) -module Region = Simple_utils.Region +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module LexerLib = Lexer_shared.LexerLib +module LexerLog = Lexer_shared.LexerLog + +(* Input/Output *) type options = < offsets : bool; diff --git a/src/passes/01-parsing/shared/ParserAPI.mli b/src/passes/01-parsing/shared/ParserAPI.mli index 90d51c392..44fafbc78 100644 --- a/src/passes/01-parsing/shared/ParserAPI.mli +++ b/src/passes/01-parsing/shared/ParserAPI.mli @@ -1,6 +1,13 @@ (* Generic parser API for LIGO *) -module Region = Simple_utils.Region +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module LexerLib = Lexer_shared.LexerLib + +(* Input/Output *) type options = < offsets : bool; diff --git a/src/passes/01-parsing/shared/ParserUnit.ml b/src/passes/01-parsing/shared/ParserUnit.ml index 8c15c1db2..1f892ca44 100644 --- a/src/passes/01-parsing/shared/ParserUnit.ml +++ b/src/passes/01-parsing/shared/ParserUnit.ml @@ -1,8 +1,16 @@ (* Functor to build a LIGO parser *) -module Region = Simple_utils.Region -module Preproc = Preprocessor.Preproc -module SSet = Set.Make (String) +(* Dependencies *) + +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module LexerLib = Lexer_shared.LexerLib +module LexerLog = Lexer_shared.LexerLog +module Preproc = Preprocessor.Preproc +module SSet = Set.Make (String) + +(* A subtype of [EvalOpt.options] *) module type SubIO = sig diff --git a/src/passes/01-parsing/shared/ParserUnit.mli b/src/passes/01-parsing/shared/ParserUnit.mli index fe3b90dc1..3551af00e 100644 --- a/src/passes/01-parsing/shared/ParserUnit.mli +++ b/src/passes/01-parsing/shared/ParserUnit.mli @@ -1,8 +1,12 @@ (* Functor to build a standalone LIGO parser *) -module Region = Simple_utils.Region +(* Dependencies *) -module SSet : Set.S with type elt = string and type t = Set.Make(String).t +module Region = Simple_utils.Region +module EvalOpt = Lexer_shared.EvalOpt +module Lexer = Lexer_shared.Lexer +module SSet : Set.S with type elt = string + and type t = Set.Make(String).t (* A subtype of [EvalOpt.options] *) diff --git a/src/passes/01-parsing/shared/dune b/src/passes/01-parsing/shared/dune index db0ce3e46..e94994956 100644 --- a/src/passes/01-parsing/shared/dune +++ b/src/passes/01-parsing/shared/dune @@ -1,29 +1,51 @@ +;; Build of the lexer in common to all Ligo's dialects + (ocamllex Lexer) +;; Build of the lexer as a library + +(library + (name lexer_shared) + (public_name ligo.lexer.shared) + (libraries + ;; Ligo + simple-utils + ;; Vendors + Preprocessor + ;; Third party + uutf + getopt + zarith) + (modules + LexerLib + LexerUnit + Lexer + LexerLog + Markup + EvalOpt + Version) + (preprocess + (pps bisect_ppx --conditional))) + +;; Build of the parser as a library + (library (name parser_shared) (public_name ligo.parser.shared) (libraries - menhirLib + ;; Ligo + lexer_shared simple-utils - uutf - getopt - zarith - Preprocessor) - (preprocess - (pps bisect_ppx --conditional)) + ;; Third party + menhirLib) (modules - LexerLib - LexerUnit ParserUnit - ParserAPI - Lexer - LexerLog - Markup - Utils - FQueue - EvalOpt - Version)) + ParserAPI) + (preprocess + (pps bisect_ppx --conditional))) +;; (flags (:standard -open Lexer_shared))) + +;; Build of the version source (for the user, as a CLI option) (rule (targets Version.ml) diff --git a/src/passes/03-tree_abstraction/pascaligo/errors.ml b/src/passes/03-tree_abstraction/pascaligo/errors.ml index 7760ea91a..cdbce4dbc 100644 --- a/src/passes/03-tree_abstraction/pascaligo/errors.ml +++ b/src/passes/03-tree_abstraction/pascaligo/errors.ml @@ -15,7 +15,7 @@ type abs_error = [ | `Concrete_pascaligo_unsupported_string_singleton of Raw.type_expr | `Concrete_pascaligo_unsupported_deep_some_pattern of Raw.pattern | `Concrete_pascaligo_unsupported_deep_list_pattern of Raw.pattern - | `Concrete_pascaligo_unsupported_deep_tuple_pattern of (Raw.pattern, Raw.wild) Parser_shared.Utils.nsepseq Raw.par Raw.reg + | `Concrete_pascaligo_unsupported_deep_tuple_pattern of (Raw.pattern, Raw.wild) Simple_utils.Utils.nsepseq Raw.par Raw.reg | `Concrete_pascaligo_unknown_built_in of string | `Concrete_pascaligo_michelson_type_wrong of Raw.type_expr * string | `Concrete_pascaligo_michelson_type_wrong_arity of Location.t * string diff --git a/src/stages/1-cst/cameligo/CST.ml b/src/stages/1-cst/cameligo/CST.ml index a6002e729..7f3926673 100644 --- a/src/stages/1-cst/cameligo/CST.ml +++ b/src/stages/1-cst/cameligo/CST.ml @@ -6,6 +6,7 @@ (* Utilities *) +module Utils = Simple_utils.Utils open Utils (* Regions @@ -23,6 +24,10 @@ module Region = Simple_utils.Region type 'a reg = 'a Region.reg +(* Lexemes *) + +type lexeme = string + (* Keywords of OCaml *) type keyword = Region.t @@ -169,7 +174,7 @@ and type_expr = | TFun of (type_expr * arrow * type_expr) reg | TPar of type_expr par reg | TVar of variable -| TString of Lexer.lexeme reg +| TString of lexeme reg and cartesian = (type_expr, times) nsepseq reg @@ -192,9 +197,9 @@ and pattern = | PFalse of kwd_false | PTrue of kwd_true | PVar of variable -| PInt of (Lexer.lexeme * Z.t) reg -| PNat of (Lexer.lexeme * Z.t) reg -| PBytes of (Lexer.lexeme * Hex.t) reg +| PInt of (lexeme * Z.t) reg +| PNat of (lexeme * Z.t) reg +| PBytes of (lexeme * Hex.t) reg | PString of string reg | PVerbatim of string reg | PWild of wild diff --git a/src/stages/1-cst/cameligo/cameligo.ml b/src/stages/1-cst/cameligo/cameligo.ml deleted file mode 100644 index 0429a03db..000000000 --- a/src/stages/1-cst/cameligo/cameligo.ml +++ /dev/null @@ -1 +0,0 @@ -include CST diff --git a/src/stages/1-cst/cameligo/dune b/src/stages/1-cst/cameligo/dune index 5249351d2..53a613ebc 100644 --- a/src/stages/1-cst/cameligo/dune +++ b/src/stages/1-cst/cameligo/dune @@ -2,12 +2,11 @@ (name cst_cameligo) (public_name ligo.cst.cameligo) (libraries + ;; Ligo simple-utils - tezos-utils - parser_shared - ) + ;; Third party + hex + zarith) + (modules CST ParserLog) (preprocess - (pps ppx_let bisect_ppx --conditional) - ) - (flags (:standard -open Parser_shared -open Simple_utils )) -) + (pps ppx_let bisect_ppx --conditional))) diff --git a/src/stages/1-cst/dune b/src/stages/1-cst/dune index 10a31affb..c29294227 100644 --- a/src/stages/1-cst/dune +++ b/src/stages/1-cst/dune @@ -2,13 +2,7 @@ (name cst) (public_name ligo.cst) (libraries - simple-utils - tezos-utils cst_cameligo - cst_pascaligo - ) + cst_pascaligo) (preprocess - (pps ppx_let bisect_ppx --conditional) - ) - (flags (:standard -open Simple_utils )) -) + (pps ppx_let bisect_ppx --conditional))) diff --git a/src/stages/1-cst/pascaligo/CST.ml b/src/stages/1-cst/pascaligo/CST.ml index 21c1d9b12..bae93dc1a 100644 --- a/src/stages/1-cst/pascaligo/CST.ml +++ b/src/stages/1-cst/pascaligo/CST.ml @@ -6,6 +6,7 @@ (* Utilities *) +module Utils = Simple_utils.Utils open Utils (* Regions @@ -23,6 +24,10 @@ module Region = Simple_utils.Region type 'a reg = 'a Region.reg +(* Lexemes *) + +type lexeme = string + (* Keywords of LIGO *) type keyword = Region.t @@ -185,7 +190,7 @@ and type_expr = | TFun of (type_expr * arrow * type_expr) reg | TPar of type_expr par reg | TVar of variable -| TString of Lexer.lexeme reg +| TString of lexeme reg and cartesian = (type_expr, times) nsepseq reg @@ -457,9 +462,9 @@ and expr = | EProj of projection reg | EUpdate of update reg | EMap of map_expr -| EVar of Lexer.lexeme reg +| EVar of lexeme reg | ECall of fun_call -| EBytes of (Lexer.lexeme * Hex.t) reg +| EBytes of (lexeme * Hex.t) reg | EUnit of c_Unit | ETuple of tuple_expr | EPar of expr par reg @@ -523,14 +528,14 @@ and arith_expr = | Div of slash bin_op reg | Mod of kwd_mod bin_op reg | Neg of minus un_op reg -| Int of (Lexer.lexeme * Z.t) reg -| Nat of (Lexer.lexeme * Z.t) reg -| Mutez of (Lexer.lexeme * Z.t) reg +| Int of (lexeme * Z.t) reg +| Nat of (lexeme * Z.t) reg +| Mutez of (lexeme * Z.t) reg and string_expr = Cat of cat bin_op reg -| String of Lexer.lexeme reg -| Verbatim of Lexer.lexeme reg +| String of lexeme reg +| Verbatim of lexeme reg and list_expr = ECons of cons bin_op reg @@ -570,7 +575,7 @@ and field_path_assignment = { and selection = FieldName of field_name -| Component of (Lexer.lexeme * Z.t) reg +| Component of (lexeme * Z.t) reg and tuple_expr = (expr, comma) nsepseq par reg @@ -614,12 +619,12 @@ and ne_injection_kwd = and pattern = PConstr of constr_pattern -| PVar of Lexer.lexeme reg +| PVar of lexeme reg | PWild of wild -| PInt of (Lexer.lexeme * Z.t) reg -| PNat of (Lexer.lexeme * Z.t) reg -| PBytes of (Lexer.lexeme * Hex.t) reg -| PString of Lexer.lexeme reg +| PInt of (lexeme * Z.t) reg +| PNat of (lexeme * Z.t) reg +| PBytes of (lexeme * Hex.t) reg +| PString of lexeme reg | PList of list_pattern | PTuple of tuple_pattern diff --git a/src/stages/1-cst/pascaligo/dune b/src/stages/1-cst/pascaligo/dune index 242fcfc0f..cc20f6a01 100644 --- a/src/stages/1-cst/pascaligo/dune +++ b/src/stages/1-cst/pascaligo/dune @@ -2,12 +2,11 @@ (name cst_pascaligo) (public_name ligo.cst.pascaligo) (libraries + ;; Ligo simple-utils - tezos-utils - parser_shared - ) + ;; Third party + hex + zarith) + (modules CST ParserLog) (preprocess - (pps ppx_let bisect_ppx --conditional) - ) - (flags (:standard -open Parser_shared -open Simple_utils )) -) + (pps ppx_let bisect_ppx --conditional))) diff --git a/src/stages/1-cst/pascaligo/pascaligo.ml b/src/stages/1-cst/pascaligo/pascaligo.ml deleted file mode 100644 index 0429a03db..000000000 --- a/src/stages/1-cst/pascaligo/pascaligo.ml +++ /dev/null @@ -1 +0,0 @@ -include CST diff --git a/vendors/Preprocessor/dune b/vendors/Preprocessor/dune index dc61c5cee..db8e82013 100644 --- a/vendors/Preprocessor/dune +++ b/vendors/Preprocessor/dune @@ -5,11 +5,17 @@ (public_name Preprocessor) (wrapped true) (libraries - getopt - simple-utils) - (modules EvalOpt E_Parser E_Lexer E_AST Preproc) + getopt + simple-utils) + (modules + EvalOpt + E_Parser + E_Lexer + E_AST + Preproc) (preprocess - (pps bisect_ppx --conditional))) + (pps bisect_ppx --conditional)) + (flags (:standard -open Simple_utils))) ;; Building the lexers of the preprocessor diff --git a/src/passes/01-parsing/shared/FQueue.ml b/vendors/ligo-utils/simple-utils/FQueue.ml similarity index 100% rename from src/passes/01-parsing/shared/FQueue.ml rename to vendors/ligo-utils/simple-utils/FQueue.ml diff --git a/src/passes/01-parsing/shared/FQueue.mli b/vendors/ligo-utils/simple-utils/FQueue.mli similarity index 100% rename from src/passes/01-parsing/shared/FQueue.mli rename to vendors/ligo-utils/simple-utils/FQueue.mli diff --git a/src/passes/01-parsing/shared/Utils.ml b/vendors/ligo-utils/simple-utils/Utils.ml similarity index 100% rename from src/passes/01-parsing/shared/Utils.ml rename to vendors/ligo-utils/simple-utils/Utils.ml diff --git a/src/passes/01-parsing/shared/Utils.mli b/vendors/ligo-utils/simple-utils/Utils.mli similarity index 100% rename from src/passes/01-parsing/shared/Utils.mli rename to vendors/ligo-utils/simple-utils/Utils.mli diff --git a/vendors/ligo-utils/simple-utils/dune b/vendors/ligo-utils/simple-utils/dune index 73b0f7dd1..b1fec4c63 100644 --- a/vendors/ligo-utils/simple-utils/dune +++ b/vendors/ligo-utils/simple-utils/dune @@ -4,9 +4,6 @@ (libraries yojson unix - str - ) + str) (preprocess - (pps ppx_let) - ) -) + (pps ppx_let))) diff --git a/vendors/ligo-utils/simple-utils/simple-utils.opam b/vendors/ligo-utils/simple-utils/simple-utils.opam index eeeaab8b0..6fe5cadb2 100644 --- a/vendors/ligo-utils/simple-utils/simple-utils.opam +++ b/vendors/ligo-utils/simple-utils/simple-utils.opam @@ -3,20 +3,16 @@ name : "simple-utils" version : "dev" synopsis : "LIGO utilities, to be used by other libraries" maintainer : "Galfour " -authors : "Galfour" +authors : "Galfour, Christian Rinderknecht" license : "MIT" -homepage: "https://gitlab.com/ligolang/ligo-utils" -bug-reports: "https://gitlab.com/ligolang/ligo-utils/issues" -depends: [ - "dune" - "base" - "yojson" - "ppx_let" - # from ppx_let: - "ocaml" {>= "4.04.2" & < "4.08.0"} - "dune" {build & >= "1.5.1"} - "ppxlib" {>= "0.5.0"} -] -build: [ - ["dune" "build" "-p" name] -] +homepage : "https://gitlab.com/ligolang/ligo-utils" +bug-reports : "https://gitlab.com/ligolang/ligo-utils/issues" +depends : ["dune" + "base" + "yojson" + "ppx_let" + # from ppx_let: + "ocaml" {>= "4.04.2" & < "4.08.0"} + "dune" {build & >= "1.5.1"} + "ppxlib" {>= "0.5.0"}] +build : [["dune" "build" "-p" name]] diff --git a/vendors/ligo-utils/simple-utils/simple_utils.ml b/vendors/ligo-utils/simple-utils/simple_utils.ml index 2df09573f..4ccd97689 100644 --- a/vendors/ligo-utils/simple-utils/simple_utils.ml +++ b/vendors/ligo-utils/simple-utils/simple_utils.ml @@ -10,10 +10,14 @@ module Int = X_int module Tuple = Tuple module Map = X_map module Tree = Tree -module Region = Region -module Pos = Pos module Var = Var module Ligo_string = X_string module Display = Display module Runned_result = Runned_result +(* Originally by Christian Rinderknecht *) + +module Pos = Pos +module Region = Region +module Utils = Utils +module FQueue = FQueue