Mercurial > emacs
annotate lisp/calc/calc-lang.el @ 87075:e8d46c0f12e6
Require individual files if needed when compiling, rather than
esh-maint. Collect any require statements. Move provide statement to
end. Move any commentary to start.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 05 Dec 2007 07:02:51 +0000 |
parents | 369fadbe988d |
children | e9cba8ba37e1 53108e6cea98 |
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. |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
37 (declare-function math-compose-vector "calccomp" (a sep prec)) |
86969
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
38 (declare-function math-compose-var "calccomp" (a)) |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
39 (declare-function math-tex-expr-is-flat "calccomp" (a)) |
86475
d76be4a4a0a5
(math-read-factor, math-read-expr-level): Declare as functions.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86135
diff
changeset
|
40 (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
|
41 (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
|
42 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
43 ;; Declare variables which are defined elsewhere. |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
44 (defvar calc-lang-slash-idiv) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
45 (defvar calc-lang-allow-underscores) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
46 (defvar math-comp-left-bracket) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
47 (defvar math-comp-right-bracket) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
48 (defvar math-comp-comma) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
49 (defvar math-comp-vector-prec) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
50 |
40785 | 51 ;;; Alternate entry/display languages. |
52 | |
53 (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
|
54 (setq math-expr-opers (or (get lang 'math-oper-table) (math-standard-ops)) |
40785 | 55 math-expr-function-mapping (get lang 'math-function-table) |
56 math-expr-variable-mapping (get lang 'math-variable-table) | |
57 calc-language-input-filter (get lang 'math-input-filter) | |
58 calc-language-output-filter (get lang 'math-output-filter) | |
59 calc-vector-brackets (or (get lang 'math-vector-brackets) "[]") | |
60 calc-complex-format (get lang 'math-complex-format) | |
61 calc-radix-formatter (get lang 'math-radix-formatter) | |
62 calc-function-open (or (get lang 'math-function-open) "(") | |
63 calc-function-close (or (get lang 'math-function-close) ")")) | |
64 (if no-refresh | |
65 (setq calc-language lang | |
66 calc-language-option option) | |
67 (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
|
68 (list lang option) t))) |
40785 | 69 |
70 (defun calc-normal-language () | |
71 (interactive) | |
72 (calc-wrapper | |
73 (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
|
74 (message "Normal language mode"))) |
40785 | 75 |
76 (defun calc-flat-language () | |
77 (interactive) | |
78 (calc-wrapper | |
79 (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
|
80 (message "Flat language mode (all stack entries shown on one line)"))) |
40785 | 81 |
82 (defun calc-big-language () | |
83 (interactive) | |
84 (calc-wrapper | |
85 (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
|
86 (message "\"Big\" language mode"))) |
40785 | 87 |
88 (defun calc-unformatted-language () | |
89 (interactive) | |
90 (calc-wrapper | |
91 (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
|
92 (message "Unformatted language mode"))) |
40785 | 93 |
94 | |
95 (defun calc-c-language () | |
96 (interactive) | |
97 (calc-wrapper | |
98 (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
|
99 (message "`C' language mode"))) |
40785 | 100 |
101 (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
|
102 '( ( "u!" calcFunc-lnot -1 1000 ) |
40785 | 103 ( "~" 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
|
104 ( "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
|
105 ( "u-" neg -1 197 ) |
40785 | 106 ( "*" * 190 191 ) |
107 ( "/" / 190 191 ) | |
108 ( "%" % 190 191 ) | |
109 ( "+" + 180 181 ) | |
110 ( "-" - 180 181 ) | |
111 ( "<<" calcFunc-lsh 170 171 ) | |
112 ( ">>" calcFunc-rsh 170 171 ) | |
113 ( "<" calcFunc-lt 160 161 ) | |
114 ( ">" calcFunc-gt 160 161 ) | |
115 ( "<=" calcFunc-leq 160 161 ) | |
116 ( ">=" calcFunc-geq 160 161 ) | |
117 ( "==" calcFunc-eq 150 151 ) | |
118 ( "!=" calcFunc-neq 150 151 ) | |
119 ( "&" calcFunc-and 140 141 ) | |
120 ( "^" calcFunc-xor 131 130 ) | |
121 ( "|" calcFunc-or 120 121 ) | |
122 ( "&&" calcFunc-land 110 111 ) | |
123 ( "||" calcFunc-lor 100 101 ) | |
124 ( "?" (math-read-if) 91 90 ) | |
125 ( "!!!" calcFunc-pnot -1 88 ) | |
126 ( "&&&" calcFunc-pand 85 86 ) | |
127 ( "|||" calcFunc-por 75 76 ) | |
128 ( "=" calcFunc-assign 51 50 ) | |
129 ( ":=" calcFunc-assign 51 50 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
130 ( "::" calcFunc-condition 45 46 ))) ; should support full assignments |
40785 | 131 |
132 (put 'c 'math-function-table | |
133 '( ( acos . calcFunc-arccos ) | |
134 ( acosh . calcFunc-arccosh ) | |
135 ( asin . calcFunc-arcsin ) | |
136 ( asinh . calcFunc-arcsinh ) | |
137 ( atan . calcFunc-arctan ) | |
138 ( atan2 . calcFunc-arctan2 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
139 ( atanh . calcFunc-arctanh ))) |
40785 | 140 |
141 (put 'c 'math-variable-table | |
142 '( ( M_PI . var-pi ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
143 ( M_E . var-e ))) |
40785 | 144 |
145 (put 'c 'math-vector-brackets "{}") | |
146 | |
147 (put 'c 'math-radix-formatter | |
148 (function (lambda (r s) | |
149 (if (= r 16) (format "0x%s" s) | |
150 (if (= r 8) (format "0%s" s) | |
151 (format "%d#%s" r s)))))) | |
152 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
153 (put 'c 'math-compose-subscr |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
154 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
155 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
156 (let ((args (cdr (cdr a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
157 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
158 (math-compose-expr (nth 1 a) 1000) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
159 "[" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
160 (math-compose-vector args ", " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
161 "]"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
162 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
163 (add-to-list 'calc-lang-slash-idiv 'c) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
164 (add-to-list 'calc-lang-allow-underscores 'c) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
165 (add-to-list 'calc-lang-c-type-hex 'c) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
166 (add-to-list 'calc-lang-brackets-are-subscripts 'c) |
40785 | 167 |
168 (defun calc-pascal-language (n) | |
169 (interactive "P") | |
170 (calc-wrapper | |
171 (and n (setq n (prefix-numeric-value n))) | |
172 (calc-set-language 'pascal n) | |
173 (message (if (and n (/= n 0)) | |
174 (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
|
175 "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
|
176 "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
|
177 "Pascal language mode")))) |
40785 | 178 |
179 (put 'pascal 'math-oper-table | |
180 '( ( "not" calcFunc-lnot -1 1000 ) | |
181 ( "*" * 190 191 ) | |
182 ( "/" / 190 191 ) | |
183 ( "and" calcFunc-and 190 191 ) | |
184 ( "div" calcFunc-idiv 190 191 ) | |
185 ( "mod" % 190 191 ) | |
186 ( "u+" ident -1 185 ) | |
187 ( "u-" neg -1 185 ) | |
188 ( "+" + 180 181 ) | |
189 ( "-" - 180 181 ) | |
190 ( "or" calcFunc-or 180 181 ) | |
191 ( "xor" calcFunc-xor 180 181 ) | |
192 ( "shl" calcFunc-lsh 180 181 ) | |
193 ( "shr" calcFunc-rsh 180 181 ) | |
194 ( "in" calcFunc-in 160 161 ) | |
195 ( "<" calcFunc-lt 160 161 ) | |
196 ( ">" calcFunc-gt 160 161 ) | |
197 ( "<=" calcFunc-leq 160 161 ) | |
198 ( ">=" calcFunc-geq 160 161 ) | |
199 ( "=" calcFunc-eq 160 161 ) | |
200 ( "<>" calcFunc-neq 160 161 ) | |
201 ( "!!!" calcFunc-pnot -1 85 ) | |
202 ( "&&&" calcFunc-pand 80 81 ) | |
203 ( "|||" calcFunc-por 75 76 ) | |
204 ( ":=" calcFunc-assign 51 50 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
205 ( "::" calcFunc-condition 45 46 ))) |
40785 | 206 |
207 (put 'pascal 'math-input-filter 'calc-input-case-filter) | |
208 (put 'pascal 'math-output-filter 'calc-output-case-filter) | |
209 | |
210 (put 'pascal 'math-radix-formatter | |
211 (function (lambda (r s) | |
212 (if (= r 16) (format "$%s" s) | |
213 (format "%d#%s" r s))))) | |
214 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
215 (put 'pascal 'math-lang-read-symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
216 '((?\$ |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
217 (eq (string-match |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
218 "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Z]\\)" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
219 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
220 math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
221 (setq math-exp-token 'number |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
222 math-expr-data (math-match-substring math-exp-str 1) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
223 math-exp-pos (match-end 1))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
224 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
225 (put 'pascal 'math-compose-subscr |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
226 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
227 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
228 (let ((args (cdr (cdr a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
229 (while (eq (car-safe (nth 1 a)) 'calcFunc-subscr) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
230 (setq args (append (cdr (cdr (nth 1 a))) args) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
231 a (nth 1 a))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
232 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
233 (math-compose-expr (nth 1 a) 1000) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
234 "[" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
235 (math-compose-vector args ", " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
236 "]"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
237 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
238 (add-to-list 'calc-lang-allow-underscores 'pascal) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
239 (add-to-list 'calc-lang-brackets-are-subscripts 'pascal) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
240 |
40785 | 241 (defun calc-input-case-filter (str) |
242 (cond ((or (null calc-language-option) (= calc-language-option 0)) | |
243 str) | |
244 (t | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
245 (downcase str)))) |
40785 | 246 |
247 (defun calc-output-case-filter (str) | |
248 (cond ((or (null calc-language-option) (= calc-language-option 0)) | |
249 str) | |
250 ((> calc-language-option 0) | |
251 (upcase str)) | |
252 (t | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
253 (downcase str)))) |
40785 | 254 |
255 | |
256 (defun calc-fortran-language (n) | |
257 (interactive "P") | |
258 (calc-wrapper | |
259 (and n (setq n (prefix-numeric-value n))) | |
260 (calc-set-language 'fortran n) | |
261 (message (if (and n (/= n 0)) | |
262 (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
|
263 "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
|
264 "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
|
265 "FORTRAN language mode")))) |
40785 | 266 |
267 (put 'fortran 'math-oper-table | |
268 '( ( "u/" (math-parse-fortran-vector) -1 1 ) | |
269 ( "/" (math-parse-fortran-vector-end) 1 -1 ) | |
270 ( "**" ^ 201 200 ) | |
271 ( "u+" ident -1 191 ) | |
272 ( "u-" neg -1 191 ) | |
273 ( "*" * 190 191 ) | |
274 ( "/" / 190 191 ) | |
275 ( "+" + 180 181 ) | |
276 ( "-" - 180 181 ) | |
277 ( ".LT." calcFunc-lt 160 161 ) | |
278 ( ".GT." calcFunc-gt 160 161 ) | |
279 ( ".LE." calcFunc-leq 160 161 ) | |
280 ( ".GE." calcFunc-geq 160 161 ) | |
281 ( ".EQ." calcFunc-eq 160 161 ) | |
282 ( ".NE." calcFunc-neq 160 161 ) | |
283 ( ".NOT." calcFunc-lnot -1 121 ) | |
284 ( ".AND." calcFunc-land 110 111 ) | |
285 ( ".OR." calcFunc-lor 100 101 ) | |
286 ( "!!!" calcFunc-pnot -1 85 ) | |
287 ( "&&&" calcFunc-pand 80 81 ) | |
288 ( "|||" calcFunc-por 75 76 ) | |
289 ( "=" calcFunc-assign 51 50 ) | |
290 ( ":=" calcFunc-assign 51 50 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
291 ( "::" calcFunc-condition 45 46 ))) |
40785 | 292 |
293 (put 'fortran 'math-vector-brackets "//") | |
294 | |
295 (put 'fortran 'math-function-table | |
296 '( ( acos . calcFunc-arccos ) | |
297 ( acosh . calcFunc-arccosh ) | |
298 ( aimag . calcFunc-im ) | |
299 ( aint . calcFunc-ftrunc ) | |
300 ( asin . calcFunc-arcsin ) | |
301 ( asinh . calcFunc-arcsinh ) | |
302 ( atan . calcFunc-arctan ) | |
303 ( atan2 . calcFunc-arctan2 ) | |
304 ( atanh . calcFunc-arctanh ) | |
305 ( conjg . calcFunc-conj ) | |
306 ( log . calcFunc-ln ) | |
307 ( nint . calcFunc-round ) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49263
diff
changeset
|
308 ( real . calcFunc-re ))) |
40785 | 309 |
310 (put 'fortran 'math-input-filter 'calc-input-case-filter) | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
311 |
40785 | 312 (put 'fortran 'math-output-filter 'calc-output-case-filter) |
313 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
314 (put 'fortran 'math-lang-read-symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
315 '((?\. |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
316 (eq (string-match "\\.[a-zA-Z][a-zA-Z][a-zA-Z]?\\." |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
317 math-exp-str math-exp-pos) math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
318 (setq math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
319 math-expr-data (upcase (math-match-substring math-exp-str 0)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
320 math-exp-pos (match-end 0))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
321 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
322 (put 'fortran 'math-compose-subscr |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
323 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
324 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
325 (let ((args (cdr (cdr a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
326 (while (eq (car-safe (nth 1 a)) 'calcFunc-subscr) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
327 (setq args (append (cdr (cdr (nth 1 a))) args) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
328 a (nth 1 a))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
329 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
330 (math-compose-expr (nth 1 a) 1000) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
331 "(" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
332 (math-compose-vector args ", " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
333 ")"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
334 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
335 (add-to-list 'calc-lang-slash-idiv 'fortran) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
336 (add-to-list 'calc-lang-allow-underscores 'fortran) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
337 (add-to-list 'calc-lang-parens-are-subscripts 'fortran) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
338 |
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
|
339 ;; 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
|
340 ;; 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
|
341 |
4ca47d70b075
(math-expr-data, math-expr-token, math-exp-old-pos): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58411
diff
changeset
|
342 (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
|
343 (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
|
344 (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
|
345 |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
346 (defvar math-parsing-fortran-vector nil) |
40785 | 347 (defun math-parse-fortran-vector (op) |
348 (let ((math-parsing-fortran-vector '(end . "\000"))) | |
349 (prog1 | |
350 (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
|
351 (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
|
352 math-expr-data (cdr math-parsing-fortran-vector))))) |
40785 | 353 |
354 (defun math-parse-fortran-vector-end (x op) | |
355 (if math-parsing-fortran-vector | |
356 (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
|
357 (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
|
358 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
|
359 math-expr-data "\000") |
40785 | 360 x) |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
361 (throw 'syntax "Unmatched closing `/'"))) |
40785 | 362 |
363 (defun math-parse-fortran-subscr (sym args) | |
364 (setq sym (math-build-var-name sym)) | |
365 (while args | |
366 (setq sym (list 'calcFunc-subscr sym (car args)) | |
367 args (cdr args))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
368 sym) |
40785 | 369 |
370 | |
371 (defun calc-tex-language (n) | |
372 (interactive "P") | |
373 (calc-wrapper | |
374 (and n (setq n (prefix-numeric-value n))) | |
375 (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
|
376 (cond ((not n) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
377 (message "TeX language mode")) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
378 ((= n 0) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
379 (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
|
380 ((= n 1) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
381 (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
|
382 ((> n 1) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
383 (message |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
384 "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
|
385 ((= n -1) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
386 (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
|
387 ((< n -1) |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
388 (message |
9eb004b49fc9
(calc-tex-language): Display more information in messages.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59915
diff
changeset
|
389 "TeX language mode with \\func(\\hbox{var}) and multiline matrices"))))) |
40785 | 390 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
391 (defun calc-latex-language (n) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
392 (interactive "P") |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
393 (calc-wrapper |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
394 (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
|
395 (calc-set-language 'latex n) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
396 (cond ((not n) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
397 (message "LaTeX language mode")) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
398 ((= n 0) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
399 (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
|
400 ((= n 1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
401 (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
|
402 ((> n 1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
403 (message |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
404 "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
|
405 ((= n -1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
406 (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
|
407 ((< n -1) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
408 (message |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
409 "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
|
410 |
40785 | 411 (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
|
412 '( ( "\\hat" calcFunc-hat -1 950 ) |
40785 | 413 ( "\\check" calcFunc-check -1 950 ) |
414 ( "\\tilde" calcFunc-tilde -1 950 ) | |
415 ( "\\acute" calcFunc-acute -1 950 ) | |
416 ( "\\grave" calcFunc-grave -1 950 ) | |
417 ( "\\dot" calcFunc-dot -1 950 ) | |
418 ( "\\ddot" calcFunc-dotdot -1 950 ) | |
419 ( "\\breve" calcFunc-breve -1 950 ) | |
420 ( "\\bar" calcFunc-bar -1 950 ) | |
421 ( "\\vec" calcFunc-Vec -1 950 ) | |
422 ( "\\underline" calcFunc-under -1 950 ) | |
423 ( "u|" calcFunc-abs -1 0 ) | |
424 ( "|" closing 0 -1 ) | |
425 ( "\\lfloor" calcFunc-floor -1 0 ) | |
426 ( "\\rfloor" closing 0 -1 ) | |
427 ( "\\lceil" calcFunc-ceil -1 0 ) | |
428 ( "\\rceil" closing 0 -1 ) | |
429 ( "\\pm" sdev 300 300 ) | |
430 ( "!" calcFunc-fact 210 -1 ) | |
431 ( "^" ^ 201 200 ) | |
432 ( "_" 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
|
433 ( "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
|
434 ( "u-" neg -1 197 ) |
40785 | 435 ( "\\times" * 191 190 ) |
436 ( "*" * 191 190 ) | |
437 ( "2x" * 191 190 ) | |
438 ( "+" + 180 181 ) | |
439 ( "-" - 180 181 ) | |
440 ( "\\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
|
441 ( "/" / 170 171 ) |
40785 | 442 ( "\\choose" calcFunc-choose 170 171 ) |
443 ( "\\mod" % 170 171 ) | |
444 ( "<" calcFunc-lt 160 161 ) | |
445 ( ">" calcFunc-gt 160 161 ) | |
446 ( "\\leq" calcFunc-leq 160 161 ) | |
447 ( "\\geq" calcFunc-geq 160 161 ) | |
448 ( "=" calcFunc-eq 160 161 ) | |
449 ( "\\neq" calcFunc-neq 160 161 ) | |
450 ( "\\ne" calcFunc-neq 160 161 ) | |
451 ( "\\lnot" calcFunc-lnot -1 121 ) | |
452 ( "\\land" calcFunc-land 110 111 ) | |
453 ( "\\lor" calcFunc-lor 100 101 ) | |
454 ( "?" (math-read-if) 91 90 ) | |
455 ( "!!!" calcFunc-pnot -1 85 ) | |
456 ( "&&&" calcFunc-pand 80 81 ) | |
457 ( "|||" calcFunc-por 75 76 ) | |
458 ( "\\gets" calcFunc-assign 51 50 ) | |
459 ( ":=" calcFunc-assign 51 50 ) | |
460 ( "::" calcFunc-condition 45 46 ) | |
461 ( "\\to" calcFunc-evalto 40 41 ) | |
462 ( "\\to" calcFunc-evalto 40 -1 ) | |
463 ( "=>" calcFunc-evalto 40 41 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
464 ( "=>" calcFunc-evalto 40 -1 ))) |
40785 | 465 |
466 (put 'tex 'math-function-table | |
467 '( ( \\arccos . calcFunc-arccos ) | |
468 ( \\arcsin . calcFunc-arcsin ) | |
469 ( \\arctan . calcFunc-arctan ) | |
470 ( \\arg . calcFunc-arg ) | |
471 ( \\cos . calcFunc-cos ) | |
472 ( \\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
|
473 ( \\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
|
474 ( \\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
|
475 ( \\csc . calcFunc-csc ) |
40785 | 476 ( \\det . calcFunc-det ) |
477 ( \\exp . calcFunc-exp ) | |
478 ( \\gcd . calcFunc-gcd ) | |
479 ( \\ln . calcFunc-ln ) | |
480 ( \\log . calcFunc-log10 ) | |
481 ( \\max . calcFunc-max ) | |
482 ( \\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
|
483 ( \\sec . calcFunc-sec ) |
40785 | 484 ( \\sin . calcFunc-sin ) |
485 ( \\sinh . calcFunc-sinh ) | |
486 ( \\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
|
487 ( \\tan . calcFunc-tan ) |
40785 | 488 ( \\tanh . calcFunc-tanh ) |
489 ( \\phi . calcFunc-totient ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
490 ( \\mu . calcFunc-moebius ))) |
40785 | 491 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
492 (put 'tex 'math-special-function-table |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
493 '((calcFunc-sum . (math-compose-tex-sum "\\sum")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
494 (calcFunc-prod . (math-compose-tex-sum "\\prod")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
495 (intv . math-compose-tex-intv))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
496 |
40785 | 497 (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
|
498 '( |
76991373b070
Add Greek letters to math-variable-table properties of tex.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
68636
diff
changeset
|
499 ;; 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
|
500 ( \\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
|
501 ( \\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
|
502 ( \\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
|
503 ( \\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
|
504 ( \\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
|
505 ( \\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
|
506 ( \\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
|
507 ( \\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
|
508 ( \\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
|
509 ( \\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
|
510 ( \\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
|
511 ( \\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
|
512 ( \\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
|
513 ( \\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
|
514 ( \\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
|
515 ( \\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
|
516 ( \\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
|
517 ( \\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
|
518 ( \\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
|
519 ( \\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
|
520 ( \\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
|
521 ( \\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
|
522 ( \\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
|
523 ( \\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
|
524 ( \\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
|
525 ( \\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
|
526 ( \\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
|
527 ( \\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
|
528 ( \\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
|
529 ( \\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
|
530 ( \\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
|
531 ( \\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
|
532 ( \\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
|
533 ( \\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
|
534 ( \\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
|
535 ( \\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
|
536 ( \\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
|
537 ( \\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
|
538 ( \\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
|
539 ( \\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
|
540 ;; Others |
76991373b070
Add Greek letters to math-variable-table properties of tex.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
68636
diff
changeset
|
541 ( \\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
|
542 ( \\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
|
543 ( \\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
|
544 ( \\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
|
545 ( \\prod . (math-parse-tex-sum calcFunc-prod) ))) |
40785 | 546 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
547 (put 'tex 'math-punc-table |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
548 '((?\{ . ?\() |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
549 (?\} . ?\)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
550 (?\& . ?\,))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
551 |
40785 | 552 (put 'tex 'math-complex-format 'i) |
553 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
554 (put 'tex 'math-input-filter 'math-tex-input-filter) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
555 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
556 (put 'tex 'math-matrix-formatter |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
557 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
558 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
559 (if (and (integerp calc-language-option) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
560 (or (= calc-language-option 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
561 (> calc-language-option 1) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
562 (< calc-language-option -1))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
563 (append '(vleft 0 "\\matrix{") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
564 (math-compose-tex-matrix (cdr a)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
565 '("}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
566 (append '(horiz "\\matrix{ ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
567 (math-compose-tex-matrix (cdr a)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
568 '(" }")))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
569 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
570 (put 'tex 'math-var-formatter 'math-compose-tex-var) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
571 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
572 (put 'tex 'math-func-formatter 'math-compose-tex-func) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
573 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
574 (put 'tex 'math-dots "\\ldots") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
575 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
576 (put 'tex 'math-big-parens '("\\left( " . " \\right)")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
577 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
578 (put 'tex 'math-evalto '("\\evalto " . " \\to ")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
579 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
580 (defconst math-tex-ignore-words |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
581 '( ("\\hbox") ("\\mbox") ("\\text") ("\\left") ("\\right") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
582 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
583 ("\\quad") ("\\qquad") ("\\hfil") ("\\hfill") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
584 ("\\displaystyle") ("\\textstyle") ("\\dsize") ("\\tsize") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
585 ("\\scriptstyle") ("\\scriptscriptstyle") ("\\ssize") ("\\sssize") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
586 ("\\rm") ("\\bf") ("\\it") ("\\sl") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
587 ("\\roman") ("\\bold") ("\\italic") ("\\slanted") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
588 ("\\cal") ("\\mit") ("\\Cal") ("\\Bbb") ("\\frak") ("\\goth") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
589 ("\\evalto") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
590 ("\\matrix" mat) ("\\bmatrix" mat) ("\\pmatrix" mat) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
591 ("\\begin" begenv) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
592 ("\\cr" punc ";") ("\\\\" punc ";") ("\\*" punc "*") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
593 ("\\{" punc "[") ("\\}" punc "]"))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
594 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
595 (defconst math-latex-ignore-words |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
596 (append math-tex-ignore-words |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
597 '(("\\begin" begenv)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
598 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
599 (put 'tex 'math-lang-read-symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
600 '((?\\ |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
601 (< math-exp-pos (1- (length math-exp-str))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
602 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
603 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
604 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
605 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
606 math-exp-str math-exp-pos)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
607 (setq math-exp-token 'symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
608 math-exp-pos (match-end 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
609 math-expr-data (math-restore-dashes |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
610 (math-match-substring math-exp-str 1))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
611 (let ((code (assoc math-expr-data math-latex-ignore-words))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
612 (cond ((null code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
613 ((null (cdr code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
614 (math-read-token)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
615 ((eq (nth 1 code) 'punc) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
616 (setq math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
617 math-expr-data (nth 2 code))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
618 ((and (eq (nth 1 code) 'mat) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
619 (string-match " *{" math-exp-str math-exp-pos)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
620 (setq math-exp-pos (match-end 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
621 math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
622 math-expr-data "[") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
623 (let ((right (string-match "}" math-exp-str math-exp-pos))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
624 (and right |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
625 (setq math-exp-str (copy-sequence math-exp-str)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
626 (aset math-exp-str right ?\])))))))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
627 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
628 (defun math-compose-tex-matrix (a &optional ltx) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
629 (if (cdr a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
630 (cons (append (math-compose-vector (cdr (car a)) " & " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
631 (if ltx '(" \\\\ ") '(" \\cr "))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
632 (math-compose-tex-matrix (cdr a) ltx)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
633 (list (math-compose-vector (cdr (car a)) " & " 0)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
634 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
635 (defun math-compose-tex-sum (a fn) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
636 (cond |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
637 ((nth 4 a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
638 (list 'horiz (nth 1 fn) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
639 "_{" (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
640 "=" (math-compose-expr (nth 3 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
641 "}^{" (math-compose-expr (nth 4 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
642 "}{" (math-compose-expr (nth 1 a) 0) "}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
643 ((nth 3 a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
644 (list 'horiz (nth 1 fn) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
645 "_{" (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
646 "=" (math-compose-expr (nth 3 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
647 "}{" (math-compose-expr (nth 1 a) 0) "}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
648 (t |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
649 (list 'horiz (nth 1 fn) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
650 "_{" (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
651 "}{" (math-compose-expr (nth 1 a) 0) "}")))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
652 |
40785 | 653 (defun math-parse-tex-sum (f val) |
654 (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
|
655 (or (equal math-expr-data "_") (throw 'syntax "Expected `_'")) |
40785 | 656 (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
|
657 (setq save math-exp-old-pos) |
40785 | 658 (setq low (math-read-factor)) |
659 (or (eq (car-safe low) 'calcFunc-eq) | |
660 (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
|
661 (setq math-exp-old-pos (1+ save)) |
40785 | 662 (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
|
663 (or (equal math-expr-data "^") (throw 'syntax "Expected `^'")) |
40785 | 664 (math-read-token) |
665 (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
|
666 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high))) |
40785 | 667 |
668 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789. | |
669 (while (string-match "[0-9]\\\\,[0-9]" str) | |
670 (setq str (concat (substring str 0 (1+ (match-beginning 0))) | |
671 (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
|
672 str) |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
673 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
674 ;(defun math-tex-print-sqrt (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
675 ; (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
676 ; "\\sqrt{" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
677 ; (math-compose-expr (nth 1 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
678 ; "}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
679 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
680 (defun math-compose-tex-intv (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
681 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
682 (if (memq (nth 1 a) '(0 1)) "(" "[") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
683 (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
684 " \\ldots " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
685 (math-compose-expr (nth 3 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
686 (if (memq (nth 1 a) '(0 2)) ")" "]"))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
687 |
86969
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
688 (defun math-compose-tex-var (a prec) |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
689 (if (and calc-language-option |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
690 (not (= calc-language-option 0)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
691 (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
692 (symbol-name (nth 1 a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
693 (if (eq calc-language 'latex) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
694 (format "\\text{%s}" (symbol-name (nth 1 a))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
695 (format "\\hbox{%s}" (symbol-name (nth 1 a)))) |
86969
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
696 (math-compose-var a))) |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
697 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
698 (defun math-compose-tex-func (func a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
699 (let (left right) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
700 (if (and calc-language-option |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
701 (not (= calc-language-option 0)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
702 (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" func)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
703 (if (< (prefix-numeric-value calc-language-option) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
704 (setq func (format "\\%s" func)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
705 (setq func (if (eq calc-language 'latex) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
706 (format "\\text{%s}" func) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
707 (format "\\hbox{%s}" func))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
708 (cond ((or (> (length a) 2) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
709 (not (math-tex-expr-is-flat (nth 1 a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
710 (setq left "\\left( " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
711 right " \\right)")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
712 ((and (eq (aref func 0) ?\\) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
713 (not (or |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
714 (string-match "\\hbox{" func) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
715 (string-match "\\text{" func))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
716 (= (length a) 2) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
717 (or (Math-realp (nth 1 a)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
718 (memq (car (nth 1 a)) '(var *)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
719 (setq left "{" right "}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
720 (t (setq left calc-function-open |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
721 right calc-function-close))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
722 (list 'horiz func |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
723 left |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
724 (math-compose-vector (cdr a) ", " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
725 right))) |
40785 | 726 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
727 (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
|
728 (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
|
729 '(( "\\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
|
730 ( "\\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
|
731 ( "\\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
|
732 ( "\\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
|
733 ( "\\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
|
734 ( "\\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
|
735 ( "\\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
|
736 ( "\\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
|
737 ( "\\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
|
738 ( "\\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
|
739 ( "\\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
|
740 ( "\\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
|
741 ( "\\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
|
742 ( "\\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
|
743 ( "\\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
|
744 ( "\\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
|
745 ( "\\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
|
746 ( "\\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
|
747 ( "\\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
|
748 ( "=" 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
|
749 ( "\\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
|
750 ( "\\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
|
751 ( "\\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
|
752 ( "\\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
|
753 ( "\\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
|
754 ( "?" (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
|
755 ( "!!!" 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
|
756 ( "&&&" 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
|
757 ( "|||" 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
|
758 ( "\\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
|
759 ( ":=" 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
|
760 ( "::" 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
|
761 ( "\\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
|
762 ( "\\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
|
763 ( "=>" 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
|
764 ( "=>" calcFunc-evalto 40 -1 )))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
765 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
766 (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
|
767 (append |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
768 (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
|
769 '(( \\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
|
770 ( \\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
|
771 ( \\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
|
772 ( \\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
|
773 ( \\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
|
774 ( \\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
|
775 ( \\phi . calcFunc-totient ) |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
776 ( \\mu . calcFunc-moebius )))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
777 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
778 (put 'latex 'math-special-function-table |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
779 '((/ . (math-compose-latex-frac "\\frac")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
780 (calcFunc-choose . (math-compose-latex-frac "\\binom")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
781 (calcFunc-sum . (math-compose-tex-sum "\\sum")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
782 (calcFunc-prod . (math-compose-tex-sum "\\prod")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
783 (intv . math-compose-tex-intv))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
784 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
785 (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
|
786 (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
|
787 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
788 (put 'latex 'math-punc-table |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
789 '((?\{ . ?\() |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
790 (?\} . ?\)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
791 (?\& . ?\,))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
792 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
793 (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
|
794 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
795 (put 'latex 'math-matrix-formatter |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
796 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
797 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
798 (if (and (integerp calc-language-option) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
799 (or (= calc-language-option 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
800 (> calc-language-option 1) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
801 (< calc-language-option -1))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
802 (append '(vleft 0 "\\begin{pmatrix}") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
803 (math-compose-tex-matrix (cdr a) t) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
804 '("\\end{pmatrix}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
805 (append '(horiz "\\begin{pmatrix} ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
806 (math-compose-tex-matrix (cdr a) t) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
807 '(" \\end{pmatrix}")))))) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
808 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
809 (put 'latex 'math-var-formatter 'math-compose-tex-var) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
810 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
811 (put 'latex 'math-func-formatter 'math-compose-tex-func) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
812 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
813 (put 'latex 'math-dots "\\ldots") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
814 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
815 (put 'latex 'math-big-parens '("\\left( " . " \\right)")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
816 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
817 (put 'latex 'math-evalto '("\\evalto " . " \\to ")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
818 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
819 (put 'latex 'math-lang-read-symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
820 '((?\\ |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
821 (< math-exp-pos (1- (length math-exp-str))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
822 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
823 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
824 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
825 (string-match "\\\\text *{\\([a-zA-Z0-9]+\\)}" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
826 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
827 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
828 math-exp-str math-exp-pos)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
829 (setq math-exp-token 'symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
830 math-exp-pos (match-end 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
831 math-expr-data (math-restore-dashes |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
832 (math-match-substring math-exp-str 1))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
833 (let ((code (assoc math-expr-data math-tex-ignore-words)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
834 envname) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
835 (cond ((null code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
836 ((null (cdr code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
837 (math-read-token)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
838 ((eq (nth 1 code) 'punc) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
839 (setq math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
840 math-expr-data (nth 2 code))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
841 ((and (eq (nth 1 code) 'begenv) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
842 (string-match " *{\\([^}]*\\)}" math-exp-str math-exp-pos)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
843 (setq math-exp-pos (match-end 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
844 envname (match-string 1 math-exp-str) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
845 math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
846 math-expr-data "[") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
847 (cond ((or (string= envname "matrix") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
848 (string= envname "bmatrix") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
849 (string= envname "smallmatrix") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
850 (string= envname "pmatrix")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
851 (if (string-match (concat "\\\\end{" envname "}") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
852 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
853 (setq math-exp-str |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
854 (replace-match "]" t t math-exp-str)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
855 (error "%s" (concat "No closing \\end{" envname "}")))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
856 ((and (eq (nth 1 code) 'mat) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
857 (string-match " *{" math-exp-str math-exp-pos)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
858 (setq math-exp-pos (match-end 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
859 math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
860 math-expr-data "[") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
861 (let ((right (string-match "}" math-exp-str math-exp-pos))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
862 (and right |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
863 (setq math-exp-str (copy-sequence math-exp-str)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
864 (aset math-exp-str right ?\])))))))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
865 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
866 (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
|
867 (let (numer denom) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
868 (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
|
869 (math-read-token) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
870 (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
|
871 (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
|
872 (Math-num-integerp denom)) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
873 (list 'frac numer denom) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
874 (list '/ numer denom)))) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
875 |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
876 (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
|
877 (let (first second) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
878 (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
|
879 (math-read-token) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
880 (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
|
881 (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
|
882 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
883 (defun math-compose-latex-frac (a fn) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
884 (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
|
885 "}{" |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
886 (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
|
887 "}")) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
888 |
59819
dea78c6f5e48
(math-latex-input-filter): Remove function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59811
diff
changeset
|
889 (put 'latex 'math-input-filter 'math-tex-input-filter) |
40785 | 890 |
891 (defun calc-eqn-language (n) | |
892 (interactive "P") | |
893 (calc-wrapper | |
894 (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
|
895 (message "Eqn language mode"))) |
40785 | 896 |
897 (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
|
898 '( ( "prime" (math-parse-eqn-prime) 950 -1 ) |
40785 | 899 ( "prime" calcFunc-Prime 950 -1 ) |
900 ( "dot" calcFunc-dot 950 -1 ) | |
901 ( "dotdot" calcFunc-dotdot 950 -1 ) | |
902 ( "hat" calcFunc-hat 950 -1 ) | |
903 ( "tilde" calcFunc-tilde 950 -1 ) | |
904 ( "vec" calcFunc-Vec 950 -1 ) | |
905 ( "dyad" calcFunc-dyad 950 -1 ) | |
906 ( "bar" calcFunc-bar 950 -1 ) | |
907 ( "under" calcFunc-under 950 -1 ) | |
908 ( "sub" calcFunc-subscr 931 930 ) | |
909 ( "sup" ^ 921 920 ) | |
910 ( "sqrt" calcFunc-sqrt -1 910 ) | |
911 ( "over" / 900 901 ) | |
912 ( "u|" calcFunc-abs -1 0 ) | |
913 ( "|" closing 0 -1 ) | |
914 ( "left floor" calcFunc-floor -1 0 ) | |
915 ( "right floor" closing 0 -1 ) | |
916 ( "left ceil" calcFunc-ceil -1 0 ) | |
917 ( "right ceil" closing 0 -1 ) | |
918 ( "+-" sdev 300 300 ) | |
919 ( "!" 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
|
920 ( "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
|
921 ( "u-" neg -1 197 ) |
40785 | 922 ( "times" * 191 190 ) |
923 ( "*" * 191 190 ) | |
924 ( "2x" * 191 190 ) | |
925 ( "/" / 180 181 ) | |
926 ( "%" % 180 181 ) | |
927 ( "+" + 170 171 ) | |
928 ( "-" - 170 171 ) | |
929 ( "<" calcFunc-lt 160 161 ) | |
930 ( ">" calcFunc-gt 160 161 ) | |
931 ( "<=" calcFunc-leq 160 161 ) | |
932 ( ">=" calcFunc-geq 160 161 ) | |
933 ( "=" calcFunc-eq 160 161 ) | |
934 ( "==" calcFunc-eq 160 161 ) | |
935 ( "!=" calcFunc-neq 160 161 ) | |
936 ( "u!" calcFunc-lnot -1 121 ) | |
937 ( "&&" calcFunc-land 110 111 ) | |
938 ( "||" calcFunc-lor 100 101 ) | |
939 ( "?" (math-read-if) 91 90 ) | |
940 ( "!!!" calcFunc-pnot -1 85 ) | |
941 ( "&&&" calcFunc-pand 80 81 ) | |
942 ( "|||" calcFunc-por 75 76 ) | |
943 ( "<-" calcFunc-assign 51 50 ) | |
944 ( ":=" calcFunc-assign 51 50 ) | |
945 ( "::" calcFunc-condition 45 46 ) | |
946 ( "->" calcFunc-evalto 40 41 ) | |
947 ( "->" calcFunc-evalto 40 -1 ) | |
948 ( "=>" calcFunc-evalto 40 41 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
949 ( "=>" calcFunc-evalto 40 -1 ))) |
40785 | 950 |
951 (put 'eqn 'math-function-table | |
952 '( ( arc\ cos . calcFunc-arccos ) | |
953 ( arc\ cosh . calcFunc-arccosh ) | |
954 ( arc\ sin . calcFunc-arcsin ) | |
955 ( arc\ sinh . calcFunc-arcsinh ) | |
956 ( arc\ tan . calcFunc-arctan ) | |
957 ( arc\ tanh . calcFunc-arctanh ) | |
958 ( GAMMA . calcFunc-gamma ) | |
959 ( phi . calcFunc-totient ) | |
960 ( mu . calcFunc-moebius ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
961 ( matrix . (math-parse-eqn-matrix) ))) |
40785 | 962 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
963 (put 'eqn 'math-special-function-table |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
964 '((intv . math-compose-eqn-intv))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
965 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
966 (put 'eqn 'math-punc-table |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
967 '((?\{ . ?\() |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
968 (?\} . ?\)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
969 |
40785 | 970 (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
|
971 '( ( inf . var-uinf ))) |
40785 | 972 |
973 (put 'eqn 'math-complex-format 'i) | |
974 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
975 (put 'eqn 'math-big-parens '("{left ( " . " right )}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
976 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
977 (put 'eqn 'math-evalto '("evalto " . " -> ")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
978 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
979 (put 'eqn 'math-matrix-formatter |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
980 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
981 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
982 (append '(horiz "matrix { ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
983 (math-compose-eqn-matrix |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
984 (cdr (math-transpose a))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
985 '("}"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
986 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
987 (put 'eqn 'math-var-formatter |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
988 (function |
86969
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
989 (lambda (a prec) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
990 (let (v) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
991 (if (and math-compose-hash-args |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
992 (let ((p calc-arg-values)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
993 (setq v 1) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
994 (while (and p (not (equal (car p) a))) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
995 (setq p (and (eq math-compose-hash-args t) (cdr p)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
996 v (1+ v))) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
997 p)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
998 (if (eq math-compose-hash-args 1) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
999 "#" |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1000 (format "#%d" v)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1001 (if (string-match ".'\\'" (symbol-name (nth 2 a))) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1002 (math-compose-expr |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1003 (list 'calcFunc-Prime |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1004 (list |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1005 'var |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1006 (intern (substring (symbol-name (nth 1 a)) 0 -1)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1007 (intern (substring (symbol-name (nth 2 a)) 0 -1)))) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1008 prec) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1009 (symbol-name (nth 1 a)))))))) |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1010 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1011 (defconst math-eqn-special-funcs |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1012 '( calcFunc-log |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1013 calcFunc-ln calcFunc-exp |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1014 calcFunc-sin calcFunc-cos calcFunc-tan |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1015 calcFunc-sec calcFunc-csc calcFunc-cot |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1016 calcFunc-sinh calcFunc-cosh calcFunc-tanh |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1017 calcFunc-sech calcFunc-csch calcFunc-coth |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1018 calcFunc-arcsin calcFunc-arccos calcFunc-arctan |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1019 calcFunc-arcsinh calcFunc-arccosh calcFunc-arctanh)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1020 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1021 (put 'eqn 'math-func-formatter |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1022 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1023 (lambda (func a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1024 (let (left right) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1025 (if (string-match "[^']'+\\'" func) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1026 (let ((n (- (length func) (match-beginning 0) 1))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1027 (setq func (substring func 0 (- n))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1028 (while (>= (setq n (1- n)) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1029 (setq func (concat func " prime"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1030 (cond ((or (> (length a) 2) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1031 (not (math-tex-expr-is-flat (nth 1 a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1032 (setq left "{left ( " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1033 right " right )}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1034 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1035 ((and |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1036 (memq (car a) math-eqn-special-funcs) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1037 (= (length a) 2) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1038 (or (Math-realp (nth 1 a)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1039 (memq (car (nth 1 a)) '(var *)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1040 (setq left "~{" right "}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1041 (t |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1042 (setq left " ( " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1043 right " )"))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1044 (list 'horiz func left |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1045 (math-compose-vector (cdr a) " , " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1046 right))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1047 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1048 (put 'eqn 'math-lang-read-symbol |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1049 '((?\" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1050 (string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1051 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1052 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1053 (setq math-exp-str (copy-sequence math-exp-str)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1054 (aset math-exp-str (match-beginning 1) ?\{) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1055 (if (< (match-end 1) (length math-exp-str)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1056 (aset math-exp-str (match-end 1) ?\})) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1057 (math-read-token))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1058 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1059 (defconst math-eqn-ignore-words |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1060 '( ("roman") ("bold") ("italic") ("mark") ("lineup") ("evalto") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1061 ("left" ("floor") ("ceil")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1062 ("right" ("floor") ("ceil")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1063 ("arc" ("sin") ("cos") ("tan") ("sinh") ("cosh") ("tanh")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1064 ("size" n) ("font" n) ("fwd" n) ("back" n) ("up" n) ("down" n) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1065 ("above" punc ","))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1066 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1067 (put 'eqn 'math-lang-adjust-words |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1068 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1069 (lambda () |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1070 (let ((code (assoc math-expr-data math-eqn-ignore-words))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1071 (cond ((null code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1072 ((null (cdr code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1073 (math-read-token)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1074 ((consp (nth 1 code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1075 (math-read-token) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1076 (if (assoc math-expr-data (cdr code)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1077 (setq math-expr-data (format "%s %s" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1078 (car code) math-expr-data)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1079 ((eq (nth 1 code) 'punc) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1080 (setq math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1081 math-expr-data (nth 2 code))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1082 (t |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1083 (math-read-token) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1084 (math-read-token))))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1085 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1086 (put 'eqn 'math-lang-read |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1087 '((eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1088 math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1089 math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1090 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1091 (setq math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1092 math-expr-data (math-match-substring math-exp-str 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1093 math-exp-pos (match-end 0)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1094 (and (eq (string-match "\\\\dots\\." math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1095 math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1096 (setq math-exp-pos (match-end 0))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1097 (if (memq (aref math-expr-data 0) '(?~ ?^)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1098 (math-read-token))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1099 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1100 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1101 (defun math-compose-eqn-matrix (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1102 (if a |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1103 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1104 (cond ((eq calc-matrix-just 'right) "rcol ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1105 ((eq calc-matrix-just 'center) "ccol ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1106 (t "lcol ")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1107 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1108 (list 'break math-compose-level) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1109 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1110 "{ " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1111 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1112 (let ((math-compose-level (1+ math-compose-level))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1113 (math-compose-vector (cdr (car a)) " above " 1000)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1114 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1115 " } " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1116 (math-compose-eqn-matrix (cdr a))))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1117 nil)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1118 |
40785 | 1119 (defun math-parse-eqn-matrix (f sym) |
1120 (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
|
1121 (while (assoc math-expr-data '(("ccol") ("lcol") ("rcol"))) |
40785 | 1122 (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
|
1123 (or (equal math-expr-data calc-function-open) |
40785 | 1124 (throw 'syntax "Expected `{'")) |
1125 (math-read-token) | |
1126 (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
|
1127 (or (equal math-expr-data calc-function-close) |
40785 | 1128 (throw 'syntax "Expected `}'")) |
1129 (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
|
1130 (or (equal math-expr-data calc-function-close) |
40785 | 1131 (throw 'syntax "Expected `}'")) |
1132 (math-read-token) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1133 (math-transpose (cons 'vec (nreverse vec))))) |
40785 | 1134 |
1135 (defun math-parse-eqn-prime (x sym) | |
1136 (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
|
1137 (if (equal math-expr-data calc-function-open) |
40785 | 1138 (progn |
1139 (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
|
1140 (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
|
1141 (eq math-exp-token 'end)) |
40785 | 1142 nil |
1143 (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
|
1144 (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
|
1145 (eq math-exp-token 'end))) |
40785 | 1146 (throw 'syntax "Expected `)'")) |
1147 (math-read-token) | |
1148 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args))) | |
1149 (list 'var | |
1150 (intern (concat (symbol-name (nth 1 x)) "'")) | |
1151 (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
|
1152 (list 'calcFunc-Prime x))) |
40785 | 1153 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1154 (defun math-compose-eqn-intv (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1155 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1156 (if (memq (nth 1 a) '(0 1)) "(" "[") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1157 (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1158 " ... " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1159 (math-compose-expr (nth 3 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1160 (if (memq (nth 1 a) '(0 2)) ")" "]"))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1161 |
40785 | 1162 |
1163 (defun calc-mathematica-language () | |
1164 (interactive) | |
1165 (calc-wrapper | |
1166 (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
|
1167 (message "Mathematica language mode"))) |
40785 | 1168 |
1169 (put 'math 'math-oper-table | |
1170 '( ( "[[" (math-read-math-subscr) 250 -1 ) | |
1171 ( "!" calcFunc-fact 210 -1 ) | |
1172 ( "!!" calcFunc-dfact 210 -1 ) | |
1173 ( "^" ^ 201 200 ) | |
1174 ( "u+" ident -1 197 ) | |
1175 ( "u-" neg -1 197 ) | |
1176 ( "/" / 195 196 ) | |
1177 ( "*" * 190 191 ) | |
1178 ( "2x" * 190 191 ) | |
1179 ( "+" + 180 181 ) | |
1180 ( "-" - 180 181 ) | |
1181 ( "<" calcFunc-lt 160 161 ) | |
1182 ( ">" calcFunc-gt 160 161 ) | |
1183 ( "<=" calcFunc-leq 160 161 ) | |
1184 ( ">=" calcFunc-geq 160 161 ) | |
1185 ( "==" calcFunc-eq 150 151 ) | |
1186 ( "!=" calcFunc-neq 150 151 ) | |
1187 ( "u!" calcFunc-lnot -1 121 ) | |
1188 ( "&&" calcFunc-land 110 111 ) | |
1189 ( "||" calcFunc-lor 100 101 ) | |
1190 ( "!!!" calcFunc-pnot -1 85 ) | |
1191 ( "&&&" calcFunc-pand 80 81 ) | |
1192 ( "|||" calcFunc-por 75 76 ) | |
1193 ( ":=" calcFunc-assign 51 50 ) | |
1194 ( "=" calcFunc-assign 51 50 ) | |
1195 ( "->" calcFunc-assign 51 50 ) | |
1196 ( ":>" calcFunc-assign 51 50 ) | |
1197 ( "::" calcFunc-condition 45 46 ) | |
1198 )) | |
1199 | |
1200 (put 'math 'math-function-table | |
1201 '( ( Abs . calcFunc-abs ) | |
1202 ( ArcCos . calcFunc-arccos ) | |
1203 ( ArcCosh . calcFunc-arccosh ) | |
1204 ( ArcSin . calcFunc-arcsin ) | |
1205 ( ArcSinh . calcFunc-arcsinh ) | |
1206 ( ArcTan . calcFunc-arctan ) | |
1207 ( ArcTanh . calcFunc-arctanh ) | |
1208 ( Arg . calcFunc-arg ) | |
1209 ( Binomial . calcFunc-choose ) | |
1210 ( Ceiling . calcFunc-ceil ) | |
1211 ( Conjugate . calcFunc-conj ) | |
1212 ( Cos . calcFunc-cos ) | |
1213 ( 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
|
1214 ( 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
|
1215 ( 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
|
1216 ( 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
|
1217 ( Csch . calcFunc-csch ) |
40785 | 1218 ( D . calcFunc-deriv ) |
1219 ( Dt . calcFunc-tderiv ) | |
1220 ( Det . calcFunc-det ) | |
1221 ( Exp . calcFunc-exp ) | |
1222 ( EulerPhi . calcFunc-totient ) | |
1223 ( Floor . calcFunc-floor ) | |
1224 ( Gamma . calcFunc-gamma ) | |
1225 ( GCD . calcFunc-gcd ) | |
1226 ( If . calcFunc-if ) | |
1227 ( Im . calcFunc-im ) | |
1228 ( Inverse . calcFunc-inv ) | |
1229 ( Integrate . calcFunc-integ ) | |
1230 ( Join . calcFunc-vconcat ) | |
1231 ( LCM . calcFunc-lcm ) | |
1232 ( Log . calcFunc-ln ) | |
1233 ( Max . calcFunc-max ) | |
1234 ( Min . calcFunc-min ) | |
1235 ( Mod . calcFunc-mod ) | |
1236 ( MoebiusMu . calcFunc-moebius ) | |
1237 ( Random . calcFunc-random ) | |
1238 ( Round . calcFunc-round ) | |
1239 ( 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
|
1240 ( 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
|
1241 ( Sech . calcFunc-sech ) |
40785 | 1242 ( Sign . calcFunc-sign ) |
1243 ( Sin . calcFunc-sin ) | |
1244 ( Sinh . calcFunc-sinh ) | |
1245 ( Sqrt . calcFunc-sqrt ) | |
1246 ( Tan . calcFunc-tan ) | |
1247 ( Tanh . calcFunc-tanh ) | |
1248 ( Transpose . calcFunc-trn ) | |
1249 ( Length . calcFunc-vlen ) | |
1250 )) | |
1251 | |
1252 (put 'math 'math-variable-table | |
1253 '( ( I . var-i ) | |
1254 ( Pi . var-pi ) | |
1255 ( E . var-e ) | |
1256 ( GoldenRatio . var-phi ) | |
1257 ( EulerGamma . var-gamma ) | |
1258 ( Infinity . var-inf ) | |
1259 ( ComplexInfinity . var-uinf ) | |
1260 ( Indeterminate . var-nan ) | |
1261 )) | |
1262 | |
1263 (put 'math 'math-vector-brackets "{}") | |
1264 (put 'math 'math-complex-format 'I) | |
1265 (put 'math 'math-function-open "[") | |
1266 (put 'math 'math-function-close "]") | |
1267 | |
1268 (put 'math 'math-radix-formatter | |
1269 (function (lambda (r s) (format "%d^^%s" r s)))) | |
1270 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1271 (put 'math 'math-lang-read |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1272 '((eq (string-match "\\[\\[\\|->\\|:>" math-exp-str math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1273 math-exp-pos) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1274 (setq math-exp-token 'punc |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1275 math-expr-data (math-match-substring math-exp-str 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1276 math-exp-pos (match-end 0)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1277 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1278 (put 'math 'math-compose-subscr |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1279 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1280 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1281 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1282 (math-compose-expr (nth 1 a) 1000) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1283 "[[" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1284 (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1285 "]]")))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1286 |
40785 | 1287 (defun math-read-math-subscr (x op) |
1288 (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
|
1289 (or (and (equal math-expr-data "]") |
40785 | 1290 (progn |
1291 (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
|
1292 (equal math-expr-data "]"))) |
40785 | 1293 (throw 'syntax "Expected ']]'")) |
1294 (math-read-token) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1295 (list 'calcFunc-subscr x idx))) |
40785 | 1296 |
1297 | |
1298 (defun calc-maple-language () | |
1299 (interactive) | |
1300 (calc-wrapper | |
1301 (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
|
1302 (message "Maple language mode"))) |
40785 | 1303 |
1304 (put 'maple 'math-oper-table | |
1305 '( ( "matrix" ident -1 300 ) | |
1306 ( "MATRIX" ident -1 300 ) | |
1307 ( "!" calcFunc-fact 210 -1 ) | |
1308 ( "^" ^ 201 200 ) | |
1309 ( "**" ^ 201 200 ) | |
1310 ( "u+" ident -1 197 ) | |
1311 ( "u-" neg -1 197 ) | |
1312 ( "/" / 191 192 ) | |
1313 ( "*" * 191 192 ) | |
1314 ( "intersect" calcFunc-vint 191 192 ) | |
1315 ( "+" + 180 181 ) | |
1316 ( "-" - 180 181 ) | |
1317 ( "union" calcFunc-vunion 180 181 ) | |
1318 ( "minus" calcFunc-vdiff 180 181 ) | |
1319 ( "mod" % 170 170 ) | |
1320 ( ".." (math-read-maple-dots) 165 165 ) | |
1321 ( "\\dots" (math-read-maple-dots) 165 165 ) | |
1322 ( "<" calcFunc-lt 160 160 ) | |
1323 ( ">" calcFunc-gt 160 160 ) | |
1324 ( "<=" calcFunc-leq 160 160 ) | |
1325 ( ">=" calcFunc-geq 160 160 ) | |
1326 ( "=" calcFunc-eq 160 160 ) | |
1327 ( "<>" calcFunc-neq 160 160 ) | |
1328 ( "not" calcFunc-lnot -1 121 ) | |
1329 ( "and" calcFunc-land 110 111 ) | |
1330 ( "or" calcFunc-lor 100 101 ) | |
1331 ( "!!!" calcFunc-pnot -1 85 ) | |
1332 ( "&&&" calcFunc-pand 80 81 ) | |
1333 ( "|||" calcFunc-por 75 76 ) | |
1334 ( ":=" calcFunc-assign 51 50 ) | |
1335 ( "::" calcFunc-condition 45 46 ) | |
1336 )) | |
1337 | |
1338 (put 'maple 'math-function-table | |
1339 '( ( bernoulli . calcFunc-bern ) | |
1340 ( binomial . calcFunc-choose ) | |
1341 ( diff . calcFunc-deriv ) | |
1342 ( GAMMA . calcFunc-gamma ) | |
1343 ( ifactor . calcFunc-prfac ) | |
1344 ( igcd . calcFunc-gcd ) | |
1345 ( ilcm . calcFunc-lcm ) | |
1346 ( int . calcFunc-integ ) | |
1347 ( modp . % ) | |
1348 ( irem . % ) | |
1349 ( iquo . calcFunc-idiv ) | |
1350 ( isprime . calcFunc-prime ) | |
1351 ( length . calcFunc-vlen ) | |
1352 ( member . calcFunc-in ) | |
1353 ( crossprod . calcFunc-cross ) | |
1354 ( inverse . calcFunc-inv ) | |
1355 ( trace . calcFunc-tr ) | |
1356 ( transpose . calcFunc-trn ) | |
1357 ( vectdim . calcFunc-vlen ) | |
1358 )) | |
1359 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1360 (put 'maple 'math-special-function-table |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1361 '((intv . math-compose-maple-intv))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1362 |
40785 | 1363 (put 'maple 'math-variable-table |
1364 '( ( I . var-i ) | |
1365 ( Pi . var-pi ) | |
1366 ( E . var-e ) | |
1367 ( infinity . var-inf ) | |
1368 ( infinity . var-uinf ) | |
1369 ( infinity . var-nan ) | |
1370 )) | |
1371 | |
1372 (put 'maple 'math-complex-format 'I) | |
1373 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1374 (put 'maple 'math-matrix-formatter |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1375 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1376 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1377 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1378 "matrix(" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1379 math-comp-left-bracket |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1380 (math-compose-vector (cdr a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1381 (concat math-comp-comma " ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1382 math-comp-vector-prec) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1383 math-comp-right-bracket |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1384 ")")))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1385 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1386 (put 'maple 'math-compose-subscr |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1387 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1388 (lambda (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1389 (let ((args (cdr (cdr a)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1390 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1391 (math-compose-expr (nth 1 a) 1000) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1392 "[" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1393 (math-compose-vector args ", " 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1394 "]"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1395 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1396 (add-to-list 'calc-lang-allow-underscores 'maple) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1397 (add-to-list 'calc-lang-brackets-are-subscripts 'maple) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1398 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1399 (defun math-compose-maple-intv (a) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1400 (list 'horiz |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1401 (math-compose-expr (nth 2 a) 0) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1402 " .. " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1403 (math-compose-expr (nth 3 a) 0))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1404 |
40785 | 1405 (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
|
1406 (list 'intv 3 x (math-read-expr-level (nth 3 op)))) |
40785 | 1407 |
1408 | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1409 ;; 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
|
1410 ;; 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
|
1411 ;; 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
|
1412 ;; 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
|
1413 ;; 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
|
1414 ;; math-read-big-balance. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1415 (defvar math-read-big-lines) |
40785 | 1416 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1417 ;; 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
|
1418 ;; 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
|
1419 ;; math-read-big-rec. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1420 (defvar math-read-big-baseline) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1421 (defvar math-read-big-h2) |
40785 | 1422 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1423 ;; 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
|
1424 ;; 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
|
1425 ;; 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
|
1426 ;; math-read-big-rec. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1427 ;; 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
|
1428 ;; which calls math-read-big-balance. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1429 (defvar math-rb-h1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1430 (defvar math-rb-h2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1431 (defvar math-rb-v1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1432 (defvar math-rb-v2) |
40785 | 1433 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1434 (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
|
1435 &optional baseline prec short) |
40785 | 1436 (or prec (setq prec 0)) |
1437 | |
1438 ;; Clip whitespace above or below. | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1439 (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
|
1440 (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
|
1441 (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
|
1442 (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
|
1443 (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
|
1444 (setq math-rb-v2 (1- math-rb-v2))) |
40785 | 1445 |
1446 ;; 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
|
1447 (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
|
1448 (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
|
1449 (> 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
|
1450 (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
|
1451 (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
|
1452 (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
|
1453 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
|
1454 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
|
1455 math-rb-h2 (math-read-expr |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1456 (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
|
1457 (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
|
1458 (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
|
1459 (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
|
1460 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
|
1461 math-rb-h2)) |
40785 | 1462 |
1463 ;; 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
|
1464 (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
|
1465 (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
|
1466 (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
|
1467 (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
|
1468 (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
|
1469 (setq math-rb-h2 (1- math-rb-h2))) |
40785 | 1470 |
1471 ;; Scan to find widest left-justified "----" in the region. | |
1472 (let* ((widest nil) | |
1473 (widest-h2 0) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1474 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines)) |
40785 | 1475 (p lines-v1) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1476 (v math-rb-v1) |
40785 | 1477 (other-v nil) |
1478 other-char line len h) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1479 (while (< v math-rb-v2) |
40785 | 1480 (setq line (car p) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1481 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
|
1482 (and (< math-rb-h1 len) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1483 (/= (aref line math-rb-h1) ?\ ) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1484 (if (and (= (aref line math-rb-h1) ?\-) |
40785 | 1485 ;; 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
|
1486 (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
|
1487 (= (aref line (1+ math-rb-h1)) ?\-)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1488 (/= (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
|
1489 (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ ))) |
40785 | 1490 (progn |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1491 (setq h math-rb-h1) |
40785 | 1492 (while (and (< (setq h (1+ h)) len) |
1493 (= (aref line h) ?\-))) | |
1494 (if (> h widest-h2) | |
1495 (setq widest v | |
1496 widest-h2 h))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1497 (or other-v (setq other-v v other-char (aref line math-rb-h1))))) |
40785 | 1498 (setq v (1+ v) |
1499 p (cdr p))) | |
1500 | |
1501 (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
|
1502 (math-read-big-error math-rb-h1 math-rb-v1)) ; Should never happen! |
40785 | 1503 |
1504 ;; Quotient. | |
1505 (widest | |
1506 (setq h widest-h2 | |
1507 v widest) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1508 (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
|
1509 (den (math-read-big-rec math-rb-h1 (1+ v) h math-rb-v2))) |
40785 | 1510 (setq p (if (and (math-integerp num) (math-integerp den)) |
1511 (math-make-frac num den) | |
1512 (list '/ num den))))) | |
1513 | |
1514 ;; Big radical sign. | |
1515 ((= other-char ?\\) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1516 (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
|
1517 (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
|
1518 (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
|
1519 (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
|
1520 (or (= (math-read-big-char (setq h (+ math-rb-h1 2)) v) ?\_) |
40785 | 1521 (math-read-big-error h v "Malformed root sign")) |
1522 (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
|
1523 (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
|
1524 (math-read-big-emptyp math-rb-h1 (1+ other-v) h math-rb-v2 nil t) |
40785 | 1525 (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
|
1526 (+ math-rb-h1 2) (1+ v) |
40785 | 1527 h (1+ other-v) baseline)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1528 v math-read-big-baseline)) |
40785 | 1529 |
1530 ;; Small radical sign. | |
1531 ((and (= other-char ?V) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1532 (= (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
|
1533 (setq h (1+ math-rb-h1)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1534 (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
|
1535 (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
|
1536 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t) |
40785 | 1537 (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_)) |
1538 (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
|
1539 (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
|
1540 v math-read-big-baseline)) |
40785 | 1541 |
1542 ;; Binomial coefficient. | |
1543 ((and (= other-char ?\() | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1544 (= (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
|
1545 (= (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
|
1546 math-rb-h1) math-rb-h1)) |
40785 | 1547 (setq h (match-end 0)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1548 (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
|
1549 (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
|
1550 (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
|
1551 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1552 (setq p (list 'calcFunc-choose |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1553 (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
|
1554 (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
|
1555 (1- h) math-rb-v2)))) |
40785 | 1556 |
1557 ;; Minus sign. | |
1558 ((= other-char ?\-) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1559 (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
|
1560 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
|
1561 v math-read-big-baseline |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1562 h math-read-big-h2)) |
40785 | 1563 |
1564 ;; Parentheses. | |
1565 ((= other-char ?\() | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1566 (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
|
1567 (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
|
1568 (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
|
1569 (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
|
1570 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1571 (let ((sep (math-read-big-char (1- h) v)) |
1572 hmid) | |
1573 (if (= sep ?\.) | |
1574 (setq h (1+ h))) | |
1575 (if (= sep ?\]) | |
1576 (math-read-big-error (1- h) v "Expected `)'")) | |
1577 (if (= sep ?\)) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1578 (setq p (math-read-big-rec |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1579 (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v)) |
40785 | 1580 (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
|
1581 p (list p |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1582 (math-read-big-rec h math-rb-v1 (1- hmid) math-rb-v2 v)) |
40785 | 1583 h hmid) |
1584 (cond ((= sep ?\.) | |
1585 (setq p (cons 'intv (cons (if (= (math-read-big-char | |
1586 (1- h) v) | |
1587 ?\)) | |
1588 0 1) | |
1589 p)))) | |
1590 ((= (math-read-big-char (1- h) v) ?\]) | |
1591 (math-read-big-error (1- h) v "Expected `)'")) | |
1592 ((= sep ?\,) | |
1593 (or (and (math-realp (car p)) (math-realp (nth 1 p))) | |
1594 (math-read-big-error | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1595 math-rb-h1 v "Complex components must be real")) |
40785 | 1596 (setq p (cons 'cplx p))) |
1597 ((= sep ?\;) | |
1598 (or (and (math-realp (car p)) (math-anglep (nth 1 p))) | |
1599 (math-read-big-error | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1600 math-rb-h1 v "Complex components must be real")) |
40785 | 1601 (setq p (cons 'polar p))))))) |
1602 | |
1603 ;; Matrix. | |
1604 ((and (= other-char ?\[) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1605 (or (= (math-read-big-char (setq h math-rb-h1) (1+ v)) ?\[) |
40785 | 1606 (= (math-read-big-char (setq h (1+ h)) v) ?\[) |
1607 (and (= (math-read-big-char h v) ?\ ) | |
1608 (= (math-read-big-char (setq h (1+ h)) v) ?\[))) | |
1609 (= (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
|
1610 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t) |
40785 | 1611 (let ((vtop v) |
1612 (hleft h) | |
1613 (hright nil)) | |
1614 (setq p nil) | |
1615 (while (progn | |
1616 (setq h (math-read-big-balance (1+ hleft) v "[")) | |
1617 (if hright | |
1618 (or (= h hright) | |
1619 (math-read-big-error hright v "Expected `]'")) | |
1620 (setq hright h)) | |
1621 (setq p (cons (math-read-big-rec | |
1622 hleft v h (1+ v)) p)) | |
1623 (and (memq (math-read-big-char h v) '(?\ ?\,)) | |
1624 (= (math-read-big-char hleft (1+ v)) ?\[))) | |
1625 (setq v (1+ v))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1626 (or (= hleft math-rb-h1) |
40785 | 1627 (progn |
1628 (if (= (math-read-big-char h v) ?\ ) | |
1629 (setq h (1+ h))) | |
1630 (and (= (math-read-big-char h v) ?\]) | |
1631 (setq h (1+ h)))) | |
1632 (math-read-big-error (1- h) v "Expected `]'")) | |
1633 (if (= (math-read-big-char h vtop) ?\,) | |
1634 (setq h (1+ h))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1635 (math-read-big-emptyp math-rb-h1 (1+ v) (1- h) math-rb-v2 nil t) |
40785 | 1636 (setq v (+ vtop (/ (- v vtop) 2)) |
1637 p (cons 'vec (nreverse p))))) | |
1638 | |
1639 ;; Square brackets. | |
1640 ((= other-char ?\[) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1641 (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
|
1642 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t) |
40785 | 1643 (setq p nil |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1644 h (1+ math-rb-h1)) |
40785 | 1645 (while (progn |
1646 (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
|
1647 (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
|
1648 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1649 (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
|
1650 h math-rb-v1 (1- widest) math-rb-v2 v) p) |
40785 | 1651 h widest) |
1652 (= (math-read-big-char (1- h) v) ?\,))) | |
1653 (setq widest (math-read-big-char (1- h) v)) | |
1654 (if (or (memq widest '(?\; ?\))) | |
1655 (and (eq widest ?\.) (cdr p))) | |
1656 (math-read-big-error (1- h) v "Expected `]'")) | |
1657 (if (= widest ?\.) | |
1658 (setq h (1+ h) | |
1659 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
|
1660 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
|
1661 h math-rb-v1 (1- widest) math-rb-v2 v))) |
40785 | 1662 h widest |
1663 p (cons 'intv (cons (if (= (math-read-big-char (1- h) v) | |
1664 ?\]) | |
1665 3 2) | |
1666 p))) | |
1667 (setq p (cons 'vec (nreverse p))))) | |
1668 | |
1669 ;; Date form. | |
1670 ((= other-char ?\<) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1671 (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
|
1672 (string-match ">" line math-rb-h1) |
40785 | 1673 (setq h (match-end 0)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1674 (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
|
1675 (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
|
1676 (setq p (math-read-big-rec math-rb-h1 v h (1+ v) v))) |
40785 | 1677 |
1678 ;; Variable name or function call. | |
1679 ((or (and (>= other-char ?a) (<= other-char ?z)) | |
1680 (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
|
1681 (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
|
1682 (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1) |
40785 | 1683 (setq h (match-end 1) |
1684 widest (match-end 0) | |
1685 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
|
1686 (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
|
1687 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t) |
40785 | 1688 (if (= (math-read-big-char widest v) ?\() |
1689 (progn | |
1690 (setq line (if (string-match "-" p) | |
1691 (intern p) | |
1692 (intern (concat "calcFunc-" p))) | |
1693 h (1+ widest) | |
1694 p nil) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1695 (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
|
1696 (math-read-big-emptyp widest (1+ v) h math-rb-v2 nil t) |
40785 | 1697 (while (progn |
1698 (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
|
1699 (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
|
1700 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1701 (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
|
1702 h math-rb-v1 (1- widest) math-rb-v2 v) p) |
40785 | 1703 h widest) |
1704 (= (math-read-big-char (1- h) v) ?\,))) | |
1705 (or (= (math-read-big-char (1- h) v) ?\)) | |
1706 (math-read-big-error (1- h) v "Expected `)'")) | |
1707 (setq p (cons line (nreverse p)))) | |
1708 (setq p (list 'var | |
1709 (intern (math-remove-dashes p)) | |
1710 (if (string-match "-" p) | |
1711 (intern p) | |
1712 (intern (concat "var-" p))))))) | |
1713 | |
1714 ;; Number. | |
1715 (t | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1716 (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
|
1717 (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 | 1718 (math-read-big-error h v "Expected a number")) |
1719 (setq h (match-end 0) | |
1720 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
|
1721 (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
|
1722 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t))) |
40785 | 1723 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1724 ;; 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
|
1725 ;; baseline = v. |
40785 | 1726 (if baseline |
1727 (or (= v baseline) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1728 (math-read-big-error math-rb-h1 v "Inconsistent baseline in formula")) |
40785 | 1729 (setq baseline v)) |
1730 | |
1731 ;; Look for superscripts or subscripts. | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1732 (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
|
1733 len (min math-rb-h2 (length line)) |
40785 | 1734 widest h) |
1735 (while (and (< widest len) | |
1736 (= (aref line widest) ?\ )) | |
1737 (setq widest (1+ widest))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1738 (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
|
1739 (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
|
1740 (if (math-read-big-emptyp h math-rb-v1 widest v) |
40785 | 1741 (setq h widest) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1742 (setq p (list '^ p (math-read-big-rec h math-rb-v1 widest v)) |
40785 | 1743 h widest)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1744 (if (math-read-big-emptyp h math-rb-v1 widest v) |
40785 | 1745 (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
|
1746 (math-read-big-rec h v widest math-rb-v2)) |
40785 | 1747 h widest))) |
1748 | |
1749 ;; Look for an operator name and grab additional terms. | |
1750 (while (and (< h len) | |
1751 (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
|
1752 h math-rb-v1 (1+ h) v) |
40785 | 1753 (math-read-big-emptyp |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1754 h (1+ v) (1+ h) math-rb-v2) |
40785 | 1755 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h) |
1756 (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
|
1757 (math-standard-ops)))) |
40785 | 1758 (and (>= (nth 2 widest) prec) |
1759 (setq h (match-end 0))) | |
1760 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h) | |
1761 h)) | |
1762 (setq widest '("2x" * 196 195))))) | |
1763 (cond ((eq (nth 3 widest) -1) | |
1764 (setq p (list (nth 1 widest) p))) | |
1765 ((equal (car widest) "?") | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1766 (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
|
1767 math-rb-v2 baseline nil t))) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1768 (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
|
1769 (math-read-big-error math-read-big-h2 baseline "Expected `:'")) |
40785 | 1770 (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
|
1771 (math-read-big-rec |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1772 (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
|
1773 baseline (nth 3 widest) t)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1774 h math-read-big-h2))) |
40785 | 1775 (t |
1776 (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
|
1777 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2 |
40785 | 1778 baseline (nth 3 widest) t)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1779 h math-read-big-h2)))) |
40785 | 1780 |
1781 ;; 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
|
1782 (setq math-read-big-baseline baseline |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1783 math-read-big-h2 h) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1784 (or short (= math-read-big-h2 math-rb-h2) |
40785 | 1785 (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
|
1786 p))) |
40785 | 1787 |
1788 (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
|
1789 (or (and (>= h math-rb-h1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1790 (< h math-rb-h2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1791 (>= v math-rb-v1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1792 (< v math-rb-v2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1793 (let ((line (nth v math-read-big-lines))) |
40785 | 1794 (and line |
1795 (< h (length line)) | |
1796 (aref line h)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1797 ?\ )) |
40785 | 1798 |
1799 (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
|
1800 (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
|
1801 (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
|
1802 (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
|
1803 (and (> eh2 math-rb-h2) (setq eh2 math-rb-h2)) |
40785 | 1804 (or what (setq what ?\ )) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1805 (let ((p (nthcdr ev1 math-read-big-lines)) |
40785 | 1806 h) |
1807 (while (and (< ev1 ev2) | |
1808 (progn | |
1809 (setq h (min eh2 (length (car p)))) | |
1810 (while (and (>= (setq h (1- h)) eh1) | |
1811 (= (aref (car p) h) what))) | |
1812 (and error (>= h eh1) | |
1813 (math-read-big-error h ev1 (if (stringp error) | |
1814 error | |
1815 "Whitespace expected"))) | |
1816 (< h eh1))) | |
1817 (setq ev1 (1+ ev1) | |
1818 p (cdr p))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1819 (>= ev1 ev2))) |
40785 | 1820 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1821 ;; 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
|
1822 ;; 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
|
1823 ;; math-read-big-expr. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1824 (defvar math-read-big-err-msg) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1825 |
40785 | 1826 (defun math-read-big-error (h v &optional msg) |
1827 (let ((pos 0) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1828 (p math-read-big-lines)) |
40785 | 1829 (while (> v 0) |
1830 (setq pos (+ pos 1 (length (car p))) | |
1831 p (cdr p) | |
1832 v (1- v))) | |
1833 (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
|
1834 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
|
1835 (throw 'syntax nil))) |
40785 | 1836 |
1837 (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
|
1838 (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
|
1839 (len (min math-rb-h2 (length line))) |
40785 | 1840 (count 1)) |
1841 (while (> count 0) | |
1842 (if (>= h len) | |
1843 (if what | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1844 (math-read-big-error nil v (format "Unmatched `%s'" what)) |
40785 | 1845 (setq count 0)) |
1846 (if (memq (aref line h) '(?\( ?\[)) | |
1847 (setq count (1+ count)) | |
1848 (if (if (and commas (= count 1)) | |
1849 (or (memq (aref line h) '(?\) ?\] ?\, ?\;)) | |
1850 (and (eq (aref line h) ?\.) | |
1851 (< (1+ h) len) | |
1852 (eq (aref line (1+ h)) ?\.))) | |
1853 (memq (aref line h) '(?\) ?\]))) | |
1854 (setq count (1- count)))) | |
1855 (setq h (1+ h)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1856 h)) |
40785 | 1857 |
58661
10224395a3c2
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58571
diff
changeset
|
1858 (provide 'calc-lang) |
10224395a3c2
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58571
diff
changeset
|
1859 |
52401 | 1860 ;;; 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
|
1861 ;;; calc-lang.el ends here |