diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-01-27 23:51:56 +0000 |
commit | 6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 (patch) | |
tree | 926065cf45450116098db664e3c61dced9e1f21a /ipl/procs/feval.icn | |
download | icon-6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1.tar.gz |
Initial upstream version 9.4.3upstream/9.4.3
Diffstat (limited to 'ipl/procs/feval.icn')
-rw-r--r-- | ipl/procs/feval.icn | 54 |
1 files changed, 54 insertions, 0 deletions
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 |