]> Repositorios git - scryer-prolog.git/commitdiff
enable op declarations with lists of operands using term expansion (#839)
authorMark Thom <[email protected]>
Sun, 28 Feb 2021 16:15:03 +0000 (09:15 -0700)
committerMark Thom <[email protected]>
Sun, 28 Feb 2021 16:15:03 +0000 (09:15 -0700)
src/toplevel.pl

index b46bf49da4395d9280937d9193a9e111085d9482..4a861259c482248fb64cef07ff06964ca91921fe 100644 (file)
@@ -108,6 +108,17 @@ repl :-
 repl :-
     repl.
 
+%% Enable op declarations with lists of operands, i.e.,
+%% :- op(900, fy, [$,@]).
+
+user:term_expansion((:- op(Pred, Spec, [Op | OtherOps])), OpResults) :-
+    expand_op_list([Op | OtherOps], Pred, Spec, OpResults).
+
+expand_op_list([], _, _, []).
+expand_op_list([Op | OtherOps], Pred, Spec, [(:- op(Pred, Spec, Op)) | OtherResults]) :-
+    expand_op_list(OtherOps, Pred, Spec, OtherResults).
+
+
 read_and_match :-
     '$read_query_term'(_, Term, _, _, VarList),
     instruction_match(Term, VarList).