Mercurial > emacs
annotate lisp/calc/calc-lang.el @ 91294:299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
glyphs.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 27 Dec 2007 01:15:39 +0000 |
parents | 2fcaae6177a5 |
children | 56a72e2bd635 |
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 |
87223
e9cba8ba37e1
(calc-lang-name): New property name.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86969
diff
changeset
|
411 (put 'tex 'math-lang-name "TeX") |
e9cba8ba37e1
(calc-lang-name): New property name.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86969
diff
changeset
|
412 (put 'latex 'math-lang-name "LaTeX") |
e9cba8ba37e1
(calc-lang-name): New property name.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86969
diff
changeset
|
413 |
40785 | 414 (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
|
415 '( ( "\\hat" calcFunc-hat -1 950 ) |
40785 | 416 ( "\\check" calcFunc-check -1 950 ) |
417 ( "\\tilde" calcFunc-tilde -1 950 ) | |
418 ( "\\acute" calcFunc-acute -1 950 ) | |
419 ( "\\grave" calcFunc-grave -1 950 ) | |
420 ( "\\dot" calcFunc-dot -1 950 ) | |
421 ( "\\ddot" calcFunc-dotdot -1 950 ) | |
422 ( "\\breve" calcFunc-breve -1 950 ) | |
423 ( "\\bar" calcFunc-bar -1 950 ) | |
424 ( "\\vec" calcFunc-Vec -1 950 ) | |
425 ( "\\underline" calcFunc-under -1 950 ) | |
426 ( "u|" calcFunc-abs -1 0 ) | |
427 ( "|" closing 0 -1 ) | |
428 ( "\\lfloor" calcFunc-floor -1 0 ) | |
429 ( "\\rfloor" closing 0 -1 ) | |
430 ( "\\lceil" calcFunc-ceil -1 0 ) | |
431 ( "\\rceil" closing 0 -1 ) | |
432 ( "\\pm" sdev 300 300 ) | |
433 ( "!" calcFunc-fact 210 -1 ) | |
434 ( "^" ^ 201 200 ) | |
435 ( "_" 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
|
436 ( "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
|
437 ( "u-" neg -1 197 ) |
40785 | 438 ( "\\times" * 191 190 ) |
439 ( "*" * 191 190 ) | |
440 ( "2x" * 191 190 ) | |
441 ( "+" + 180 181 ) | |
442 ( "-" - 180 181 ) | |
443 ( "\\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
|
444 ( "/" / 170 171 ) |
40785 | 445 ( "\\choose" calcFunc-choose 170 171 ) |
446 ( "\\mod" % 170 171 ) | |
447 ( "<" calcFunc-lt 160 161 ) | |
448 ( ">" calcFunc-gt 160 161 ) | |
449 ( "\\leq" calcFunc-leq 160 161 ) | |
450 ( "\\geq" calcFunc-geq 160 161 ) | |
451 ( "=" calcFunc-eq 160 161 ) | |
452 ( "\\neq" calcFunc-neq 160 161 ) | |
453 ( "\\ne" calcFunc-neq 160 161 ) | |
454 ( "\\lnot" calcFunc-lnot -1 121 ) | |
455 ( "\\land" calcFunc-land 110 111 ) | |
456 ( "\\lor" calcFunc-lor 100 101 ) | |
457 ( "?" (math-read-if) 91 90 ) | |
458 ( "!!!" calcFunc-pnot -1 85 ) | |
459 ( "&&&" calcFunc-pand 80 81 ) | |
460 ( "|||" calcFunc-por 75 76 ) | |
461 ( "\\gets" calcFunc-assign 51 50 ) | |
462 ( ":=" calcFunc-assign 51 50 ) | |
463 ( "::" calcFunc-condition 45 46 ) | |
464 ( "\\to" calcFunc-evalto 40 41 ) | |
465 ( "\\to" calcFunc-evalto 40 -1 ) | |
466 ( "=>" calcFunc-evalto 40 41 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
467 ( "=>" calcFunc-evalto 40 -1 ))) |
40785 | 468 |
469 (put 'tex 'math-function-table | |
470 '( ( \\arccos . calcFunc-arccos ) | |
471 ( \\arcsin . calcFunc-arcsin ) | |
472 ( \\arctan . calcFunc-arctan ) | |
473 ( \\arg . calcFunc-arg ) | |
474 ( \\cos . calcFunc-cos ) | |
475 ( \\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
|
476 ( \\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
|
477 ( \\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
|
478 ( \\csc . calcFunc-csc ) |
40785 | 479 ( \\det . calcFunc-det ) |
480 ( \\exp . calcFunc-exp ) | |
481 ( \\gcd . calcFunc-gcd ) | |
482 ( \\ln . calcFunc-ln ) | |
483 ( \\log . calcFunc-log10 ) | |
484 ( \\max . calcFunc-max ) | |
485 ( \\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
|
486 ( \\sec . calcFunc-sec ) |
40785 | 487 ( \\sin . calcFunc-sin ) |
488 ( \\sinh . calcFunc-sinh ) | |
489 ( \\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
|
490 ( \\tan . calcFunc-tan ) |
40785 | 491 ( \\tanh . calcFunc-tanh ) |
492 ( \\phi . calcFunc-totient ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
493 ( \\mu . calcFunc-moebius ))) |
40785 | 494 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
495 (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
|
496 '((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
|
497 (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
|
498 (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
|
499 |
40785 | 500 (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
|
501 '( |
76991373b070
Add Greek letters to math-variable-table properties of tex.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
68636
diff
changeset
|
502 ;; 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
|
503 ( \\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
|
504 ( \\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
|
505 ( \\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
|
506 ( \\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
|
507 ( \\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
|
508 ( \\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
|
509 ( \\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
|
510 ( \\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
|
511 ( \\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
|
512 ( \\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
|
513 ( \\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
|
514 ( \\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
|
515 ( \\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
|
516 ( \\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
|
517 ( \\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
|
518 ( \\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
|
519 ( \\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
|
520 ( \\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
|
521 ( \\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
|
522 ( \\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
|
523 ( \\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
|
524 ( \\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
|
525 ( \\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
|
526 ( \\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
|
527 ( \\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
|
528 ( \\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
|
529 ( \\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
|
530 ( \\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
|
531 ( \\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
|
532 ( \\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
|
533 ( \\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
|
534 ( \\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
|
535 ( \\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
|
536 ( \\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
|
537 ( \\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
|
538 ( \\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
|
539 ( \\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
|
540 ( \\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
|
541 ( \\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
|
542 ( \\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
|
543 ;; Others |
76991373b070
Add Greek letters to math-variable-table properties of tex.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
68636
diff
changeset
|
544 ( \\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
|
545 ( \\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
|
546 ( \\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
|
547 ( \\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
|
548 ( \\prod . (math-parse-tex-sum calcFunc-prod) ))) |
40785 | 549 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
550 (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
|
551 '((?\{ . ?\() |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
552 (?\} . ?\)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
553 (?\& . ?\,))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
554 |
40785 | 555 (put 'tex 'math-complex-format 'i) |
556 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
557 (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
|
558 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
559 (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
|
560 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
561 (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
|
562 (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
|
563 (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
|
564 (> 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
|
565 (< 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
|
566 (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
|
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 (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
|
570 (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
|
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 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
573 (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
|
574 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
575 (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
|
576 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
577 (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
|
578 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
579 (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
|
580 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
581 (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
|
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 (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
|
584 '( ("\\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
|
585 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
586 ("\\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
|
587 ("\\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
|
588 ("\\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
|
589 ("\\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
|
590 ("\\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
|
591 ("\\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
|
592 ("\\evalto") |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
593 ("\\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
|
594 ("\\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
|
595 ("\\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
|
596 ("\\{" 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
|
597 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
598 (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
|
599 (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
|
600 '(("\\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
|
601 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
602 (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
|
603 '((?\\ |
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-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
|
605 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
606 (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
|
607 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
|
608 (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
|
609 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
|
610 (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
|
611 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
|
612 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
|
613 (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
|
614 (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
|
615 (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
|
616 ((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
|
617 (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
|
618 ((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
|
619 (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
|
620 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
|
621 ((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
|
622 (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
|
623 (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
|
624 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
|
625 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
|
626 (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
|
627 (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
|
628 (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
|
629 (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
|
630 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
631 (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
|
632 (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
|
633 (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
|
634 (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
|
635 (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
|
636 (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
|
637 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
638 (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
|
639 (cond |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
640 ((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
|
641 (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
|
642 "_{" (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
|
643 "=" (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
|
644 "}^{" (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
|
645 "}{" (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
|
646 ((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
|
647 (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
|
648 "_{" (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
|
649 "=" (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
|
650 "}{" (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
|
651 (t |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
652 (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
|
653 "_{" (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
|
654 "}{" (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
|
655 |
40785 | 656 (defun math-parse-tex-sum (f val) |
657 (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
|
658 (or (equal math-expr-data "_") (throw 'syntax "Expected `_'")) |
40785 | 659 (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
|
660 (setq save math-exp-old-pos) |
40785 | 661 (setq low (math-read-factor)) |
662 (or (eq (car-safe low) 'calcFunc-eq) | |
663 (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
|
664 (setq math-exp-old-pos (1+ save)) |
40785 | 665 (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
|
666 (or (equal math-expr-data "^") (throw 'syntax "Expected `^'")) |
40785 | 667 (math-read-token) |
668 (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
|
669 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high))) |
40785 | 670 |
671 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789. | |
672 (while (string-match "[0-9]\\\\,[0-9]" str) | |
673 (setq str (concat (substring str 0 (1+ (match-beginning 0))) | |
674 (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
|
675 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
|
676 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
677 ;(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
|
678 ; (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
|
679 ; "\\sqrt{" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
680 ; (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
|
681 ; "}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
682 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
683 (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
|
684 (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
|
685 (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
|
686 (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
|
687 " \\ldots " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
688 (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
|
689 (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
|
690 |
86969
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
691 (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
|
692 (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
|
693 (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
|
694 (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
|
695 (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
|
696 (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
|
697 (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
|
698 (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
|
699 (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
|
700 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
701 (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
|
702 (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
|
703 (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
|
704 (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
|
705 (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
|
706 (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
|
707 (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
|
708 (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
|
709 (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
|
710 (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
|
711 (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
|
712 (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
|
713 (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
|
714 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
|
715 ((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
|
716 (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
|
717 (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
|
718 (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
|
719 (= (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
|
720 (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
|
721 (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
|
722 (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
|
723 (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
|
724 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
|
725 (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
|
726 left |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
727 (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
|
728 right))) |
40785 | 729 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
730 (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
|
731 (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
|
732 '(( "\\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
|
733 ( "\\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
|
734 ( "\\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
|
735 ( "\\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
|
736 ( "\\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
|
737 ( "\\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
|
738 ( "\\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
|
739 ( "\\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
|
740 ( "\\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
|
741 ( "\\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
|
742 ( "\\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
|
743 ( "\\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
|
744 ( "\\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
|
745 ( "\\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
|
746 ( "\\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
|
747 ( "\\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
|
748 ( "\\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
|
749 ( "\\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
|
750 ( "\\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
|
751 ( "=" 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
|
752 ( "\\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
|
753 ( "\\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
|
754 ( "\\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
|
755 ( "\\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
|
756 ( "\\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
|
757 ( "?" (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
|
758 ( "!!!" 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
|
759 ( "&&&" 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
|
760 ( "|||" 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
|
761 ( "\\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
|
762 ( ":=" 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
|
763 ( "::" 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
|
764 ( "\\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
|
765 ( "\\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
|
766 ( "=>" 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
|
767 ( "=>" calcFunc-evalto 40 -1 )))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
768 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
769 (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
|
770 (append |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
771 (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
|
772 '(( \\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
|
773 ( \\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
|
774 ( \\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
|
775 ( \\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
|
776 ( \\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
|
777 ( \\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
|
778 ( \\phi . calcFunc-totient ) |
502b609847e8
(math-function-table, math-oper-table, math-variable-table):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59819
diff
changeset
|
779 ( \\mu . calcFunc-moebius )))) |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
780 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
781 (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
|
782 '((/ . (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
|
783 (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
|
784 (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
|
785 (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
|
786 (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
|
787 |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
788 (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
|
789 (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
|
790 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
791 (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
|
792 '((?\{ . ?\() |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
793 (?\} . ?\)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
794 (?\& . ?\,))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
795 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
796 (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
|
797 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
798 (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
|
799 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
800 (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
|
801 (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
|
802 (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
|
803 (> 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
|
804 (< 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
|
805 (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
|
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}")) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
808 (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
|
809 (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
|
810 '(" \\end{pmatrix}")))))) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
811 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
812 (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
|
813 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
814 (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
|
815 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
816 (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
|
817 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
818 (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
|
819 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
820 (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
|
821 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
822 (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
|
823 '((?\\ |
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-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
|
825 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
826 (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
|
827 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
|
828 (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
|
829 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
|
830 (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
|
831 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
|
832 (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
|
833 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
|
834 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
|
835 (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
|
836 (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
|
837 envname) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
838 (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
|
839 ((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
|
840 (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
|
841 ((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
|
842 (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
|
843 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
|
844 ((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
|
845 (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
|
846 (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
|
847 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
|
848 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
|
849 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
|
850 (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
|
851 (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
|
852 (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
|
853 (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
|
854 (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
|
855 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
|
856 (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
|
857 (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
|
858 (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
|
859 ((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
|
860 (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
|
861 (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
|
862 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
|
863 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
|
864 (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
|
865 (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
|
866 (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
|
867 (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
|
868 |
59811
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
869 (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
|
870 (let (numer denom) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
871 (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
|
872 (math-read-token) |
59915
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
873 (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
|
874 (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
|
875 (Math-num-integerp denom)) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
876 (list 'frac numer denom) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
877 (list '/ numer denom)))) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
878 |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
879 (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
|
880 (let (first second) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
881 (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
|
882 (math-read-token) |
937e422a1694
(math-latex-parse-frac): Don't use arguments.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59829
diff
changeset
|
883 (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
|
884 (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
|
885 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
886 (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
|
887 (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
|
888 "}{" |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
889 (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
|
890 "}")) |
9e28f5bc25bb
(calc-latex-language, math-latex-parse-frac)
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58661
diff
changeset
|
891 |
59819
dea78c6f5e48
(math-latex-input-filter): Remove function.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
59811
diff
changeset
|
892 (put 'latex 'math-input-filter 'math-tex-input-filter) |
40785 | 893 |
894 (defun calc-eqn-language (n) | |
895 (interactive "P") | |
896 (calc-wrapper | |
897 (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
|
898 (message "Eqn language mode"))) |
40785 | 899 |
900 (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
|
901 '( ( "prime" (math-parse-eqn-prime) 950 -1 ) |
40785 | 902 ( "prime" calcFunc-Prime 950 -1 ) |
903 ( "dot" calcFunc-dot 950 -1 ) | |
904 ( "dotdot" calcFunc-dotdot 950 -1 ) | |
905 ( "hat" calcFunc-hat 950 -1 ) | |
906 ( "tilde" calcFunc-tilde 950 -1 ) | |
907 ( "vec" calcFunc-Vec 950 -1 ) | |
908 ( "dyad" calcFunc-dyad 950 -1 ) | |
909 ( "bar" calcFunc-bar 950 -1 ) | |
910 ( "under" calcFunc-under 950 -1 ) | |
911 ( "sub" calcFunc-subscr 931 930 ) | |
912 ( "sup" ^ 921 920 ) | |
913 ( "sqrt" calcFunc-sqrt -1 910 ) | |
914 ( "over" / 900 901 ) | |
915 ( "u|" calcFunc-abs -1 0 ) | |
916 ( "|" closing 0 -1 ) | |
917 ( "left floor" calcFunc-floor -1 0 ) | |
918 ( "right floor" closing 0 -1 ) | |
919 ( "left ceil" calcFunc-ceil -1 0 ) | |
920 ( "right ceil" closing 0 -1 ) | |
921 ( "+-" sdev 300 300 ) | |
922 ( "!" 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
|
923 ( "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
|
924 ( "u-" neg -1 197 ) |
40785 | 925 ( "times" * 191 190 ) |
926 ( "*" * 191 190 ) | |
927 ( "2x" * 191 190 ) | |
928 ( "/" / 180 181 ) | |
929 ( "%" % 180 181 ) | |
930 ( "+" + 170 171 ) | |
931 ( "-" - 170 171 ) | |
932 ( "<" calcFunc-lt 160 161 ) | |
933 ( ">" calcFunc-gt 160 161 ) | |
934 ( "<=" calcFunc-leq 160 161 ) | |
935 ( ">=" calcFunc-geq 160 161 ) | |
936 ( "=" calcFunc-eq 160 161 ) | |
937 ( "==" calcFunc-eq 160 161 ) | |
938 ( "!=" calcFunc-neq 160 161 ) | |
939 ( "u!" calcFunc-lnot -1 121 ) | |
940 ( "&&" calcFunc-land 110 111 ) | |
941 ( "||" calcFunc-lor 100 101 ) | |
942 ( "?" (math-read-if) 91 90 ) | |
943 ( "!!!" calcFunc-pnot -1 85 ) | |
944 ( "&&&" calcFunc-pand 80 81 ) | |
945 ( "|||" calcFunc-por 75 76 ) | |
946 ( "<-" calcFunc-assign 51 50 ) | |
947 ( ":=" calcFunc-assign 51 50 ) | |
948 ( "::" calcFunc-condition 45 46 ) | |
949 ( "->" calcFunc-evalto 40 41 ) | |
950 ( "->" calcFunc-evalto 40 -1 ) | |
951 ( "=>" calcFunc-evalto 40 41 ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
952 ( "=>" calcFunc-evalto 40 -1 ))) |
40785 | 953 |
954 (put 'eqn 'math-function-table | |
955 '( ( arc\ cos . calcFunc-arccos ) | |
956 ( arc\ cosh . calcFunc-arccosh ) | |
957 ( arc\ sin . calcFunc-arcsin ) | |
958 ( arc\ sinh . calcFunc-arcsinh ) | |
959 ( arc\ tan . calcFunc-arctan ) | |
960 ( arc\ tanh . calcFunc-arctanh ) | |
961 ( GAMMA . calcFunc-gamma ) | |
962 ( phi . calcFunc-totient ) | |
963 ( mu . calcFunc-moebius ) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
964 ( matrix . (math-parse-eqn-matrix) ))) |
40785 | 965 |
86932
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-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
|
967 '((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
|
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 (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
|
970 '((?\{ . ?\() |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
971 (?\} . ?\)))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
972 |
40785 | 973 (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
|
974 '( ( inf . var-uinf ))) |
40785 | 975 |
976 (put 'eqn 'math-complex-format 'i) | |
977 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
978 (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
|
979 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
980 (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
|
981 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
982 (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
|
983 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
984 (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
|
985 (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
|
986 (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
|
987 (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
|
988 '("}"))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
989 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
990 (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
|
991 (function |
86969
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
992 (lambda (a prec) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
993 (let (v) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
994 (if (and math-compose-hash-args |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
995 (let ((p calc-arg-values)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
996 (setq v 1) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
997 (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
|
998 (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
|
999 v (1+ v))) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1000 p)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1001 (if (eq math-compose-hash-args 1) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1002 "#" |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1003 (format "#%d" v)) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1004 (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
|
1005 (math-compose-expr |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1006 (list 'calcFunc-Prime |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1007 (list |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1008 'var |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1009 (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
|
1010 (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
|
1011 prec) |
369fadbe988d
(math-compose-var): Adjust declaration.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86933
diff
changeset
|
1012 (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
|
1013 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1014 (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
|
1015 '( 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
|
1016 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
|
1017 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
|
1018 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
|
1019 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
|
1020 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
|
1021 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
|
1022 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
|
1023 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1024 (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
|
1025 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1026 (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
|
1027 (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
|
1028 (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
|
1029 (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
|
1030 (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
|
1031 (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
|
1032 (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
|
1033 (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
|
1034 (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
|
1035 (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
|
1036 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
|
1037 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1038 ((and |
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 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
|
1040 (= (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
|
1041 (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
|
1042 (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
|
1043 (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
|
1044 (t |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1045 (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
|
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 (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
|
1048 (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
|
1049 right))))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1050 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1051 (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
|
1052 '((?\" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1053 (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
|
1054 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
|
1055 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1056 (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
|
1057 (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
|
1058 (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
|
1059 (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
|
1060 (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
|
1061 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1062 (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
|
1063 '( ("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
|
1064 ("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
|
1065 ("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
|
1066 ("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
|
1067 ("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
|
1068 ("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
|
1069 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1070 (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
|
1071 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1072 (lambda () |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1073 (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
|
1074 (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
|
1075 ((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
|
1076 (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
|
1077 ((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
|
1078 (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
|
1079 (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
|
1080 (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
|
1081 (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
|
1082 ((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
|
1083 (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
|
1084 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
|
1085 (t |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1086 (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
|
1087 (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
|
1088 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1089 (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
|
1090 '((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
|
1091 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
|
1092 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
|
1093 (progn |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1094 (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
|
1095 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
|
1096 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 (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
|
1098 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
|
1099 (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
|
1100 (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
|
1101 (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
|
1102 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1103 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1104 (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
|
1105 (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
|
1106 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1107 (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
|
1108 ((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
|
1109 (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
|
1110 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1111 (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
|
1112 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1113 "{ " |
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 (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
|
1116 (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
|
1117 (cons |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1118 " } " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1119 (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
|
1120 nil)) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1121 |
40785 | 1122 (defun math-parse-eqn-matrix (f sym) |
1123 (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
|
1124 (while (assoc math-expr-data '(("ccol") ("lcol") ("rcol"))) |
40785 | 1125 (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
|
1126 (or (equal math-expr-data calc-function-open) |
40785 | 1127 (throw 'syntax "Expected `{'")) |
1128 (math-read-token) | |
1129 (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
|
1130 (or (equal math-expr-data calc-function-close) |
40785 | 1131 (throw 'syntax "Expected `}'")) |
1132 (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
|
1133 (or (equal math-expr-data calc-function-close) |
40785 | 1134 (throw 'syntax "Expected `}'")) |
1135 (math-read-token) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1136 (math-transpose (cons 'vec (nreverse vec))))) |
40785 | 1137 |
1138 (defun math-parse-eqn-prime (x sym) | |
1139 (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
|
1140 (if (equal math-expr-data calc-function-open) |
40785 | 1141 (progn |
1142 (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
|
1143 (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
|
1144 (eq math-exp-token 'end)) |
40785 | 1145 nil |
1146 (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
|
1147 (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
|
1148 (eq math-exp-token 'end))) |
40785 | 1149 (throw 'syntax "Expected `)'")) |
1150 (math-read-token) | |
1151 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args))) | |
1152 (list 'var | |
1153 (intern (concat (symbol-name (nth 1 x)) "'")) | |
1154 (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
|
1155 (list 'calcFunc-Prime x))) |
40785 | 1156 |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1157 (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
|
1158 (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
|
1159 (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
|
1160 (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
|
1161 " ... " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1162 (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
|
1163 (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
|
1164 |
40785 | 1165 |
1166 (defun calc-mathematica-language () | |
1167 (interactive) | |
1168 (calc-wrapper | |
1169 (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
|
1170 (message "Mathematica language mode"))) |
40785 | 1171 |
1172 (put 'math 'math-oper-table | |
1173 '( ( "[[" (math-read-math-subscr) 250 -1 ) | |
1174 ( "!" calcFunc-fact 210 -1 ) | |
1175 ( "!!" calcFunc-dfact 210 -1 ) | |
1176 ( "^" ^ 201 200 ) | |
1177 ( "u+" ident -1 197 ) | |
1178 ( "u-" neg -1 197 ) | |
1179 ( "/" / 195 196 ) | |
1180 ( "*" * 190 191 ) | |
1181 ( "2x" * 190 191 ) | |
1182 ( "+" + 180 181 ) | |
1183 ( "-" - 180 181 ) | |
1184 ( "<" calcFunc-lt 160 161 ) | |
1185 ( ">" calcFunc-gt 160 161 ) | |
1186 ( "<=" calcFunc-leq 160 161 ) | |
1187 ( ">=" calcFunc-geq 160 161 ) | |
1188 ( "==" calcFunc-eq 150 151 ) | |
1189 ( "!=" calcFunc-neq 150 151 ) | |
1190 ( "u!" calcFunc-lnot -1 121 ) | |
1191 ( "&&" calcFunc-land 110 111 ) | |
1192 ( "||" calcFunc-lor 100 101 ) | |
1193 ( "!!!" calcFunc-pnot -1 85 ) | |
1194 ( "&&&" calcFunc-pand 80 81 ) | |
1195 ( "|||" calcFunc-por 75 76 ) | |
1196 ( ":=" calcFunc-assign 51 50 ) | |
1197 ( "=" calcFunc-assign 51 50 ) | |
1198 ( "->" calcFunc-assign 51 50 ) | |
1199 ( ":>" calcFunc-assign 51 50 ) | |
1200 ( "::" calcFunc-condition 45 46 ) | |
1201 )) | |
1202 | |
1203 (put 'math 'math-function-table | |
1204 '( ( Abs . calcFunc-abs ) | |
1205 ( ArcCos . calcFunc-arccos ) | |
1206 ( ArcCosh . calcFunc-arccosh ) | |
1207 ( ArcSin . calcFunc-arcsin ) | |
1208 ( ArcSinh . calcFunc-arcsinh ) | |
1209 ( ArcTan . calcFunc-arctan ) | |
1210 ( ArcTanh . calcFunc-arctanh ) | |
1211 ( Arg . calcFunc-arg ) | |
1212 ( Binomial . calcFunc-choose ) | |
1213 ( Ceiling . calcFunc-ceil ) | |
1214 ( Conjugate . calcFunc-conj ) | |
1215 ( Cos . calcFunc-cos ) | |
1216 ( 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
|
1217 ( 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
|
1218 ( 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
|
1219 ( 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
|
1220 ( Csch . calcFunc-csch ) |
40785 | 1221 ( D . calcFunc-deriv ) |
1222 ( Dt . calcFunc-tderiv ) | |
1223 ( Det . calcFunc-det ) | |
1224 ( Exp . calcFunc-exp ) | |
1225 ( EulerPhi . calcFunc-totient ) | |
1226 ( Floor . calcFunc-floor ) | |
1227 ( Gamma . calcFunc-gamma ) | |
1228 ( GCD . calcFunc-gcd ) | |
1229 ( If . calcFunc-if ) | |
1230 ( Im . calcFunc-im ) | |
1231 ( Inverse . calcFunc-inv ) | |
1232 ( Integrate . calcFunc-integ ) | |
1233 ( Join . calcFunc-vconcat ) | |
1234 ( LCM . calcFunc-lcm ) | |
1235 ( Log . calcFunc-ln ) | |
1236 ( Max . calcFunc-max ) | |
1237 ( Min . calcFunc-min ) | |
1238 ( Mod . calcFunc-mod ) | |
1239 ( MoebiusMu . calcFunc-moebius ) | |
1240 ( Random . calcFunc-random ) | |
1241 ( Round . calcFunc-round ) | |
1242 ( 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
|
1243 ( 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
|
1244 ( Sech . calcFunc-sech ) |
40785 | 1245 ( Sign . calcFunc-sign ) |
1246 ( Sin . calcFunc-sin ) | |
1247 ( Sinh . calcFunc-sinh ) | |
1248 ( Sqrt . calcFunc-sqrt ) | |
1249 ( Tan . calcFunc-tan ) | |
1250 ( Tanh . calcFunc-tanh ) | |
1251 ( Transpose . calcFunc-trn ) | |
1252 ( Length . calcFunc-vlen ) | |
1253 )) | |
1254 | |
1255 (put 'math 'math-variable-table | |
1256 '( ( I . var-i ) | |
1257 ( Pi . var-pi ) | |
1258 ( E . var-e ) | |
1259 ( GoldenRatio . var-phi ) | |
1260 ( EulerGamma . var-gamma ) | |
1261 ( Infinity . var-inf ) | |
1262 ( ComplexInfinity . var-uinf ) | |
1263 ( Indeterminate . var-nan ) | |
1264 )) | |
1265 | |
1266 (put 'math 'math-vector-brackets "{}") | |
1267 (put 'math 'math-complex-format 'I) | |
1268 (put 'math 'math-function-open "[") | |
1269 (put 'math 'math-function-close "]") | |
1270 | |
1271 (put 'math 'math-radix-formatter | |
1272 (function (lambda (r s) (format "%d^^%s" r s)))) | |
1273 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1274 (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
|
1275 '((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
|
1276 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
|
1277 (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
|
1278 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
|
1279 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
|
1280 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1281 (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
|
1282 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1283 (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
|
1284 (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
|
1285 (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
|
1286 "[[" |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1287 (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
|
1288 "]]")))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1289 |
40785 | 1290 (defun math-read-math-subscr (x op) |
1291 (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
|
1292 (or (and (equal math-expr-data "]") |
40785 | 1293 (progn |
1294 (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
|
1295 (equal math-expr-data "]"))) |
40785 | 1296 (throw 'syntax "Expected ']]'")) |
1297 (math-read-token) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1298 (list 'calcFunc-subscr x idx))) |
40785 | 1299 |
1300 | |
1301 (defun calc-maple-language () | |
1302 (interactive) | |
1303 (calc-wrapper | |
1304 (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
|
1305 (message "Maple language mode"))) |
40785 | 1306 |
1307 (put 'maple 'math-oper-table | |
1308 '( ( "matrix" ident -1 300 ) | |
1309 ( "MATRIX" ident -1 300 ) | |
1310 ( "!" calcFunc-fact 210 -1 ) | |
1311 ( "^" ^ 201 200 ) | |
1312 ( "**" ^ 201 200 ) | |
1313 ( "u+" ident -1 197 ) | |
1314 ( "u-" neg -1 197 ) | |
1315 ( "/" / 191 192 ) | |
1316 ( "*" * 191 192 ) | |
1317 ( "intersect" calcFunc-vint 191 192 ) | |
1318 ( "+" + 180 181 ) | |
1319 ( "-" - 180 181 ) | |
1320 ( "union" calcFunc-vunion 180 181 ) | |
1321 ( "minus" calcFunc-vdiff 180 181 ) | |
1322 ( "mod" % 170 170 ) | |
1323 ( ".." (math-read-maple-dots) 165 165 ) | |
1324 ( "\\dots" (math-read-maple-dots) 165 165 ) | |
1325 ( "<" calcFunc-lt 160 160 ) | |
1326 ( ">" calcFunc-gt 160 160 ) | |
1327 ( "<=" calcFunc-leq 160 160 ) | |
1328 ( ">=" calcFunc-geq 160 160 ) | |
1329 ( "=" calcFunc-eq 160 160 ) | |
1330 ( "<>" calcFunc-neq 160 160 ) | |
1331 ( "not" calcFunc-lnot -1 121 ) | |
1332 ( "and" calcFunc-land 110 111 ) | |
1333 ( "or" calcFunc-lor 100 101 ) | |
1334 ( "!!!" calcFunc-pnot -1 85 ) | |
1335 ( "&&&" calcFunc-pand 80 81 ) | |
1336 ( "|||" calcFunc-por 75 76 ) | |
1337 ( ":=" calcFunc-assign 51 50 ) | |
1338 ( "::" calcFunc-condition 45 46 ) | |
1339 )) | |
1340 | |
1341 (put 'maple 'math-function-table | |
1342 '( ( bernoulli . calcFunc-bern ) | |
1343 ( binomial . calcFunc-choose ) | |
1344 ( diff . calcFunc-deriv ) | |
1345 ( GAMMA . calcFunc-gamma ) | |
1346 ( ifactor . calcFunc-prfac ) | |
1347 ( igcd . calcFunc-gcd ) | |
1348 ( ilcm . calcFunc-lcm ) | |
1349 ( int . calcFunc-integ ) | |
1350 ( modp . % ) | |
1351 ( irem . % ) | |
1352 ( iquo . calcFunc-idiv ) | |
1353 ( isprime . calcFunc-prime ) | |
1354 ( length . calcFunc-vlen ) | |
1355 ( member . calcFunc-in ) | |
1356 ( crossprod . calcFunc-cross ) | |
1357 ( inverse . calcFunc-inv ) | |
1358 ( trace . calcFunc-tr ) | |
1359 ( transpose . calcFunc-trn ) | |
1360 ( vectdim . calcFunc-vlen ) | |
1361 )) | |
1362 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1363 (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
|
1364 '((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
|
1365 |
40785 | 1366 (put 'maple 'math-variable-table |
1367 '( ( I . var-i ) | |
1368 ( Pi . var-pi ) | |
1369 ( E . var-e ) | |
1370 ( infinity . var-inf ) | |
1371 ( infinity . var-uinf ) | |
1372 ( infinity . var-nan ) | |
1373 )) | |
1374 | |
1375 (put 'maple 'math-complex-format 'I) | |
1376 | |
86932
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1377 (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
|
1378 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1379 (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
|
1380 (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
|
1381 "matrix(" |
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-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
|
1383 (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
|
1384 (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
|
1385 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
|
1386 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
|
1387 ")")))) |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1388 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1389 (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
|
1390 (function |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1391 (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
|
1392 (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
|
1393 (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
|
1394 (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
|
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 (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
|
1397 "]"))))) |
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 (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
|
1400 (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
|
1401 |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1402 (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
|
1403 (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
|
1404 (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
|
1405 " .. " |
15347a4d3180
(math-compose-vector, math-compose-var, math-tex-expr-is-flat):
Jay Belanger <jay.p.belanger@gmail.com>
parents:
86475
diff
changeset
|
1406 (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
|
1407 |
40785 | 1408 (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
|
1409 (list 'intv 3 x (math-read-expr-level (nth 3 op)))) |
40785 | 1410 |
1411 | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1412 ;; 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
|
1413 ;; 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
|
1414 ;; 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
|
1415 ;; 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
|
1416 ;; 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
|
1417 ;; math-read-big-balance. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1418 (defvar math-read-big-lines) |
40785 | 1419 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1420 ;; 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
|
1421 ;; 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
|
1422 ;; math-read-big-rec. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1423 (defvar math-read-big-baseline) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1424 (defvar math-read-big-h2) |
40785 | 1425 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1426 ;; 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
|
1427 ;; 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
|
1428 ;; 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
|
1429 ;; math-read-big-rec. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1430 ;; 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
|
1431 ;; which calls math-read-big-balance. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1432 (defvar math-rb-h1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1433 (defvar math-rb-h2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1434 (defvar math-rb-v1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1435 (defvar math-rb-v2) |
40785 | 1436 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1437 (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
|
1438 &optional baseline prec short) |
40785 | 1439 (or prec (setq prec 0)) |
1440 | |
1441 ;; Clip whitespace above or below. | |
58411
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 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
|
1444 (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
|
1445 (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
|
1446 (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
|
1447 (setq math-rb-v2 (1- math-rb-v2))) |
40785 | 1448 |
1449 ;; 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
|
1450 (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
|
1451 (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
|
1452 (> 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
|
1453 (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
|
1454 (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
|
1455 (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
|
1456 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
|
1457 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
|
1458 math-rb-h2 (math-read-expr |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1459 (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
|
1460 (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
|
1461 (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
|
1462 (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
|
1463 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
|
1464 math-rb-h2)) |
40785 | 1465 |
1466 ;; 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
|
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 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
|
1469 (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
|
1470 (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
|
1471 (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
|
1472 (setq math-rb-h2 (1- math-rb-h2))) |
40785 | 1473 |
1474 ;; Scan to find widest left-justified "----" in the region. | |
1475 (let* ((widest nil) | |
1476 (widest-h2 0) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1477 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines)) |
40785 | 1478 (p lines-v1) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1479 (v math-rb-v1) |
40785 | 1480 (other-v nil) |
1481 other-char line len h) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1482 (while (< v math-rb-v2) |
40785 | 1483 (setq line (car p) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1484 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
|
1485 (and (< math-rb-h1 len) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1486 (/= (aref line math-rb-h1) ?\ ) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1487 (if (and (= (aref line math-rb-h1) ?\-) |
40785 | 1488 ;; 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
|
1489 (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
|
1490 (= (aref line (1+ math-rb-h1)) ?\-)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1491 (/= (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
|
1492 (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ ))) |
40785 | 1493 (progn |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1494 (setq h math-rb-h1) |
40785 | 1495 (while (and (< (setq h (1+ h)) len) |
1496 (= (aref line h) ?\-))) | |
1497 (if (> h widest-h2) | |
1498 (setq widest v | |
1499 widest-h2 h))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1500 (or other-v (setq other-v v other-char (aref line math-rb-h1))))) |
40785 | 1501 (setq v (1+ v) |
1502 p (cdr p))) | |
1503 | |
1504 (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
|
1505 (math-read-big-error math-rb-h1 math-rb-v1)) ; Should never happen! |
40785 | 1506 |
1507 ;; Quotient. | |
1508 (widest | |
1509 (setq h widest-h2 | |
1510 v widest) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1511 (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
|
1512 (den (math-read-big-rec math-rb-h1 (1+ v) h math-rb-v2))) |
40785 | 1513 (setq p (if (and (math-integerp num) (math-integerp den)) |
1514 (math-make-frac num den) | |
1515 (list '/ num den))))) | |
1516 | |
1517 ;; Big radical sign. | |
1518 ((= other-char ?\\) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1519 (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
|
1520 (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
|
1521 (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
|
1522 (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
|
1523 (or (= (math-read-big-char (setq h (+ math-rb-h1 2)) v) ?\_) |
40785 | 1524 (math-read-big-error h v "Malformed root sign")) |
1525 (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
|
1526 (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
|
1527 (math-read-big-emptyp math-rb-h1 (1+ other-v) h math-rb-v2 nil t) |
40785 | 1528 (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
|
1529 (+ math-rb-h1 2) (1+ v) |
40785 | 1530 h (1+ other-v) baseline)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1531 v math-read-big-baseline)) |
40785 | 1532 |
1533 ;; Small radical sign. | |
1534 ((and (= other-char ?V) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1535 (= (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
|
1536 (setq h (1+ math-rb-h1)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1537 (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
|
1538 (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
|
1539 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t) |
40785 | 1540 (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_)) |
1541 (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
|
1542 (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
|
1543 v math-read-big-baseline)) |
40785 | 1544 |
1545 ;; Binomial coefficient. | |
1546 ((and (= other-char ?\() | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1547 (= (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
|
1548 (= (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
|
1549 math-rb-h1) math-rb-h1)) |
40785 | 1550 (setq h (match-end 0)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1551 (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
|
1552 (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
|
1553 (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
|
1554 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1555 (setq p (list 'calcFunc-choose |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1556 (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
|
1557 (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
|
1558 (1- h) math-rb-v2)))) |
40785 | 1559 |
1560 ;; Minus sign. | |
1561 ((= other-char ?\-) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1562 (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
|
1563 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
|
1564 v math-read-big-baseline |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1565 h math-read-big-h2)) |
40785 | 1566 |
1567 ;; Parentheses. | |
1568 ((= other-char ?\() | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1569 (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
|
1570 (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
|
1571 (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
|
1572 (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
|
1573 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1574 (let ((sep (math-read-big-char (1- h) v)) |
1575 hmid) | |
1576 (if (= sep ?\.) | |
1577 (setq h (1+ h))) | |
1578 (if (= sep ?\]) | |
1579 (math-read-big-error (1- h) v "Expected `)'")) | |
1580 (if (= sep ?\)) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1581 (setq p (math-read-big-rec |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1582 (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v)) |
40785 | 1583 (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
|
1584 p (list p |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1585 (math-read-big-rec h math-rb-v1 (1- hmid) math-rb-v2 v)) |
40785 | 1586 h hmid) |
1587 (cond ((= sep ?\.) | |
1588 (setq p (cons 'intv (cons (if (= (math-read-big-char | |
1589 (1- h) v) | |
1590 ?\)) | |
1591 0 1) | |
1592 p)))) | |
1593 ((= (math-read-big-char (1- h) v) ?\]) | |
1594 (math-read-big-error (1- h) v "Expected `)'")) | |
1595 ((= sep ?\,) | |
1596 (or (and (math-realp (car p)) (math-realp (nth 1 p))) | |
1597 (math-read-big-error | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1598 math-rb-h1 v "Complex components must be real")) |
40785 | 1599 (setq p (cons 'cplx p))) |
1600 ((= sep ?\;) | |
1601 (or (and (math-realp (car p)) (math-anglep (nth 1 p))) | |
1602 (math-read-big-error | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1603 math-rb-h1 v "Complex components must be real")) |
40785 | 1604 (setq p (cons 'polar p))))))) |
1605 | |
1606 ;; Matrix. | |
1607 ((and (= other-char ?\[) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1608 (or (= (math-read-big-char (setq h math-rb-h1) (1+ v)) ?\[) |
40785 | 1609 (= (math-read-big-char (setq h (1+ h)) v) ?\[) |
1610 (and (= (math-read-big-char h v) ?\ ) | |
1611 (= (math-read-big-char (setq h (1+ h)) v) ?\[))) | |
1612 (= (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
|
1613 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t) |
40785 | 1614 (let ((vtop v) |
1615 (hleft h) | |
1616 (hright nil)) | |
1617 (setq p nil) | |
1618 (while (progn | |
1619 (setq h (math-read-big-balance (1+ hleft) v "[")) | |
1620 (if hright | |
1621 (or (= h hright) | |
1622 (math-read-big-error hright v "Expected `]'")) | |
1623 (setq hright h)) | |
1624 (setq p (cons (math-read-big-rec | |
1625 hleft v h (1+ v)) p)) | |
1626 (and (memq (math-read-big-char h v) '(?\ ?\,)) | |
1627 (= (math-read-big-char hleft (1+ v)) ?\[))) | |
1628 (setq v (1+ v))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1629 (or (= hleft math-rb-h1) |
40785 | 1630 (progn |
1631 (if (= (math-read-big-char h v) ?\ ) | |
1632 (setq h (1+ h))) | |
1633 (and (= (math-read-big-char h v) ?\]) | |
1634 (setq h (1+ h)))) | |
1635 (math-read-big-error (1- h) v "Expected `]'")) | |
1636 (if (= (math-read-big-char h vtop) ?\,) | |
1637 (setq h (1+ h))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1638 (math-read-big-emptyp math-rb-h1 (1+ v) (1- h) math-rb-v2 nil t) |
40785 | 1639 (setq v (+ vtop (/ (- v vtop) 2)) |
1640 p (cons 'vec (nreverse p))))) | |
1641 | |
1642 ;; Square brackets. | |
1643 ((= other-char ?\[) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1644 (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
|
1645 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t) |
40785 | 1646 (setq p nil |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1647 h (1+ math-rb-h1)) |
40785 | 1648 (while (progn |
1649 (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
|
1650 (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
|
1651 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1652 (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
|
1653 h math-rb-v1 (1- widest) math-rb-v2 v) p) |
40785 | 1654 h widest) |
1655 (= (math-read-big-char (1- h) v) ?\,))) | |
1656 (setq widest (math-read-big-char (1- h) v)) | |
1657 (if (or (memq widest '(?\; ?\))) | |
1658 (and (eq widest ?\.) (cdr p))) | |
1659 (math-read-big-error (1- h) v "Expected `]'")) | |
1660 (if (= widest ?\.) | |
1661 (setq h (1+ h) | |
1662 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
|
1663 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
|
1664 h math-rb-v1 (1- widest) math-rb-v2 v))) |
40785 | 1665 h widest |
1666 p (cons 'intv (cons (if (= (math-read-big-char (1- h) v) | |
1667 ?\]) | |
1668 3 2) | |
1669 p))) | |
1670 (setq p (cons 'vec (nreverse p))))) | |
1671 | |
1672 ;; Date form. | |
1673 ((= other-char ?\<) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1674 (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
|
1675 (string-match ">" line math-rb-h1) |
40785 | 1676 (setq h (match-end 0)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1677 (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
|
1678 (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
|
1679 (setq p (math-read-big-rec math-rb-h1 v h (1+ v) v))) |
40785 | 1680 |
1681 ;; Variable name or function call. | |
1682 ((or (and (>= other-char ?a) (<= other-char ?z)) | |
1683 (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
|
1684 (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
|
1685 (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1) |
40785 | 1686 (setq h (match-end 1) |
1687 widest (match-end 0) | |
1688 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
|
1689 (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
|
1690 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t) |
40785 | 1691 (if (= (math-read-big-char widest v) ?\() |
1692 (progn | |
1693 (setq line (if (string-match "-" p) | |
1694 (intern p) | |
1695 (intern (concat "calcFunc-" p))) | |
1696 h (1+ widest) | |
1697 p nil) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1698 (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
|
1699 (math-read-big-emptyp widest (1+ v) h math-rb-v2 nil t) |
40785 | 1700 (while (progn |
1701 (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
|
1702 (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
|
1703 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t) |
40785 | 1704 (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
|
1705 h math-rb-v1 (1- widest) math-rb-v2 v) p) |
40785 | 1706 h widest) |
1707 (= (math-read-big-char (1- h) v) ?\,))) | |
1708 (or (= (math-read-big-char (1- h) v) ?\)) | |
1709 (math-read-big-error (1- h) v "Expected `)'")) | |
1710 (setq p (cons line (nreverse p)))) | |
1711 (setq p (list 'var | |
1712 (intern (math-remove-dashes p)) | |
1713 (if (string-match "-" p) | |
1714 (intern p) | |
1715 (intern (concat "var-" p))))))) | |
1716 | |
1717 ;; Number. | |
1718 (t | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1719 (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
|
1720 (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 | 1721 (math-read-big-error h v "Expected a number")) |
1722 (setq h (match-end 0) | |
1723 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
|
1724 (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
|
1725 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t))) |
40785 | 1726 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1727 ;; 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
|
1728 ;; baseline = v. |
40785 | 1729 (if baseline |
1730 (or (= v baseline) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1731 (math-read-big-error math-rb-h1 v "Inconsistent baseline in formula")) |
40785 | 1732 (setq baseline v)) |
1733 | |
1734 ;; Look for superscripts or subscripts. | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1735 (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
|
1736 len (min math-rb-h2 (length line)) |
40785 | 1737 widest h) |
1738 (while (and (< widest len) | |
1739 (= (aref line widest) ?\ )) | |
1740 (setq widest (1+ widest))) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1741 (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
|
1742 (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
|
1743 (if (math-read-big-emptyp h math-rb-v1 widest v) |
40785 | 1744 (setq h widest) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1745 (setq p (list '^ p (math-read-big-rec h math-rb-v1 widest v)) |
40785 | 1746 h widest)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1747 (if (math-read-big-emptyp h math-rb-v1 widest v) |
40785 | 1748 (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
|
1749 (math-read-big-rec h v widest math-rb-v2)) |
40785 | 1750 h widest))) |
1751 | |
1752 ;; Look for an operator name and grab additional terms. | |
1753 (while (and (< h len) | |
1754 (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
|
1755 h math-rb-v1 (1+ h) v) |
40785 | 1756 (math-read-big-emptyp |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1757 h (1+ v) (1+ h) math-rb-v2) |
40785 | 1758 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h) |
1759 (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
|
1760 (math-standard-ops)))) |
40785 | 1761 (and (>= (nth 2 widest) prec) |
1762 (setq h (match-end 0))) | |
1763 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h) | |
1764 h)) | |
1765 (setq widest '("2x" * 196 195))))) | |
1766 (cond ((eq (nth 3 widest) -1) | |
1767 (setq p (list (nth 1 widest) p))) | |
1768 ((equal (car widest) "?") | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1769 (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
|
1770 math-rb-v2 baseline nil t))) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1771 (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
|
1772 (math-read-big-error math-read-big-h2 baseline "Expected `:'")) |
40785 | 1773 (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
|
1774 (math-read-big-rec |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1775 (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
|
1776 baseline (nth 3 widest) t)) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1777 h math-read-big-h2))) |
40785 | 1778 (t |
1779 (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
|
1780 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2 |
40785 | 1781 baseline (nth 3 widest) t)) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1782 h math-read-big-h2)))) |
40785 | 1783 |
1784 ;; 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
|
1785 (setq math-read-big-baseline baseline |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1786 math-read-big-h2 h) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1787 (or short (= math-read-big-h2 math-rb-h2) |
40785 | 1788 (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
|
1789 p))) |
40785 | 1790 |
1791 (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
|
1792 (or (and (>= h math-rb-h1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1793 (< h math-rb-h2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1794 (>= v math-rb-v1) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1795 (< v math-rb-v2) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1796 (let ((line (nth v math-read-big-lines))) |
40785 | 1797 (and line |
1798 (< h (length line)) | |
1799 (aref line h)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1800 ?\ )) |
40785 | 1801 |
1802 (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
|
1803 (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
|
1804 (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
|
1805 (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
|
1806 (and (> eh2 math-rb-h2) (setq eh2 math-rb-h2)) |
40785 | 1807 (or what (setq what ?\ )) |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1808 (let ((p (nthcdr ev1 math-read-big-lines)) |
40785 | 1809 h) |
1810 (while (and (< ev1 ev2) | |
1811 (progn | |
1812 (setq h (min eh2 (length (car p)))) | |
1813 (while (and (>= (setq h (1- h)) eh1) | |
1814 (= (aref (car p) h) what))) | |
1815 (and error (>= h eh1) | |
1816 (math-read-big-error h ev1 (if (stringp error) | |
1817 error | |
1818 "Whitespace expected"))) | |
1819 (< h eh1))) | |
1820 (setq ev1 (1+ ev1) | |
1821 p (cdr p))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1822 (>= ev1 ev2))) |
40785 | 1823 |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1824 ;; 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
|
1825 ;; 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
|
1826 ;; math-read-big-expr. |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1827 (defvar math-read-big-err-msg) |
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1828 |
40785 | 1829 (defun math-read-big-error (h v &optional msg) |
1830 (let ((pos 0) | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1831 (p math-read-big-lines)) |
40785 | 1832 (while (> v 0) |
1833 (setq pos (+ pos 1 (length (car p))) | |
1834 p (cdr p) | |
1835 v (1- v))) | |
1836 (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
|
1837 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
|
1838 (throw 'syntax nil))) |
40785 | 1839 |
1840 (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
|
1841 (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
|
1842 (len (min math-rb-h2 (length line))) |
40785 | 1843 (count 1)) |
1844 (while (> count 0) | |
1845 (if (>= h len) | |
1846 (if what | |
58411
9ceda393e263
(math-read-big-lines): New variable.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58134
diff
changeset
|
1847 (math-read-big-error nil v (format "Unmatched `%s'" what)) |
40785 | 1848 (setq count 0)) |
1849 (if (memq (aref line h) '(?\( ?\[)) | |
1850 (setq count (1+ count)) | |
1851 (if (if (and commas (= count 1)) | |
1852 (or (memq (aref line h) '(?\) ?\] ?\, ?\;)) | |
1853 (and (eq (aref line h) ?\.) | |
1854 (< (1+ h) len) | |
1855 (eq (aref line (1+ h)) ?\.))) | |
1856 (memq (aref line h) '(?\) ?\]))) | |
1857 (setq count (1- count)))) | |
1858 (setq h (1+ h)))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
1859 h)) |
40785 | 1860 |
58661
10224395a3c2
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58571
diff
changeset
|
1861 (provide 'calc-lang) |
10224395a3c2
Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
58571
diff
changeset
|
1862 |
52401 | 1863 ;;; 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
|
1864 ;;; calc-lang.el ends here |