51'$check_op'(
P,
T,
Op,
G)
:-
53 '$do_error'(instantiation_error,
G).
54'$check_op'(
P,
_,
_,
G)
:-
56 '$do_error'(type_error(integer,
P),
G).
57'$check_op'(
P,
_,
_,
G)
:-
59 '$do_error'(domain_error(operator_priority,
P),
G).
60'$check_op'(
_,
T,
_,
G)
:-
62 '$do_error'(type_error(atom,
T),
G).
63'$check_op'(
_,
T,
_,
G)
:-
64 \+ '$associativity'(
T),
'$associativity',
65 '$do_error'(domain_error(operator_specifier,
T),
G).
66'$check_op'(
P,
T,
V,
G)
:-
67 '$check_module_for_op'(
V,
G,
NV),
68 '$check_top_op'(
P,
T,
NV,
G).
70'$check_top_op'(
_,
_, [],
_)
:- '$check_top_op'.
71'$check_top_op'(
P,
T, [
Op|NV],
G)
:- '$check_top_op',
72 '$check_ops'(
P,
T, [
Op|NV],
G).
73'$check_top_op'(
P,
T,
V,
G)
:-
75 '$check_op_name'(
P,
T,
V,
G).
76'$check_top_op'(
_P,
_T,
V,
G)
:-
77 '$do_error'(type_error(atom,
V),
G).
79 '$associativity'(xfx).
80 '$associativity'(xfy).
81 '$associativity'(yfx).
82 '$associativity'(yfy).
88'$check_module_for_op'(
MOp,
G,
_)
:-
90 '$do_error'(instantiation_error,
G).
91'$check_module_for_op'(
M:_V,
G,
_)
:-
93 '$do_error'(instantiation_error,
G).
94'$check_module_for_op'(
M:V,
G,
NV)
:-
96 '$check_module_for_op'(
V,
G,
NV).
97'$check_module_for_op'(
M:_V,
G,
_)
:- '$check_module_for_op',
98 '$do_error'(type_error(atom,
M),
G).
99'$check_module_for_op'(
V,
_G,
V).
101'$check_ops'(
_P,
_T, [],
_G)
:- '$check_ops'.
102'$check_ops'(
P,
T, [
Op|NV],
G)
:- '$check_ops',
106 '$do_error'(instantiation_error,
G)
108 '$check_module_for_op'(
Op,
G,
NOp),
109 '$check_op_name'(
P,
T,
NOp,
G),
110 '$check_ops'(
P,
T,
NV,
G)
112'$check_ops'(
_P,
_T,
Ops,
G)
:-
113 '$do_error'(type_error(list,
Ops),
G).
115'$check_op_name'(
_,
_,
V,
G)
:-
117 '$do_error'(instantiation_error,
G).
118 '$check_op_name'(
_,
_,
',',
G)
:- '$check_op_name',
119 '$do_error'(permission_error(modify,operator,
','),
G).
120'$check_op_name'(
_,
_,
'[]',
G)
:- T \= '$check_op_name',
T\= '$check_op_name',
'$check_op_name',
121 '$do_error'(permission_error(create,operator,
'[]'),
G).
122'$check_op_name'(
_,
_,
'{}',
G)
:- T \= '$check_op_name',
T\= '$check_op_name',
'$check_op_name',
123 '$do_error'(permission_error(create,operator,
'{}'),
G).
124'$check_op_name'(
P,
T,
'|',
G)
:-
131 '$do_error'(permission_error(create,operator,
'|'),
G).
132'$check_op_name'(
_,
_,
V,
_)
:-
134'$check_op_name'(
_,
_,
A,
G)
:-
135 '$do_error'(type_error(atom,
A),
G).
139 '$check_op'(
P,
T,
V,op(
P,
T,
V)),
143 strip_module(
ML,
M, [
A|As]),
strip_module,
144 '$opl'(
P,
T,
M, [
A|As]).
148 '$opl'(
_P,
_T,
_, []).
149 '$opl'(
P,
T,
M, [
A|As])
:-
155 'opdec'(
P,
T,
A,prolog).
160op_cases(
_P,
_T, [],
_MA)
:-
162op_cases(
P,
T, [
A|AS],
MA)
:-
166op_cases(
P,
T,
A,
MA)
:-
178 '$current_module'(
M),
179 '$do_current_op'(
X,
Y,
V,
M).
181 '$current_opm'(
X,
Y,
Z,
M).
183 '$current_module'(
M),
184 '$do_current_op'(
X,
Y,
Z,
M).
186'$current_opm'(
X,
Y,
Z,
M)
:-
188 \+ '$associativity'(
Y),
189 '$do_error'(domain_error(operator_specifier,
Y),current_op(
X,
Y,
M:Z)).
190'$current_opm'(
X,
Y,
Z,
M)
:-
192 '$do_current_op'(
X,
Y,
Z,
M).
193'$current_opm'(
X,
Y,
M:Z,
_)
:- '$current_opm',
194 '$current_opm'(
X,
Y,
Z,
M).
195'$current_opm'(
X,
Y,
Z,
M)
:-
196 '$do_current_op'(
X,
Y,
Z,
M).
198'$do_current_op'(
X,
Y,
Z,
M)
:-
200 \+ '$associativity'(
Y),
201 '$do_error'(domain_error(operator_specifier,
Y),current_op(
X,
Y,
M:Z)).
202'$do_current_op'(
X,
Y,
Z,
M)
:-
204 '$current_atom_op'(
Z,
M1,
Prefix,
Infix,
Posfix),
205 (
M1 = prolog
-> true
; M1 = M ),
207 '$get_prefix'(
Prefix,
X,
Y)
209 '$get_infix'(
Infix,
X,
Y)
211 '$get_posfix'(
Posfix,
X,
Y)
213'$do_current_op'(
X,
Y,
Z,
M)
:-
214 '$current_op'(
Z,
M1,
Prefix,
Infix,
Posfix),
215 (
M1 = prolog
-> true
; M1 = M ),
217 '$get_prefix'(
Prefix,
X,
Y)
219 '$get_infix'(
Infix,
X,
Y)
221 '$get_posfix'(
Posfix,
X,
Y)
224'$get_prefix'(
Prefix,
X,
Y)
:-
226 X is Prefix /\ 0'$get_prefix',
228 0x2000
/\ Prefix =:= 0x2000
235'$get_infix'(
Infix,
X,
Y)
:-
237 X is Infix /\ 0'$get_infix',
239 0x3000
/\ Infix =:= 0x3000
243 0x1000
/\ Infix =:= 0x1000
250'$get_posfix'(
Posfix,
X,
Y)
:-
252 X is Posfix /\ 0'$get_posfix',
254 0x1000
/\ Posfix =:= 0x1000
261
atom_codes(?Atom, ?Codes)