home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / FEVAL.ICN < prev    next >
Text File  |  1991-09-05  |  1KB  |  57 lines

  1. ############################################################################
  2. #
  3. #    Name:    feval.icn
  4. #
  5. #    Title:    Evaluate string for function call
  6. #
  7. #    Author:    Ralph E. Griswold
  8. #
  9. #    Date:    June 29, 1990
  10. #
  11. ############################################################################
  12. #
  13. #  This procedure analyzes a string representing an Icon function or
  14. #  procedure call and evaluates the result.
  15. #
  16. #  It assumes the string is well-formed.  The arguments can only be
  17. #  Icon literals. Escapes, commas, and parentheses in strings literals
  18. #  are not handled.
  19. #
  20. ############################################################################
  21. #
  22. #  Links:  ivalue
  23. #
  24. ############################################################################
  25.  
  26. link ivalue
  27.  
  28. procedure feval(s)
  29.    local fnc, argl
  30.  
  31.    s ? {
  32.       fnc := getfnc()
  33.       argl := []
  34.       while put(argl,getarg())
  35.       suspend fnc!argl
  36.       }
  37.  
  38. end
  39.  
  40. #
  41. #  Get an argument.  This procedure is naive and could be improved.
  42. #
  43. procedure getarg()
  44.  
  45.    return 1(ivalue(tab(upto(',)'))), move(1))
  46.  
  47. end
  48.  
  49. #
  50. #  Get the function name.  Could be extended.
  51. #
  52. procedure getfnc()
  53.  
  54.    return 1(tab(upto('(')), move(1))
  55.  
  56. end
  57.