parent
c50ed643f9
commit
bf40154ff1
@ -222,8 +222,8 @@ system_message(error(permission_error(modify,dynamic_procedure,_), Where)) -->
|
|||||||
[ 'PERMISSION ERROR- ~w: modifying a dynamic procedure' - [Where] ].
|
[ 'PERMISSION ERROR- ~w: modifying a dynamic procedure' - [Where] ].
|
||||||
system_message(error(permission_error(modify,flag,W), _)) -->
|
system_message(error(permission_error(modify,flag,W), _)) -->
|
||||||
[ 'PERMISSION ERROR- cannot modify flag ~w' - [W] ].
|
[ 'PERMISSION ERROR- cannot modify flag ~w' - [W] ].
|
||||||
system_message(error(permission_error(modify,operator,W), _)) -->
|
system_message(error(permission_error(modify,operator,W), Q)) -->
|
||||||
[ 'PERMISSION ERROR- T cannot declare ~w an operator' - [W] ].
|
[ 'PERMISSION ERROR- ~w: cannot modify operator ~q' - [Q,W] ].
|
||||||
system_message(error(permission_error(modify,dynamic_procedure,F), Where)) -->
|
system_message(error(permission_error(modify,dynamic_procedure,F), Where)) -->
|
||||||
[ 'PERMISSION ERROR- ~w: modifying dynamic procedure ~w' - [Where,F] ].
|
[ 'PERMISSION ERROR- ~w: modifying dynamic procedure ~w' - [Where,F] ].
|
||||||
system_message(error(permission_error(modify,static_procedure,F), Where)) -->
|
system_message(error(permission_error(modify,static_procedure,F), Where)) -->
|
||||||
|
131
pl/utils.yap
131
pl/utils.yap
@ -1,65 +1,80 @@
|
|||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* *
|
* *
|
||||||
* YAP Prolog *
|
* YAP Prolog *
|
||||||
* *
|
* *
|
||||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
||||||
* *
|
* *
|
||||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
||||||
* *
|
* *
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* *
|
* *
|
||||||
* File: utils.yap *
|
* File: utils.yap *
|
||||||
* Last rev: 8/2/88 *
|
* Last rev: 8/2/88 *
|
||||||
* mods: *
|
* mods: *
|
||||||
* comments: Some utility predicates available in yap *
|
* comments: Some utility predicates available in yap *
|
||||||
* *
|
* *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
op(P,T,V) :-
|
op(P,T,V) :-
|
||||||
'$check_op'(P,T,V,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,G) :-
|
'$check_op'(P,T,V,G) :-
|
||||||
(
|
(
|
||||||
var(P) ->
|
var(P) ->
|
||||||
'$do_error'(instantiation_error,G)
|
'$do_error'(instantiation_error,G)
|
||||||
;
|
;
|
||||||
var(T) ->
|
var(T) ->
|
||||||
'$do_error'(instantiation_error,G)
|
'$do_error'(instantiation_error,G)
|
||||||
;
|
;
|
||||||
var(V) ->
|
var(V) ->
|
||||||
'$do_error'(instantiation_error,G)
|
'$do_error'(instantiation_error,G)
|
||||||
;
|
;
|
||||||
\+ integer(P) ->
|
\+ integer(P) ->
|
||||||
'$do_error'(type_error(integer,P),G)
|
'$do_error'(type_error(integer,P),G)
|
||||||
;
|
;
|
||||||
\+ atom(T) ->
|
\+ atom(T) ->
|
||||||
'$do_error'(type_error(atom,T),G)
|
'$do_error'(type_error(atom,T),G)
|
||||||
;
|
;
|
||||||
P < 0 ->
|
P < 0 ->
|
||||||
'$do_error'(domain_error(operator_priority,P),G)
|
'$do_error'(domain_error(operator_priority,P),G)
|
||||||
;
|
;
|
||||||
P > 1200 ->
|
P > 1200 ->
|
||||||
'$do_error'(domain_error(operator_priority,P),G)
|
'$do_error'(domain_error(operator_priority,P),G)
|
||||||
;
|
;
|
||||||
\+ '$associativity'(T) ->
|
\+ '$associativity'(T) ->
|
||||||
'$do_error'(domain_error(operator_specifier,T),G)
|
'$do_error'(domain_error(operator_specifier,T),G)
|
||||||
;
|
;
|
||||||
'$check_op_name'(V,G)
|
'$check_op_name'(V,G)
|
||||||
).
|
).
|
||||||
|
|
||||||
'$associativity'(xfx).
|
'$associativity'(xfx).
|
||||||
'$associativity'(xfy).
|
'$associativity'(xfy).
|
||||||
'$associativity'(yfx).
|
'$associativity'(yfx).
|
||||||
'$associativity'(yfy).
|
'$associativity'(yfy).
|
||||||
'$associativity'(xf).
|
'$associativity'(xf).
|
||||||
'$associativity'(yf).
|
'$associativity'(yf).
|
||||||
'$associativity'(fx).
|
'$associativity'(fx).
|
||||||
'$associativity'(fy).
|
'$associativity'(fy).
|
||||||
|
|
||||||
'$check_op_name'(V,G) :-
|
'$check_op_name'(V,G) :-
|
||||||
var(V), !,
|
var(V), !,
|
||||||
'$do_error'(instantiation_error,G).
|
'$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,_) :-
|
'$check_op_name'(V,_) :-
|
||||||
atom(V), !.
|
atom(V), !.
|
||||||
'$check_op_name'(M:A, G) :-
|
'$check_op_name'(M:A, G) :-
|
||||||
|
Reference in New Issue
Block a user