let tree_failed entry prev_symb_result prev_symb tree =
let txt = name_of_tree_failed entry tree in
let txt =
match prev_symb with
| Slist0 s ->
let txt1 = name_of_symbol_failed entry s
in txt1 ^ (" or " ^ (txt ^ " expected"))
| Slist1 s ->
let txt1 = name_of_symbol_failed entry s
in txt1 ^ (" or " ^ (txt ^ " expected"))
| Slist0sep (s, sep) ->
(match magic "tree_failed: 'a -> list 'b"
prev_symb_result
with
| [] ->
let txt1 = name_of_symbol_failed entry s
in txt1 ^ (" or " ^ (txt ^ " expected"))
| _ ->
let txt1 = name_of_symbol_failed entry sep
in txt1 ^ (" or " ^ (txt ^ " expected")))
| Slist1sep (s, sep) ->
(match magic "tree_failed: 'a -> list 'b"
prev_symb_result
with
| [] ->
let txt1 = name_of_symbol_failed entry s
in txt1 ^ (" or " ^ (txt ^ " expected"))
| _ ->
let txt1 = name_of_symbol_failed entry sep
in txt1 ^ (" or " ^ (txt ^ " expected")))
| Stry _ | Sopt _ | Stree _ -> txt ^ " expected"
| _ ->
txt ^
(" expected after " ^
(name_of_symbol entry prev_symb))
in
(if !(entry.egram.error_verbose)
then
(let tree =
Search.tree_in_entry prev_symb tree entry.edesc in
let ppf = err_formatter
in
(fprintf ppf "@[<v 0>@,";
fprintf ppf "----------------------------------@,";
fprintf ppf
"Parse error in entry [%s], rule:@;<0 2>"
entry.ename;
fprintf ppf "@[";
Print.print_level ppf pp_force_newline
(Print.flatten_tree tree);
fprintf ppf "@]@,";
fprintf ppf "----------------------------------@,";
fprintf ppf "@]@."))
else ();
txt ^ (" (in [" ^ (entry.ename ^ "])")))