diff options
author | Alain Frisch <alain@frisch.fr> | 2012-10-16 14:04:33 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2012-10-16 14:04:33 +0000 |
commit | 238814e29339d82520524ee319b18928931837f8 (patch) | |
tree | aeaa1ea33c7edb2a3c1fd567c4263986914d5bdd /parsing/syntaxerr.ml | |
parent | e7546ca216f1d6ca6d9ea29ff171d9468631742b (diff) |
#5770: Syntax error messages involving unclosed parens are sometimes incorrect.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13019 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'parsing/syntaxerr.ml')
-rw-r--r-- | parsing/syntaxerr.ml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/parsing/syntaxerr.ml b/parsing/syntaxerr.ml index bd5fafb25..5c17a99a3 100644 --- a/parsing/syntaxerr.ml +++ b/parsing/syntaxerr.ml @@ -16,11 +16,13 @@ open Format type error = Unclosed of Location.t * string * Location.t * string + | Expecting of Location.t * string | Applicative_path of Location.t | Variable_in_scope of Location.t * string | Other of Location.t + exception Error of error exception Escape_error @@ -36,6 +38,10 @@ let report_error ppf = function fprintf ppf "%aThis '%s' might be unmatched" Location.print_error opening_loc opening end + | Expecting (loc, nonterm) -> + fprintf ppf + "%a@[Syntax error: %s expected.@]" + Location.print_error loc nonterm | Applicative_path loc -> fprintf ppf "%aSyntax error: applicative paths of the form F(X).t \ @@ -48,3 +54,11 @@ let report_error ppf = function Location.print_error loc var var | Other loc -> fprintf ppf "%aSyntax error" Location.print_error loc + + +let location_of_error = function + | Unclosed(l,_,_,_) + | Applicative_path l + | Variable_in_scope(l,_) + | Other l + | Expecting (l, _) -> l |