login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Waldek Hebisch helped me to write the following Lisp code to call the SPAD compiler from the FriCAS/AXIOM interpreter.

fricas
)set output algebra on
 
fricas
)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 ....

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) ))
lisp
; compiling file "/var/aw/var/LatexWiki/3873059015307512640-25px002.lisp" (written 25 APR 2013 05:47:58 PM):
; /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3873059015307512640-25px002.fasl written ; compilation finished in 0:00:00.155 Value = T

For example:

fricas
S:=[")abbrev domain XXX xxx",
    "xxx():BasicType == Integer"]
(1) [")abbrev domain XXX xxx","xxx():BasicType == Integer"]
Type: List(String)

fricas
STRING2SPAD(S)$Lisp
>> System error: The value NIL is not of type (OR (VECTOR CHARACTER) (VECTOR NIL) BASE-STRING PATHNAME STREAM).

The output is sent to the console but the text stream can be captured as a string and returned to the caller as follows:

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* ) ))
lisp
; compiling file "/var/aw/var/LatexWiki/6402112609625608357-25px005.lisp" (written 25 APR 2013 05:47:58 PM):
; /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6402112609625608357-25px005.fasl written ; compilation finished in 0:00:00.011 Value = T

and we can get the result as a string

fricas
result:=string STRING2SPAD(S)$Lisp




  Subject:   Be Bold !!
  ( 14 subscribers )  
Please rate this page: