Fixed format of syntax error messages.

This commit is contained in:
Christian Rinderknecht 2020-04-13 16:31:56 +02:00
parent ffb3d05864
commit 1ccf6f247d
4 changed files with 17 additions and 16 deletions

View File

@ -3,7 +3,7 @@ open Cli_expect
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/gitlab_111.religo" ; "main" ] ;
[%expect {|
ligo: : Parse error in file "gitlab_111.religo", line 2, characters 0-3, after "=" and before "let":
ligo: : Parse error in file "gitlab_111.religo", line 2, characters 0-3 at "let", after "=":
This is an incorrect let binding.
-
Examples of correct let bindings:
@ -23,7 +23,7 @@ let%expect_test _ =
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/missing_rpar.religo" ; "main" ] ;
[%expect {|
ligo: : Parse error in file "missing_rpar.religo", line 5, characters 0-3, after "m" and before "let":
ligo: : Parse error in file "missing_rpar.religo", line 5, characters 0-3 at "let", after "m":
Missing `)`.
{}

View File

@ -3,7 +3,7 @@ open Cli_expect
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; "../../test/contracts/negative/error_syntax.ligo" ; "main" ] ;
[%expect {|
ligo: : Parse error in file "error_syntax.ligo", line 1, characters 16-17, after "bar" and before "-":
ligo: : Parse error in file "error_syntax.ligo", line 1, characters 16-17 at "-", after "bar":
15: <syntax error> {}

View File

@ -77,8 +77,8 @@
; (targets error.messages)
; (deps Parser.mly ParToken.mly error.messages.checked-in)
; (action
; (with-stdout-to %{targets}
; (bash
; (with-stdout-to %{targets}
; (bash
; "menhir \
; --unused-tokens \
; --list-errors \
@ -97,11 +97,11 @@
(targets error.messages)
(deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli)
(action
(with-stdout-to %{targets}
(run
(with-stdout-to %{targets}
(run
menhir
--unused-tokens
--update-errors error.messages.checked-in
--update-errors error.messages.checked-in
--table
--strict
--external-tokens LexToken.mli
@ -115,8 +115,8 @@
(rule
(target error.messages.new)
(action
(with-stdout-to %{target}
(run
(with-stdout-to %{target}
(run
menhir
--unused-tokens
--list-errors
@ -135,7 +135,7 @@
(name runtest)
(deps error.messages error.messages.new)
(action
(run
(run
menhir
--unused-tokens
--table
@ -156,8 +156,8 @@
(targets ParErr.ml)
(deps Parser.mly ParToken.mly error.messages.checked-in LexToken.mli)
(action
(with-stdout-to %{targets}
(run
(with-stdout-to %{targets}
(run
menhir
--unused-tokens
--table

View File

@ -103,11 +103,12 @@ module Make (IO: IO)
Printf.sprintf ", at \"%s\"" invalid_lexeme
| Some valid ->
let valid_lexeme = Lexer.Token.to_lexeme valid in
let valid = Printf.sprintf ", after \"%s\"" valid_lexeme in
if Lexer.Token.is_eof invalid then valid
if Lexer.Token.is_eof invalid then
Printf.sprintf ", after \"%s\"" valid_lexeme
else
let invalid_lexeme = Lexer.Token.to_lexeme invalid in
Printf.sprintf "at \"%s\", before %s" invalid_lexeme valid in
Printf.sprintf " at \"%s\", after \"%s\""
invalid_lexeme valid_lexeme in
let header = header ^ trailer in
let msg =
header ^ (if msg = "" then ".\n" else ":\n" ^ msg)