Mercurial > emacs
annotate lisp/calc/calc-lang.el @ 59959:9a988a8e5302
(Undo): Fix typo.
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Sun, 06 Feb 2005 13:16:57 +0000 |
parents | 937e422a1694 |
children | 9eb004b49fc9 72cf6261961e |
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) | |
294 (message (if (and n (/= n 0)) | |
295 (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
|
296 "TeX language mode with \\hbox{func}(\\hbox{var})" |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
297 "TeX language mode with \\func{\\hbox{var}}") |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
298 "TeX language mode")))) |
40785 | 299 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
300 (defun calc-latex-language (n) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
301 (interactive "P") |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
302 (calc-wrapper |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
303 (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
|
304 (calc-set-language 'latex n) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
305 (cond ((not n) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
306 (message "LaTeX language mode")) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
307 ((= n 0) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
308 (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
|
309 ((= n 1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
310 (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
|
311 ((> n 1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
312 (message |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
313 "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
|
314 ((= n -1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
315 (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
|
316 ((< n -1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
317 (message |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
318 "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
|
319 |
40785 | 320 (put 'tex 'math-oper-table |
321 '( ( "u+" ident -1 1000 ) | |
322 ( "u-" neg -1 1000 ) | |
323 ( "\\hat" calcFunc-hat -1 950 ) | |
324 ( "\\check" calcFunc-check -1 950 ) | |
325 ( "\\tilde" calcFunc-tilde -1 950 ) | |
326 ( "\\acute" calcFunc-acute -1 950 ) | |
327 ( "\\grave" calcFunc-grave -1 950 ) | |
328 ( "\\dot" calcFunc-dot -1 950 ) | |
329 ( "\\ddot" calcFunc-dotdot -1 950 ) | |
330 ( "\\breve" calcFunc-breve -1 950 ) | |
331 ( "\\bar" calcFunc-bar -1 950 ) | |
332 ( "\\vec" calcFunc-Vec -1 950 ) | |
333 ( "\\underline" calcFunc-under -1 950 ) | |
334 ( "u|" calcFunc-abs -1 0 ) | |
335 ( "|" closing 0 -1 ) | |
336 ( "\\lfloor" calcFunc-floor -1 0 ) | |
337 ( "\\rfloor" closing 0 -1 ) | |
338 ( "\\lceil" calcFunc-ceil -1 0 ) | |
339 ( "\\rceil" closing 0 -1 ) | |
340 ( "\\pm" sdev 300 300 ) | |
341 ( "!" calcFunc-fact 210 -1 ) | |
342 ( "^" ^ 201 200 ) | |
343 ( "_" calcFunc-subscr 201 200 ) | |
344 ( "\\times" * 191 190 ) | |
345 ( "*" * 191 190 ) | |
346 ( "2x" * 191 190 ) | |
347 ( "+" + 180 181 ) | |
348 ( "-" - 180 181 ) | |
349 ( "\\over" / 170 171 ) | |
350 ( "/" / 170 171 ) | |
351 ( "\\choose" calcFunc-choose 170 171 ) | |
352 ( "\\mod" % 170 171 ) | |
353 ( "<" calcFunc-lt 160 161 ) | |
354 ( ">" calcFunc-gt 160 161 ) | |
355 ( "\\leq" calcFunc-leq 160 161 ) | |
356 ( "\\geq" calcFunc-geq 160 161 ) | |
357 ( "=" calcFunc-eq 160 161 ) | |
358 ( "\\neq" calcFunc-neq 160 161 ) | |
359 ( "\\ne" calcFunc-neq 160 161 ) | |
360 ( "\\lnot" calcFunc-lnot -1 121 ) | |
361 ( "\\land" calcFunc-land 110 111 ) | |
362 ( "\\lor" calcFunc-lor 100 101 ) | |
363 ( "?" (math-read-if) 91 90 ) | |
364 ( "!!!" calcFunc-pnot -1 85 ) | |
365 ( "&&&" calcFunc-pand 80 81 ) | |
366 ( "|||" calcFunc-por 75 76 ) | |
367 ( "\\gets" calcFunc-assign 51 50 ) | |
368 ( ":=" calcFunc-assign 51 50 ) | |
369 ( "::" calcFunc-condition 45 46 ) | |
370 ( "\\to" calcFunc-evalto 40 41 ) | |
371 ( "\\to" calcFunc-evalto 40 -1 ) | |
372 ( "=>" calcFunc-evalto 40 41 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
373 ( "=>" calcFunc-evalto 40 -1 ))) |
40785 | 374 |
375 (put 'tex 'math-function-table | |
376 '( ( \\arccos . calcFunc-arccos ) | |
377 ( \\arcsin . calcFunc-arcsin ) | |
378 ( \\arctan . calcFunc-arctan ) | |
379 ( \\arg . calcFunc-arg ) | |
380 ( \\cos . calcFunc-cos ) | |
381 ( \\cosh . calcFunc-cosh ) | |
382 ( \\det . calcFunc-det ) | |
383 ( \\exp . calcFunc-exp ) | |
384 ( \\gcd . calcFunc-gcd ) | |
385 ( \\ln . calcFunc-ln ) | |
386 ( \\log . calcFunc-log10 ) | |
387 ( \\max . calcFunc-max ) | |
388 ( \\min . calcFunc-min ) | |
389 ( \\tan . calcFunc-tan ) | |
390 ( \\sin . calcFunc-sin ) | |
391 ( \\sinh . calcFunc-sinh ) | |
392 ( \\sqrt . calcFunc-sqrt ) | |
393 ( \\tanh . calcFunc-tanh ) | |
394 ( \\phi . calcFunc-totient ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
395 ( \\mu . calcFunc-moebius ))) |
40785 | 396 |
397 (put 'tex 'math-variable-table | |
398 '( ( \\pi . var-pi ) | |
399 ( \\infty . var-inf ) | |
400 ( \\infty . var-uinf ) | |
401 ( \\phi . var-phi ) | |
402 ( \\gamma . var-gamma ) | |
403 ( \\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
|
404 ( \\prod . (math-parse-tex-sum calcFunc-prod) ))) |
40785 | 405 |
406 (put 'tex 'math-complex-format 'i) | |
407 | |
408 (defun math-parse-tex-sum (f val) | |
409 (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
|
410 (or (equal math-expr-data "_") (throw 'syntax "Expected `_'")) |
40785 | 411 (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
|
412 (setq save math-exp-old-pos) |
40785 | 413 (setq low (math-read-factor)) |
414 (or (eq (car-safe low) 'calcFunc-eq) | |
415 (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
|
416 (setq math-exp-old-pos (1+ save)) |
40785 | 417 (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
|
418 (or (equal math-expr-data "^") (throw 'syntax "Expected `^'")) |
40785 | 419 (math-read-token) |
420 (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
|
421 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high))) |
40785 | 422 |
423 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789. | |
424 (while (string-match "[0-9]\\\\,[0-9]" str) | |
425 (setq str (concat (substring str 0 (1+ (match-beginning 0))) | |
426 (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
|
427 str) |
40785 | 428 (put 'tex 'math-input-filter 'math-tex-input-filter) |
429 | |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
430 (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
|
431 (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
|
432 '(( "\\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
|
433 ( "\\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
|
434 ( "\\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
|
435 ( "\\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
|
436 ( "\\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
|
437 ( "\\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
|
438 ( "\\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
|
439 ( "\\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
|
440 ( "\\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
|
441 ( "\\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
|
442 ( "\\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
|
443 ( "\\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
|
444 ( "\div" / 170 171 ) |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
445 ( "\\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
|
446 ( "\\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
|
447 ( "\\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
|
448 ( "\\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
|
449 ( "\\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
|
450 ( "\\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
|
451 ( "=" 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
|
452 ( "\\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
|
453 ( "\\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
|
454 ( "\\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
|
455 ( "\\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
|
456 ( "\\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
|
457 ( "?" (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
|
458 ( "!!!" 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
|
459 ( "&&&" 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
|
460 ( "|||" 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
|
461 ( "\\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
|
462 ( ":=" 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
|
463 ( "::" 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
|
464 ( "\\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
|
465 ( "\\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
|
466 ( "=>" 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
|
467 ( "=>" calcFunc-evalto 40 -1 )))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
468 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
469 (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
|
470 (append |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
471 (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
|
472 '(( \\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
|
473 ( \\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
|
474 ( \\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
|
475 ( \\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
|
476 ( \\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
|
477 ( \\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
|
478 ( \\phi . calcFunc-totient ) |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
479 ( \\mu . calcFunc-moebius )))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
480 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
481 (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
|
482 '((/ . (math-latex-print-frac "\\frac")) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
483 (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
|
484 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
485 (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
|
486 (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
|
487 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
488 (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
|
489 |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
490 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
491 (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
|
492 (let (numer denom) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
493 (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
|
494 (math-read-token) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
495 (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
|
496 (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
|
497 (Math-num-integerp denom)) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
498 (list 'frac numer denom) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
499 (list '/ numer denom)))) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
500 |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
501 (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
|
502 (let (first second) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
503 (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
|
504 (math-read-token) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
505 (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
|
506 (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
|
507 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
508 (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
|
509 (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
|
510 "}{" |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
511 (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
|
512 "}")) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
513 |
59819
dea78c6f5e48
(math-latex-input-filter): Remove function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59811
diff
changeset
|
514 (put 'latex 'math-input-filter 'math-tex-input-filter) |
40785 | 515 |
516 (defun calc-eqn-language (n) | |
517 (interactive "P") | |
518 (calc-wrapper | |
519 (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
|
520 (message "Eqn language mode"))) |
40785 | 521 |
522 (put 'eqn 'math-oper-table | |
523 '( ( "u+" ident -1 1000 ) | |
524 ( "u-" neg -1 1000 ) | |
525 ( "prime" (math-parse-eqn-prime) 950 -1 ) | |
526 ( "prime" calcFunc-Prime 950 -1 ) | |
527 ( "dot" calcFunc-dot 950 -1 ) | |
528 ( "dotdot" calcFunc-dotdot 950 -1 ) | |
529 ( "hat" calcFunc-hat 950 -1 ) | |
530 ( "tilde" calcFunc-tilde 950 -1 ) | |
531 ( "vec" calcFunc-Vec 950 -1 ) | |
532 ( "dyad" calcFunc-dyad 950 -1 ) | |
533 ( "bar" calcFunc-bar 950 -1 ) | |
534 ( "under" calcFunc-under 950 -1 ) | |
535 ( "sub" calcFunc-subscr 931 930 ) | |
536 ( "sup" ^ 921 920 ) | |
537 ( "sqrt" calcFunc-sqrt -1 910 ) | |
538 ( "over" / 900 901 ) | |
539 ( "u|" calcFunc-abs -1 0 ) | |
540 ( "|" closing 0 -1 ) | |
541 ( "left floor" calcFunc-floor -1 0 ) | |
542 ( "right floor" closing 0 -1 ) | |
543 ( "left ceil" calcFunc-ceil -1 0 ) | |
544 ( "right ceil" closing 0 -1 ) | |
545 ( "+-" sdev 300 300 ) | |
546 ( "!" calcFunc-fact 210 -1 ) | |
547 ( "times" * 191 190 ) | |
548 ( "*" * 191 190 ) | |
549 ( "2x" * 191 190 ) | |
550 ( "/" / 180 181 ) | |
551 ( "%" % 180 181 ) | |
552 ( "+" + 170 171 ) | |
553 ( "-" - 170 171 ) | |
554 ( "<" calcFunc-lt 160 161 ) | |
555 ( ">" calcFunc-gt 160 161 ) | |
556 ( "<=" calcFunc-leq 160 161 ) | |
557 ( ">=" calcFunc-geq 160 161 ) | |
558 ( "=" calcFunc-eq 160 161 ) | |
559 ( "==" calcFunc-eq 160 161 ) | |
560 ( "!=" calcFunc-neq 160 161 ) | |
561 ( "u!" calcFunc-lnot -1 121 ) | |
562 ( "&&" calcFunc-land 110 111 ) | |
563 ( "||" calcFunc-lor 100 101 ) | |
564 ( "?" (math-read-if) 91 90 ) | |
565 ( "!!!" calcFunc-pnot -1 85 ) | |
566 ( "&&&" calcFunc-pand 80 81 ) | |
567 ( "|||" calcFunc-por 75 76 ) | |
568 ( "<-" calcFunc-assign 51 50 ) | |
569 ( ":=" calcFunc-assign 51 50 ) | |
570 ( "::" calcFunc-condition 45 46 ) | |
571 ( "->" calcFunc-evalto 40 41 ) | |
572 ( "->" calcFunc-evalto 40 -1 ) | |
573 ( "=>" calcFunc-evalto 40 41 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
574 ( "=>" calcFunc-evalto 40 -1 ))) |
40785 | 575 |
576 (put 'eqn 'math-function-table | |
577 '( ( arc\ cos . calcFunc-arccos ) | |
578 ( arc\ cosh . calcFunc-arccosh ) | |
579 ( arc\ sin . calcFunc-arcsin ) | |
580 ( arc\ sinh . calcFunc-arcsinh ) | |
581 ( arc\ tan . calcFunc-arctan ) | |
582 ( arc\ tanh . calcFunc-arctanh ) | |
583 ( GAMMA . calcFunc-gamma ) | |
584 ( phi . calcFunc-totient ) | |
585 ( mu . calcFunc-moebius ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
586 ( matrix . (math-parse-eqn-matrix) ))) |
40785 | 587 |
588 (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
|
589 '( ( inf . var-uinf ))) |
40785 | 590 |
591 (put 'eqn 'math-complex-format 'i) | |
592 | |
593 (defun math-parse-eqn-matrix (f sym) | |
594 (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
|
595 (while (assoc math-expr-data '(("ccol") ("lcol") ("rcol"))) |
40785 | 596 (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
|
597 (or (equal math-expr-data calc-function-open) |
40785 | 598 (throw 'syntax "Expected `{'")) |
599 (math-read-token) | |
600 (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
|
601 (or (equal math-expr-data calc-function-close) |
40785 | 602 (throw 'syntax "Expected `}'")) |
603 (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
|
604 (or (equal math-expr-data calc-function-close) |
40785 | 605 (throw 'syntax "Expected `}'")) |
606 (math-read-token) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
607 (math-transpose (cons 'vec (nreverse vec))))) |
40785 | 608 |
609 (defun math-parse-eqn-prime (x sym) | |
610 (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
|
611 (if (equal math-expr-data calc-function-open) |
40785 | 612 (progn |
613 (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
|
614 (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
|
615 (eq math-exp-token 'end)) |
40785 | 616 nil |
617 (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
|
618 (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
|
619 (eq math-exp-token 'end))) |
40785 | 620 (throw 'syntax "Expected `)'")) |
621 (math-read-token) | |
622 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args))) | |
623 (list 'var | |
624 (intern (concat (symbol-name (nth 1 x)) "'")) | |
625 (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
|
626 (list 'calcFunc-Prime x))) |
40785 | 627 |
628 | |
629 (defun calc-mathematica-language () | |
630 (interactive) | |
631 (calc-wrapper | |
632 (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
|
633 (message "Mathematica language mode"))) |
40785 | 634 |
635 (put 'math 'math-oper-table | |
636 '( ( "[[" (math-read-math-subscr) 250 -1 ) | |
637 ( "!" calcFunc-fact 210 -1 ) | |
638 ( "!!" calcFunc-dfact 210 -1 ) | |
639 ( "^" ^ 201 200 ) | |
640 ( "u+" ident -1 197 ) | |
641 ( "u-" neg -1 197 ) | |
642 ( "/" / 195 196 ) | |
643 ( "*" * 190 191 ) | |
644 ( "2x" * 190 191 ) | |
645 ( "+" + 180 181 ) | |
646 ( "-" - 180 181 ) | |
647 ( "<" calcFunc-lt 160 161 ) | |
648 ( ">" calcFunc-gt 160 161 ) | |
649 ( "<=" calcFunc-leq 160 161 ) | |
650 ( ">=" calcFunc-geq 160 161 ) | |
651 ( "==" calcFunc-eq 150 151 ) | |
652 ( "!=" calcFunc-neq 150 151 ) | |
653 ( "u!" calcFunc-lnot -1 121 ) | |
654 ( "&&" calcFunc-land 110 111 ) | |
655 ( "||" calcFunc-lor 100 101 ) | |
656 ( "!!!" calcFunc-pnot -1 85 ) | |
657 ( "&&&" calcFunc-pand 80 81 ) | |
658 ( "|||" calcFunc-por 75 76 ) | |
659 ( ":=" calcFunc-assign 51 50 ) | |
660 ( "=" calcFunc-assign 51 50 ) | |
661 ( "->" calcFunc-assign 51 50 ) | |
662 ( ":>" calcFunc-assign 51 50 ) | |
663 ( "::" calcFunc-condition 45 46 ) | |
664 )) | |
665 | |
666 (put 'math 'math-function-table | |
667 '( ( Abs . calcFunc-abs ) | |
668 ( ArcCos . calcFunc-arccos ) | |
669 ( ArcCosh . calcFunc-arccosh ) | |
670 ( ArcSin . calcFunc-arcsin ) | |
671 ( ArcSinh . calcFunc-arcsinh ) | |
672 ( ArcTan . calcFunc-arctan ) | |
673 ( ArcTanh . calcFunc-arctanh ) | |
674 ( Arg . calcFunc-arg ) | |
675 ( Binomial . calcFunc-choose ) | |
676 ( Ceiling . calcFunc-ceil ) | |
677 ( Conjugate . calcFunc-conj ) | |
678 ( Cos . calcFunc-cos ) | |
679 ( Cosh . calcFunc-cosh ) | |
680 ( D . calcFunc-deriv ) | |
681 ( Dt . calcFunc-tderiv ) | |
682 ( Det . calcFunc-det ) | |
683 ( Exp . calcFunc-exp ) | |
684 ( EulerPhi . calcFunc-totient ) | |
685 ( Floor . calcFunc-floor ) | |
686 ( Gamma . calcFunc-gamma ) | |
687 ( GCD . calcFunc-gcd ) | |
688 ( If . calcFunc-if ) | |
689 ( Im . calcFunc-im ) | |
690 ( Inverse . calcFunc-inv ) | |
691 ( Integrate . calcFunc-integ ) | |
692 ( Join . calcFunc-vconcat ) | |
693 ( LCM . calcFunc-lcm ) | |
694 ( Log . calcFunc-ln ) | |
695 ( Max . calcFunc-max ) | |
696 ( Min . calcFunc-min ) | |
697 ( Mod . calcFunc-mod ) | |
698 ( MoebiusMu . calcFunc-moebius ) | |
699 ( Random . calcFunc-random ) | |
700 ( Round . calcFunc-round ) | |
701 ( Re . calcFunc-re ) | |
702 ( Sign . calcFunc-sign ) | |
703 ( Sin . calcFunc-sin ) | |
704 ( Sinh . calcFunc-sinh ) | |
705 ( Sqrt . calcFunc-sqrt ) | |
706 ( Tan . calcFunc-tan ) | |
707 ( Tanh . calcFunc-tanh ) | |
708 ( Transpose . calcFunc-trn ) | |
709 ( Length . calcFunc-vlen ) | |
710 )) | |
711 | |
712 (put 'math 'math-variable-table | |
713 '( ( I . var-i ) | |
714 ( Pi . var-pi ) | |
715 ( E . var-e ) | |
716 ( GoldenRatio . var-phi ) | |
717 ( EulerGamma . var-gamma ) | |
718 ( Infinity . var-inf ) | |
719 ( ComplexInfinity . var-uinf ) | |
720 ( Indeterminate . var-nan ) | |
721 )) | |
722 | |
723 (put 'math 'math-vector-brackets "{}") | |
724 (put 'math 'math-complex-format 'I) | |
725 (put 'math 'math-function-open "[") | |
726 (put 'math 'math-function-close "]") | |
727 | |
728 (put 'math 'math-radix-formatter | |
729 (function (lambda (r s) (format "%d^^%s" r s)))) | |
730 | |
731 (defun math-read-math-subscr (x op) | |
732 (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
|
733 (or (and (equal math-expr-data "]") |
40785 | 734 (progn |
735 (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
|
736 (equal math-expr-data "]"))) |
40785 | 737 (throw 'syntax "Expected ']]'")) |
738 (math-read-token) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
739 (list 'calcFunc-subscr x idx))) |
40785 | 740 |
741 | |
742 (defun calc-maple-language () | |
743 (interactive) | |
744 (calc-wrapper | |
745 (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
|
746 (message "Maple language mode"))) |
40785 | 747 |
748 (put 'maple 'math-oper-table | |
749 '( ( "matrix" ident -1 300 ) | |
750 ( "MATRIX" ident -1 300 ) | |
751 ( "!" calcFunc-fact 210 -1 ) | |
752 ( "^" ^ 201 200 ) | |
753 ( "**" ^ 201 200 ) | |
754 ( "u+" ident -1 197 ) | |
755 ( "u-" neg -1 197 ) | |
756 ( "/" / 191 192 ) | |
757 ( "*" * 191 192 ) | |
758 ( "intersect" calcFunc-vint 191 192 ) | |
759 ( "+" + 180 181 ) | |
760 ( "-" - 180 181 ) | |
761 ( "union" calcFunc-vunion 180 181 ) | |
762 ( "minus" calcFunc-vdiff 180 181 ) | |
763 ( "mod" % 170 170 ) | |
764 ( ".." (math-read-maple-dots) 165 165 ) | |
765 ( "\\dots" (math-read-maple-dots) 165 165 ) | |
766 ( "<" calcFunc-lt 160 160 ) | |
767 ( ">" calcFunc-gt 160 160 ) | |
768 ( "<=" calcFunc-leq 160 160 ) | |
769 ( ">=" calcFunc-geq 160 160 ) | |
770 ( "=" calcFunc-eq 160 160 ) | |
771 ( "<>" calcFunc-neq 160 160 ) | |
772 ( "not" calcFunc-lnot -1 121 ) | |
773 ( "and" calcFunc-land 110 111 ) | |
774 ( "or" calcFunc-lor 100 101 ) | |
775 ( "!!!" calcFunc-pnot -1 85 ) | |
776 ( "&&&" calcFunc-pand 80 81 ) | |
777 ( "|||" calcFunc-por 75 76 ) | |
778 ( ":=" calcFunc-assign 51 50 ) | |
779 ( "::" calcFunc-condition 45 46 ) | |
780 )) | |
781 | |
782 (put 'maple 'math-function-table | |
783 '( ( bernoulli . calcFunc-bern ) | |
784 ( binomial . calcFunc-choose ) | |
785 ( diff . calcFunc-deriv ) | |
786 ( GAMMA . calcFunc-gamma ) | |
787 ( ifactor . calcFunc-prfac ) | |
788 ( igcd . calcFunc-gcd ) | |
789 ( ilcm . calcFunc-lcm ) | |
790 ( int . calcFunc-integ ) | |
791 ( modp . % ) | |
792 ( irem . % ) | |
793 ( iquo . calcFunc-idiv ) | |
794 ( isprime . calcFunc-prime ) | |
795 ( length . calcFunc-vlen ) | |
796 ( member . calcFunc-in ) | |
797 ( crossprod . calcFunc-cross ) | |
798 ( inverse . calcFunc-inv ) | |
799 ( trace . calcFunc-tr ) | |
800 ( transpose . calcFunc-trn ) | |
801 ( vectdim . calcFunc-vlen ) | |
802 )) | |
803 | |
804 (put 'maple 'math-variable-table | |
805 '( ( I . var-i ) | |
806 ( Pi . var-pi ) | |
807 ( E . var-e ) | |
808 ( infinity . var-inf ) | |
809 ( infinity . var-uinf ) | |
810 ( infinity . var-nan ) | |
811 )) | |
812 | |
813 (put 'maple 'math-complex-format 'I) | |
814 | |
815 (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
|
816 (list 'intv 3 x (math-read-expr-level (nth 3 op)))) |
40785 | 817 |
818 | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
819 ;; 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
|
820 ;; 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
|
821 ;; 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
|
822 ;; 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
|
823 ;; 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
|
824 ;; math-read-big-balance. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
825 (defvar math-read-big-lines) |
40785 | 826 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
827 ;; 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
|
828 ;; 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
|
829 ;; math-read-big-rec. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
830 (defvar math-read-big-baseline) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
831 (defvar math-read-big-h2) |
40785 | 832 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
833 ;; 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
|
834 ;; 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
|
835 ;; 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
|
836 ;; math-read-big-rec. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
837 ;; 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
|
838 ;; which calls math-read-big-balance. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
839 (defvar math-rb-h1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
840 (defvar math-rb-h2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
841 (defvar math-rb-v1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
842 (defvar math-rb-v2) |
40785 | 843 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
844 (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
|
845 &optional baseline prec short) |
40785 | 846 (or prec (setq prec 0)) |
847 | |
848 ;; Clip whitespace above or below. | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
849 (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
|
850 (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
|
851 (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
|
852 (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
|
853 (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
|
854 (setq math-rb-v2 (1- math-rb-v2))) |
40785 | 855 |
856 ;; 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
|
857 (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
|
858 (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
|
859 (> 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
|
860 (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
|
861 (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
|
862 (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
|
863 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
|
864 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
|
865 math-rb-h2 (math-read-expr |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
866 (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
|
867 (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
|
868 (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
|
869 (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
|
870 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
|
871 math-rb-h2)) |
40785 | 872 |
873 ;; 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
|
874 (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
|
875 (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
|
876 (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
|
877 (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
|
878 (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
|
879 (setq math-rb-h2 (1- math-rb-h2))) |
40785 | 880 |
881 ;; Scan to find widest left-justified "----" in the region. | |
882 (let* ((widest nil) | |
883 (widest-h2 0) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
884 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines)) |
40785 | 885 (p lines-v1) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
886 (v math-rb-v1) |
40785 | 887 (other-v nil) |
888 other-char line len h) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
889 (while (< v math-rb-v2) |
40785 | 890 (setq line (car p) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
891 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
|
892 (and (< math-rb-h1 len) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
893 (/= (aref line math-rb-h1) ?\ ) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
894 (if (and (= (aref line math-rb-h1) ?\-) |
40785 | 895 ;; 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
|
896 (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
|
897 (= (aref line (1+ math-rb-h1)) ?\-)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
898 (/= (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
|
899 (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ ))) |
40785 | 900 (progn |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
901 (setq h math-rb-h1) |
40785 | 902 (while (and (< (setq h (1+ h)) len) |
903 (= (aref line h) ?\-))) | |
904 (if (> h widest-h2) | |
905 (setq widest v | |
906 widest-h2 h))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
907 (or other-v (setq other-v v other-char (aref line math-rb-h1))))) |
40785 | 908 (setq v (1+ v) |
909 p (cdr p))) | |
910 | |
911 (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
|
912 (math-read-big-error math-rb-h1 math-rb-v1)) ; Should never happen! |
40785 | 913 |
914 ;; Quotient. | |
915 (widest | |
916 (setq h widest-h2 | |
917 v widest) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
918 (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
|
919 (den (math-read-big-rec math-rb-h1 (1+ v) h math-rb-v2))) |
40785 | 920 (setq p (if (and (math-integerp num) (math-integerp den)) |
921 (math-make-frac num den) | |
922 (list '/ num den))))) | |
923 | |
924 ;; Big radical sign. | |
925 ((= other-char ?\\) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
926 (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
|
927 (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
|
928 (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
|
929 (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
|
930 (or (= (math-read-big-char (setq h (+ math-rb-h1 2)) v) ?\_) |
40785 | 931 (math-read-big-error h v "Malformed root sign")) |
932 (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
|
933 (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
|
934 (math-read-big-emptyp math-rb-h1 (1+ other-v) h math-rb-v2 nil t) |
40785 | 935 (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
|
936 (+ math-rb-h1 2) (1+ v) |
40785 | 937 h (1+ other-v) baseline)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
938 v math-read-big-baseline)) |
40785 | 939 |
940 ;; Small radical sign. | |
941 ((and (= other-char ?V) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
942 (= (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
|
943 (setq h (1+ math-rb-h1)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
944 (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
|
945 (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
|
946 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t) |
40785 | 947 (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_)) |
948 (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
|
949 (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
|
950 v math-read-big-baseline)) |
40785 | 951 |
952 ;; Binomial coefficient. | |
953 ((and (= other-char ?\() | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
954 (= (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
|
955 (= (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
|
956 math-rb-h1) math-rb-h1)) |
40785 | 957 (setq h (match-end 0)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
958 (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
|
959 (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
|
960 (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
|
961 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 962 (setq p (list 'calcFunc-choose |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
963 (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
|
964 (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
|
965 (1- h) math-rb-v2)))) |
40785 | 966 |
967 ;; Minus sign. | |
968 ((= other-char ?\-) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
969 (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
|
970 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
|
971 v math-read-big-baseline |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
972 h math-read-big-h2)) |
40785 | 973 |
974 ;; Parentheses. | |
975 ((= other-char ?\() | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
976 (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
|
977 (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
|
978 (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
|
979 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
980 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 981 (let ((sep (math-read-big-char (1- h) v)) |
982 hmid) | |
983 (if (= sep ?\.) | |
984 (setq h (1+ h))) | |
985 (if (= sep ?\]) | |
986 (math-read-big-error (1- h) v "Expected `)'")) | |
987 (if (= sep ?\)) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
988 (setq p (math-read-big-rec |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
989 (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v)) |
40785 | 990 (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
|
991 p (list p |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
992 (math-read-big-rec h math-rb-v1 (1- hmid) math-rb-v2 v)) |
40785 | 993 h hmid) |
994 (cond ((= sep ?\.) | |
995 (setq p (cons 'intv (cons (if (= (math-read-big-char | |
996 (1- h) v) | |
997 ?\)) | |
998 0 1) | |
999 p)))) | |
1000 ((= (math-read-big-char (1- h) v) ?\]) | |
1001 (math-read-big-error (1- h) v "Expected `)'")) | |
1002 ((= sep ?\,) | |
1003 (or (and (math-realp (car p)) (math-realp (nth 1 p))) | |
1004 (math-read-big-error | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1005 math-rb-h1 v "Complex components must be real")) |
40785 | 1006 (setq p (cons 'cplx p))) |
1007 ((= sep ?\;) | |
1008 (or (and (math-realp (car p)) (math-anglep (nth 1 p))) | |
1009 (math-read-big-error | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1010 math-rb-h1 v "Complex components must be real")) |
40785 | 1011 (setq p (cons 'polar p))))))) |
1012 | |
1013 ;; Matrix. | |
1014 ((and (= other-char ?\[) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1015 (or (= (math-read-big-char (setq h math-rb-h1) (1+ v)) ?\[) |
40785 | 1016 (= (math-read-big-char (setq h (1+ h)) v) ?\[) |
1017 (and (= (math-read-big-char h v) ?\ ) | |
1018 (= (math-read-big-char (setq h (1+ h)) v) ?\[))) | |
1019 (= (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
|
1020 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t) |
40785 | 1021 (let ((vtop v) |
1022 (hleft h) | |
1023 (hright nil)) | |
1024 (setq p nil) | |
1025 (while (progn | |
1026 (setq h (math-read-big-balance (1+ hleft) v "[")) | |
1027 (if hright | |
1028 (or (= h hright) | |
1029 (math-read-big-error hright v "Expected `]'")) | |
1030 (setq hright h)) | |
1031 (setq p (cons (math-read-big-rec | |
1032 hleft v h (1+ v)) p)) | |
1033 (and (memq (math-read-big-char h v) '(?\ ?\,)) | |
1034 (= (math-read-big-char hleft (1+ v)) ?\[))) | |
1035 (setq v (1+ v))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1036 (or (= hleft math-rb-h1) |
40785 | 1037 (progn |
1038 (if (= (math-read-big-char h v) ?\ ) | |
1039 (setq h (1+ h))) | |
1040 (and (= (math-read-big-char h v) ?\]) | |
1041 (setq h (1+ h)))) | |
1042 (math-read-big-error (1- h) v "Expected `]'")) | |
1043 (if (= (math-read-big-char h vtop) ?\,) | |
1044 (setq h (1+ h))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1045 (math-read-big-emptyp math-rb-h1 (1+ v) (1- h) math-rb-v2 nil t) |
40785 | 1046 (setq v (+ vtop (/ (- v vtop) 2)) |
1047 p (cons 'vec (nreverse p))))) | |
1048 | |
1049 ;; Square brackets. | |
1050 ((= other-char ?\[) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1051 (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
|
1052 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t) |
40785 | 1053 (setq p nil |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1054 h (1+ math-rb-h1)) |
40785 | 1055 (while (progn |
1056 (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
|
1057 (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
|
1058 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1059 (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
|
1060 h math-rb-v1 (1- widest) math-rb-v2 v) p) |
40785 | 1061 h widest) |
1062 (= (math-read-big-char (1- h) v) ?\,))) | |
1063 (setq widest (math-read-big-char (1- h) v)) | |
1064 (if (or (memq widest '(?\; ?\))) | |
1065 (and (eq widest ?\.) (cdr p))) | |
1066 (math-read-big-error (1- h) v "Expected `]'")) | |
1067 (if (= widest ?\.) | |
1068 (setq h (1+ h) | |
1069 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
|
1070 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
|
1071 h math-rb-v1 (1- widest) math-rb-v2 v))) |
40785 | 1072 h widest |
1073 p (cons 'intv (cons (if (= (math-read-big-char (1- h) v) | |
1074 ?\]) | |
1075 3 2) | |
1076 p))) | |
1077 (setq p (cons 'vec (nreverse p))))) | |
1078 | |
1079 ;; Date form. | |
1080 ((= other-char ?\<) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1081 (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
|
1082 (string-match ">" line math-rb-h1) |
40785 | 1083 (setq h (match-end 0)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1084 (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
|
1085 (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
|
1086 (setq p (math-read-big-rec math-rb-h1 v h (1+ v) v))) |
40785 | 1087 |
1088 ;; Variable name or function call. | |
1089 ((or (and (>= other-char ?a) (<= other-char ?z)) | |
1090 (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
|
1091 (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
|
1092 (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1) |
40785 | 1093 (setq h (match-end 1) |
1094 widest (match-end 0) | |
1095 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
|
1096 (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
|
1097 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t) |
40785 | 1098 (if (= (math-read-big-char widest v) ?\() |
1099 (progn | |
1100 (setq line (if (string-match "-" p) | |
1101 (intern p) | |
1102 (intern (concat "calcFunc-" p))) | |
1103 h (1+ widest) | |
1104 p nil) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1105 (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
|
1106 (math-read-big-emptyp widest (1+ v) h math-rb-v2 nil t) |
40785 | 1107 (while (progn |
1108 (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
|
1109 (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
|
1110 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1111 (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
|
1112 h math-rb-v1 (1- widest) math-rb-v2 v) p) |
40785 | 1113 h widest) |
1114 (= (math-read-big-char (1- h) v) ?\,))) | |
1115 (or (= (math-read-big-char (1- h) v) ?\)) | |
1116 (math-read-big-error (1- h) v "Expected `)'")) | |
1117 (setq p (cons line (nreverse p)))) | |
1118 (setq p (list 'var | |
1119 (intern (math-remove-dashes p)) | |
1120 (if (string-match "-" p) | |
1121 (intern p) | |
1122 (intern (concat "var-" p))))))) | |
1123 | |
1124 ;; Number. | |
1125 (t | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1126 (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
|
1127 (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 | 1128 (math-read-big-error h v "Expected a number")) |
1129 (setq h (match-end 0) | |
1130 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
|
1131 (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
|
1132 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t))) |
40785 | 1133 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1134 ;; 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
|
1135 ;; baseline = v. |
40785 | 1136 (if baseline |
1137 (or (= v baseline) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1138 (math-read-big-error math-rb-h1 v "Inconsistent baseline in formula")) |
40785 | 1139 (setq baseline v)) |
1140 | |
1141 ;; Look for superscripts or subscripts. | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1142 (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
|
1143 len (min math-rb-h2 (length line)) |
40785 | 1144 widest h) |
1145 (while (and (< widest len) | |
1146 (= (aref line widest) ?\ )) | |
1147 (setq widest (1+ widest))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1148 (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
|
1149 (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
|
1150 (if (math-read-big-emptyp h math-rb-v1 widest v) |
40785 | 1151 (setq h widest) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1152 (setq p (list '^ p (math-read-big-rec h math-rb-v1 widest v)) |
40785 | 1153 h widest)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1154 (if (math-read-big-emptyp h math-rb-v1 widest v) |
40785 | 1155 (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
|
1156 (math-read-big-rec h v widest math-rb-v2)) |
40785 | 1157 h widest))) |
1158 | |
1159 ;; Look for an operator name and grab additional terms. | |
1160 (while (and (< h len) | |
1161 (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
|
1162 h math-rb-v1 (1+ h) v) |
40785 | 1163 (math-read-big-emptyp |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1164 h (1+ v) (1+ h) math-rb-v2) |
40785 | 1165 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h) |
1166 (assoc (math-match-substring line 0) | |
1167 math-standard-opers))) | |
1168 (and (>= (nth 2 widest) prec) | |
1169 (setq h (match-end 0))) | |
1170 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h) | |
1171 h)) | |
1172 (setq widest '("2x" * 196 195))))) | |
1173 (cond ((eq (nth 3 widest) -1) | |
1174 (setq p (list (nth 1 widest) p))) | |
1175 ((equal (car widest) "?") | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1176 (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
|
1177 math-rb-v2 baseline nil t))) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1178 (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
|
1179 (math-read-big-error math-read-big-h2 baseline "Expected `:'")) |
40785 | 1180 (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
|
1181 (math-read-big-rec |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1182 (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
|
1183 baseline (nth 3 widest) t)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1184 h math-read-big-h2))) |
40785 | 1185 (t |
1186 (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
|
1187 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2 |
40785 | 1188 baseline (nth 3 widest) t)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1189 h math-read-big-h2)))) |
40785 | 1190 |
1191 ;; 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
|
1192 (setq math-read-big-baseline baseline |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1193 math-read-big-h2 h) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1194 (or short (= math-read-big-h2 math-rb-h2) |
40785 | 1195 (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
|
1196 p))) |
40785 | 1197 |
1198 (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
|
1199 (or (and (>= h math-rb-h1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1200 (< h math-rb-h2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1201 (>= v math-rb-v1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1202 (< v math-rb-v2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1203 (let ((line (nth v math-read-big-lines))) |
40785 | 1204 (and line |
1205 (< h (length line)) | |
1206 (aref line h)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1207 ?\ )) |
40785 | 1208 |
1209 (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
|
1210 (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
|
1211 (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
|
1212 (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
|
1213 (and (> eh2 math-rb-h2) (setq eh2 math-rb-h2)) |
40785 | 1214 (or what (setq what ?\ )) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1215 (let ((p (nthcdr ev1 math-read-big-lines)) |
40785 | 1216 h) |
1217 (while (and (< ev1 ev2) | |
1218 (progn | |
1219 (setq h (min eh2 (length (car p)))) | |
1220 (while (and (>= (setq h (1- h)) eh1) | |
1221 (= (aref (car p) h) what))) | |
1222 (and error (>= h eh1) | |
1223 (math-read-big-error h ev1 (if (stringp error) | |
1224 error | |
1225 "Whitespace expected"))) | |
1226 (< h eh1))) | |
1227 (setq ev1 (1+ ev1) | |
1228 p (cdr p))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1229 (>= ev1 ev2))) |
40785 | 1230 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1231 ;; 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
|
1232 ;; 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
|
1233 ;; math-read-big-expr. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1234 (defvar math-read-big-err-msg) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1235 |
40785 | 1236 (defun math-read-big-error (h v &optional msg) |
1237 (let ((pos 0) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1238 (p math-read-big-lines)) |
40785 | 1239 (while (> v 0) |
1240 (setq pos (+ pos 1 (length (car p))) | |
1241 p (cdr p) | |
1242 v (1- v))) | |
1243 (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
|
1244 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
|
1245 (throw 'syntax nil))) |
40785 | 1246 |
1247 (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
|
1248 (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
|
1249 (len (min math-rb-h2 (length line))) |
40785 | 1250 (count 1)) |
1251 (while (> count 0) | |
1252 (if (>= h len) | |
1253 (if what | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1254 (math-read-big-error nil v (format "Unmatched `%s'" what)) |
40785 | 1255 (setq count 0)) |
1256 (if (memq (aref line h) '(?\( ?\[)) | |
1257 (setq count (1+ count)) | |
1258 (if (if (and commas (= count 1)) | |
1259 (or (memq (aref line h) '(?\) ?\] ?\, ?\;)) | |
1260 (and (eq (aref line h) ?\.) | |
1261 (< (1+ h) len) | |
1262 (eq (aref line (1+ h)) ?\.))) | |
1263 (memq (aref line h) '(?\) ?\]))) | |
1264 (setq count (1- count)))) | |
1265 (setq h (1+ h)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1266 h)) |
40785 | 1267 |
58661
10224395a3c2
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58571
diff
changeset
|
1268 (provide 'calc-lang) |
10224395a3c2
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58571
diff
changeset
|
1269 |
52401 | 1270 ;;; 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
|
1271 ;;; calc-lang.el ends here |