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