interpret-block

9 views
Skip to first unread message

Ralf Hemmecke

unread,
Oct 4, 2020, 4:19:41 AM10/4/20
to fricas-devel
Hi Waldek,

In jfricas I needed a function that could interpret multiline code.
Initially, this was done by writing out the code to a file and then use
)read file.input. Eventually, I traced down what actually happens when
fricas reads a .input file and so put together a function that as input
gets a string (possibly with newlines) that is then interpreted as if it
came from a file.

I think |interpret-block| should be part of FriCAS. Maybe under another
name, which one would you like?

I do not exactly know where it would best fit in FriCAS, so it would be
good, if you can put this on your TODO-list.

It certainly could also help in the fricas terminal input if there where
a method that not immediately sends input to the interpreter, but waits,
for example, if the input line contained an open parenthesis.

Ralf

https://github.com/fricas/jfricas/blob/master/jfricas/webspad.lisp#L101

;;; interpret-block takes a code string that is interpreted as if it
;;; comes from a .input file.
(DEFUN |interpret-block| (|code|)
(PROG (|$ncMsgList| |$erMsgToss| |$lastPos| |$EchoLines| |st|)
(DECLARE (SPECIAL |$ncMsgList| |$erMsgToss| |$lastPos| |$EchoLines|))
(RETURN
(PROGN
(SETQ |$EchoLines| NIL)
(SETQ |$lastPos| |$nopos|)
(SETQ |$erMsgToss| NIL)
(SETQ |$ncMsgList| NIL)
(SETQ |st| (MAKE-STRING-INPUT-STREAM |code|))
(|intloopInclude0| |st| '|webspad| 0)))))
Reply all
Reply to author
Forward
0 new messages