From bf40154ff1c94ceb71153922a446c3150d9f8381 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 27 Sep 2010 22:31:06 +0100 Subject: [PATCH] fix UN #189 and #172 --- pl/messages.yap | 4 +- pl/utils.yap | 131 +++++++++++++++++++++++++++--------------------- 2 files changed, 75 insertions(+), 60 deletions(-) diff --git a/pl/messages.yap b/pl/messages.yap index 8a71829b6..611206611 100644 --- a/pl/messages.yap +++ b/pl/messages.yap @@ -222,8 +222,8 @@ system_message(error(permission_error(modify,dynamic_procedure,_), Where)) --> [ 'PERMISSION ERROR- ~w: modifying a dynamic procedure' - [Where] ]. system_message(error(permission_error(modify,flag,W), _)) --> [ 'PERMISSION ERROR- cannot modify flag ~w' - [W] ]. -system_message(error(permission_error(modify,operator,W), _)) --> - [ 'PERMISSION ERROR- T cannot declare ~w an operator' - [W] ]. +system_message(error(permission_error(modify,operator,W), Q)) --> + [ 'PERMISSION ERROR- ~w: cannot modify operator ~q' - [Q,W] ]. system_message(error(permission_error(modify,dynamic_procedure,F), Where)) --> [ 'PERMISSION ERROR- ~w: modifying dynamic procedure ~w' - [Where,F] ]. system_message(error(permission_error(modify,static_procedure,F), Where)) --> diff --git a/pl/utils.yap b/pl/utils.yap index 7ceb01e24..816515f73 100644 --- a/pl/utils.yap +++ b/pl/utils.yap @@ -1,65 +1,80 @@ -/************************************************************************* -* * -* YAP Prolog * -* * -* Yap Prolog was developed at NCCUP - Universidade do Porto * -* * -* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * -* * -************************************************************************** -* * -* File: utils.yap * -* Last rev: 8/2/88 * -* mods: * -* comments: Some utility predicates available in yap * -* * -*************************************************************************/ + /************************************************************************* + * * + * YAP Prolog * + * * + * Yap Prolog was developed at NCCUP - Universidade do Porto * + * * + * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 * + * * + ************************************************************************** + * * + * File: utils.yap * + * Last rev: 8/2/88 * + * mods: * + * comments: Some utility predicates available in yap * + * * + *************************************************************************/ -op(P,T,V) :- - '$check_op'(P,T,V,op(P,T,V)), - '$op'(P, T, V). + op(P,T,V) :- + '$check_op'(P,T,V,op(P,T,V)), + '$op'(P, T, V). -'$check_op'(P,T,V,G) :- - ( - var(P) -> - '$do_error'(instantiation_error,G) - ; - var(T) -> - '$do_error'(instantiation_error,G) - ; - var(V) -> - '$do_error'(instantiation_error,G) - ; - \+ integer(P) -> - '$do_error'(type_error(integer,P),G) - ; - \+ atom(T) -> - '$do_error'(type_error(atom,T),G) - ; - P < 0 -> - '$do_error'(domain_error(operator_priority,P),G) - ; - P > 1200 -> - '$do_error'(domain_error(operator_priority,P),G) - ; - \+ '$associativity'(T) -> - '$do_error'(domain_error(operator_specifier,T),G) - ; - '$check_op_name'(V,G) - ). + '$check_op'(P,T,V,G) :- + ( + var(P) -> + '$do_error'(instantiation_error,G) + ; + var(T) -> + '$do_error'(instantiation_error,G) + ; + var(V) -> + '$do_error'(instantiation_error,G) + ; + \+ integer(P) -> + '$do_error'(type_error(integer,P),G) + ; + \+ atom(T) -> + '$do_error'(type_error(atom,T),G) + ; + P < 0 -> + '$do_error'(domain_error(operator_priority,P),G) + ; + P > 1200 -> + '$do_error'(domain_error(operator_priority,P),G) + ; + \+ '$associativity'(T) -> + '$do_error'(domain_error(operator_specifier,T),G) + ; + '$check_op_name'(V,G) + ). -'$associativity'(xfx). -'$associativity'(xfy). -'$associativity'(yfx). -'$associativity'(yfy). -'$associativity'(xf). -'$associativity'(yf). -'$associativity'(fx). -'$associativity'(fy). + '$associativity'(xfx). + '$associativity'(xfy). + '$associativity'(yfx). + '$associativity'(yfy). + '$associativity'(xf). + '$associativity'(yf). + '$associativity'(fx). + '$associativity'(fy). -'$check_op_name'(V,G) :- - var(V), !, - '$do_error'(instantiation_error,G). + '$check_op_name'(V,G) :- + var(V), !, + '$do_error'(instantiation_error,G). + '$check_op_name'(',',G) :- !, + '$do_error'(permission_error(modify,operator,','),G). + '$check_op_name'('[]',G) :- !, + '$do_error'(permission_error(create,operator,'[]'),G). + '$check_op_name'('{}',G) :- !, + '$do_error'(permission_error(create,operator,'{}'),G). + '$check_op_name'('|',G) :- !, + G = op(P, T, _), + ( + integer(P), + P < 1001 + ; + Fix \== xfx, Fix \== xfy, Fix \== yfx, Fix \== yfy + ), + '$do_error'(permission_error(create,operator,'|'),G). '$check_op_name'(V,_) :- atom(V), !. '$check_op_name'(M:A, G) :-