Newsgroups: comp.lang.pop
Subject: Reading expressions in pop-11 - a cheapie.
Summary:
Followup-To:
Distribution: world
Organization: University of Massachusetts, Amherst
Keywords:
/*
popterm.p Robin Popplestone JAN 95
Provides a macro which allows mathematical expressions to be read in
using POP-11 syntax and to be converted into Prolog terms.
This does NOT require Prolog to be loaded. For example
|: (x+sin(y)*2) :|
will give rise to the prolog term:
** <prologterm + x <prologterm * <prologterm sin y> 2>>
Bugs etc. You had better not use anything than constants, variables
and procedure calls, or funny things will happen.
*/
applist([sysPUSH sysCALL sysPUSHQ], sysunprotect);
define newCALL(w);
lvars n = pdnargs(valof(w));
prolog_maketerm(/*..*/,w,n);
enddefine;
define macro |: ;
dlocal sysPUSH = identfn, sysCALL=newCALL, sysPUSHQ=identfn;
pop11_comp_expr_to(":|")->;
enddefine;
/*
|: (x+sin(y)*2) :| =>
** <prologterm + x <prologterm * <prologterm sin y> 2>>
*/
applist([sysPUSH sysCALL sysPUSHQ], sysprotect);
|