From 1ccf6f247d0ab48322a92fb275463ac8254ef164 Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Mon, 13 Apr 2020 16:31:56 +0200 Subject: [PATCH] Fixed format of syntax error messages. --- src/bin/expect_tests/error_messages_tests.ml | 4 ++-- src/bin/expect_tests/syntax_error_tests.ml | 2 +- src/passes/1-parser/cameligo/dune | 20 ++++++++++---------- src/passes/1-parser/shared/ParserAPI.ml | 7 ++++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/bin/expect_tests/error_messages_tests.ml b/src/bin/expect_tests/error_messages_tests.ml index 284b21e89..a28a145b5 100644 --- a/src/bin/expect_tests/error_messages_tests.ml +++ b/src/bin/expect_tests/error_messages_tests.ml @@ -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 `)`. {} diff --git a/src/bin/expect_tests/syntax_error_tests.ml b/src/bin/expect_tests/syntax_error_tests.ml index 8969c68a7..7a092f443 100644 --- a/src/bin/expect_tests/syntax_error_tests.ml +++ b/src/bin/expect_tests/syntax_error_tests.ml @@ -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: {} diff --git a/src/passes/1-parser/cameligo/dune b/src/passes/1-parser/cameligo/dune index 8824fdcd4..85a06d174 100644 --- a/src/passes/1-parser/cameligo/dune +++ b/src/passes/1-parser/cameligo/dune @@ -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 diff --git a/src/passes/1-parser/shared/ParserAPI.ml b/src/passes/1-parser/shared/ParserAPI.ml index 2b4d7c87e..5d4eedbd4 100644 --- a/src/passes/1-parser/shared/ParserAPI.ml +++ b/src/passes/1-parser/shared/ParserAPI.ml @@ -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)