diff --git a/src/passes/1-parser/pascaligo/Misc/pascaligo.ml b/src/passes/1-parser/pascaligo/Misc/pascaligo.ml deleted file mode 100644 index c323496e5..000000000 --- a/src/passes/1-parser/pascaligo/Misc/pascaligo.ml +++ /dev/null @@ -1,39 +0,0 @@ - -module ParserLog = Parser_pascaligo.ParserLog -module ParErr = Parser_pascaligo.ParErr -module SSet = Utils.String.Set - -(* Mock options. TODO: Plug in cmdliner. *) - -let pre_options = - EvalOpt.make - ~libs:[] - ~verbose:SSet.empty - ~offsets:true - ~mode:`Point - ~cmd:EvalOpt.Quiet - ~mono:true (* Monolithic API of Menhir for now *) -(* ~input:None *) -(* ~expr:true *) - -module Parser = - struct - type ast = AST.t - type expr = AST.expr - include Parser_pascaligo.Parser - end - -module ParserLog = - struct - type ast = AST.t - type expr = AST.expr - include Parser_pascaligo.ParserLog - end - -module PreUnit = ParserUnit.Make (Lexer)(AST)(Parser)(ParErr)(ParserLog) -module Front = ParserAPI.Make (Lexer)(Parser)(ParErr) - -let issue_error point = - let error = Front.format_error ~offsets:true (* TODO: CLI *) - `Point (* TODO: CLI *) point - in Stdlib.Error error diff --git a/vendors/Preprocessor/E_LexerMain.ml b/vendors/Preprocessor/E_LexerMain.ml index b1d47c253..93b0a5930 100644 --- a/vendors/Preprocessor/E_LexerMain.ml +++ b/vendors/Preprocessor/E_LexerMain.ml @@ -5,7 +5,7 @@ module Region = Simple_utils.Region let highlight msg = Printf.eprintf "\027[31m%s\027[0m%!" msg -let options = EvalOpt.read ~lang:EvalOpt.PascaLIGO ~ext:".ligo" +let options = EvalOpt.(read ~lang:`PascaLIGO ~ext:".ligo") let lex in_chan = let buffer = Lexing.from_channel in_chan in diff --git a/vendors/Preprocessor/E_ParserMain.ml b/vendors/Preprocessor/E_ParserMain.ml index 4ea6817f5..653e80425 100644 --- a/vendors/Preprocessor/E_ParserMain.ml +++ b/vendors/Preprocessor/E_ParserMain.ml @@ -5,7 +5,7 @@ module Region = Simple_utils.Region let highlight msg = Printf.eprintf "\027[31m%s\027[0m%!" msg -let options = EvalOpt.read ~lang:EvalOpt.PascaLIGO ~ext:".ligo" +let options = EvalOpt.(read ~lang:`PascaLIGO ~ext:".ligo") let parse in_chan = let buffer = Lexing.from_channel in_chan in diff --git a/vendors/Preprocessor/EvalOpt.ml b/vendors/Preprocessor/EvalOpt.ml index ed6927960..cc658c0dc 100644 --- a/vendors/Preprocessor/EvalOpt.ml +++ b/vendors/Preprocessor/EvalOpt.ml @@ -2,14 +2,14 @@ (* The type [options] gathers the command-line options. *) -module SSet = Set.Make (String) - -type language = PascaLIGO | CameLIGO | ReasonLIGO +type language = [`PascaLIGO | `CameLIGO | `ReasonLIGO] let lang_to_string = function - PascaLIGO -> "PascaLIGO" -| CameLIGO -> "CameLIGO" -| ReasonLIGO -> "ReasonLIGO" + `PascaLIGO -> "PascaLIGO" +| `CameLIGO -> "CameLIGO" +| `ReasonLIGO -> "ReasonLIGO" + +module SSet = Set.Make (String) type options = < input : string option; diff --git a/vendors/Preprocessor/EvalOpt.mli b/vendors/Preprocessor/EvalOpt.mli index 1680a1540..4adf4c382 100644 --- a/vendors/Preprocessor/EvalOpt.mli +++ b/vendors/Preprocessor/EvalOpt.mli @@ -2,10 +2,11 @@ (* The type [options] gathers the command-line options. *) -type language = PascaLIGO | CameLIGO | ReasonLIGO +type language = [`PascaLIGO | `CameLIGO | `ReasonLIGO] + val lang_to_string : language -> string -module SSet : Set.S with type elt = string +module SSet : Set.S with type elt = string and type t = Set.Make(String).t type options = < input : string option; diff --git a/vendors/Preprocessor/Preproc.mli b/vendors/Preprocessor/Preproc.mli index 5620e0353..d39b95618 100644 --- a/vendors/Preprocessor/Preproc.mli +++ b/vendors/Preprocessor/Preproc.mli @@ -9,8 +9,7 @@ val mk_reg : Lexing.lexbuf -> Region.t (* Errors *) type error = - Invalid_directive of string -| Directive_inside_line + Directive_inside_line | Missing_endif | Invalid_line_indicator of string | No_line_indicator diff --git a/vendors/Preprocessor/Preproc.mll b/vendors/Preprocessor/Preproc.mll index c453d821d..cb2779cc5 100644 --- a/vendors/Preprocessor/Preproc.mll +++ b/vendors/Preprocessor/Preproc.mll @@ -111,8 +111,7 @@ let mk_path state = (* ERRORS *) type error = - Invalid_directive of string -| Directive_inside_line + Directive_inside_line | Missing_endif | Invalid_line_indicator of string | No_line_indicator @@ -139,9 +138,7 @@ type error = | Invalid_character of char let error_to_string = function - Invalid_directive name -> - sprintf "Invalid directive \"%s\"." name -| Directive_inside_line -> + Directive_inside_line -> sprintf "Directive inside a line." | Missing_endif -> sprintf "Missing #endif directive." @@ -484,9 +481,14 @@ rule scan state = parse scan state lexbuf } | directive { if not (List.mem id directives) - then fail (Invalid_directive id) state lexbuf; + then begin + if state.mode = Copy then copy state lexbuf; + scan state lexbuf + end + else if state.offset = Inline - then fail Directive_inside_line state lexbuf; + then fail Directive_inside_line state lexbuf + else let region = mk_reg lexbuf in match id with "include" -> @@ -611,7 +613,7 @@ rule scan state = parse begin expand_offset state; copy state lexbuf; - if state.opt#lang = EvalOpt.ReasonLIGO then + if state.opt#lang = `ReasonLIGO then reasonLIGO_com (mk_reg lexbuf) state lexbuf end; scan {state with offset=Inline} lexbuf } @@ -619,8 +621,8 @@ rule scan state = parse begin expand_offset state; copy state lexbuf; - if state.opt#lang = EvalOpt.CameLIGO - || state.opt#lang = EvalOpt.PascaLIGO then + if state.opt#lang = `CameLIGO + || state.opt#lang = `PascaLIGO then cameLIGO_com (mk_reg lexbuf) state lexbuf end; scan {state with offset=Inline} lexbuf } diff --git a/vendors/Preprocessor/PreprocMain.ml b/vendors/Preprocessor/PreprocMain.ml index 2a527ca69..b8418a878 100644 --- a/vendors/Preprocessor/PreprocMain.ml +++ b/vendors/Preprocessor/PreprocMain.ml @@ -4,7 +4,7 @@ module Region = Simple_utils.Region let highlight msg = Printf.eprintf "\027[31m%s\027[0m\n%!" msg -let options = EvalOpt.read ~lang:EvalOpt.PascaLIGO ~ext:".ligo";; +let options = EvalOpt.(read ~lang:`PascaLIGO ~ext:".ligo") let preproc cin = let buffer = Lexing.from_channel cin in diff --git a/vendors/Preprocessor/dune b/vendors/Preprocessor/dune index 2d967c8eb..5ed61429d 100644 --- a/vendors/Preprocessor/dune +++ b/vendors/Preprocessor/dune @@ -10,7 +10,7 @@ (libraries getopt simple-utils) - (wrapped false) + (wrapped true) (modules EvalOpt E_Parser E_Lexer E_AST Preproc) (preprocess (pps bisect_ppx --conditional)))