From: SourceForge.net <no...@so...> - 2004-03-05 06:50:51
|
Bugs item #910271, was opened at 2004-03-05 01:36 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=910271&group_id=4933 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Stavros Macrakis (macrakis) Assigned to: Nobody/Anonymous (nobody) Summary: macsyma-read-string /FIX Initial Comment: Macsyma-read-string currently doesn't work in GCL 5.9.0 (problem with vector-push-extend) and has no error handling. Here's a fixed version with good error handling. Example: (meval (macsyma-read-string "diff(x^2,x)")) => ((MTIMES SIMP) 2 |$x|) ;;; Copyright 2004 by Stavros Macrakis ;;; Licensed under your choice of the GPL or the modified BSD license ;;; Parse a string as a Maxima expression ;;; Return the parsed form ;;; If there's an error, it returns the symbol parse-error; the ;;; second return value is then the error string. ;;; Usage examples: ;;; ;;; (macsyma-read-string "1/+3*x") => ;;; ((MQUOTIENT) 1 ((MPLUS) ((MTIMES) 3 |$x|))) ;;; NIL ;;; ;;; Note that this is simply parsed -- no simplification. ;;; The simplified form is ;;; ((MTIMES SIMP) ((RAT SIMP) 1 3) ((MEXPT SIMP) |$x| -1)) ;;; ;;; (macsyma-read-string "1.2.3") => ;;; NIL ;;; "Incorrect syntax: 0.29999999999999999 is not an infix operator" (defun macsyma-read-string (str) (with-input-from-string (stream (concatenate 'string str "$")) (let* ((*standard-input* stream) (*standard-output* (make-string-output- stream)) ;; catches error strings (expr (catch 'macsyma-quit (list (caddr (mread stream))))) (error-string (get-output-stream-string *standard-output*))) (values (if (atom expr) 'parse-error (car expr)) (cond ((not (equal error-string "")) error-string) ((tyi stream) "Excess characters in input string") ((not (listp expr)) "Unknown read error") (t nil)))))) _______________________________________________ Maxima mailing list Ma...@ww... http://www.math.utexas.edu/mailman/listinfo/maxima ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=910271&group_id=4933 |