|
|
last edited 13 years ago by page |
1 2 3 4 5 6 7 | ||
Editor: page
Time: 2011/03/11 09:14:57 GMT-8 |
||
Note: format lisp |
changed: -\begin{axiom} -)lisp (defun string2spad (the-string-list) (let* ( ($LISPLIB t) (|$QuickLet| t) (|$QuickCode| t) (|$InteractiveMode| nil) (*standard-input* (make-string-input-stream (format nil "~{~A~^~%~}" the-string-list))) ) (declare (special $LISPLIB |$InteractiveMode|)) (|oldCompilerAutoloadOnceTrigger|) (|spadCompile| nil) )) -\end{axiom} This code can be compiled as below or executed directly in the interpreter via ')lisp ...'. \begin{lisp} (defun string2spad (the-string-list) (let* ( ($LISPLIB t) (|$QuickLet| t) (|$QuickCode| t) (|$InteractiveMode| nil) (*standard-input* (make-string-input-stream (format nil "~{~A~^~%~}" the-string-list))) ) (declare (special $LISPLIB |$InteractiveMode|)) (|oldCompilerAutoloadOnceTrigger|) (|spadCompile| nil) )) \end{lisp} changed: -\begin{axiom} -)lisp (defun string2spad (the-string-list) (let* ( ($LISPLIB t) (|$QuickLet| t) (|$QuickCode| t) (|$InteractiveMode| nil) (*standard-input* (make-string-input-stream (format nil "~{~A~^~%~}" the-string-list))) (*standard-output* (make-string-output-stream)) ) (declare (special $LISPLIB |$InteractiveMode|)) (|spadCompile| nil) (get-output-stream-string *standard-output* ) )) -\end{axiom} \begin{lisp} (defun string2spad (the-string-list) (let* ( ($LISPLIB t) (|$QuickLet| t) (|$QuickCode| t) (|$InteractiveMode| nil) (*standard-input* (make-string-input-stream (format nil "~{~A~^~%~}" the-string-list))) (*standard-output* (make-string-output-stream)) ) (declare (special $LISPLIB |$InteractiveMode|)) (|spadCompile| nil) (get-output-stream-string *standard-output* ) )) \end{lisp}
Waldek Hebisch helped me to write the following Lisp code to call the SPAD compiler from the FriCAS/AXIOM interpreter.
(1) -> )set output algebra on
)set output tex off
This function can be called from the interpreter to compile a SPAD program. The program source is passed as a List of Strings which is sent to the compiler as a text stream. Several flags and parameters must be set and dynamical loading of the compiler itself must be performed before calling the compiler. The parameter nil instructs the compiler to read form standard input, which in turn has been re-directed to the text stream.
This code can be compiled as below or executed directly in the interpreter via )lisp ...
.
(defun string2spad (the-string-list) (let* ( ($LISPLIB t) (|$QuickLet| t) (|$QuickCode| t) (|$InteractiveMode| nil) (*standard-input* (make-string-input-stream (format nil "~{~A~^~%~}" the-string-list))) ) (declare (special $LISPLIB |$InteractiveMode|)) (|oldCompilerAutoloadOnceTrigger|) (|spadCompile| nil) ))
Your user access level is compiler and this command is therefore not available. See the )set userlevel command for more information.
For example:
S:=[")abbrev domain XXX xxx","xxx():BasicType == Integer"]
(1) [")abbrev domain XXX xxx","xxx():BasicType == Integer"]
STRING2SPAD(S)$Lisp
STRING2SPAD is not a lisp function and so cannot be used with $Lisp.
The output is sent to the console but the text stream can be captured as a string and returned to the caller as follows:
(defun string2spad (the-string-list) (let* ( ($LISPLIB t) (|$QuickLet| t) (|$QuickCode| t) (|$InteractiveMode| nil) (*standard-input* (make-string-input-stream (format nil "~{~A~^~%~}" the-string-list))) (*standard-output* (make-string-output-stream)) ) (declare (special $LISPLIB |$InteractiveMode|)) (|spadCompile| nil) (get-output-stream-string *standard-output* ) ))
Your user access level is compiler and this command is therefore not available. See the )set userlevel command for more information.
and we can get the result as a string
result:=string STRING2SPAD(S)$Lisp
STRING2SPAD is not a lisp function and so cannot be used with $Lisp.