emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/calc/calc-lang.el [emacs-unicode-2]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/calc/calc-lang.el [emacs-unicode-2]
Date: Wed, 08 Dec 2004 01:05:22 -0500

Index: emacs/lisp/calc/calc-lang.el
diff -c emacs/lisp/calc/calc-lang.el:1.5.4.2 
emacs/lisp/calc/calc-lang.el:1.5.4.3
*** emacs/lisp/calc/calc-lang.el:1.5.4.2        Fri Nov 12 02:53:01 2004
--- emacs/lisp/calc/calc-lang.el        Wed Dec  8 05:02:18 2004
***************
*** 3,10 ****
  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
  
  ;; Author: David Gillespie <address@hidden>
! ;; Maintainers: D. Goel <address@hidden>
! ;;              Colin Walters <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
--- 3,9 ----
  ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
  
  ;; Author: David Gillespie <address@hidden>
! ;; Maintainer: Jay Belanger <address@hidden>
  
  ;; This file is part of GNU Emacs.
  
***************
*** 27,41 ****
  
  ;;; Code:
  
- 
  ;; This file is autoloaded from calc-ext.el.
- (require 'calc-ext)
  
  (require 'calc-macs)
  
- (defun calc-Need-calc-lang () nil)
- 
- 
  ;;; Alternate entry/display languages.
  
  (defun calc-set-language (lang &optional option no-refresh)
--- 26,36 ----
  
  ;;; Code:
  
  ;; This file is autoloaded from calc-ext.el.
  
+ (require 'calc-ext)
  (require 'calc-macs)
  
  ;;; Alternate entry/display languages.
  
  (defun calc-set-language (lang &optional option no-refresh)
***************
*** 258,263 ****
--- 253,265 ----
  (put 'fortran 'math-input-filter 'calc-input-case-filter)
  (put 'fortran 'math-output-filter 'calc-output-case-filter)
  
+ ;; The next few variables are local to math-read-exprs in calc-aent.el 
+ ;; and math-read-expr in calc-ext.el, but are set in functions they call.
+ 
+ (defvar math-exp-token)
+ (defvar math-expr-data)
+ (defvar math-exp-old-pos)
+ 
  (defvar math-parsing-fortran-vector nil)
  (defun math-parse-fortran-vector (op)
    (let ((math-parsing-fortran-vector '(end . "\000")))
***************
*** 708,841 ****
    (list 'intv 3 x (math-read-expr-level (nth 3 op))))
  
  
  
! 
! 
! (defun math-read-big-rec (h1 v1 h2 v2 &optional baseline prec short)
    (or prec (setq prec 0))
  
    ;; Clip whitespace above or below.
!   (while (and (< v1 v2) (math-read-big-emptyp h1 v1 h2 (1+ v1)))
!     (setq v1 (1+ v1)))
!   (while (and (< v1 v2) (math-read-big-emptyp h1 (1- v2) h2 v2))
!     (setq v2 (1- v2)))
  
    ;; If formula is a single line high, normal parser can handle it.
!   (if (<= v2 (1+ v1))
!       (if (or (<= v2 v1)
!             (> h1 (length (setq v2 (nth v1 lines)))))
!         (math-read-big-error h1 v1)
!       (setq the-baseline v1
!             the-h2 h2
!             v2 (nth v1 lines)
!             h2 (math-read-expr (substring v2 h1 (min h2 (length v2)))))
!       (if (eq (car-safe h2) 'error)
!           (math-read-big-error (+ h1 (nth 1 h2)) v1 (nth 2 h2))
!         h2))
  
      ;; Clip whitespace at left or right.
!     (while (and (< h1 h2) (math-read-big-emptyp h1 v1 (1+ h1) v2))
!       (setq h1 (1+ h1)))
!     (while (and (< h1 h2) (math-read-big-emptyp (1- h2) v1 h2 v2))
!       (setq h2 (1- h2)))
  
      ;; Scan to find widest left-justified "----" in the region.
      (let* ((widest nil)
           (widest-h2 0)
!          (lines-v1 (nthcdr v1 lines))
           (p lines-v1)
!          (v v1)
           (other-v nil)
           other-char line len h)
!       (while (< v v2)
        (setq line (car p)
!             len (min h2 (length line)))
!       (and (< h1 len)
!            (/= (aref line h1) ?\ )
!            (if (and (= (aref line h1) ?\-)
                      ;; Make sure it's not a minus sign.
!                     (or (and (< (1+ h1) len) (= (aref line (1+ h1)) ?\-))
!                         (/= (math-read-big-char h1 (1- v)) ?\ )
!                         (/= (math-read-big-char h1 (1+ v)) ?\ )))
                 (progn
!                  (setq h h1)
                   (while (and (< (setq h (1+ h)) len)
                               (= (aref line h) ?\-)))
                   (if (> h widest-h2)
                       (setq widest v
                             widest-h2 h)))
!              (or other-v (setq other-v v other-char (aref line h1)))))
        (setq v (1+ v)
              p (cdr p)))
  
        (cond ((not (setq v other-v))
!            (math-read-big-error h1 v1))   ; Should never happen!
  
            ;; Quotient.
            (widest
             (setq h widest-h2
                   v widest)
!            (let ((num (math-read-big-rec h1 v1 h v))
!                  (den (math-read-big-rec h1 (1+ v) h v2)))
               (setq p (if (and (math-integerp num) (math-integerp den))
                           (math-make-frac num den)
                         (list '/ num den)))))
  
            ;; Big radical sign.
            ((= other-char ?\\)
!            (or (= (math-read-big-char (1+ h1) v) ?\|)
!                (math-read-big-error (1+ h1) v "Malformed root sign"))
!            (math-read-big-emptyp h1 v1 (1+ h1) v nil t)
!            (while (= (math-read-big-char (1+ h1) (setq v (1- v))) ?\|))
!            (or (= (math-read-big-char (setq h (+ h1 2)) v) ?\_)
                 (math-read-big-error h v "Malformed root sign"))
             (while (= (math-read-big-char (setq h (1+ h)) v) ?\_))
!            (math-read-big-emptyp h1 v1 (1+ h1) v nil t)
!            (math-read-big-emptyp h1 (1+ other-v) h v2 nil t)
             (setq p (list 'calcFunc-sqrt (math-read-big-rec
!                                          (+ h1 2) (1+ v)
                                           h (1+ other-v) baseline))
!                  v the-baseline))
  
            ;; Small radical sign.
            ((and (= other-char ?V)
!                 (= (math-read-big-char (1+ h1) (1- v)) ?\_))
!            (setq h (1+ h1))
!            (math-read-big-emptyp h1 v1 h (1- v) nil t)
!            (math-read-big-emptyp h1 (1+ v) h v2 nil t)
!            (math-read-big-emptyp h1 v1 (1+ h1) v nil t)
             (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_))
             (setq p (list 'calcFunc-sqrt (math-read-big-rec
!                                          (1+ h1) v h (1+ v) t))
!                  v the-baseline))
  
            ;; Binomial coefficient.
            ((and (= other-char ?\()
!                 (= (math-read-big-char (1+ h1) v) ?\ )
!                 (= (string-match "( *)" (nth v lines) h1) h1))
             (setq h (match-end 0))
!            (math-read-big-emptyp h1 v1 (1+ h1) v nil t)
!            (math-read-big-emptyp h1 (1+ v) (1+ h1) v2 nil t)
!            (math-read-big-emptyp (1- h) v1 h v nil t)
!            (math-read-big-emptyp (1- h) (1+ v) h v2 nil t)
             (setq p (list 'calcFunc-choose
!                          (math-read-big-rec (1+ h1) v1 (1- h) v)
!                          (math-read-big-rec (1+ h1) (1+ v)
!                                             (1- h) v2))))
  
            ;; Minus sign.
            ((= other-char ?\-)
!            (setq p (list 'neg (math-read-big-rec (1+ h1) v1 h2 v2 v 250 t))
!                  v the-baseline
!                  h the-h2))
  
            ;; Parentheses.
            ((= other-char ?\()
!            (math-read-big-emptyp h1 v1 (1+ h1) v nil t)
!            (math-read-big-emptyp h1 (1+ v) (1+ h1) v2 nil t)
!            (setq h (math-read-big-balance (1+ h1) v "(" t))
!            (math-read-big-emptyp (1- h) v1 h v nil t)
!            (math-read-big-emptyp (1- h) (1+ v) h v2 nil t)
             (let ((sep (math-read-big-char (1- h) v))
                   hmid)
               (if (= sep ?\.)
--- 710,877 ----
    (list 'intv 3 x (math-read-expr-level (nth 3 op))))
  
  
+ ;; The variable math-read-big-lines is local to math-read-big-expr in
+ ;; calc-ext.el, but is used by math-read-big-rec, math-read-big-char,
+ ;; math-read-big-emptyp, math-read-big-error and math-read-big-balance,
+ ;; which are called (directly and indirectly) by math-read-big-expr.
+ ;; It is also local to math-read-big-bigp in calc-ext.el, which calls
+ ;; math-read-big-balance.
+ (defvar math-read-big-lines)
+ 
+ ;; The variables math-read-big-baseline and math-read-big-h2 are
+ ;; local to math-read-big-expr in calc-ext.el, but used by
+ ;; math-read-big-rec.
+ (defvar math-read-big-baseline)
+ (defvar math-read-big-h2)
+ 
+ ;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2 
+ ;; are local to math-read-big-rec, but are used by math-read-big-char, 
+ ;; math-read-big-emptyp and math-read-big-balance which are called by 
+ ;; math-read-big-rec.
+ ;; math-rb-h2 is also local to math-read-big-bigp in calc-ext.el,
+ ;; which calls math-read-big-balance.
+ (defvar math-rb-h1)
+ (defvar math-rb-h2)
+ (defvar math-rb-v1)
+ (defvar math-rb-v2)
  
! (defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2 
!                                      &optional baseline prec short)
    (or prec (setq prec 0))
  
    ;; Clip whitespace above or below.
!   (while (and (< math-rb-v1 math-rb-v2) 
!               (math-read-big-emptyp math-rb-h1 math-rb-v1 math-rb-h2 (1+ 
math-rb-v1)))
!     (setq math-rb-v1 (1+ math-rb-v1)))
!   (while (and (< math-rb-v1 math-rb-v2) 
!               (math-read-big-emptyp math-rb-h1 (1- math-rb-v2) math-rb-h2 
math-rb-v2))
!     (setq math-rb-v2 (1- math-rb-v2)))
  
    ;; If formula is a single line high, normal parser can handle it.
!   (if (<= math-rb-v2 (1+ math-rb-v1))
!       (if (or (<= math-rb-v2 math-rb-v1)
!             (> math-rb-h1 (length (setq math-rb-v2 
!                                           (nth math-rb-v1 
math-read-big-lines)))))
!         (math-read-big-error math-rb-h1 math-rb-v1)
!       (setq math-read-big-baseline math-rb-v1
!             math-read-big-h2 math-rb-h2
!             math-rb-v2 (nth math-rb-v1 math-read-big-lines)
!             math-rb-h2 (math-read-expr 
!                           (substring math-rb-v2 math-rb-h1 
!                                      (min math-rb-h2 (length math-rb-v2)))))
!       (if (eq (car-safe math-rb-h2) 'error)
!           (math-read-big-error (+ math-rb-h1 (nth 1 math-rb-h2)) 
!                                  math-rb-v1 (nth 2 math-rb-h2))
!         math-rb-h2))
  
      ;; Clip whitespace at left or right.
!     (while (and (< math-rb-h1 math-rb-h2) 
!                 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) 
math-rb-v2))
!       (setq math-rb-h1 (1+ math-rb-h1)))
!     (while (and (< math-rb-h1 math-rb-h2) 
!                 (math-read-big-emptyp (1- math-rb-h2) math-rb-v1 math-rb-h2 
math-rb-v2))
!       (setq math-rb-h2 (1- math-rb-h2)))
  
      ;; Scan to find widest left-justified "----" in the region.
      (let* ((widest nil)
           (widest-h2 0)
!          (lines-v1 (nthcdr math-rb-v1 math-read-big-lines))
           (p lines-v1)
!          (v math-rb-v1)
           (other-v nil)
           other-char line len h)
!       (while (< v math-rb-v2)
        (setq line (car p)
!             len (min math-rb-h2 (length line)))
!       (and (< math-rb-h1 len)
!            (/= (aref line math-rb-h1) ?\ )
!            (if (and (= (aref line math-rb-h1) ?\-)
                      ;; Make sure it's not a minus sign.
!                     (or (and (< (1+ math-rb-h1) len) 
!                                (= (aref line (1+ math-rb-h1)) ?\-))
!                         (/= (math-read-big-char math-rb-h1 (1- v)) ?\ )
!                         (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ )))
                 (progn
!                  (setq h math-rb-h1)
                   (while (and (< (setq h (1+ h)) len)
                               (= (aref line h) ?\-)))
                   (if (> h widest-h2)
                       (setq widest v
                             widest-h2 h)))
!              (or other-v (setq other-v v other-char (aref line math-rb-h1)))))
        (setq v (1+ v)
              p (cdr p)))
  
        (cond ((not (setq v other-v))
!            (math-read-big-error math-rb-h1 math-rb-v1))   ; Should never 
happen!
  
            ;; Quotient.
            (widest
             (setq h widest-h2
                   v widest)
!            (let ((num (math-read-big-rec math-rb-h1 math-rb-v1 h v))
!                  (den (math-read-big-rec math-rb-h1 (1+ v) h math-rb-v2)))
               (setq p (if (and (math-integerp num) (math-integerp den))
                           (math-make-frac num den)
                         (list '/ num den)))))
  
            ;; Big radical sign.
            ((= other-char ?\\)
!            (or (= (math-read-big-char (1+ math-rb-h1) v) ?\|)
!                (math-read-big-error (1+ math-rb-h1) v "Malformed root sign"))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil 
t)
!            (while (= (math-read-big-char (1+ math-rb-h1) (setq v (1- v))) 
?\|))
!            (or (= (math-read-big-char (setq h (+ math-rb-h1 2)) v) ?\_)
                 (math-read-big-error h v "Malformed root sign"))
             (while (= (math-read-big-char (setq h (1+ h)) v) ?\_))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil 
t)
!            (math-read-big-emptyp math-rb-h1 (1+ other-v) h math-rb-v2 nil t)
             (setq p (list 'calcFunc-sqrt (math-read-big-rec
!                                          (+ math-rb-h1 2) (1+ v)
                                           h (1+ other-v) baseline))
!                  v math-read-big-baseline))
  
            ;; Small radical sign.
            ((and (= other-char ?V)
!                 (= (math-read-big-char (1+ math-rb-h1) (1- v)) ?\_))
!            (setq h (1+ math-rb-h1))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 h (1- v) nil t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil 
t)
             (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_))
             (setq p (list 'calcFunc-sqrt (math-read-big-rec
!                                          (1+ math-rb-h1) v h (1+ v) t))
!                  v math-read-big-baseline))
  
            ;; Binomial coefficient.
            ((and (= other-char ?\()
!                 (= (math-read-big-char (1+ math-rb-h1) v) ?\ )
!                 (= (string-match "( *)" (nth v math-read-big-lines) 
!                                    math-rb-h1) math-rb-h1))
             (setq h (match-end 0))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil 
t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 
nil t)
!            (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
!            (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
             (setq p (list 'calcFunc-choose
!                          (math-read-big-rec (1+ math-rb-h1) math-rb-v1 (1- h) 
v)
!                          (math-read-big-rec (1+ math-rb-h1) (1+ v)
!                                             (1- h) math-rb-v2))))
  
            ;; Minus sign.
            ((= other-char ?\-)
!            (setq p (list 'neg (math-read-big-rec (1+ math-rb-h1) math-rb-v1 
!                                                    math-rb-h2 math-rb-v2 v 
250 t))
!                  v math-read-big-baseline
!                  h math-read-big-h2))
  
            ;; Parentheses.
            ((= other-char ?\()
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil 
t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 
nil t)
!            (setq h (math-read-big-balance (1+ math-rb-h1) v "(" t))
!            (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
!            (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
             (let ((sep (math-read-big-char (1- h) v))
                   hmid)
               (if (= sep ?\.)
***************
*** 843,851 ****
               (if (= sep ?\])
                   (math-read-big-error (1- h) v "Expected `)'"))
               (if (= sep ?\))
!                  (setq p (math-read-big-rec (1+ h1) v1 (1- h) v2 v))
                 (setq hmid (math-read-big-balance h v "(")
!                      p (list p (math-read-big-rec h v1 (1- hmid) v2 v))
                       h hmid)
                 (cond ((= sep ?\.)
                        (setq p (cons 'intv (cons (if (= (math-read-big-char
--- 879,889 ----
               (if (= sep ?\])
                   (math-read-big-error (1- h) v "Expected `)'"))
               (if (= sep ?\))
!                  (setq p (math-read-big-rec 
!                             (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v))
                 (setq hmid (math-read-big-balance h v "(")
!                      p (list p 
!                                (math-read-big-rec h math-rb-v1 (1- hmid) 
math-rb-v2 v))
                       h hmid)
                 (cond ((= sep ?\.)
                        (setq p (cons 'intv (cons (if (= (math-read-big-char
***************
*** 858,879 ****
                       ((= sep ?\,)
                        (or (and (math-realp (car p)) (math-realp (nth 1 p)))
                            (math-read-big-error
!                            h1 v "Complex components must be real"))
                        (setq p (cons 'cplx p)))
                       ((= sep ?\;)
                        (or (and (math-realp (car p)) (math-anglep (nth 1 p)))
                            (math-read-big-error
!                            h1 v "Complex components must be real"))
                        (setq p (cons 'polar p)))))))
  
            ;; Matrix.
            ((and (= other-char ?\[)
!                 (or (= (math-read-big-char (setq h h1) (1+ v)) ?\[)
                      (= (math-read-big-char (setq h (1+ h)) v) ?\[)
                      (and (= (math-read-big-char h v) ?\ )
                           (= (math-read-big-char (setq h (1+ h)) v) ?\[)))
                  (= (math-read-big-char h (1+ v)) ?\[))
!            (math-read-big-emptyp h1 v1 h v nil t)
             (let ((vtop v)
                   (hleft h)
                   (hright nil))
--- 896,917 ----
                       ((= sep ?\,)
                        (or (and (math-realp (car p)) (math-realp (nth 1 p)))
                            (math-read-big-error
!                            math-rb-h1 v "Complex components must be real"))
                        (setq p (cons 'cplx p)))
                       ((= sep ?\;)
                        (or (and (math-realp (car p)) (math-anglep (nth 1 p)))
                            (math-read-big-error
!                            math-rb-h1 v "Complex components must be real"))
                        (setq p (cons 'polar p)))))))
  
            ;; Matrix.
            ((and (= other-char ?\[)
!                 (or (= (math-read-big-char (setq h math-rb-h1) (1+ v)) ?\[)
                      (= (math-read-big-char (setq h (1+ h)) v) ?\[)
                      (and (= (math-read-big-char h v) ?\ )
                           (= (math-read-big-char (setq h (1+ h)) v) ?\[)))
                  (= (math-read-big-char h (1+ v)) ?\[))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
             (let ((vtop v)
                   (hleft h)
                   (hright nil))
***************
*** 889,895 ****
                        (and (memq (math-read-big-char h v) '(?\  ?\,))
                             (= (math-read-big-char hleft (1+ v)) ?\[)))
                 (setq v (1+ v)))
!              (or (= hleft h1)
                   (progn
                     (if (= (math-read-big-char h v) ?\ )
                         (setq h (1+ h)))
--- 927,933 ----
                        (and (memq (math-read-big-char h v) '(?\  ?\,))
                             (= (math-read-big-char hleft (1+ v)) ?\[)))
                 (setq v (1+ v)))
!              (or (= hleft math-rb-h1)
                   (progn
                     (if (= (math-read-big-char h v) ?\ )
                         (setq h (1+ h)))
***************
*** 898,919 ****
                   (math-read-big-error (1- h) v "Expected `]'"))
               (if (= (math-read-big-char h vtop) ?\,)
                   (setq h (1+ h)))
!              (math-read-big-emptyp h1 (1+ v) (1- h) v2 nil t)
               (setq v (+ vtop (/ (- v vtop) 2))
                     p (cons 'vec (nreverse p)))))
  
            ;; Square brackets.
            ((= other-char ?\[)
!            (math-read-big-emptyp h1 v1 (1+ h1) v nil t)
!            (math-read-big-emptyp h1 (1+ v) (1+ h1) v2 nil t)
             (setq p nil
!                  h (1+ h1))
             (while (progn
                      (setq widest (math-read-big-balance h v "[" t))
!                     (math-read-big-emptyp (1- h) v1 h v nil t)
!                     (math-read-big-emptyp (1- h) (1+ v) h v2 nil t)
                      (setq p (cons (math-read-big-rec
!                                    h v1 (1- widest) v2 v) p)
                            h widest)
                      (= (math-read-big-char (1- h) v) ?\,)))
             (setq widest (math-read-big-char (1- h) v))
--- 936,957 ----
                   (math-read-big-error (1- h) v "Expected `]'"))
               (if (= (math-read-big-char h vtop) ?\,)
                   (setq h (1+ h)))
!              (math-read-big-emptyp math-rb-h1 (1+ v) (1- h) math-rb-v2 nil t)
               (setq v (+ vtop (/ (- v vtop) 2))
                     p (cons 'vec (nreverse p)))))
  
            ;; Square brackets.
            ((= other-char ?\[)
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil 
t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 
nil t)
             (setq p nil
!                  h (1+ math-rb-h1))
             (while (progn
                      (setq widest (math-read-big-balance h v "[" t))
!                     (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
!                     (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
                      (setq p (cons (math-read-big-rec
!                                    h math-rb-v1 (1- widest) math-rb-v2 v) p)
                            h widest)
                      (= (math-read-big-char (1- h) v) ?\,)))
             (setq widest (math-read-big-char (1- h) v))
***************
*** 923,930 ****
             (if (= widest ?\.)
                 (setq h (1+ h)
                       widest (math-read-big-balance h v "[")
!                      p (nconc p (list (math-read-big-big-rec
!                                        h v1 (1- widest) v2 v)))
                       h widest
                       p (cons 'intv (cons (if (= (math-read-big-char (1- h) v)
                                                  ?\])
--- 961,968 ----
             (if (= widest ?\.)
                 (setq h (1+ h)
                       widest (math-read-big-balance h v "[")
!                      p (nconc p (list (math-read-big-rec
!                                        h math-rb-v1 (1- widest) math-rb-v2 
v)))
                       h widest
                       p (cons 'intv (cons (if (= (math-read-big-char (1- h) v)
                                                  ?\])
***************
*** 934,956 ****
  
            ;; Date form.
            ((= other-char ?\<)
!            (setq line (nth v lines))
!            (string-match ">" line h1)
             (setq h (match-end 0))
!            (math-read-big-emptyp h1 v1 h v nil t)
!            (math-read-big-emptyp h1 (1+ v) h v2 nil t)
!            (setq p (math-read-big-rec h1 v h (1+ v) v)))
  
            ;; Variable name or function call.
            ((or (and (>= other-char ?a) (<= other-char ?z))
                 (and (>= other-char ?A) (<= other-char ?Z)))
!            (setq line (nth v lines))
!            (string-match "\\([a-zA-Z'_]+\\) *" line h1)
             (setq h (match-end 1)
                   widest (match-end 0)
                   p (math-match-substring line 1))
!            (math-read-big-emptyp h1 v1 h v nil t)
!            (math-read-big-emptyp h1 (1+ v) h v2 nil t)
             (if (= (math-read-big-char widest v) ?\()
                 (progn
                   (setq line (if (string-match "-" p)
--- 972,994 ----
  
            ;; Date form.
            ((= other-char ?\<)
!            (setq line (nth v math-read-big-lines))
!            (string-match ">" line math-rb-h1)
             (setq h (match-end 0))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
!            (setq p (math-read-big-rec math-rb-h1 v h (1+ v) v)))
  
            ;; Variable name or function call.
            ((or (and (>= other-char ?a) (<= other-char ?z))
                 (and (>= other-char ?A) (<= other-char ?Z)))
!            (setq line (nth v math-read-big-lines))
!            (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1)
             (setq h (match-end 1)
                   widest (match-end 0)
                   p (math-match-substring line 1))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
             (if (= (math-read-big-char widest v) ?\()
                 (progn
                   (setq line (if (string-match "-" p)
***************
*** 958,971 ****
                                (intern (concat "calcFunc-" p)))
                         h (1+ widest)
                         p nil)
!                  (math-read-big-emptyp widest v1 h v nil t)
!                  (math-read-big-emptyp widest (1+ v) h v2 nil t)
                   (while (progn
                            (setq widest (math-read-big-balance h v "(" t))
!                           (math-read-big-emptyp (1- h) v1 h v nil t)
!                           (math-read-big-emptyp (1- h) (1+ v) h v2 nil t)
                            (setq p (cons (math-read-big-rec
!                                          h v1 (1- widest) v2 v) p)
                                  h widest)
                            (= (math-read-big-char (1- h) v) ?\,)))
                   (or (= (math-read-big-char (1- h) v) ?\))
--- 996,1009 ----
                                (intern (concat "calcFunc-" p)))
                         h (1+ widest)
                         p nil)
!                  (math-read-big-emptyp widest math-rb-v1 h v nil t)
!                  (math-read-big-emptyp widest (1+ v) h math-rb-v2 nil t)
                   (while (progn
                            (setq widest (math-read-big-balance h v "(" t))
!                           (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
!                           (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 
nil t)
                            (setq p (cons (math-read-big-rec
!                                          h math-rb-v1 (1- widest) math-rb-v2 
v) p)
                                  h widest)
                            (= (math-read-big-char (1- h) v) ?\,)))
                   (or (= (math-read-big-char (1- h) v) ?\))
***************
*** 979,1022 ****
  
            ;; Number.
            (t
!            (setq line (nth v lines))
!            (or (= (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' 
*\\)?\\([0-9]+\\(#\\|\\^\\^\\)[0-9a-zA-Z:]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
 line h1) h1)
                 (math-read-big-error h v "Expected a number"))
             (setq h (match-end 0)
                   p (math-read-number (math-match-substring line 0)))
!            (math-read-big-emptyp h1 v1 h v nil t)
!            (math-read-big-emptyp h1 (1+ v) h v2 nil t)))
  
!       ;; Now left term is bounded by h1, v1, h, v2; baseline = v.
        (if baseline
          (or (= v baseline)
!             (math-read-big-error h1 v "Inconsistent baseline in formula"))
        (setq baseline v))
  
        ;; Look for superscripts or subscripts.
!       (setq line (nth baseline lines)
!           len (min h2 (length line))
            widest h)
        (while (and (< widest len)
                  (= (aref line widest) ?\ ))
        (setq widest (1+ widest)))
!       (and (>= widest len) (setq widest h2))
!       (if (math-read-big-emptyp h v widest v2)
!         (if (math-read-big-emptyp h v1 widest v)
              (setq h widest)
!           (setq p (list '^ p (math-read-big-rec h v1 widest v))
                  h widest))
!         (if (math-read-big-emptyp h v1 widest v)
              (setq p (list 'calcFunc-subscr p
!                           (math-read-big-rec h v widest v2))
                    h widest)))
  
        ;; Look for an operator name and grab additional terms.
        (while (and (< h len)
                  (if (setq widest (and (math-read-big-emptyp
!                                        h v1 (1+ h) v)
                                        (math-read-big-emptyp
!                                        h (1+ v) (1+ h) v2)
                                        (string-match 
"<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h)
                                        (assoc (math-match-substring line 0)
                                               math-standard-opers)))
--- 1017,1061 ----
  
            ;; Number.
            (t
!            (setq line (nth v math-read-big-lines))
!            (or (= (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' 
*\\)?\\([0-9]+\\(#\\|\\^\\^\\)[0-9a-zA-Z:]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
 line math-rb-h1) math-rb-h1)
                 (math-read-big-error h v "Expected a number"))
             (setq h (match-end 0)
                   p (math-read-number (math-match-substring line 0)))
!            (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
!            (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)))
  
!       ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2; 
!       ;; baseline = v.
        (if baseline
          (or (= v baseline)
!             (math-read-big-error math-rb-h1 v "Inconsistent baseline in 
formula"))
        (setq baseline v))
  
        ;; Look for superscripts or subscripts.
!       (setq line (nth baseline math-read-big-lines)
!           len (min math-rb-h2 (length line))
            widest h)
        (while (and (< widest len)
                  (= (aref line widest) ?\ ))
        (setq widest (1+ widest)))
!       (and (>= widest len) (setq widest math-rb-h2))
!       (if (math-read-big-emptyp h v widest math-rb-v2)
!         (if (math-read-big-emptyp h math-rb-v1 widest v)
              (setq h widest)
!           (setq p (list '^ p (math-read-big-rec h math-rb-v1 widest v))
                  h widest))
!         (if (math-read-big-emptyp h math-rb-v1 widest v)
              (setq p (list 'calcFunc-subscr p
!                           (math-read-big-rec h v widest math-rb-v2))
                    h widest)))
  
        ;; Look for an operator name and grab additional terms.
        (while (and (< h len)
                  (if (setq widest (and (math-read-big-emptyp
!                                        h math-rb-v1 (1+ h) v)
                                        (math-read-big-emptyp
!                                        h (1+ v) (1+ h) math-rb-v2)
                                        (string-match 
"<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h)
                                        (assoc (math-match-substring line 0)
                                               math-standard-opers)))
***************
*** 1028,1071 ****
        (cond ((eq (nth 3 widest) -1)
               (setq p (list (nth 1 widest) p)))
              ((equal (car widest) "?")
!              (let ((y (math-read-big-rec h v1 h2 v2 baseline nil t)))
!                (or (= (math-read-big-char the-h2 baseline) ?\:)
!                    (math-read-big-error the-h2 baseline "Expected `:'"))
                 (setq p (list (nth 1 widest) p y
!                              (math-read-big-rec (1+ the-h2) v1 h2 v2
!                                                 baseline (nth 3 widest) t))
!                      h the-h2)))
              (t
               (setq p (list (nth 1 widest) p
!                            (math-read-big-rec h v1 h2 v2
                                                baseline (nth 3 widest) t))
!                    h the-h2))))
  
        ;; Return all relevant information to caller.
!       (setq the-baseline baseline
!           the-h2 h)
!       (or short (= the-h2 h2)
          (math-read-big-error h baseline))
        p)))
  
  (defun math-read-big-char (h v)
!   (or (and (>= h h1)
!          (< h h2)
!          (>= v v1)
!          (< v v2)
!          (let ((line (nth v lines)))
             (and line
                  (< h (length line))
                  (aref line h))))
        ?\ ))
  
  (defun math-read-big-emptyp (eh1 ev1 eh2 ev2 &optional what error)
!   (and (< ev1 v1) (setq ev1 v1))
!   (and (< eh1 h1) (setq eh1 h1))
!   (and (> ev2 v2) (setq ev2 v2))
!   (and (> eh2 h2) (setq eh2 h2))
    (or what (setq what ?\ ))
!   (let ((p (nthcdr ev1 lines))
        h)
      (while (and (< ev1 ev2)
                (progn
--- 1067,1112 ----
        (cond ((eq (nth 3 widest) -1)
               (setq p (list (nth 1 widest) p)))
              ((equal (car widest) "?")
!              (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2 
!                                            math-rb-v2 baseline nil t)))
!                (or (= (math-read-big-char math-read-big-h2 baseline) ?\:)
!                    (math-read-big-error math-read-big-h2 baseline "Expected 
`:'"))
                 (setq p (list (nth 1 widest) p y
!                              (math-read-big-rec 
!                                 (1+ math-read-big-h2) math-rb-v1 math-rb-h2 
math-rb-v2
!                                 baseline (nth 3 widest) t))
!                      h math-read-big-h2)))
              (t
               (setq p (list (nth 1 widest) p
!                            (math-read-big-rec h math-rb-v1 math-rb-h2 
math-rb-v2
                                                baseline (nth 3 widest) t))
!                    h math-read-big-h2))))
  
        ;; Return all relevant information to caller.
!       (setq math-read-big-baseline baseline
!           math-read-big-h2 h)
!       (or short (= math-read-big-h2 math-rb-h2)
          (math-read-big-error h baseline))
        p)))
  
  (defun math-read-big-char (h v)
!   (or (and (>= h math-rb-h1)
!          (< h math-rb-h2)
!          (>= v math-rb-v1)
!          (< v math-rb-v2)
!          (let ((line (nth v math-read-big-lines)))
             (and line
                  (< h (length line))
                  (aref line h))))
        ?\ ))
  
  (defun math-read-big-emptyp (eh1 ev1 eh2 ev2 &optional what error)
!   (and (< ev1 math-rb-v1) (setq ev1 math-rb-v1))
!   (and (< eh1 math-rb-h1) (setq eh1 math-rb-h1))
!   (and (> ev2 math-rb-v2) (setq ev2 math-rb-v2))
!   (and (> eh2 math-rb-h2) (setq eh2 math-rb-h2))
    (or what (setq what ?\ ))
!   (let ((p (nthcdr ev1 math-read-big-lines))
        h)
      (while (and (< ev1 ev2)
                (progn
***************
*** 1081,1105 ****
            p (cdr p)))
      (>= ev1 ev2)))
  
  (defun math-read-big-error (h v &optional msg)
    (let ((pos 0)
!       (p lines))
      (while (> v 0)
        (setq pos (+ pos 1 (length (car p)))
            p (cdr p)
            v (1- v)))
      (setq h (+ pos (min h (length (car p))))
!         err-msg (list 'error h (or msg "Syntax error")))
      (throw 'syntax nil)))
  
  (defun math-read-big-balance (h v what &optional commas)
!   (let* ((line (nth v lines))
!        (len (min h2 (length line)))
         (count 1))
      (while (> count 0)
        (if (>= h len)
          (if what
!             (math-read-big-error h1 v (format "Unmatched `%s'" what))
            (setq count 0))
        (if (memq (aref line h) '(?\( ?\[))
            (setq count (1+ count))
--- 1122,1151 ----
            p (cdr p)))
      (>= ev1 ev2)))
  
+ ;; math-read-big-err-msg is local to math-read-big-expr in calc-ext.el,
+ ;; but is used by math-read-big-error which is called (indirectly) by
+ ;; math-read-big-expr.
+ (defvar math-read-big-err-msg)
+ 
  (defun math-read-big-error (h v &optional msg)
    (let ((pos 0)
!       (p math-read-big-lines))
      (while (> v 0)
        (setq pos (+ pos 1 (length (car p)))
            p (cdr p)
            v (1- v)))
      (setq h (+ pos (min h (length (car p))))
!         math-read-big-err-msg (list 'error h (or msg "Syntax error")))
      (throw 'syntax nil)))
  
  (defun math-read-big-balance (h v what &optional commas)
!   (let* ((line (nth v math-read-big-lines))
!        (len (min math-rb-h2 (length line)))
         (count 1))
      (while (> count 0)
        (if (>= h len)
          (if what
!             (math-read-big-error nil v (format "Unmatched `%s'" what))
            (setq count 0))
        (if (memq (aref line h) '(?\( ?\[))
            (setq count (1+ count))
***************
*** 1113,1117 ****
--- 1159,1165 ----
        (setq h (1+ h))))
      h))
  
+ (provide 'calc-lang)
+ 
  ;;; arch-tag: 483bfe15-f290-4fef-bb7d-ce65be687f2e
  ;;; calc-lang.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]