From dc4f14d46991e529cdae69dc567d1e8e05579962 Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Wed, 24 Jul 2019 15:41:52 +0200 Subject: [PATCH] Parsing the command line by calling [EvalOpt.read], not a side-effect. --- src/parser/pascaligo/EvalOpt.ml | 184 ++++++++++++++++------------- src/parser/pascaligo/EvalOpt.mli | 68 ++++++----- src/parser/pascaligo/Lexer.mli | 47 ++++---- src/parser/pascaligo/LexerLog.ml | 14 +-- src/parser/pascaligo/LexerMain.ml | 24 ++-- src/parser/pascaligo/ParserMain.ml | 44 ++++--- 6 files changed, 214 insertions(+), 167 deletions(-) diff --git a/src/parser/pascaligo/EvalOpt.ml b/src/parser/pascaligo/EvalOpt.ml index 20d039603..386403635 100644 --- a/src/parser/pascaligo/EvalOpt.ml +++ b/src/parser/pascaligo/EvalOpt.ml @@ -1,8 +1,26 @@ -(* Parsing the command-line option for testing the LIGO lexer and - parser *) +(* Parsing the command-line options of PascaLIGO *) + +(* The type [command] denotes some possible behaviours of the + compiler. *) + +type command = Quiet | Copy | Units | Tokens + +(* The type [options] gathers the command-line options. *) + +type options = { + input : string option; + libs : string list; + verbose : Utils.String.Set.t; + offsets : bool; + mode : [`Byte | `Point]; + cmd : command +} + +(* Auxiliary functions *) let printf = Printf.printf let sprintf = Printf.sprintf +let print = print_endline let abort msg = Utils.highlight (sprintf "Command-line error: %s\n" msg); exit 1 @@ -12,18 +30,18 @@ let abort msg = let help () = let file = Filename.basename Sys.argv.(0) in printf "Usage: %s [