Patch for number parser



I've always found it rather annoying that maxima doesn't think that
1d0 or 1b0 is a number---it always wants a decimal point before the
exponent marker.

Here's a small patch that makes maxima recognize these as numbers.

Ray

Index: nparse.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima-pre59/src/nparse.lisp,v
retrieving revision 1.8
diff -u -r1.8 nparse.lisp
--- nparse.lisp	2001/04/17 15:09:39	1.8
+++ nparse.lisp	2002/01/08 16:43:40
@@ -423,7 +423,7 @@
       (READLIST (APPLY #'APPEND DATA))
       ;; For bigfloats, turn them into rational numbers then convert to bigfloat
       ($BFLOAT `((MTIMES) ((MPLUS) ,(READLIST (FIRST DATA))
-				   ((MTIMES) ,(READLIST (THIRD DATA))
+				   ((MTIMES) ,(READLIST (or (THIRD DATA) '(#\0)))
 					     ((MEXPT) 10. ,(f- (LENGTH (THIRD DATA))))))
 			  ((MEXPT) 10. ,(FUNCALL (IF (char= (FIRST (FIFTH DATA)) #\-) #'- #'+)
 						 (READLIST (SIXTH DATA))))))))
@@ -442,6 +442,7 @@
 	      (MAKE-NUMBER (CONS (NREVERSE L) DATA)))))
     (PARSE-TYI)))
 
+#+nil
 (DEFUN SCAN-NUMBER-BEFORE-DOT (DATA)
   (SCAN-DIGITS DATA '(#. period-char) #'SCAN-NUMBER-AFTER-DOT))
 
@@ -456,6 +457,23 @@
 	DATA)
   (SCAN-DIGITS DATA () ()))
 
+(defun scan-number-rest (data)
+  (let ((c (caar data)))
+    (cond ((imember c '(#. period-char))
+	   ;; We found a dot
+	   (scan-number-after-dot data))
+	  ((imember c '(#\E #\e #\B #\b #\D #\d #\S #\s))
+	   ;; Dot missing but found exponent marker.  Fake it.
+	   (setf data (push (ncons #\.) (rest data)))
+	   (push (ncons #\0) data)
+	   (push (ncons c) data)
+	   (scan-number-exponent data)))))
+
+(defun scan-number-before-dot (data)
+  (scan-digits data '(#. period-char #\E #\e #\B #\b #\D #\d #\S #\s)
+	       #'scan-number-rest))
+
+    
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;                                                                    ;;;;;