Removed error "Invalid directive" as PascaLIGO has the operator #
.
This commit is contained in:
parent
f5e0dad979
commit
6c1a1f91e2
@ -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
|
|
2
vendors/Preprocessor/E_LexerMain.ml
vendored
2
vendors/Preprocessor/E_LexerMain.ml
vendored
@ -5,7 +5,7 @@ module Region = Simple_utils.Region
|
|||||||
|
|
||||||
let highlight msg = Printf.eprintf "\027[31m%s\027[0m%!" msg
|
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 lex in_chan =
|
||||||
let buffer = Lexing.from_channel in_chan in
|
let buffer = Lexing.from_channel in_chan in
|
||||||
|
2
vendors/Preprocessor/E_ParserMain.ml
vendored
2
vendors/Preprocessor/E_ParserMain.ml
vendored
@ -5,7 +5,7 @@ module Region = Simple_utils.Region
|
|||||||
|
|
||||||
let highlight msg = Printf.eprintf "\027[31m%s\027[0m%!" msg
|
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 parse in_chan =
|
||||||
let buffer = Lexing.from_channel in_chan in
|
let buffer = Lexing.from_channel in_chan in
|
||||||
|
12
vendors/Preprocessor/EvalOpt.ml
vendored
12
vendors/Preprocessor/EvalOpt.ml
vendored
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
(* The type [options] gathers the command-line options. *)
|
(* 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
|
let lang_to_string = function
|
||||||
PascaLIGO -> "PascaLIGO"
|
`PascaLIGO -> "PascaLIGO"
|
||||||
| CameLIGO -> "CameLIGO"
|
| `CameLIGO -> "CameLIGO"
|
||||||
| ReasonLIGO -> "ReasonLIGO"
|
| `ReasonLIGO -> "ReasonLIGO"
|
||||||
|
|
||||||
|
module SSet = Set.Make (String)
|
||||||
|
|
||||||
type options = <
|
type options = <
|
||||||
input : string option;
|
input : string option;
|
||||||
|
5
vendors/Preprocessor/EvalOpt.mli
vendored
5
vendors/Preprocessor/EvalOpt.mli
vendored
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
(* The type [options] gathers the command-line options. *)
|
(* The type [options] gathers the command-line options. *)
|
||||||
|
|
||||||
type language = PascaLIGO | CameLIGO | ReasonLIGO
|
type language = [`PascaLIGO | `CameLIGO | `ReasonLIGO]
|
||||||
|
|
||||||
val lang_to_string : language -> string
|
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 = <
|
type options = <
|
||||||
input : string option;
|
input : string option;
|
||||||
|
3
vendors/Preprocessor/Preproc.mli
vendored
3
vendors/Preprocessor/Preproc.mli
vendored
@ -9,8 +9,7 @@ val mk_reg : Lexing.lexbuf -> Region.t
|
|||||||
(* Errors *)
|
(* Errors *)
|
||||||
|
|
||||||
type error =
|
type error =
|
||||||
Invalid_directive of string
|
Directive_inside_line
|
||||||
| Directive_inside_line
|
|
||||||
| Missing_endif
|
| Missing_endif
|
||||||
| Invalid_line_indicator of string
|
| Invalid_line_indicator of string
|
||||||
| No_line_indicator
|
| No_line_indicator
|
||||||
|
22
vendors/Preprocessor/Preproc.mll
vendored
22
vendors/Preprocessor/Preproc.mll
vendored
@ -111,8 +111,7 @@ let mk_path state =
|
|||||||
(* ERRORS *)
|
(* ERRORS *)
|
||||||
|
|
||||||
type error =
|
type error =
|
||||||
Invalid_directive of string
|
Directive_inside_line
|
||||||
| Directive_inside_line
|
|
||||||
| Missing_endif
|
| Missing_endif
|
||||||
| Invalid_line_indicator of string
|
| Invalid_line_indicator of string
|
||||||
| No_line_indicator
|
| No_line_indicator
|
||||||
@ -139,9 +138,7 @@ type error =
|
|||||||
| Invalid_character of char
|
| Invalid_character of char
|
||||||
|
|
||||||
let error_to_string = function
|
let error_to_string = function
|
||||||
Invalid_directive name ->
|
Directive_inside_line ->
|
||||||
sprintf "Invalid directive \"%s\"." name
|
|
||||||
| Directive_inside_line ->
|
|
||||||
sprintf "Directive inside a line."
|
sprintf "Directive inside a line."
|
||||||
| Missing_endif ->
|
| Missing_endif ->
|
||||||
sprintf "Missing #endif directive."
|
sprintf "Missing #endif directive."
|
||||||
@ -484,9 +481,14 @@ rule scan state = parse
|
|||||||
scan state lexbuf }
|
scan state lexbuf }
|
||||||
| directive {
|
| directive {
|
||||||
if not (List.mem id directives)
|
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
|
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
|
let region = mk_reg lexbuf in
|
||||||
match id with
|
match id with
|
||||||
"include" ->
|
"include" ->
|
||||||
@ -611,7 +613,7 @@ rule scan state = parse
|
|||||||
begin
|
begin
|
||||||
expand_offset state;
|
expand_offset state;
|
||||||
copy state lexbuf;
|
copy state lexbuf;
|
||||||
if state.opt#lang = EvalOpt.ReasonLIGO then
|
if state.opt#lang = `ReasonLIGO then
|
||||||
reasonLIGO_com (mk_reg lexbuf) state lexbuf
|
reasonLIGO_com (mk_reg lexbuf) state lexbuf
|
||||||
end;
|
end;
|
||||||
scan {state with offset=Inline} lexbuf }
|
scan {state with offset=Inline} lexbuf }
|
||||||
@ -619,8 +621,8 @@ rule scan state = parse
|
|||||||
begin
|
begin
|
||||||
expand_offset state;
|
expand_offset state;
|
||||||
copy state lexbuf;
|
copy state lexbuf;
|
||||||
if state.opt#lang = EvalOpt.CameLIGO
|
if state.opt#lang = `CameLIGO
|
||||||
|| state.opt#lang = EvalOpt.PascaLIGO then
|
|| state.opt#lang = `PascaLIGO then
|
||||||
cameLIGO_com (mk_reg lexbuf) state lexbuf
|
cameLIGO_com (mk_reg lexbuf) state lexbuf
|
||||||
end;
|
end;
|
||||||
scan {state with offset=Inline} lexbuf }
|
scan {state with offset=Inline} lexbuf }
|
||||||
|
2
vendors/Preprocessor/PreprocMain.ml
vendored
2
vendors/Preprocessor/PreprocMain.ml
vendored
@ -4,7 +4,7 @@ module Region = Simple_utils.Region
|
|||||||
|
|
||||||
let highlight msg = Printf.eprintf "\027[31m%s\027[0m\n%!" msg
|
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 preproc cin =
|
||||||
let buffer = Lexing.from_channel cin in
|
let buffer = Lexing.from_channel cin in
|
||||||
|
2
vendors/Preprocessor/dune
vendored
2
vendors/Preprocessor/dune
vendored
@ -10,7 +10,7 @@
|
|||||||
(libraries
|
(libraries
|
||||||
getopt
|
getopt
|
||||||
simple-utils)
|
simple-utils)
|
||||||
(wrapped false)
|
(wrapped true)
|
||||||
(modules EvalOpt E_Parser E_Lexer E_AST Preproc)
|
(modules EvalOpt E_Parser E_Lexer E_AST Preproc)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps bisect_ppx --conditional)))
|
(pps bisect_ppx --conditional)))
|
||||||
|
Loading…
Reference in New Issue
Block a user