comparison lisp/calc/calc-lang.el @ 41047:73f364fd8aaa

Style cleanup; don't put closing parens on their own line, add "foo.el ends here" to each file, and update copyright date.
author Colin Walters <walters@gnu.org>
date Wed, 14 Nov 2001 09:09:09 +0000
parents 2fb9d407ae73
children fcd507927105
comparison
equal deleted inserted replaced
41046:14b73d89514a 41047:73f364fd8aaa
1 ;; Calculator for GNU Emacs, part II [calc-lang.el] 1 ;; Calculator for GNU Emacs, part II [calc-lang.el]
2 ;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. 2 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
3 ;; Written by Dave Gillespie, daveg@synaptics.com. 3 ;; Written by Dave Gillespie, daveg@synaptics.com.
4 4
5 ;; This file is part of GNU Emacs. 5 ;; This file is part of GNU Emacs.
6 6
7 ;; GNU Emacs is distributed in the hope that it will be useful, 7 ;; GNU Emacs is distributed in the hope that it will be useful,
44 calc-function-close (or (get lang 'math-function-close) ")")) 44 calc-function-close (or (get lang 'math-function-close) ")"))
45 (if no-refresh 45 (if no-refresh
46 (setq calc-language lang 46 (setq calc-language lang
47 calc-language-option option) 47 calc-language-option option)
48 (calc-change-mode '(calc-language calc-language-option) 48 (calc-change-mode '(calc-language calc-language-option)
49 (list lang option) t)) 49 (list lang option) t)))
50 )
51 50
52 (defun calc-normal-language () 51 (defun calc-normal-language ()
53 (interactive) 52 (interactive)
54 (calc-wrapper 53 (calc-wrapper
55 (calc-set-language nil) 54 (calc-set-language nil)
56 (message "Normal language mode.")) 55 (message "Normal language mode.")))
57 )
58 56
59 (defun calc-flat-language () 57 (defun calc-flat-language ()
60 (interactive) 58 (interactive)
61 (calc-wrapper 59 (calc-wrapper
62 (calc-set-language 'flat) 60 (calc-set-language 'flat)
63 (message "Flat language mode (all stack entries shown on one line).")) 61 (message "Flat language mode (all stack entries shown on one line).")))
64 )
65 62
66 (defun calc-big-language () 63 (defun calc-big-language ()
67 (interactive) 64 (interactive)
68 (calc-wrapper 65 (calc-wrapper
69 (calc-set-language 'big) 66 (calc-set-language 'big)
70 (message "\"Big\" language mode.")) 67 (message "\"Big\" language mode.")))
71 )
72 68
73 (defun calc-unformatted-language () 69 (defun calc-unformatted-language ()
74 (interactive) 70 (interactive)
75 (calc-wrapper 71 (calc-wrapper
76 (calc-set-language 'unform) 72 (calc-set-language 'unform)
77 (message "Unformatted language mode.")) 73 (message "Unformatted language mode.")))
78 )
79 74
80 75
81 (defun calc-c-language () 76 (defun calc-c-language ()
82 (interactive) 77 (interactive)
83 (calc-wrapper 78 (calc-wrapper
84 (calc-set-language 'c) 79 (calc-set-language 'c)
85 (message "`C' language mode.")) 80 (message "`C' language mode.")))
86 )
87 81
88 (put 'c 'math-oper-table 82 (put 'c 'math-oper-table
89 '( ( "u+" ident -1 1000 ) 83 '( ( "u+" ident -1 1000 )
90 ( "u-" neg -1 1000 ) 84 ( "u-" neg -1 1000 )
91 ( "u!" calcFunc-lnot -1 1000 ) 85 ( "u!" calcFunc-lnot -1 1000 )
112 ( "!!!" calcFunc-pnot -1 88 ) 106 ( "!!!" calcFunc-pnot -1 88 )
113 ( "&&&" calcFunc-pand 85 86 ) 107 ( "&&&" calcFunc-pand 85 86 )
114 ( "|||" calcFunc-por 75 76 ) 108 ( "|||" calcFunc-por 75 76 )
115 ( "=" calcFunc-assign 51 50 ) 109 ( "=" calcFunc-assign 51 50 )
116 ( ":=" calcFunc-assign 51 50 ) 110 ( ":=" calcFunc-assign 51 50 )
117 ( "::" calcFunc-condition 45 46 ) 111 ( "::" calcFunc-condition 45 46 ))) ; should support full assignments
118 )) ; should support full assignments
119 112
120 (put 'c 'math-function-table 113 (put 'c 'math-function-table
121 '( ( acos . calcFunc-arccos ) 114 '( ( acos . calcFunc-arccos )
122 ( acosh . calcFunc-arccosh ) 115 ( acosh . calcFunc-arccosh )
123 ( asin . calcFunc-arcsin ) 116 ( asin . calcFunc-arcsin )
124 ( asinh . calcFunc-arcsinh ) 117 ( asinh . calcFunc-arcsinh )
125 ( atan . calcFunc-arctan ) 118 ( atan . calcFunc-arctan )
126 ( atan2 . calcFunc-arctan2 ) 119 ( atan2 . calcFunc-arctan2 )
127 ( atanh . calcFunc-arctanh ) 120 ( atanh . calcFunc-arctanh )))
128 ))
129 121
130 (put 'c 'math-variable-table 122 (put 'c 'math-variable-table
131 '( ( M_PI . var-pi ) 123 '( ( M_PI . var-pi )
132 ( M_E . var-e ) 124 ( M_E . var-e )))
133 ))
134 125
135 (put 'c 'math-vector-brackets "{}") 126 (put 'c 'math-vector-brackets "{}")
136 127
137 (put 'c 'math-radix-formatter 128 (put 'c 'math-radix-formatter
138 (function (lambda (r s) 129 (function (lambda (r s)
148 (calc-set-language 'pascal n) 139 (calc-set-language 'pascal n)
149 (message (if (and n (/= n 0)) 140 (message (if (and n (/= n 0))
150 (if (> n 0) 141 (if (> n 0)
151 "Pascal language mode (all uppercase)." 142 "Pascal language mode (all uppercase)."
152 "Pascal language mode (all lowercase).") 143 "Pascal language mode (all lowercase).")
153 "Pascal language mode."))) 144 "Pascal language mode."))))
154 )
155 145
156 (put 'pascal 'math-oper-table 146 (put 'pascal 'math-oper-table
157 '( ( "not" calcFunc-lnot -1 1000 ) 147 '( ( "not" calcFunc-lnot -1 1000 )
158 ( "*" * 190 191 ) 148 ( "*" * 190 191 )
159 ( "/" / 190 191 ) 149 ( "/" / 190 191 )
177 ( "<>" calcFunc-neq 160 161 ) 167 ( "<>" calcFunc-neq 160 161 )
178 ( "!!!" calcFunc-pnot -1 85 ) 168 ( "!!!" calcFunc-pnot -1 85 )
179 ( "&&&" calcFunc-pand 80 81 ) 169 ( "&&&" calcFunc-pand 80 81 )
180 ( "|||" calcFunc-por 75 76 ) 170 ( "|||" calcFunc-por 75 76 )
181 ( ":=" calcFunc-assign 51 50 ) 171 ( ":=" calcFunc-assign 51 50 )
182 ( "::" calcFunc-condition 45 46 ) 172 ( "::" calcFunc-condition 45 46 )))
183 ))
184 173
185 (put 'pascal 'math-input-filter 'calc-input-case-filter) 174 (put 'pascal 'math-input-filter 'calc-input-case-filter)
186 (put 'pascal 'math-output-filter 'calc-output-case-filter) 175 (put 'pascal 'math-output-filter 'calc-output-case-filter)
187 176
188 (put 'pascal 'math-radix-formatter 177 (put 'pascal 'math-radix-formatter
192 181
193 (defun calc-input-case-filter (str) 182 (defun calc-input-case-filter (str)
194 (cond ((or (null calc-language-option) (= calc-language-option 0)) 183 (cond ((or (null calc-language-option) (= calc-language-option 0))
195 str) 184 str)
196 (t 185 (t
197 (downcase str))) 186 (downcase str))))
198 )
199 187
200 (defun calc-output-case-filter (str) 188 (defun calc-output-case-filter (str)
201 (cond ((or (null calc-language-option) (= calc-language-option 0)) 189 (cond ((or (null calc-language-option) (= calc-language-option 0))
202 str) 190 str)
203 ((> calc-language-option 0) 191 ((> calc-language-option 0)
204 (upcase str)) 192 (upcase str))
205 (t 193 (t
206 (downcase str))) 194 (downcase str))))
207 )
208 195
209 196
210 (defun calc-fortran-language (n) 197 (defun calc-fortran-language (n)
211 (interactive "P") 198 (interactive "P")
212 (calc-wrapper 199 (calc-wrapper
214 (calc-set-language 'fortran n) 201 (calc-set-language 'fortran n)
215 (message (if (and n (/= n 0)) 202 (message (if (and n (/= n 0))
216 (if (> n 0) 203 (if (> n 0)
217 "FORTRAN language mode (all uppercase)." 204 "FORTRAN language mode (all uppercase)."
218 "FORTRAN language mode (all lowercase).") 205 "FORTRAN language mode (all lowercase).")
219 "FORTRAN language mode."))) 206 "FORTRAN language mode."))))
220 )
221 207
222 (put 'fortran 'math-oper-table 208 (put 'fortran 'math-oper-table
223 '( ( "u/" (math-parse-fortran-vector) -1 1 ) 209 '( ( "u/" (math-parse-fortran-vector) -1 1 )
224 ( "/" (math-parse-fortran-vector-end) 1 -1 ) 210 ( "/" (math-parse-fortran-vector-end) 1 -1 )
225 ( "**" ^ 201 200 ) 211 ( "**" ^ 201 200 )
241 ( "!!!" calcFunc-pnot -1 85 ) 227 ( "!!!" calcFunc-pnot -1 85 )
242 ( "&&&" calcFunc-pand 80 81 ) 228 ( "&&&" calcFunc-pand 80 81 )
243 ( "|||" calcFunc-por 75 76 ) 229 ( "|||" calcFunc-por 75 76 )
244 ( "=" calcFunc-assign 51 50 ) 230 ( "=" calcFunc-assign 51 50 )
245 ( ":=" calcFunc-assign 51 50 ) 231 ( ":=" calcFunc-assign 51 50 )
246 ( "::" calcFunc-condition 45 46 ) 232 ( "::" calcFunc-condition 45 46 )))
247 ))
248 233
249 (put 'fortran 'math-vector-brackets "//") 234 (put 'fortran 'math-vector-brackets "//")
250 235
251 (put 'fortran 'math-function-table 236 (put 'fortran 'math-function-table
252 '( ( acos . calcFunc-arccos ) 237 '( ( acos . calcFunc-arccos )
259 ( atan2 . calcFunc-arctan2 ) 244 ( atan2 . calcFunc-arctan2 )
260 ( atanh . calcFunc-arctanh ) 245 ( atanh . calcFunc-arctanh )
261 ( conjg . calcFunc-conj ) 246 ( conjg . calcFunc-conj )
262 ( log . calcFunc-ln ) 247 ( log . calcFunc-ln )
263 ( nint . calcFunc-round ) 248 ( nint . calcFunc-round )
264 ( real . calcFunc-re ) 249 ( real . calcFunc-re )))
265 ))
266 250
267 (put 'fortran 'math-input-filter 'calc-input-case-filter) 251 (put 'fortran 'math-input-filter 'calc-input-case-filter)
268 (put 'fortran 'math-output-filter 'calc-output-case-filter) 252 (put 'fortran 'math-output-filter 'calc-output-case-filter)
269 253
270 (defun math-parse-fortran-vector (op) 254 (defun math-parse-fortran-vector (op)
271 (let ((math-parsing-fortran-vector '(end . "\000"))) 255 (let ((math-parsing-fortran-vector '(end . "\000")))
272 (prog1 256 (prog1
273 (math-read-brackets t "]") 257 (math-read-brackets t "]")
274 (setq exp-token (car math-parsing-fortran-vector) 258 (setq exp-token (car math-parsing-fortran-vector)
275 exp-data (cdr math-parsing-fortran-vector)))) 259 exp-data (cdr math-parsing-fortran-vector)))))
276 )
277 260
278 (defun math-parse-fortran-vector-end (x op) 261 (defun math-parse-fortran-vector-end (x op)
279 (if math-parsing-fortran-vector 262 (if math-parsing-fortran-vector
280 (progn 263 (progn
281 (setq math-parsing-fortran-vector (cons exp-token exp-data) 264 (setq math-parsing-fortran-vector (cons exp-token exp-data)
282 exp-token 'end 265 exp-token 'end
283 exp-data "\000") 266 exp-data "\000")
284 x) 267 x)
285 (throw 'syntax "Unmatched closing `/'")) 268 (throw 'syntax "Unmatched closing `/'")))
286 )
287 (setq math-parsing-fortran-vector nil) 269 (setq math-parsing-fortran-vector nil)
288 270
289 (defun math-parse-fortran-subscr (sym args) 271 (defun math-parse-fortran-subscr (sym args)
290 (setq sym (math-build-var-name sym)) 272 (setq sym (math-build-var-name sym))
291 (while args 273 (while args
292 (setq sym (list 'calcFunc-subscr sym (car args)) 274 (setq sym (list 'calcFunc-subscr sym (car args))
293 args (cdr args))) 275 args (cdr args)))
294 sym 276 sym)
295 )
296 277
297 278
298 (defun calc-tex-language (n) 279 (defun calc-tex-language (n)
299 (interactive "P") 280 (interactive "P")
300 (calc-wrapper 281 (calc-wrapper
302 (calc-set-language 'tex n) 283 (calc-set-language 'tex n)
303 (message (if (and n (/= n 0)) 284 (message (if (and n (/= n 0))
304 (if (> n 0) 285 (if (> n 0)
305 "TeX language mode with \\hbox{func}(\\hbox{var})." 286 "TeX language mode with \\hbox{func}(\\hbox{var})."
306 "TeX language mode with \\func{\\hbox{var}}.") 287 "TeX language mode with \\func{\\hbox{var}}.")
307 "TeX language mode."))) 288 "TeX language mode."))))
308 )
309 289
310 (put 'tex 'math-oper-table 290 (put 'tex 'math-oper-table
311 '( ( "u+" ident -1 1000 ) 291 '( ( "u+" ident -1 1000 )
312 ( "u-" neg -1 1000 ) 292 ( "u-" neg -1 1000 )
313 ( "\\hat" calcFunc-hat -1 950 ) 293 ( "\\hat" calcFunc-hat -1 950 )
358 ( ":=" calcFunc-assign 51 50 ) 338 ( ":=" calcFunc-assign 51 50 )
359 ( "::" calcFunc-condition 45 46 ) 339 ( "::" calcFunc-condition 45 46 )
360 ( "\\to" calcFunc-evalto 40 41 ) 340 ( "\\to" calcFunc-evalto 40 41 )
361 ( "\\to" calcFunc-evalto 40 -1 ) 341 ( "\\to" calcFunc-evalto 40 -1 )
362 ( "=>" calcFunc-evalto 40 41 ) 342 ( "=>" calcFunc-evalto 40 41 )
363 ( "=>" calcFunc-evalto 40 -1 ) 343 ( "=>" calcFunc-evalto 40 -1 )))
364 ))
365 344
366 (put 'tex 'math-function-table 345 (put 'tex 'math-function-table
367 '( ( \\arccos . calcFunc-arccos ) 346 '( ( \\arccos . calcFunc-arccos )
368 ( \\arcsin . calcFunc-arcsin ) 347 ( \\arcsin . calcFunc-arcsin )
369 ( \\arctan . calcFunc-arctan ) 348 ( \\arctan . calcFunc-arctan )
381 ( \\sin . calcFunc-sin ) 360 ( \\sin . calcFunc-sin )
382 ( \\sinh . calcFunc-sinh ) 361 ( \\sinh . calcFunc-sinh )
383 ( \\sqrt . calcFunc-sqrt ) 362 ( \\sqrt . calcFunc-sqrt )
384 ( \\tanh . calcFunc-tanh ) 363 ( \\tanh . calcFunc-tanh )
385 ( \\phi . calcFunc-totient ) 364 ( \\phi . calcFunc-totient )
386 ( \\mu . calcFunc-moebius ) 365 ( \\mu . calcFunc-moebius )))
387 ))
388 366
389 (put 'tex 'math-variable-table 367 (put 'tex 'math-variable-table
390 '( ( \\pi . var-pi ) 368 '( ( \\pi . var-pi )
391 ( \\infty . var-inf ) 369 ( \\infty . var-inf )
392 ( \\infty . var-uinf ) 370 ( \\infty . var-uinf )
393 ( \\phi . var-phi ) 371 ( \\phi . var-phi )
394 ( \\gamma . var-gamma ) 372 ( \\gamma . var-gamma )
395 ( \\sum . (math-parse-tex-sum calcFunc-sum) ) 373 ( \\sum . (math-parse-tex-sum calcFunc-sum) )
396 ( \\prod . (math-parse-tex-sum calcFunc-prod) ) 374 ( \\prod . (math-parse-tex-sum calcFunc-prod) )))
397 ))
398 375
399 (put 'tex 'math-complex-format 'i) 376 (put 'tex 'math-complex-format 'i)
400 377
401 (defun math-parse-tex-sum (f val) 378 (defun math-parse-tex-sum (f val)
402 (let (low high save) 379 (let (low high save)
409 (setq exp-old-pos (1+ save)) 386 (setq exp-old-pos (1+ save))
410 (throw 'syntax "Expected equation"))) 387 (throw 'syntax "Expected equation")))
411 (or (equal exp-data "^") (throw 'syntax "Expected `^'")) 388 (or (equal exp-data "^") (throw 'syntax "Expected `^'"))
412 (math-read-token) 389 (math-read-token)
413 (setq high (math-read-factor)) 390 (setq high (math-read-factor))
414 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high)) 391 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high)))
415 )
416 392
417 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789. 393 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789.
418 (while (string-match "[0-9]\\\\,[0-9]" str) 394 (while (string-match "[0-9]\\\\,[0-9]" str)
419 (setq str (concat (substring str 0 (1+ (match-beginning 0))) 395 (setq str (concat (substring str 0 (1+ (match-beginning 0)))
420 (substring str (1- (match-end 0)))))) 396 (substring str (1- (match-end 0))))))
421 str 397 str)
422 )
423 (put 'tex 'math-input-filter 'math-tex-input-filter) 398 (put 'tex 'math-input-filter 'math-tex-input-filter)
424 399
425 400
426 (defun calc-eqn-language (n) 401 (defun calc-eqn-language (n)
427 (interactive "P") 402 (interactive "P")
428 (calc-wrapper 403 (calc-wrapper
429 (calc-set-language 'eqn) 404 (calc-set-language 'eqn)
430 (message "Eqn language mode.")) 405 (message "Eqn language mode.")))
431 )
432 406
433 (put 'eqn 'math-oper-table 407 (put 'eqn 'math-oper-table
434 '( ( "u+" ident -1 1000 ) 408 '( ( "u+" ident -1 1000 )
435 ( "u-" neg -1 1000 ) 409 ( "u-" neg -1 1000 )
436 ( "prime" (math-parse-eqn-prime) 950 -1 ) 410 ( "prime" (math-parse-eqn-prime) 950 -1 )
480 ( ":=" calcFunc-assign 51 50 ) 454 ( ":=" calcFunc-assign 51 50 )
481 ( "::" calcFunc-condition 45 46 ) 455 ( "::" calcFunc-condition 45 46 )
482 ( "->" calcFunc-evalto 40 41 ) 456 ( "->" calcFunc-evalto 40 41 )
483 ( "->" calcFunc-evalto 40 -1 ) 457 ( "->" calcFunc-evalto 40 -1 )
484 ( "=>" calcFunc-evalto 40 41 ) 458 ( "=>" calcFunc-evalto 40 41 )
485 ( "=>" calcFunc-evalto 40 -1 ) 459 ( "=>" calcFunc-evalto 40 -1 )))
486 ))
487 460
488 (put 'eqn 'math-function-table 461 (put 'eqn 'math-function-table
489 '( ( arc\ cos . calcFunc-arccos ) 462 '( ( arc\ cos . calcFunc-arccos )
490 ( arc\ cosh . calcFunc-arccosh ) 463 ( arc\ cosh . calcFunc-arccosh )
491 ( arc\ sin . calcFunc-arcsin ) 464 ( arc\ sin . calcFunc-arcsin )
493 ( arc\ tan . calcFunc-arctan ) 466 ( arc\ tan . calcFunc-arctan )
494 ( arc\ tanh . calcFunc-arctanh ) 467 ( arc\ tanh . calcFunc-arctanh )
495 ( GAMMA . calcFunc-gamma ) 468 ( GAMMA . calcFunc-gamma )
496 ( phi . calcFunc-totient ) 469 ( phi . calcFunc-totient )
497 ( mu . calcFunc-moebius ) 470 ( mu . calcFunc-moebius )
498 ( matrix . (math-parse-eqn-matrix) ) 471 ( matrix . (math-parse-eqn-matrix) )))
499 ))
500 472
501 (put 'eqn 'math-variable-table 473 (put 'eqn 'math-variable-table
502 '( ( inf . var-uinf ) 474 '( ( inf . var-uinf )))
503 ))
504 475
505 (put 'eqn 'math-complex-format 'i) 476 (put 'eqn 'math-complex-format 'i)
506 477
507 (defun math-parse-eqn-matrix (f sym) 478 (defun math-parse-eqn-matrix (f sym)
508 (let ((vec nil)) 479 (let ((vec nil))
516 (throw 'syntax "Expected `}'")) 487 (throw 'syntax "Expected `}'"))
517 (math-read-token)) 488 (math-read-token))
518 (or (equal exp-data calc-function-close) 489 (or (equal exp-data calc-function-close)
519 (throw 'syntax "Expected `}'")) 490 (throw 'syntax "Expected `}'"))
520 (math-read-token) 491 (math-read-token)
521 (math-transpose (cons 'vec (nreverse vec)))) 492 (math-transpose (cons 'vec (nreverse vec)))))
522 )
523 493
524 (defun math-parse-eqn-prime (x sym) 494 (defun math-parse-eqn-prime (x sym)
525 (if (eq (car-safe x) 'var) 495 (if (eq (car-safe x) 'var)
526 (if (equal exp-data calc-function-open) 496 (if (equal exp-data calc-function-open)
527 (progn 497 (progn
536 (math-read-token) 506 (math-read-token)
537 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args))) 507 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args)))
538 (list 'var 508 (list 'var
539 (intern (concat (symbol-name (nth 1 x)) "'")) 509 (intern (concat (symbol-name (nth 1 x)) "'"))
540 (intern (concat (symbol-name (nth 2 x)) "'")))) 510 (intern (concat (symbol-name (nth 2 x)) "'"))))
541 (list 'calcFunc-Prime x)) 511 (list 'calcFunc-Prime x)))
542 )
543 512
544 513
545 (defun calc-mathematica-language () 514 (defun calc-mathematica-language ()
546 (interactive) 515 (interactive)
547 (calc-wrapper 516 (calc-wrapper
548 (calc-set-language 'math) 517 (calc-set-language 'math)
549 (message "Mathematica language mode.")) 518 (message "Mathematica language mode.")))
550 )
551 519
552 (put 'math 'math-oper-table 520 (put 'math 'math-oper-table
553 '( ( "[[" (math-read-math-subscr) 250 -1 ) 521 '( ( "[[" (math-read-math-subscr) 250 -1 )
554 ( "!" calcFunc-fact 210 -1 ) 522 ( "!" calcFunc-fact 210 -1 )
555 ( "!!" calcFunc-dfact 210 -1 ) 523 ( "!!" calcFunc-dfact 210 -1 )
651 (progn 619 (progn
652 (math-read-token) 620 (math-read-token)
653 (equal exp-data "]"))) 621 (equal exp-data "]")))
654 (throw 'syntax "Expected ']]'")) 622 (throw 'syntax "Expected ']]'"))
655 (math-read-token) 623 (math-read-token)
656 (list 'calcFunc-subscr x idx)) 624 (list 'calcFunc-subscr x idx)))
657 )
658 625
659 626
660 (defun calc-maple-language () 627 (defun calc-maple-language ()
661 (interactive) 628 (interactive)
662 (calc-wrapper 629 (calc-wrapper
663 (calc-set-language 'maple) 630 (calc-set-language 'maple)
664 (message "Maple language mode.")) 631 (message "Maple language mode.")))
665 )
666 632
667 (put 'maple 'math-oper-table 633 (put 'maple 'math-oper-table
668 '( ( "matrix" ident -1 300 ) 634 '( ( "matrix" ident -1 300 )
669 ( "MATRIX" ident -1 300 ) 635 ( "MATRIX" ident -1 300 )
670 ( "!" calcFunc-fact 210 -1 ) 636 ( "!" calcFunc-fact 210 -1 )
730 )) 696 ))
731 697
732 (put 'maple 'math-complex-format 'I) 698 (put 'maple 'math-complex-format 'I)
733 699
734 (defun math-read-maple-dots (x op) 700 (defun math-read-maple-dots (x op)
735 (list 'intv 3 x (math-read-expr-level (nth 3 op))) 701 (list 'intv 3 x (math-read-expr-level (nth 3 op))))
736 )
737 702
738 703
739 704
740 705
741 706
1072 ;; Return all relevant information to caller. 1037 ;; Return all relevant information to caller.
1073 (setq the-baseline baseline 1038 (setq the-baseline baseline
1074 the-h2 h) 1039 the-h2 h)
1075 (or short (= the-h2 h2) 1040 (or short (= the-h2 h2)
1076 (math-read-big-error h baseline)) 1041 (math-read-big-error h baseline))
1077 p)) 1042 p)))
1078 )
1079 1043
1080 (defun math-read-big-char (h v) 1044 (defun math-read-big-char (h v)
1081 (or (and (>= h h1) 1045 (or (and (>= h h1)
1082 (< h h2) 1046 (< h h2)
1083 (>= v v1) 1047 (>= v v1)
1084 (< v v2) 1048 (< v v2)
1085 (let ((line (nth v lines))) 1049 (let ((line (nth v lines)))
1086 (and line 1050 (and line
1087 (< h (length line)) 1051 (< h (length line))
1088 (aref line h)))) 1052 (aref line h))))
1089 ?\ ) 1053 ?\ ))
1090 )
1091 1054
1092 (defun math-read-big-emptyp (eh1 ev1 eh2 ev2 &optional what error) 1055 (defun math-read-big-emptyp (eh1 ev1 eh2 ev2 &optional what error)
1093 (and (< ev1 v1) (setq ev1 v1)) 1056 (and (< ev1 v1) (setq ev1 v1))
1094 (and (< eh1 h1) (setq eh1 h1)) 1057 (and (< eh1 h1) (setq eh1 h1))
1095 (and (> ev2 v2) (setq ev2 v2)) 1058 (and (> ev2 v2) (setq ev2 v2))
1107 error 1070 error
1108 "Whitespace expected"))) 1071 "Whitespace expected")))
1109 (< h eh1))) 1072 (< h eh1)))
1110 (setq ev1 (1+ ev1) 1073 (setq ev1 (1+ ev1)
1111 p (cdr p))) 1074 p (cdr p)))
1112 (>= ev1 ev2)) 1075 (>= ev1 ev2)))
1113 )
1114 1076
1115 (defun math-read-big-error (h v &optional msg) 1077 (defun math-read-big-error (h v &optional msg)
1116 (let ((pos 0) 1078 (let ((pos 0)
1117 (p lines)) 1079 (p lines))
1118 (while (> v 0) 1080 (while (> v 0)
1119 (setq pos (+ pos 1 (length (car p))) 1081 (setq pos (+ pos 1 (length (car p)))
1120 p (cdr p) 1082 p (cdr p)
1121 v (1- v))) 1083 v (1- v)))
1122 (setq h (+ pos (min h (length (car p)))) 1084 (setq h (+ pos (min h (length (car p))))
1123 err-msg (list 'error h (or msg "Syntax error"))) 1085 err-msg (list 'error h (or msg "Syntax error")))
1124 (throw 'syntax nil)) 1086 (throw 'syntax nil)))
1125 )
1126 1087
1127 (defun math-read-big-balance (h v what &optional commas) 1088 (defun math-read-big-balance (h v what &optional commas)
1128 (let* ((line (nth v lines)) 1089 (let* ((line (nth v lines))
1129 (len (min h2 (length line))) 1090 (len (min h2 (length line)))
1130 (count 1)) 1091 (count 1))
1141 (< (1+ h) len) 1102 (< (1+ h) len)
1142 (eq (aref line (1+ h)) ?\.))) 1103 (eq (aref line (1+ h)) ?\.)))
1143 (memq (aref line h) '(?\) ?\]))) 1104 (memq (aref line h) '(?\) ?\])))
1144 (setq count (1- count)))) 1105 (setq count (1- count))))
1145 (setq h (1+ h)))) 1106 (setq h (1+ h))))
1146 h) 1107 h))
1147 ) 1108
1148 1109 ;;; calc-lang.el ends here
1149
1150
1151