Removed the open type [Error.t] (less [assert false]).

I also had to remove the keywords [Down], [Fail] and [Step] in
PascaLIGO that made a mysterious and unwanted come back. (I did not
bother with [git blame]).
This commit is contained in:
Christian Rinderknecht 2019-12-17 14:56:16 +01:00 committed by Christian Rinderknecht
parent 531dd238a7
commit 757b0da78c
12 changed files with 42 additions and 71 deletions

View File

@ -6,7 +6,6 @@ $HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml $HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
../shared/Lexer.mli ../shared/Lexer.mli
../shared/Lexer.mll ../shared/Lexer.mll
../shared/Error.mli
../shared/EvalOpt.ml ../shared/EvalOpt.ml
../shared/EvalOpt.mli ../shared/EvalOpt.mli
../shared/FQueue.ml ../shared/FQueue.ml

View File

@ -25,15 +25,14 @@ let () = Printexc.record_backtrace true
let external_ text = let external_ text =
Utils.highlight (Printf.sprintf "External error: %s" text); exit 1;; Utils.highlight (Printf.sprintf "External error: %s" text); exit 1;;
type Error.t += ParseError type error = SyntaxError
let error_to_string = function let error_to_string = function
ParseError -> "Syntax error.\n" SyntaxError -> "Syntax error.\n"
| _ -> assert false
let print_error ?(offsets=true) mode Region.{region; value} ~file = let print_error ?(offsets=true) mode Region.{region; value} ~file =
let msg = error_to_string value in let msg = error_to_string value
let reg = region#to_string ~file ~offsets mode in and reg = region#to_string ~file ~offsets mode in
Utils.highlight (sprintf "Parse error %s:\n%s%!" reg msg) Utils.highlight (sprintf "Parse error %s:\n%s%!" reg msg)
(** {1 Preprocessing the input source and opening the input channels} *) (** {1 Preprocessing the input source and opening the input channels} *)
@ -126,7 +125,7 @@ let () =
options#mode err ~file options#mode err ~file
| Parser.Error -> | Parser.Error ->
let region = get_last () in let region = get_last () in
let error = Region.{region; value=ParseError} in let error = Region.{region; value=SyntaxError} in
let () = close_all () in let () = close_all () in
print_error ~offsets:options#offsets print_error ~offsets:options#offsets
options#mode error ~file options#mode error ~file

View File

@ -6,7 +6,6 @@ $HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml $HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
../shared/Lexer.mli ../shared/Lexer.mli
../shared/Lexer.mll ../shared/Lexer.mll
../shared/Error.mli
../shared/EvalOpt.ml ../shared/EvalOpt.ml
../shared/EvalOpt.mli ../shared/EvalOpt.mli
../shared/FQueue.ml ../shared/FQueue.ml

View File

@ -77,10 +77,8 @@ type t =
| Case of Region.t (* "case" *) | Case of Region.t (* "case" *)
| Const of Region.t (* "const" *) | Const of Region.t (* "const" *)
| Contains of Region.t (* "contains" *) | Contains of Region.t (* "contains" *)
| Down of Region.t (* "down" *)
| Else of Region.t (* "else" *) | Else of Region.t (* "else" *)
| End of Region.t (* "end" *) | End of Region.t (* "end" *)
| Fail of Region.t (* "fail" *)
| False of Region.t (* "False" *) | False of Region.t (* "False" *)
| For of Region.t (* "for" *) | For of Region.t (* "for" *)
| From of Region.t (* "from" *) | From of Region.t (* "from" *)
@ -100,7 +98,6 @@ type t =
| Remove of Region.t (* "remove" *) | Remove of Region.t (* "remove" *)
| Set of Region.t (* "set" *) | Set of Region.t (* "set" *)
| Skip of Region.t (* "skip" *) | Skip of Region.t (* "skip" *)
| Step of Region.t (* "step" *)
| Then of Region.t (* "then" *) | Then of Region.t (* "then" *)
| To of Region.t (* "to" *) | To of Region.t (* "to" *)
| True of Region.t (* "True" *) | True of Region.t (* "True" *)

View File

@ -75,10 +75,8 @@ type t =
| Case of Region.t (* "case" *) | Case of Region.t (* "case" *)
| Const of Region.t (* "const" *) | Const of Region.t (* "const" *)
| Contains of Region.t (* "contains" *) | Contains of Region.t (* "contains" *)
| Down of Region.t (* "down" *)
| Else of Region.t (* "else" *) | Else of Region.t (* "else" *)
| End of Region.t (* "end" *) | End of Region.t (* "end" *)
| Fail of Region.t (* "fail" *)
| False of Region.t (* "False" *) | False of Region.t (* "False" *)
| For of Region.t (* "for" *) | For of Region.t (* "for" *)
| From of Region.t (* "from" *) | From of Region.t (* "from" *)
@ -98,7 +96,6 @@ type t =
| Remove of Region.t (* "remove" *) | Remove of Region.t (* "remove" *)
| Set of Region.t (* "set" *) | Set of Region.t (* "set" *)
| Skip of Region.t (* "skip" *) | Skip of Region.t (* "skip" *)
| Step of Region.t (* "step" *)
| Then of Region.t (* "then" *) | Then of Region.t (* "then" *)
| To of Region.t (* "to" *) | To of Region.t (* "to" *)
| True of Region.t (* "True" *) | True of Region.t (* "True" *)
@ -184,10 +181,8 @@ let proj_token = function
| Case region -> region, "Case" | Case region -> region, "Case"
| Const region -> region, "Const" | Const region -> region, "Const"
| Contains region -> region, "Contains" | Contains region -> region, "Contains"
| Down region -> region, "Down"
| Else region -> region, "Else" | Else region -> region, "Else"
| End region -> region, "End" | End region -> region, "End"
| Fail region -> region, "Fail"
| False region -> region, "False" | False region -> region, "False"
| For region -> region, "For" | For region -> region, "For"
| From region -> region, "From" | From region -> region, "From"
@ -207,7 +202,6 @@ let proj_token = function
| Remove region -> region, "Remove" | Remove region -> region, "Remove"
| Set region -> region, "Set" | Set region -> region, "Set"
| Skip region -> region, "Skip" | Skip region -> region, "Skip"
| Step region -> region, "Step"
| Then region -> region, "Then" | Then region -> region, "Then"
| To region -> region, "To" | To region -> region, "To"
| True region -> region, "True" | True region -> region, "True"
@ -276,10 +270,8 @@ let to_lexeme = function
| Case _ -> "case" | Case _ -> "case"
| Const _ -> "const" | Const _ -> "const"
| Contains _ -> "contains" | Contains _ -> "contains"
| Down _ -> "down"
| Else _ -> "else" | Else _ -> "else"
| End _ -> "end" | End _ -> "end"
| Fail _ -> "fail"
| False _ -> "False" | False _ -> "False"
| For _ -> "for" | For _ -> "for"
| From _ -> "from" | From _ -> "from"
@ -299,7 +291,6 @@ let to_lexeme = function
| Remove _ -> "remove" | Remove _ -> "remove"
| Set _ -> "set" | Set _ -> "set"
| Skip _ -> "skip" | Skip _ -> "skip"
| Step _ -> "step"
| Then _ -> "then" | Then _ -> "then"
| To _ -> "to" | To _ -> "to"
| True _ -> "True" | True _ -> "True"
@ -336,13 +327,11 @@ let keywords = [
(fun reg -> Case reg); (fun reg -> Case reg);
(fun reg -> Const reg); (fun reg -> Const reg);
(fun reg -> Contains reg); (fun reg -> Contains reg);
(fun reg -> Down reg);
(fun reg -> Else reg); (fun reg -> Else reg);
(fun reg -> End reg); (fun reg -> End reg);
(fun reg -> For reg); (fun reg -> For reg);
(fun reg -> From reg); (fun reg -> From reg);
(fun reg -> Function reg); (fun reg -> Function reg);
(fun reg -> Fail reg);
(fun reg -> False reg); (fun reg -> False reg);
(fun reg -> If reg); (fun reg -> If reg);
(fun reg -> In reg); (fun reg -> In reg);
@ -360,7 +349,6 @@ let keywords = [
(fun reg -> Remove reg); (fun reg -> Remove reg);
(fun reg -> Set reg); (fun reg -> Set reg);
(fun reg -> Skip reg); (fun reg -> Skip reg);
(fun reg -> Step reg);
(fun reg -> Then reg); (fun reg -> Then reg);
(fun reg -> To reg); (fun reg -> To reg);
(fun reg -> True reg); (fun reg -> True reg);
@ -560,10 +548,8 @@ let is_kwd = function
| Case _ | Case _
| Const _ | Const _
| Contains _ | Contains _
| Down _
| Else _ | Else _
| End _ | End _
| Fail _
| False _ | False _
| For _ | For _
| From _ | From _
@ -583,7 +569,6 @@ let is_kwd = function
| Remove _ | Remove _
| Set _ | Set _
| Skip _ | Skip _
| Step _
| Then _ | Then _
| To _ | To _
| True _ | True _

View File

@ -25,15 +25,14 @@ let () = Printexc.record_backtrace true
let external_ text = let external_ text =
Utils.highlight (Printf.sprintf "External error: %s" text); exit 1;; Utils.highlight (Printf.sprintf "External error: %s" text); exit 1;;
type Error.t += ParseError type error = SyntaxError
let error_to_string = function let error_to_string = function
ParseError -> "Syntax error.\n" SyntaxError -> "Syntax error.\n"
| _ -> assert false
let print_error ?(offsets=true) mode Region.{region; value} ~file = let print_error ?(offsets=true) mode Region.{region; value} ~file =
let msg = error_to_string value in let msg = error_to_string value
let reg = region#to_string ~file ~offsets mode in and reg = region#to_string ~file ~offsets mode in
Utils.highlight (sprintf "Parse error %s:\n%s%!" reg msg) Utils.highlight (sprintf "Parse error %s:\n%s%!" reg msg)
(** {1 Preprocessing the input source and opening the input channels} *) (** {1 Preprocessing the input source and opening the input channels} *)
@ -126,7 +125,7 @@ let () =
options#mode err ~file options#mode err ~file
| Parser.Error -> | Parser.Error ->
let region = get_last () in let region = get_last () in
let error = Region.{region; value=ParseError} in let error = Region.{region; value=SyntaxError} in
let () = close_all () in let () = close_all () in
print_error ~offsets:options#offsets print_error ~offsets:options#offsets
options#mode error ~file options#mode error ~file

View File

@ -6,7 +6,6 @@ $HOME/git/ligo/vendors/ligo-utils/simple-utils/region.mli
$HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml $HOME/git/ligo/vendors/ligo-utils/simple-utils/region.ml
../shared/Lexer.mli ../shared/Lexer.mli
../shared/Lexer.mll ../shared/Lexer.mll
../shared/Error.mli
../shared/EvalOpt.ml ../shared/EvalOpt.ml
../shared/EvalOpt.mli ../shared/EvalOpt.mli
../shared/FQueue.ml ../shared/FQueue.ml

View File

@ -25,15 +25,14 @@ let () = Printexc.record_backtrace true
let external_ text = let external_ text =
Utils.highlight (Printf.sprintf "External error: %s" text); exit 1;; Utils.highlight (Printf.sprintf "External error: %s" text); exit 1;;
type Error.t += ParseError type error = SyntaxError
let error_to_string = function let error_to_string = function
ParseError -> "Syntax error.\n" SyntaxError -> "Syntax error.\n"
| _ -> assert false
let print_error ?(offsets=true) mode Region.{region; value} ~file = let print_error ?(offsets=true) mode Region.{region; value} ~file =
let msg = error_to_string value in let msg = error_to_string value
let reg = region#to_string ~file ~offsets mode in and reg = region#to_string ~file ~offsets mode in
Utils.highlight (sprintf "Parse error %s:\n%s%!" reg msg) Utils.highlight (sprintf "Parse error %s:\n%s%!" reg msg)
(** {1 Preprocessing the input source and opening the input channels} *) (** {1 Preprocessing the input source and opening the input channels} *)
@ -126,7 +125,7 @@ let () =
options#mode err ~file options#mode err ~file
| Parser.Error -> | Parser.Error ->
let region = get_last () in let region = get_last () in
let error = Region.{region; value=ParseError} in let error = Region.{region; value=SyntaxError} in
let () = close_all () in let () = close_all () in
print_error ~offsets:options#offsets print_error ~offsets:options#offsets
options#mode error ~file options#mode error ~file

View File

@ -1,3 +0,0 @@
type t = ..
type error = t

View File

@ -136,11 +136,13 @@ module type S =
(* Error reporting *) (* Error reporting *)
exception Error of Error.t Region.reg type error
exception Error of error Region.reg
val print_error : val print_error :
?offsets:bool -> [`Byte | `Point] -> ?offsets:bool -> [`Byte | `Point] ->
Error.t Region.reg -> file:bool -> unit error Region.reg -> file:bool -> unit
end end

View File

@ -159,10 +159,11 @@ module type S = sig
(* Error reporting *) (* Error reporting *)
exception Error of Error.t Region.reg type error
exception Error of error Region.reg
val print_error : ?offsets:bool -> [`Byte | `Point] -> val print_error : ?offsets:bool -> [`Byte | `Point] ->
Error.t Region.reg -> file:bool -> unit error Region.reg -> file:bool -> unit
end end
(* The functorised interface (* The functorised interface
@ -330,22 +331,23 @@ module Make (Token: TOKEN) : (S with module Token = Token) =
(* ERRORS *) (* ERRORS *)
type Error.t += Invalid_utf8_sequence type error =
type Error.t += Unexpected_character of char Invalid_utf8_sequence
type Error.t += Undefined_escape_sequence | Unexpected_character of char
type Error.t += Missing_break | Undefined_escape_sequence
type Error.t += Unterminated_string | Missing_break
type Error.t += Unterminated_integer | Unterminated_string
type Error.t += Odd_lengthed_bytes | Unterminated_integer
type Error.t += Unterminated_comment | Odd_lengthed_bytes
type Error.t += Orphan_minus | Unterminated_comment
type Error.t += Non_canonical_zero | Orphan_minus
type Error.t += Negative_byte_sequence | Non_canonical_zero
type Error.t += Broken_string | Negative_byte_sequence
type Error.t += Invalid_character_in_string | Broken_string
type Error.t += Reserved_name | Invalid_character_in_string
type Error.t += Invalid_symbol | Reserved_name
type Error.t += Invalid_natural | Invalid_symbol
| Invalid_natural
let error_to_string = function let error_to_string = function
Invalid_utf8_sequence -> Invalid_utf8_sequence ->
@ -393,9 +395,8 @@ module Make (Token: TOKEN) : (S with module Token = Token) =
Hint: Check the LIGO syntax you use.\n" Hint: Check the LIGO syntax you use.\n"
| Invalid_natural -> | Invalid_natural ->
"Invalid natural." "Invalid natural."
| _ -> assert false
exception Error of Error.t Region.reg exception Error of error Region.reg
let print_error ?(offsets=true) mode Region.{region; value} ~file = let print_error ?(offsets=true) mode Region.{region; value} ~file =
let msg = error_to_string value in let msg = error_to_string value in

View File

@ -7,20 +7,15 @@
simple-utils simple-utils
uutf uutf
getopt getopt
zarith zarith)
)
(modules (modules
Error
Lexer Lexer
LexerLog LexerLog
Utils Utils
Markup Markup
FQueue FQueue
EvalOpt EvalOpt
Version Version))
)
(modules_without_implementation Error)
)
(rule (rule
(targets Version.ml) (targets Version.ml)