From 6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sun, 27 Jan 2013 23:51:56 +0000 Subject: Initial upstream version 9.4.3 --- ipl/procs/feval.icn | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 ipl/procs/feval.icn (limited to 'ipl/procs/feval.icn') diff --git a/ipl/procs/feval.icn b/ipl/procs/feval.icn new file mode 100644 index 0000000..2d84dad --- /dev/null +++ b/ipl/procs/feval.icn @@ -0,0 +1,54 @@ +############################################################################ +# +# File: feval.icn +# +# Subject: Procedure to evaluate string as function call +# +# Author: Ralph E. Griswold +# +# Date: June 8, 1994 +# +############################################################################ +# +# This file is in the public domain. +# +############################################################################ +# +# This procedure analyzes a string representing an Icon function or +# procedure call and evaluates the result. +# +# It assumes the string is well-formed. The arguments can only be +# Icon literals. Escapes, commas, and parentheses in strings literals +# are not handled. +# +############################################################################ +# +# Links: ivalue +# +############################################################################ + +invocable all + +link ivalue + +procedure feval(s) + local fnc, argl + + s ? { + fnc := tab(upto('(')) | { + write(&errout, "*** syntax error") + fail + } + fnc := proc(fnc, 3 to 1 by -1) | { + write(&errout, "*** invalid function or operation") + fail + } + move(1) + + argl := [] + while put(argl, ivalue(tab(upto(',)')))) do move(1) + + suspend fnc ! argl + } + +end -- cgit v1.2.3