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