comparison lisp/calc/calc-aent.el @ 74579:d5f79339859e

(calc-eval-error): Doc fix.
author Juanma Barranquero <lekktu@gmail.com>
date Sun, 10 Dec 2006 23:48:40 +0000
parents 52f1e8d569ad
children 7a3f13e2dd57 6588c6259dfb
comparison
equal deleted inserted replaced
74578:34b20acf743f 74579:d5f79339859e
230 res (cdr res))) 230 res (cdr res)))
231 buf))))))))) 231 buf)))))))))
232 232
233 (defvar calc-eval-error nil 233 (defvar calc-eval-error nil
234 "Determines how calc handles errors. 234 "Determines how calc handles errors.
235 NIL means return a list containing the character position of error. 235 If nil, return a list containing the character position of error.
236 STRING means return error message as string rather than list. 236 STRING means return error message as string rather than list.
237 T means abort and give an error message.") 237 The value t means abort and give an error message.")
238 238
239 (defun calc-eval-error (msg) 239 (defun calc-eval-error (msg)
240 (if calc-eval-error 240 (if calc-eval-error
241 (if (eq calc-eval-error 'string) 241 (if (eq calc-eval-error 'string)
242 (nth 1 msg) 242 (nth 1 msg)
698 (t 698 (t
699 (math-read-token) 699 (math-read-token)
700 (math-read-token)))))) 700 (math-read-token))))))
701 ((or (and (>= ch ?0) (<= ch ?9)) 701 ((or (and (>= ch ?0) (<= ch ?9))
702 (and (eq ch '?\.) 702 (and (eq ch '?\.)
703 (eq (string-match "\\.[0-9]" math-exp-str math-exp-pos) 703 (eq (string-match "\\.[0-9]" math-exp-str math-exp-pos)
704 math-exp-pos)) 704 math-exp-pos))
705 (and (eq ch '?_) 705 (and (eq ch '?_)
706 (eq (string-match "_\\.?[0-9]" math-exp-str math-exp-pos) 706 (eq (string-match "_\\.?[0-9]" math-exp-str math-exp-pos)
707 math-exp-pos) 707 math-exp-pos)
708 (or (eq math-exp-pos 0) 708 (or (eq math-exp-pos 0)
709 (and (memq calc-language '(nil flat big unform 709 (and (memq calc-language '(nil flat big unform
710 tex latex eqn)) 710 tex latex eqn))
711 (eq (string-match "[^])}\"a-zA-Z0-9'$]_" 711 (eq (string-match "[^])}\"a-zA-Z0-9'$]_"
712 math-exp-str (1- math-exp-pos)) 712 math-exp-str (1- math-exp-pos))
713 (1- math-exp-pos)))))) 713 (1- math-exp-pos))))))
714 (or (and (eq calc-language 'c) 714 (or (and (eq calc-language 'c)
715 (string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos)) 715 (string-match "0[xX][0-9a-fA-F]+" math-exp-str math-exp-pos))
716 (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" 716 (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?"
717 math-exp-str math-exp-pos)) 717 math-exp-str math-exp-pos))
718 (setq math-exp-token 'number 718 (setq math-exp-token 'number
719 math-expr-data (math-match-substring math-exp-str 0) 719 math-expr-data (math-match-substring math-exp-str 0)
720 math-exp-pos (match-end 0))) 720 math-exp-pos (match-end 0)))
721 ((eq ch ?\$) 721 ((eq ch ?\$)
749 math-exp-pos) 749 math-exp-pos)
750 (setq math-exp-token 'punc 750 (setq math-exp-token 'punc
751 math-expr-data (math-match-substring math-exp-str 0) 751 math-expr-data (math-match-substring math-exp-str 0)
752 math-exp-pos (match-end 0))) 752 math-exp-pos (match-end 0)))
753 ((and (eq ch ?\") 753 ((and (eq ch ?\")
754 (string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)" 754 (string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)"
755 math-exp-str math-exp-pos)) 755 math-exp-str math-exp-pos))
756 (if (eq calc-language 'eqn) 756 (if (eq calc-language 'eqn)
757 (progn 757 (progn
758 (setq math-exp-str (copy-sequence math-exp-str)) 758 (setq math-exp-str (copy-sequence math-exp-str))
759 (aset math-exp-str (match-beginning 1) ?\{) 759 (aset math-exp-str (match-beginning 1) ?\{)
763 (setq math-exp-token 'string 763 (setq math-exp-token 'string
764 math-expr-data (math-match-substring math-exp-str 1) 764 math-expr-data (math-match-substring math-exp-str 1)
765 math-exp-pos (match-end 0)))) 765 math-exp-pos (match-end 0))))
766 ((and (= ch ?\\) (eq calc-language 'tex) 766 ((and (= ch ?\\) (eq calc-language 'tex)
767 (< math-exp-pos (1- (length math-exp-str)))) 767 (< math-exp-pos (1- (length math-exp-str))))
768 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}" 768 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}"
769 math-exp-str math-exp-pos) 769 math-exp-str math-exp-pos)
770 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" 770 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)"
771 math-exp-str math-exp-pos)) 771 math-exp-str math-exp-pos))
772 (setq math-exp-token 'symbol 772 (setq math-exp-token 'symbol
773 math-exp-pos (match-end 0) 773 math-exp-pos (match-end 0)
774 math-expr-data (math-restore-dashes 774 math-expr-data (math-restore-dashes
775 (math-match-substring math-exp-str 1))) 775 (math-match-substring math-exp-str 1)))
789 (and right 789 (and right
790 (setq math-exp-str (copy-sequence math-exp-str)) 790 (setq math-exp-str (copy-sequence math-exp-str))
791 (aset math-exp-str right ?\]))))))) 791 (aset math-exp-str right ?\])))))))
792 ((and (= ch ?\\) (eq calc-language 'latex) 792 ((and (= ch ?\\) (eq calc-language 'latex)
793 (< math-exp-pos (1- (length math-exp-str)))) 793 (< math-exp-pos (1- (length math-exp-str))))
794 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}" 794 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}"
795 math-exp-str math-exp-pos) 795 math-exp-str math-exp-pos)
796 (string-match "\\\\text *{\\([a-zA-Z0-9]+\\)}" 796 (string-match "\\\\text *{\\([a-zA-Z0-9]+\\)}"
797 math-exp-str math-exp-pos) 797 math-exp-str math-exp-pos)
798 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" 798 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)"
799 math-exp-str math-exp-pos)) 799 math-exp-str math-exp-pos))
800 (setq math-exp-token 'symbol 800 (setq math-exp-token 'symbol
801 math-exp-pos (match-end 0) 801 math-exp-pos (match-end 0)
802 math-expr-data (math-restore-dashes 802 math-expr-data (math-restore-dashes
803 (math-match-substring math-exp-str 1))) 803 (math-match-substring math-exp-str 1)))
819 (string= envname "bmatrix") 819 (string= envname "bmatrix")
820 (string= envname "smallmatrix") 820 (string= envname "smallmatrix")
821 (string= envname "pmatrix")) 821 (string= envname "pmatrix"))
822 (if (string-match (concat "\\\\end{" envname "}") 822 (if (string-match (concat "\\\\end{" envname "}")
823 math-exp-str math-exp-pos) 823 math-exp-str math-exp-pos)
824 (setq math-exp-str 824 (setq math-exp-str
825 (replace-match "]" t t math-exp-str)) 825 (replace-match "]" t t math-exp-str))
826 (error "%s" (concat "No closing \\end{" envname "}")))))) 826 (error "%s" (concat "No closing \\end{" envname "}"))))))
827 ((and (eq (nth 1 code) 'mat) 827 ((and (eq (nth 1 code) 'mat)
828 (string-match " *{" math-exp-str math-exp-pos)) 828 (string-match " *{" math-exp-str math-exp-pos))
829 (setq math-exp-pos (match-end 0) 829 (setq math-exp-pos (match-end 0)
850 math-exp-str math-exp-pos) 850 math-exp-str math-exp-pos)
851 math-exp-pos)) 851 math-exp-pos))
852 (setq math-exp-token 'punc 852 (setq math-exp-token 'punc
853 math-expr-data (math-match-substring math-exp-str 0) 853 math-expr-data (math-match-substring math-exp-str 0)
854 math-exp-pos (match-end 0)) 854 math-exp-pos (match-end 0))
855 (and (eq (string-match "\\\\dots\\." math-exp-str math-exp-pos) 855 (and (eq (string-match "\\\\dots\\." math-exp-str math-exp-pos)
856 math-exp-pos) 856 math-exp-pos)
857 (setq math-exp-pos (match-end 0))) 857 (setq math-exp-pos (match-end 0)))
858 (if (memq (aref math-expr-data 0) '(?~ ?^)) 858 (if (memq (aref math-expr-data 0) '(?~ ?^))
859 (math-read-token))) 859 (math-read-token)))
860 ((eq (string-match "%%.*$" math-exp-str math-exp-pos) math-exp-pos) 860 ((eq (string-match "%%.*$" math-exp-str math-exp-pos) math-exp-pos)