Removed error "Invalid directive" as PascaLIGO has the operator #.

This commit is contained in:
Christian Rinderknecht 2020-04-03 19:06:35 +02:00
parent f5e0dad979
commit 6c1a1f91e2
9 changed files with 26 additions and 63 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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 }

View File

@ -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

View File

@ -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)))