annotate lisp/calc/calc-lang.el @ 62513:038037bfdf1f

Add --enable-locallisppath.
author Lute Kamstra <lute@gnu.org>
date Thu, 19 May 2005 08:28:29 +0000
parents a27ed02e5a65
children 1db49616ce05 62afea0771d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
1 ;;; calc-lang.el --- calc language functions
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
2
62165
a27ed02e5a65 Update copyright year.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 61069
diff changeset
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2005 Free Software Foundation, Inc.
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
4
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
5 ;; Author: David Gillespie <daveg@synaptics.com>
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
6 ;; Maintainer: Jay Belanger <belanger@truman.edu>
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
7
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is distributed in the hope that it will be useful,
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12 ;; accepts responsibility to anyone for the consequences of using it
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 ;; or for whether it serves any particular purpose or works at all,
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15 ;; License for full details.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17 ;; Everyone is granted permission to copy, modify and redistribute
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs, but only under the conditions described in the
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 ;; GNU Emacs General Public License. A copy of this license is
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20 ;; supposed to have been given to you along with GNU Emacs so you
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21 ;; can know your rights and responsibilities. It should be in a
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22 ;; file named COPYING. Among other things, the copyright notice
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 ;; and this notice must be preserved on all copies.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
25 ;;; Commentary:
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
26
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
27 ;;; Code:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29 ;; This file is autoloaded from calc-ext.el.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30
58661
10224395a3c2 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58571
diff changeset
31 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32 (require 'calc-macs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 ;;; Alternate entry/display languages.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 (defun calc-set-language (lang &optional option no-refresh)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 (setq math-expr-opers (or (get lang 'math-oper-table) math-standard-opers)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 math-expr-function-mapping (get lang 'math-function-table)
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
39 math-expr-special-function-mapping (get lang 'math-special-function-table)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40 math-expr-variable-mapping (get lang 'math-variable-table)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 calc-language-input-filter (get lang 'math-input-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 calc-language-output-filter (get lang 'math-output-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 calc-vector-brackets (or (get lang 'math-vector-brackets) "[]")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44 calc-complex-format (get lang 'math-complex-format)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 calc-radix-formatter (get lang 'math-radix-formatter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 calc-function-open (or (get lang 'math-function-open) "(")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 calc-function-close (or (get lang 'math-function-close) ")"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 (if no-refresh
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 (setq calc-language lang
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 calc-language-option option)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51 (calc-change-mode '(calc-language calc-language-option)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
52 (list lang option) t)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54 (defun calc-normal-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
55 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
57 (calc-set-language nil)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
58 (message "Normal language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 (defun calc-flat-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 (calc-set-language 'flat)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
64 (message "Flat language mode (all stack entries shown on one line)")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 (defun calc-big-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 (calc-set-language 'big)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
70 (message "\"Big\" language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 (defun calc-unformatted-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75 (calc-set-language 'unform)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
76 (message "Unformatted language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79 (defun calc-c-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 (calc-set-language 'c)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
83 (message "`C' language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 (put 'c 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 '( ( "u+" ident -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 ( "u-" neg -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 ( "u!" calcFunc-lnot -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 ( "~" calcFunc-not -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 ( "*" * 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 ( "/" / 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 ( "%" % 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 ( "+" + 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94 ( "-" - 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95 ( "<<" calcFunc-lsh 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96 ( ">>" calcFunc-rsh 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 ( "<" calcFunc-lt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98 ( ">" calcFunc-gt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99 ( "<=" calcFunc-leq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100 ( ">=" calcFunc-geq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 ( "==" calcFunc-eq 150 151 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 ( "!=" calcFunc-neq 150 151 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 ( "&" calcFunc-and 140 141 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 ( "^" calcFunc-xor 131 130 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105 ( "|" calcFunc-or 120 121 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106 ( "&&" calcFunc-land 110 111 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107 ( "||" calcFunc-lor 100 101 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 ( "?" (math-read-if) 91 90 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 ( "!!!" calcFunc-pnot -1 88 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 ( "&&&" calcFunc-pand 85 86 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 ( "=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113 ( ":=" calcFunc-assign 51 50 )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
114 ( "::" calcFunc-condition 45 46 ))) ; should support full assignments
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 (put 'c 'math-function-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 '( ( acos . calcFunc-arccos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 ( acosh . calcFunc-arccosh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 ( asin . calcFunc-arcsin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 ( asinh . calcFunc-arcsinh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121 ( atan . calcFunc-arctan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 ( atan2 . calcFunc-arctan2 )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
123 ( atanh . calcFunc-arctanh )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 (put 'c 'math-variable-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 '( ( M_PI . var-pi )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
127 ( M_E . var-e )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (put 'c 'math-vector-brackets "{}")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 (put 'c 'math-radix-formatter
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 (function (lambda (r s)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 (if (= r 16) (format "0x%s" s)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (if (= r 8) (format "0%s" s)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 (format "%d#%s" r s))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 (defun calc-pascal-language (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 (and n (setq n (prefix-numeric-value n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (calc-set-language 'pascal n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 (message (if (and n (/= n 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 (if (> n 0)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
145 "Pascal language mode (all uppercase)"
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
146 "Pascal language mode (all lowercase)")
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
147 "Pascal language mode"))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (put 'pascal 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 '( ( "not" calcFunc-lnot -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151 ( "*" * 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 ( "/" / 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 ( "and" calcFunc-and 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 ( "div" calcFunc-idiv 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 ( "mod" % 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 ( "u+" ident -1 185 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 ( "u-" neg -1 185 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 ( "+" + 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159 ( "-" - 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 ( "or" calcFunc-or 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 ( "xor" calcFunc-xor 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 ( "shl" calcFunc-lsh 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 ( "shr" calcFunc-rsh 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 ( "in" calcFunc-in 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 ( "<" calcFunc-lt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 ( ">" calcFunc-gt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 ( "<=" calcFunc-leq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 ( ">=" calcFunc-geq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 ( "=" calcFunc-eq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 ( "<>" calcFunc-neq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 ( "!!!" calcFunc-pnot -1 85 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 ( "&&&" calcFunc-pand 80 81 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 ( ":=" calcFunc-assign 51 50 )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
175 ( "::" calcFunc-condition 45 46 )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 (put 'pascal 'math-input-filter 'calc-input-case-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 (put 'pascal 'math-output-filter 'calc-output-case-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180 (put 'pascal 'math-radix-formatter
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 (function (lambda (r s)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 (if (= r 16) (format "$%s" s)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 (format "%d#%s" r s)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 (defun calc-input-case-filter (str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 (cond ((or (null calc-language-option) (= calc-language-option 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 (t
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
189 (downcase str))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 (defun calc-output-case-filter (str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 (cond ((or (null calc-language-option) (= calc-language-option 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 ((> calc-language-option 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195 (upcase str))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 (t
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
197 (downcase str))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
199
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200 (defun calc-fortran-language (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 (and n (setq n (prefix-numeric-value n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 (calc-set-language 'fortran n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 (message (if (and n (/= n 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 (if (> n 0)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
207 "FORTRAN language mode (all uppercase)"
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
208 "FORTRAN language mode (all lowercase)")
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
209 "FORTRAN language mode"))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 (put 'fortran 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 '( ( "u/" (math-parse-fortran-vector) -1 1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 ( "/" (math-parse-fortran-vector-end) 1 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 ( "**" ^ 201 200 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215 ( "u+" ident -1 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216 ( "u-" neg -1 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 ( "*" * 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 ( "/" / 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 ( "+" + 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 ( "-" - 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 ( ".LT." calcFunc-lt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 ( ".GT." calcFunc-gt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 ( ".LE." calcFunc-leq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
224 ( ".GE." calcFunc-geq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 ( ".EQ." calcFunc-eq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 ( ".NE." calcFunc-neq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 ( ".NOT." calcFunc-lnot -1 121 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 ( ".AND." calcFunc-land 110 111 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 ( ".OR." calcFunc-lor 100 101 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 ( "!!!" calcFunc-pnot -1 85 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231 ( "&&&" calcFunc-pand 80 81 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 ( "=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 ( ":=" calcFunc-assign 51 50 )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
235 ( "::" calcFunc-condition 45 46 )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 (put 'fortran 'math-vector-brackets "//")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
238
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
239 (put 'fortran 'math-function-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 '( ( acos . calcFunc-arccos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 ( acosh . calcFunc-arccosh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
242 ( aimag . calcFunc-im )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
243 ( aint . calcFunc-ftrunc )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 ( asin . calcFunc-arcsin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245 ( asinh . calcFunc-arcsinh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 ( atan . calcFunc-arctan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 ( atan2 . calcFunc-arctan2 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248 ( atanh . calcFunc-arctanh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 ( conjg . calcFunc-conj )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 ( log . calcFunc-ln )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251 ( nint . calcFunc-round )
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49263
diff changeset
252 ( real . calcFunc-re )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
254 (put 'fortran 'math-input-filter 'calc-input-case-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255 (put 'fortran 'math-output-filter 'calc-output-case-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
256
58571
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
257 ;; The next few variables are local to math-read-exprs in calc-aent.el
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
258 ;; and math-read-expr in calc-ext.el, but are set in functions they call.
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
259
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
260 (defvar math-exp-token)
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
261 (defvar math-expr-data)
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
262 (defvar math-exp-old-pos)
4ca47d70b075 (math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58411
diff changeset
263
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
264 (defvar math-parsing-fortran-vector nil)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 (defun math-parse-fortran-vector (op)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 (let ((math-parsing-fortran-vector '(end . "\000")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 (prog1
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 (math-read-brackets t "]")
58134
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
269 (setq math-exp-token (car math-parsing-fortran-vector)
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
270 math-expr-data (cdr math-parsing-fortran-vector)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 (defun math-parse-fortran-vector-end (x op)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 (if math-parsing-fortran-vector
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 (progn
58134
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
275 (setq math-parsing-fortran-vector (cons math-exp-token math-expr-data)
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
276 math-exp-token 'end
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
277 math-expr-data "\000")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 x)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
279 (throw 'syntax "Unmatched closing `/'")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 (defun math-parse-fortran-subscr (sym args)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 (setq sym (math-build-var-name sym))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 (while args
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 (setq sym (list 'calcFunc-subscr sym (car args))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285 args (cdr args)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
286 sym)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 (defun calc-tex-language (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 (and n (setq n (prefix-numeric-value n)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 (calc-set-language 'tex n)
59966
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
294 (cond ((not n)
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
295 (message "TeX language mode"))
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
296 ((= n 0)
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
297 (message "TeX language mode with multiline matrices"))
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
298 ((= n 1)
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
299 (message "TeX language mode with \\hbox{func}(\\hbox{var})"))
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
300 ((> n 1)
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
301 (message
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
302 "TeX language mode with \\hbox{func}(\\hbox{var}) and multiline matrices"))
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
303 ((= n -1)
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
304 (message "TeX language mode with \\func(\\hbox{var})"))
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
305 ((< n -1)
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
306 (message
9eb004b49fc9 (calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59915
diff changeset
307 "TeX language mode with \\func(\\hbox{var}) and multiline matrices")))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
309 (defun calc-latex-language (n)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
310 (interactive "P")
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
311 (calc-wrapper
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
312 (and n (setq n (prefix-numeric-value n)))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
313 (calc-set-language 'latex n)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
314 (cond ((not n)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
315 (message "LaTeX language mode"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
316 ((= n 0)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
317 (message "LaTeX language mode with multiline matrices"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
318 ((= n 1)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
319 (message "LaTeX language mode with \\text{func}(\\text{var})"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
320 ((> n 1)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
321 (message
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
322 "LaTeX language mode with \\text{func}(\\text{var}) and multiline matrices"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
323 ((= n -1)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
324 (message "LaTeX language mode with \\func(\\text{var})"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
325 ((< n -1)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
326 (message
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
327 "LaTeX language mode with \\func(\\text{var}) and multiline matrices")))))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
328
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
329 (put 'tex 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
330 '( ( "u+" ident -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
331 ( "u-" neg -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 ( "\\hat" calcFunc-hat -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 ( "\\check" calcFunc-check -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
334 ( "\\tilde" calcFunc-tilde -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335 ( "\\acute" calcFunc-acute -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
336 ( "\\grave" calcFunc-grave -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
337 ( "\\dot" calcFunc-dot -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
338 ( "\\ddot" calcFunc-dotdot -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
339 ( "\\breve" calcFunc-breve -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
340 ( "\\bar" calcFunc-bar -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
341 ( "\\vec" calcFunc-Vec -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 ( "\\underline" calcFunc-under -1 950 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 ( "u|" calcFunc-abs -1 0 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 ( "|" closing 0 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345 ( "\\lfloor" calcFunc-floor -1 0 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 ( "\\rfloor" closing 0 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 ( "\\lceil" calcFunc-ceil -1 0 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 ( "\\rceil" closing 0 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
349 ( "\\pm" sdev 300 300 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350 ( "!" calcFunc-fact 210 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351 ( "^" ^ 201 200 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
352 ( "_" calcFunc-subscr 201 200 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 ( "\\times" * 191 190 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 ( "*" * 191 190 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 ( "2x" * 191 190 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 ( "+" + 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 ( "-" - 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
358 ( "\\over" / 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 ( "/" / 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 ( "\\choose" calcFunc-choose 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361 ( "\\mod" % 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362 ( "<" calcFunc-lt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 ( ">" calcFunc-gt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 ( "\\leq" calcFunc-leq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 ( "\\geq" calcFunc-geq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 ( "=" calcFunc-eq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367 ( "\\neq" calcFunc-neq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
368 ( "\\ne" calcFunc-neq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
369 ( "\\lnot" calcFunc-lnot -1 121 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370 ( "\\land" calcFunc-land 110 111 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371 ( "\\lor" calcFunc-lor 100 101 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
372 ( "?" (math-read-if) 91 90 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373 ( "!!!" calcFunc-pnot -1 85 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 ( "&&&" calcFunc-pand 80 81 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
375 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
376 ( "\\gets" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377 ( ":=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 ( "::" calcFunc-condition 45 46 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 ( "\\to" calcFunc-evalto 40 41 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 ( "\\to" calcFunc-evalto 40 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 ( "=>" calcFunc-evalto 40 41 )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
382 ( "=>" calcFunc-evalto 40 -1 )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
383
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
384 (put 'tex 'math-function-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385 '( ( \\arccos . calcFunc-arccos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
386 ( \\arcsin . calcFunc-arcsin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387 ( \\arctan . calcFunc-arctan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
388 ( \\arg . calcFunc-arg )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 ( \\cos . calcFunc-cos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
390 ( \\cosh . calcFunc-cosh )
61069
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
391 ( \\cot . calcFunc-cot )
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
392 ( \\coth . calcFunc-coth )
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
393 ( \\csc . calcFunc-csc )
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
394 ( \\det . calcFunc-det )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 ( \\exp . calcFunc-exp )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396 ( \\gcd . calcFunc-gcd )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
397 ( \\ln . calcFunc-ln )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
398 ( \\log . calcFunc-log10 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399 ( \\max . calcFunc-max )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
400 ( \\min . calcFunc-min )
61069
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
401 ( \\sec . calcFunc-sec )
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402 ( \\sin . calcFunc-sin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403 ( \\sinh . calcFunc-sinh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 ( \\sqrt . calcFunc-sqrt )
61069
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
405 ( \\tan . calcFunc-tan )
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 ( \\tanh . calcFunc-tanh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 ( \\phi . calcFunc-totient )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
408 ( \\mu . calcFunc-moebius )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
410 (put 'tex 'math-variable-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 '( ( \\pi . var-pi )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412 ( \\infty . var-inf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
413 ( \\infty . var-uinf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414 ( \\phi . var-phi )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415 ( \\gamma . var-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
416 ( \\sum . (math-parse-tex-sum calcFunc-sum) )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
417 ( \\prod . (math-parse-tex-sum calcFunc-prod) )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 (put 'tex 'math-complex-format 'i)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
420
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
421 (defun math-parse-tex-sum (f val)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
422 (let (low high save)
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
423 (or (equal math-expr-data "_") (throw 'syntax "Expected `_'"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424 (math-read-token)
58134
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
425 (setq save math-exp-old-pos)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426 (setq low (math-read-factor))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (or (eq (car-safe low) 'calcFunc-eq)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (progn
58134
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
429 (setq math-exp-old-pos (1+ save))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430 (throw 'syntax "Expected equation")))
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
431 (or (equal math-expr-data "^") (throw 'syntax "Expected `^'"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 (setq high (math-read-factor))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
434 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
435
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
437 (while (string-match "[0-9]\\\\,[0-9]" str)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
438 (setq str (concat (substring str 0 (1+ (match-beginning 0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
439 (substring str (1- (match-end 0))))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
440 str)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 (put 'tex 'math-input-filter 'math-tex-input-filter)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
443 (put 'latex 'math-oper-table
59829
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
444 (append (get 'tex 'math-oper-table)
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
445 '(( "\\Hat" calcFunc-Hat -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
446 ( "\\Check" calcFunc-Check -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
447 ( "\\Tilde" calcFunc-Tilde -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
448 ( "\\Acute" calcFunc-Acute -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
449 ( "\\Grave" calcFunc-Grave -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
450 ( "\\Dot" calcFunc-Dot -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
451 ( "\\Ddot" calcFunc-Dotdot -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
452 ( "\\Breve" calcFunc-Breve -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
453 ( "\\Bar" calcFunc-Bar -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
454 ( "\\Vec" calcFunc-VEC -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
455 ( "\\dddot" calcFunc-dddot -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
456 ( "\\ddddot" calcFunc-ddddot -1 950 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
457 ( "\div" / 170 171 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
458 ( "\\le" calcFunc-leq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
459 ( "\\leqq" calcFunc-leq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
460 ( "\\leqsland" calcFunc-leq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
461 ( "\\ge" calcFunc-geq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
462 ( "\\geqq" calcFunc-geq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
463 ( "\\geqslant" calcFunc-geq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
464 ( "=" calcFunc-eq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
465 ( "\\neq" calcFunc-neq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
466 ( "\\ne" calcFunc-neq 160 161 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
467 ( "\\lnot" calcFunc-lnot -1 121 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
468 ( "\\land" calcFunc-land 110 111 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
469 ( "\\lor" calcFunc-lor 100 101 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
470 ( "?" (math-read-if) 91 90 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
471 ( "!!!" calcFunc-pnot -1 85 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
472 ( "&&&" calcFunc-pand 80 81 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
473 ( "|||" calcFunc-por 75 76 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
474 ( "\\gets" calcFunc-assign 51 50 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
475 ( ":=" calcFunc-assign 51 50 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
476 ( "::" calcFunc-condition 45 46 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
477 ( "\\to" calcFunc-evalto 40 41 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
478 ( "\\to" calcFunc-evalto 40 -1 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
479 ( "=>" calcFunc-evalto 40 41 )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
480 ( "=>" calcFunc-evalto 40 -1 ))))
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
481
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
482 (put 'latex 'math-function-table
59829
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
483 (append
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
484 (get 'tex 'math-function-table)
59915
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
485 '(( \\frac . (math-latex-parse-frac))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
486 ( \\tfrac . (math-latex-parse-frac))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
487 ( \\dfrac . (math-latex-parse-frac))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
488 ( \\binom . (math-latex-parse-two-args calcFunc-choose))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
489 ( \\tbinom . (math-latex-parse-two-args calcFunc-choose))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
490 ( \\dbinom . (math-latex-parse-two-args calcFunc-choose))
59829
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
491 ( \\phi . calcFunc-totient )
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
492 ( \\mu . calcFunc-moebius ))))
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
493
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
494 (put 'latex 'math-special-function-table
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
495 '((/ . (math-latex-print-frac "\\frac"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
496 (calcFunc-choose . (math-latex-print-frac "\\binom"))))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
497
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
498 (put 'latex 'math-variable-table
59829
502b609847e8 (math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59819
diff changeset
499 (get 'tex 'math-variable-table))
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
500
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
501 (put 'latex 'math-complex-format 'i)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
502
59915
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
503
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
504 (defun math-latex-parse-frac (f val)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
505 (let (numer denom)
59915
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
506 (setq numer (car (math-read-expr-list)))
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
507 (math-read-token)
59915
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
508 (setq denom (math-read-factor))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
509 (if (and (Math-num-integerp numer)
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
510 (Math-num-integerp denom))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
511 (list 'frac numer denom)
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
512 (list '/ numer denom))))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
513
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
514 (defun math-latex-parse-two-args (f val)
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
515 (let (first second)
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
516 (setq first (car (math-read-expr-list)))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
517 (math-read-token)
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
518 (setq second (math-read-factor))
937e422a1694 (math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59829
diff changeset
519 (list (nth 2 f) first second)))
59811
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
520
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
521 (defun math-latex-print-frac (a fn)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
522 (list 'horiz (nth 1 fn) "{" (math-compose-expr (nth 1 a) -1)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
523 "}{"
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
524 (math-compose-expr (nth 2 a) -1)
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
525 "}"))
9e28f5bc25bb (calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58661
diff changeset
526
59819
dea78c6f5e48 (math-latex-input-filter): Remove function.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59811
diff changeset
527 (put 'latex 'math-input-filter 'math-tex-input-filter)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529 (defun calc-eqn-language (n)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 (interactive "P")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
532 (calc-set-language 'eqn)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
533 (message "Eqn language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
534
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
535 (put 'eqn 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
536 '( ( "u+" ident -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
537 ( "u-" neg -1 1000 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
538 ( "prime" (math-parse-eqn-prime) 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
539 ( "prime" calcFunc-Prime 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
540 ( "dot" calcFunc-dot 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
541 ( "dotdot" calcFunc-dotdot 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
542 ( "hat" calcFunc-hat 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
543 ( "tilde" calcFunc-tilde 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
544 ( "vec" calcFunc-Vec 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
545 ( "dyad" calcFunc-dyad 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
546 ( "bar" calcFunc-bar 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
547 ( "under" calcFunc-under 950 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
548 ( "sub" calcFunc-subscr 931 930 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
549 ( "sup" ^ 921 920 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
550 ( "sqrt" calcFunc-sqrt -1 910 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
551 ( "over" / 900 901 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
552 ( "u|" calcFunc-abs -1 0 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
553 ( "|" closing 0 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
554 ( "left floor" calcFunc-floor -1 0 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
555 ( "right floor" closing 0 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
556 ( "left ceil" calcFunc-ceil -1 0 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
557 ( "right ceil" closing 0 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
558 ( "+-" sdev 300 300 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
559 ( "!" calcFunc-fact 210 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
560 ( "times" * 191 190 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
561 ( "*" * 191 190 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
562 ( "2x" * 191 190 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
563 ( "/" / 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
564 ( "%" % 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
565 ( "+" + 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
566 ( "-" - 170 171 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
567 ( "<" calcFunc-lt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
568 ( ">" calcFunc-gt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
569 ( "<=" calcFunc-leq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
570 ( ">=" calcFunc-geq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
571 ( "=" calcFunc-eq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
572 ( "==" calcFunc-eq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
573 ( "!=" calcFunc-neq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
574 ( "u!" calcFunc-lnot -1 121 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
575 ( "&&" calcFunc-land 110 111 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
576 ( "||" calcFunc-lor 100 101 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
577 ( "?" (math-read-if) 91 90 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
578 ( "!!!" calcFunc-pnot -1 85 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
579 ( "&&&" calcFunc-pand 80 81 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
580 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
581 ( "<-" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
582 ( ":=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
583 ( "::" calcFunc-condition 45 46 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
584 ( "->" calcFunc-evalto 40 41 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
585 ( "->" calcFunc-evalto 40 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
586 ( "=>" calcFunc-evalto 40 41 )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
587 ( "=>" calcFunc-evalto 40 -1 )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
588
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
589 (put 'eqn 'math-function-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
590 '( ( arc\ cos . calcFunc-arccos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
591 ( arc\ cosh . calcFunc-arccosh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
592 ( arc\ sin . calcFunc-arcsin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
593 ( arc\ sinh . calcFunc-arcsinh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
594 ( arc\ tan . calcFunc-arctan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
595 ( arc\ tanh . calcFunc-arctanh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
596 ( GAMMA . calcFunc-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
597 ( phi . calcFunc-totient )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
598 ( mu . calcFunc-moebius )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
599 ( matrix . (math-parse-eqn-matrix) )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
600
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
601 (put 'eqn 'math-variable-table
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
602 '( ( inf . var-uinf )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
603
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
604 (put 'eqn 'math-complex-format 'i)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
605
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
606 (defun math-parse-eqn-matrix (f sym)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
607 (let ((vec nil))
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
608 (while (assoc math-expr-data '(("ccol") ("lcol") ("rcol")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
609 (math-read-token)
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
610 (or (equal math-expr-data calc-function-open)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
611 (throw 'syntax "Expected `{'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
612 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
613 (setq vec (cons (cons 'vec (math-read-expr-list)) vec))
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
614 (or (equal math-expr-data calc-function-close)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
615 (throw 'syntax "Expected `}'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
616 (math-read-token))
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
617 (or (equal math-expr-data calc-function-close)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
618 (throw 'syntax "Expected `}'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
619 (math-read-token)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
620 (math-transpose (cons 'vec (nreverse vec)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
621
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
622 (defun math-parse-eqn-prime (x sym)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
623 (if (eq (car-safe x) 'var)
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
624 (if (equal math-expr-data calc-function-open)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
625 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
626 (math-read-token)
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
627 (let ((args (if (or (equal math-expr-data calc-function-close)
58134
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
628 (eq math-exp-token 'end))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
629 nil
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
630 (math-read-expr-list))))
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
631 (if (not (or (equal math-expr-data calc-function-close)
58134
3089957051ea (math-parse-tex-sum): Use declared variable math-exp-old-pos.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58107
diff changeset
632 (eq math-exp-token 'end)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
633 (throw 'syntax "Expected `)'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
634 (math-read-token)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
635 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
636 (list 'var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
637 (intern (concat (symbol-name (nth 1 x)) "'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
638 (intern (concat (symbol-name (nth 2 x)) "'"))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
639 (list 'calcFunc-Prime x)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
640
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
641
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
642 (defun calc-mathematica-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
643 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
644 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
645 (calc-set-language 'math)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
646 (message "Mathematica language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
647
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
648 (put 'math 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
649 '( ( "[[" (math-read-math-subscr) 250 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
650 ( "!" calcFunc-fact 210 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
651 ( "!!" calcFunc-dfact 210 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
652 ( "^" ^ 201 200 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
653 ( "u+" ident -1 197 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
654 ( "u-" neg -1 197 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
655 ( "/" / 195 196 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
656 ( "*" * 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
657 ( "2x" * 190 191 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
658 ( "+" + 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
659 ( "-" - 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
660 ( "<" calcFunc-lt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
661 ( ">" calcFunc-gt 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
662 ( "<=" calcFunc-leq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
663 ( ">=" calcFunc-geq 160 161 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
664 ( "==" calcFunc-eq 150 151 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
665 ( "!=" calcFunc-neq 150 151 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
666 ( "u!" calcFunc-lnot -1 121 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
667 ( "&&" calcFunc-land 110 111 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
668 ( "||" calcFunc-lor 100 101 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
669 ( "!!!" calcFunc-pnot -1 85 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
670 ( "&&&" calcFunc-pand 80 81 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
671 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
672 ( ":=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
673 ( "=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
674 ( "->" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
675 ( ":>" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
676 ( "::" calcFunc-condition 45 46 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
677 ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
678
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
679 (put 'math 'math-function-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
680 '( ( Abs . calcFunc-abs )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
681 ( ArcCos . calcFunc-arccos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
682 ( ArcCosh . calcFunc-arccosh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
683 ( ArcSin . calcFunc-arcsin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
684 ( ArcSinh . calcFunc-arcsinh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
685 ( ArcTan . calcFunc-arctan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
686 ( ArcTanh . calcFunc-arctanh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
687 ( Arg . calcFunc-arg )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
688 ( Binomial . calcFunc-choose )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
689 ( Ceiling . calcFunc-ceil )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
690 ( Conjugate . calcFunc-conj )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
691 ( Cos . calcFunc-cos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
692 ( Cosh . calcFunc-cosh )
61069
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
693 ( Cot . calcFunc-cot )
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
694 ( Coth . calcFunc-coth )
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
695 ( Csc . calcFunc-csc )
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
696 ( Csch . calcFunc-csch )
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
697 ( D . calcFunc-deriv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
698 ( Dt . calcFunc-tderiv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
699 ( Det . calcFunc-det )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
700 ( Exp . calcFunc-exp )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
701 ( EulerPhi . calcFunc-totient )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
702 ( Floor . calcFunc-floor )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
703 ( Gamma . calcFunc-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
704 ( GCD . calcFunc-gcd )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
705 ( If . calcFunc-if )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
706 ( Im . calcFunc-im )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
707 ( Inverse . calcFunc-inv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
708 ( Integrate . calcFunc-integ )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
709 ( Join . calcFunc-vconcat )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
710 ( LCM . calcFunc-lcm )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
711 ( Log . calcFunc-ln )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
712 ( Max . calcFunc-max )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
713 ( Min . calcFunc-min )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
714 ( Mod . calcFunc-mod )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
715 ( MoebiusMu . calcFunc-moebius )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
716 ( Random . calcFunc-random )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
717 ( Round . calcFunc-round )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
718 ( Re . calcFunc-re )
61069
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
719 ( Sec . calcFunc-sec )
803f4b2d0113 Add functions to math-function-table properties of tex and math.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 59966
diff changeset
720 ( Sech . calcFunc-sech )
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
721 ( Sign . calcFunc-sign )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
722 ( Sin . calcFunc-sin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
723 ( Sinh . calcFunc-sinh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
724 ( Sqrt . calcFunc-sqrt )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
725 ( Tan . calcFunc-tan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
726 ( Tanh . calcFunc-tanh )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
727 ( Transpose . calcFunc-trn )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
728 ( Length . calcFunc-vlen )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
729 ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
730
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
731 (put 'math 'math-variable-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
732 '( ( I . var-i )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
733 ( Pi . var-pi )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
734 ( E . var-e )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
735 ( GoldenRatio . var-phi )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
736 ( EulerGamma . var-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
737 ( Infinity . var-inf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
738 ( ComplexInfinity . var-uinf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
739 ( Indeterminate . var-nan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
740 ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
741
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
742 (put 'math 'math-vector-brackets "{}")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
743 (put 'math 'math-complex-format 'I)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
744 (put 'math 'math-function-open "[")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
745 (put 'math 'math-function-close "]")
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
746
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
747 (put 'math 'math-radix-formatter
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
748 (function (lambda (r s) (format "%d^^%s" r s))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
749
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
750 (defun math-read-math-subscr (x op)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
751 (let ((idx (math-read-expr-level 0)))
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
752 (or (and (equal math-expr-data "]")
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
753 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
754 (math-read-token)
58107
cfad3432f125 (math-parse-fortran-vector, math-parse-fortran-vector-end,
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
755 (equal math-expr-data "]")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
756 (throw 'syntax "Expected ']]'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
757 (math-read-token)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
758 (list 'calcFunc-subscr x idx)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
759
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
760
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
761 (defun calc-maple-language ()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
762 (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
763 (calc-wrapper
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
764 (calc-set-language 'maple)
41271
fcd507927105 Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
765 (message "Maple language mode")))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
766
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
767 (put 'maple 'math-oper-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
768 '( ( "matrix" ident -1 300 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
769 ( "MATRIX" ident -1 300 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
770 ( "!" calcFunc-fact 210 -1 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
771 ( "^" ^ 201 200 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
772 ( "**" ^ 201 200 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
773 ( "u+" ident -1 197 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
774 ( "u-" neg -1 197 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
775 ( "/" / 191 192 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
776 ( "*" * 191 192 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
777 ( "intersect" calcFunc-vint 191 192 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
778 ( "+" + 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
779 ( "-" - 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
780 ( "union" calcFunc-vunion 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
781 ( "minus" calcFunc-vdiff 180 181 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
782 ( "mod" % 170 170 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
783 ( ".." (math-read-maple-dots) 165 165 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
784 ( "\\dots" (math-read-maple-dots) 165 165 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
785 ( "<" calcFunc-lt 160 160 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
786 ( ">" calcFunc-gt 160 160 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
787 ( "<=" calcFunc-leq 160 160 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
788 ( ">=" calcFunc-geq 160 160 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
789 ( "=" calcFunc-eq 160 160 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
790 ( "<>" calcFunc-neq 160 160 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
791 ( "not" calcFunc-lnot -1 121 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
792 ( "and" calcFunc-land 110 111 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
793 ( "or" calcFunc-lor 100 101 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
794 ( "!!!" calcFunc-pnot -1 85 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
795 ( "&&&" calcFunc-pand 80 81 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
796 ( "|||" calcFunc-por 75 76 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
797 ( ":=" calcFunc-assign 51 50 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
798 ( "::" calcFunc-condition 45 46 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
799 ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
800
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
801 (put 'maple 'math-function-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
802 '( ( bernoulli . calcFunc-bern )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
803 ( binomial . calcFunc-choose )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
804 ( diff . calcFunc-deriv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
805 ( GAMMA . calcFunc-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
806 ( ifactor . calcFunc-prfac )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
807 ( igcd . calcFunc-gcd )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
808 ( ilcm . calcFunc-lcm )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
809 ( int . calcFunc-integ )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
810 ( modp . % )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
811 ( irem . % )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
812 ( iquo . calcFunc-idiv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
813 ( isprime . calcFunc-prime )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
814 ( length . calcFunc-vlen )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
815 ( member . calcFunc-in )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
816 ( crossprod . calcFunc-cross )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
817 ( inverse . calcFunc-inv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
818 ( trace . calcFunc-tr )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
819 ( transpose . calcFunc-trn )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
820 ( vectdim . calcFunc-vlen )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
821 ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
822
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
823 (put 'maple 'math-variable-table
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
824 '( ( I . var-i )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
825 ( Pi . var-pi )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
826 ( E . var-e )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
827 ( infinity . var-inf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
828 ( infinity . var-uinf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
829 ( infinity . var-nan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
830 ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
831
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
832 (put 'maple 'math-complex-format 'I)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
833
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
834 (defun math-read-maple-dots (x op)
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
835 (list 'intv 3 x (math-read-expr-level (nth 3 op))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
836
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
837
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
838 ;; The variable math-read-big-lines is local to math-read-big-expr in
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
839 ;; calc-ext.el, but is used by math-read-big-rec, math-read-big-char,
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
840 ;; math-read-big-emptyp, math-read-big-error and math-read-big-balance,
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
841 ;; which are called (directly and indirectly) by math-read-big-expr.
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
842 ;; It is also local to math-read-big-bigp in calc-ext.el, which calls
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
843 ;; math-read-big-balance.
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
844 (defvar math-read-big-lines)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
845
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
846 ;; The variables math-read-big-baseline and math-read-big-h2 are
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
847 ;; local to math-read-big-expr in calc-ext.el, but used by
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
848 ;; math-read-big-rec.
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
849 (defvar math-read-big-baseline)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
850 (defvar math-read-big-h2)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
851
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
852 ;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
853 ;; are local to math-read-big-rec, but are used by math-read-big-char,
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
854 ;; math-read-big-emptyp and math-read-big-balance which are called by
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
855 ;; math-read-big-rec.
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
856 ;; math-rb-h2 is also local to math-read-big-bigp in calc-ext.el,
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
857 ;; which calls math-read-big-balance.
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
858 (defvar math-rb-h1)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
859 (defvar math-rb-h2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
860 (defvar math-rb-v1)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
861 (defvar math-rb-v2)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
862
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
863 (defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
864 &optional baseline prec short)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
865 (or prec (setq prec 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
866
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
867 ;; Clip whitespace above or below.
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
868 (while (and (< math-rb-v1 math-rb-v2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
869 (math-read-big-emptyp math-rb-h1 math-rb-v1 math-rb-h2 (1+ math-rb-v1)))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
870 (setq math-rb-v1 (1+ math-rb-v1)))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
871 (while (and (< math-rb-v1 math-rb-v2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
872 (math-read-big-emptyp math-rb-h1 (1- math-rb-v2) math-rb-h2 math-rb-v2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
873 (setq math-rb-v2 (1- math-rb-v2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
874
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
875 ;; If formula is a single line high, normal parser can handle it.
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
876 (if (<= math-rb-v2 (1+ math-rb-v1))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
877 (if (or (<= math-rb-v2 math-rb-v1)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
878 (> math-rb-h1 (length (setq math-rb-v2
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
879 (nth math-rb-v1 math-read-big-lines)))))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
880 (math-read-big-error math-rb-h1 math-rb-v1)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
881 (setq math-read-big-baseline math-rb-v1
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
882 math-read-big-h2 math-rb-h2
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
883 math-rb-v2 (nth math-rb-v1 math-read-big-lines)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
884 math-rb-h2 (math-read-expr
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
885 (substring math-rb-v2 math-rb-h1
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
886 (min math-rb-h2 (length math-rb-v2)))))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
887 (if (eq (car-safe math-rb-h2) 'error)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
888 (math-read-big-error (+ math-rb-h1 (nth 1 math-rb-h2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
889 math-rb-v1 (nth 2 math-rb-h2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
890 math-rb-h2))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
891
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
892 ;; Clip whitespace at left or right.
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
893 (while (and (< math-rb-h1 math-rb-h2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
894 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) math-rb-v2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
895 (setq math-rb-h1 (1+ math-rb-h1)))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
896 (while (and (< math-rb-h1 math-rb-h2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
897 (math-read-big-emptyp (1- math-rb-h2) math-rb-v1 math-rb-h2 math-rb-v2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
898 (setq math-rb-h2 (1- math-rb-h2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
899
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
900 ;; Scan to find widest left-justified "----" in the region.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
901 (let* ((widest nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
902 (widest-h2 0)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
903 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
904 (p lines-v1)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
905 (v math-rb-v1)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
906 (other-v nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
907 other-char line len h)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
908 (while (< v math-rb-v2)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
909 (setq line (car p)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
910 len (min math-rb-h2 (length line)))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
911 (and (< math-rb-h1 len)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
912 (/= (aref line math-rb-h1) ?\ )
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
913 (if (and (= (aref line math-rb-h1) ?\-)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
914 ;; Make sure it's not a minus sign.
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
915 (or (and (< (1+ math-rb-h1) len)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
916 (= (aref line (1+ math-rb-h1)) ?\-))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
917 (/= (math-read-big-char math-rb-h1 (1- v)) ?\ )
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
918 (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ )))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
919 (progn
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
920 (setq h math-rb-h1)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
921 (while (and (< (setq h (1+ h)) len)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
922 (= (aref line h) ?\-)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
923 (if (> h widest-h2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
924 (setq widest v
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
925 widest-h2 h)))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
926 (or other-v (setq other-v v other-char (aref line math-rb-h1)))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
927 (setq v (1+ v)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
928 p (cdr p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
929
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
930 (cond ((not (setq v other-v))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
931 (math-read-big-error math-rb-h1 math-rb-v1)) ; Should never happen!
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
932
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
933 ;; Quotient.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
934 (widest
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
935 (setq h widest-h2
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
936 v widest)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
937 (let ((num (math-read-big-rec math-rb-h1 math-rb-v1 h v))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
938 (den (math-read-big-rec math-rb-h1 (1+ v) h math-rb-v2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
939 (setq p (if (and (math-integerp num) (math-integerp den))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
940 (math-make-frac num den)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
941 (list '/ num den)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
942
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
943 ;; Big radical sign.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
944 ((= other-char ?\\)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
945 (or (= (math-read-big-char (1+ math-rb-h1) v) ?\|)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
946 (math-read-big-error (1+ math-rb-h1) v "Malformed root sign"))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
947 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
948 (while (= (math-read-big-char (1+ math-rb-h1) (setq v (1- v))) ?\|))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
949 (or (= (math-read-big-char (setq h (+ math-rb-h1 2)) v) ?\_)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
950 (math-read-big-error h v "Malformed root sign"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
951 (while (= (math-read-big-char (setq h (1+ h)) v) ?\_))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
952 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
953 (math-read-big-emptyp math-rb-h1 (1+ other-v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
954 (setq p (list 'calcFunc-sqrt (math-read-big-rec
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
955 (+ math-rb-h1 2) (1+ v)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
956 h (1+ other-v) baseline))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
957 v math-read-big-baseline))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
958
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
959 ;; Small radical sign.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
960 ((and (= other-char ?V)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
961 (= (math-read-big-char (1+ math-rb-h1) (1- v)) ?\_))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
962 (setq h (1+ math-rb-h1))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
963 (math-read-big-emptyp math-rb-h1 math-rb-v1 h (1- v) nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
964 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
965 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
966 (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
967 (setq p (list 'calcFunc-sqrt (math-read-big-rec
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
968 (1+ math-rb-h1) v h (1+ v) t))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
969 v math-read-big-baseline))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
970
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
971 ;; Binomial coefficient.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
972 ((and (= other-char ?\()
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
973 (= (math-read-big-char (1+ math-rb-h1) v) ?\ )
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
974 (= (string-match "( *)" (nth v math-read-big-lines)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
975 math-rb-h1) math-rb-h1))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
976 (setq h (match-end 0))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
977 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
978 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
979 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
980 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
981 (setq p (list 'calcFunc-choose
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
982 (math-read-big-rec (1+ math-rb-h1) math-rb-v1 (1- h) v)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
983 (math-read-big-rec (1+ math-rb-h1) (1+ v)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
984 (1- h) math-rb-v2))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
985
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
986 ;; Minus sign.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
987 ((= other-char ?\-)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
988 (setq p (list 'neg (math-read-big-rec (1+ math-rb-h1) math-rb-v1
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
989 math-rb-h2 math-rb-v2 v 250 t))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
990 v math-read-big-baseline
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
991 h math-read-big-h2))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
992
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
993 ;; Parentheses.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
994 ((= other-char ?\()
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
995 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
996 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
997 (setq h (math-read-big-balance (1+ math-rb-h1) v "(" t))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
998 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
999 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1000 (let ((sep (math-read-big-char (1- h) v))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1001 hmid)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1002 (if (= sep ?\.)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1003 (setq h (1+ h)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1004 (if (= sep ?\])
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1005 (math-read-big-error (1- h) v "Expected `)'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1006 (if (= sep ?\))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1007 (setq p (math-read-big-rec
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1008 (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1009 (setq hmid (math-read-big-balance h v "(")
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1010 p (list p
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1011 (math-read-big-rec h math-rb-v1 (1- hmid) math-rb-v2 v))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1012 h hmid)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1013 (cond ((= sep ?\.)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1014 (setq p (cons 'intv (cons (if (= (math-read-big-char
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1015 (1- h) v)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1016 ?\))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1017 0 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1018 p))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1019 ((= (math-read-big-char (1- h) v) ?\])
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1020 (math-read-big-error (1- h) v "Expected `)'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1021 ((= sep ?\,)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1022 (or (and (math-realp (car p)) (math-realp (nth 1 p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1023 (math-read-big-error
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1024 math-rb-h1 v "Complex components must be real"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1025 (setq p (cons 'cplx p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1026 ((= sep ?\;)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1027 (or (and (math-realp (car p)) (math-anglep (nth 1 p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1028 (math-read-big-error
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1029 math-rb-h1 v "Complex components must be real"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1030 (setq p (cons 'polar p)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1031
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1032 ;; Matrix.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1033 ((and (= other-char ?\[)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1034 (or (= (math-read-big-char (setq h math-rb-h1) (1+ v)) ?\[)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1035 (= (math-read-big-char (setq h (1+ h)) v) ?\[)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1036 (and (= (math-read-big-char h v) ?\ )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1037 (= (math-read-big-char (setq h (1+ h)) v) ?\[)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1038 (= (math-read-big-char h (1+ v)) ?\[))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1039 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1040 (let ((vtop v)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1041 (hleft h)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1042 (hright nil))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1043 (setq p nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1044 (while (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1045 (setq h (math-read-big-balance (1+ hleft) v "["))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1046 (if hright
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1047 (or (= h hright)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1048 (math-read-big-error hright v "Expected `]'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1049 (setq hright h))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1050 (setq p (cons (math-read-big-rec
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1051 hleft v h (1+ v)) p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1052 (and (memq (math-read-big-char h v) '(?\ ?\,))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1053 (= (math-read-big-char hleft (1+ v)) ?\[)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1054 (setq v (1+ v)))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1055 (or (= hleft math-rb-h1)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1056 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1057 (if (= (math-read-big-char h v) ?\ )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1058 (setq h (1+ h)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1059 (and (= (math-read-big-char h v) ?\])
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1060 (setq h (1+ h))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1061 (math-read-big-error (1- h) v "Expected `]'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1062 (if (= (math-read-big-char h vtop) ?\,)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1063 (setq h (1+ h)))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1064 (math-read-big-emptyp math-rb-h1 (1+ v) (1- h) math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1065 (setq v (+ vtop (/ (- v vtop) 2))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1066 p (cons 'vec (nreverse p)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1067
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1068 ;; Square brackets.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1069 ((= other-char ?\[)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1070 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1071 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1072 (setq p nil
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1073 h (1+ math-rb-h1))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1074 (while (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1075 (setq widest (math-read-big-balance h v "[" t))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1076 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1077 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1078 (setq p (cons (math-read-big-rec
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1079 h math-rb-v1 (1- widest) math-rb-v2 v) p)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1080 h widest)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1081 (= (math-read-big-char (1- h) v) ?\,)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1082 (setq widest (math-read-big-char (1- h) v))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1083 (if (or (memq widest '(?\; ?\)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1084 (and (eq widest ?\.) (cdr p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1085 (math-read-big-error (1- h) v "Expected `]'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1086 (if (= widest ?\.)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1087 (setq h (1+ h)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1088 widest (math-read-big-balance h v "[")
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1089 p (nconc p (list (math-read-big-rec
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1090 h math-rb-v1 (1- widest) math-rb-v2 v)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1091 h widest
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1092 p (cons 'intv (cons (if (= (math-read-big-char (1- h) v)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1093 ?\])
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1094 3 2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1095 p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1096 (setq p (cons 'vec (nreverse p)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1097
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1098 ;; Date form.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1099 ((= other-char ?\<)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1100 (setq line (nth v math-read-big-lines))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1101 (string-match ">" line math-rb-h1)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1102 (setq h (match-end 0))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1103 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1104 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1105 (setq p (math-read-big-rec math-rb-h1 v h (1+ v) v)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1106
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1107 ;; Variable name or function call.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1108 ((or (and (>= other-char ?a) (<= other-char ?z))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1109 (and (>= other-char ?A) (<= other-char ?Z)))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1110 (setq line (nth v math-read-big-lines))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1111 (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1112 (setq h (match-end 1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1113 widest (match-end 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1114 p (math-match-substring line 1))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1115 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1116 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1117 (if (= (math-read-big-char widest v) ?\()
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1118 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1119 (setq line (if (string-match "-" p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1120 (intern p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1121 (intern (concat "calcFunc-" p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1122 h (1+ widest)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1123 p nil)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1124 (math-read-big-emptyp widest math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1125 (math-read-big-emptyp widest (1+ v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1126 (while (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1127 (setq widest (math-read-big-balance h v "(" t))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1128 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1129 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1130 (setq p (cons (math-read-big-rec
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1131 h math-rb-v1 (1- widest) math-rb-v2 v) p)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1132 h widest)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1133 (= (math-read-big-char (1- h) v) ?\,)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1134 (or (= (math-read-big-char (1- h) v) ?\))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1135 (math-read-big-error (1- h) v "Expected `)'"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1136 (setq p (cons line (nreverse p))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1137 (setq p (list 'var
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1138 (intern (math-remove-dashes p))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1139 (if (string-match "-" p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1140 (intern p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1141 (intern (concat "var-" p)))))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1142
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1143 ;; Number.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1144 (t
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1145 (setq line (nth v math-read-big-lines))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1146 (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)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1147 (math-read-big-error h v "Expected a number"))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1148 (setq h (match-end 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1149 p (math-read-number (math-match-substring line 0)))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1150 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1151 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1152
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1153 ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2;
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1154 ;; baseline = v.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1155 (if baseline
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1156 (or (= v baseline)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1157 (math-read-big-error math-rb-h1 v "Inconsistent baseline in formula"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1158 (setq baseline v))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1159
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1160 ;; Look for superscripts or subscripts.
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1161 (setq line (nth baseline math-read-big-lines)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1162 len (min math-rb-h2 (length line))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1163 widest h)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1164 (while (and (< widest len)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1165 (= (aref line widest) ?\ ))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1166 (setq widest (1+ widest)))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1167 (and (>= widest len) (setq widest math-rb-h2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1168 (if (math-read-big-emptyp h v widest math-rb-v2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1169 (if (math-read-big-emptyp h math-rb-v1 widest v)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1170 (setq h widest)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1171 (setq p (list '^ p (math-read-big-rec h math-rb-v1 widest v))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1172 h widest))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1173 (if (math-read-big-emptyp h math-rb-v1 widest v)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1174 (setq p (list 'calcFunc-subscr p
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1175 (math-read-big-rec h v widest math-rb-v2))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1176 h widest)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1177
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1178 ;; Look for an operator name and grab additional terms.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1179 (while (and (< h len)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1180 (if (setq widest (and (math-read-big-emptyp
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1181 h math-rb-v1 (1+ h) v)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1182 (math-read-big-emptyp
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1183 h (1+ v) (1+ h) math-rb-v2)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1184 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1185 (assoc (math-match-substring line 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1186 math-standard-opers)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1187 (and (>= (nth 2 widest) prec)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1188 (setq h (match-end 0)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1189 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1190 h))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1191 (setq widest '("2x" * 196 195)))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1192 (cond ((eq (nth 3 widest) -1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1193 (setq p (list (nth 1 widest) p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1194 ((equal (car widest) "?")
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1195 (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1196 math-rb-v2 baseline nil t)))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1197 (or (= (math-read-big-char math-read-big-h2 baseline) ?\:)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1198 (math-read-big-error math-read-big-h2 baseline "Expected `:'"))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1199 (setq p (list (nth 1 widest) p y
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1200 (math-read-big-rec
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1201 (1+ math-read-big-h2) math-rb-v1 math-rb-h2 math-rb-v2
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1202 baseline (nth 3 widest) t))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1203 h math-read-big-h2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1204 (t
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1205 (setq p (list (nth 1 widest) p
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1206 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1207 baseline (nth 3 widest) t))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1208 h math-read-big-h2))))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1209
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1210 ;; Return all relevant information to caller.
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1211 (setq math-read-big-baseline baseline
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1212 math-read-big-h2 h)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1213 (or short (= math-read-big-h2 math-rb-h2)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1214 (math-read-big-error h baseline))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1215 p)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1216
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1217 (defun math-read-big-char (h v)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1218 (or (and (>= h math-rb-h1)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1219 (< h math-rb-h2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1220 (>= v math-rb-v1)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1221 (< v math-rb-v2)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1222 (let ((line (nth v math-read-big-lines)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1223 (and line
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1224 (< h (length line))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1225 (aref line h))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1226 ?\ ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1227
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1228 (defun math-read-big-emptyp (eh1 ev1 eh2 ev2 &optional what error)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1229 (and (< ev1 math-rb-v1) (setq ev1 math-rb-v1))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1230 (and (< eh1 math-rb-h1) (setq eh1 math-rb-h1))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1231 (and (> ev2 math-rb-v2) (setq ev2 math-rb-v2))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1232 (and (> eh2 math-rb-h2) (setq eh2 math-rb-h2))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1233 (or what (setq what ?\ ))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1234 (let ((p (nthcdr ev1 math-read-big-lines))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1235 h)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1236 (while (and (< ev1 ev2)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1237 (progn
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1238 (setq h (min eh2 (length (car p))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1239 (while (and (>= (setq h (1- h)) eh1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1240 (= (aref (car p) h) what)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1241 (and error (>= h eh1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1242 (math-read-big-error h ev1 (if (stringp error)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1243 error
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1244 "Whitespace expected")))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1245 (< h eh1)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1246 (setq ev1 (1+ ev1)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1247 p (cdr p)))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1248 (>= ev1 ev2)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1249
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1250 ;; math-read-big-err-msg is local to math-read-big-expr in calc-ext.el,
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1251 ;; but is used by math-read-big-error which is called (indirectly) by
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1252 ;; math-read-big-expr.
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1253 (defvar math-read-big-err-msg)
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1254
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1255 (defun math-read-big-error (h v &optional msg)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1256 (let ((pos 0)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1257 (p math-read-big-lines))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1258 (while (> v 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1259 (setq pos (+ pos 1 (length (car p)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1260 p (cdr p)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1261 v (1- v)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1262 (setq h (+ pos (min h (length (car p))))
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1263 math-read-big-err-msg (list 'error h (or msg "Syntax error")))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1264 (throw 'syntax nil)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1265
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1266 (defun math-read-big-balance (h v what &optional commas)
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1267 (let* ((line (nth v math-read-big-lines))
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1268 (len (min math-rb-h2 (length line)))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1269 (count 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1270 (while (> count 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1271 (if (>= h len)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1272 (if what
58411
9ceda393e263 (math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58134
diff changeset
1273 (math-read-big-error nil v (format "Unmatched `%s'" what))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1274 (setq count 0))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1275 (if (memq (aref line h) '(?\( ?\[))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1276 (setq count (1+ count))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1277 (if (if (and commas (= count 1))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1278 (or (memq (aref line h) '(?\) ?\] ?\, ?\;))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1279 (and (eq (aref line h) ?\.)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1280 (< (1+ h) len)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1281 (eq (aref line (1+ h)) ?\.)))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1282 (memq (aref line h) '(?\) ?\])))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1283 (setq count (1- count))))
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1284 (setq h (1+ h))))
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1285 h))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1286
58661
10224395a3c2 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58571
diff changeset
1287 (provide 'calc-lang)
10224395a3c2 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58571
diff changeset
1288
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
1289 ;;; arch-tag: 483bfe15-f290-4fef-bb7d-ce65be687f2e
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40785
diff changeset
1290 ;;; calc-lang.el ends here