1 ;;; calc-lang.el --- calc language functions
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: David Gillespie <daveg@synaptics.com>
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
30 ;; This file is autoloaded from calc-ext.el.
36 ;; Declare functions which are defined elsewhere.
37 (declare-function math-compose-vector
"calccomp" (a sep prec
))
38 (declare-function math-compose-var
"calccomp" (a))
39 (declare-function math-tex-expr-is-flat
"calccomp" (a))
40 (declare-function math-read-factor
"calc-aent" ())
41 (declare-function math-read-expr-level
"calc-aent" (exp-prec &optional exp-term
))
43 ;; Declare variables which are defined elsewhere.
44 (defvar calc-lang-slash-idiv
)
45 (defvar calc-lang-allow-underscores
)
46 (defvar math-comp-left-bracket
)
47 (defvar math-comp-right-bracket
)
48 (defvar math-comp-comma
)
49 (defvar math-comp-vector-prec
)
51 ;;; Alternate entry/display languages.
53 (defun calc-set-language (lang &optional option no-refresh
)
54 (setq math-expr-opers
(or (get lang
'math-oper-table
) (math-standard-ops))
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
) ")"))
65 (setq calc-language lang
66 calc-language-option option
)
67 (calc-change-mode '(calc-language calc-language-option
)
68 (list lang option
) t
)))
70 (defun calc-normal-language ()
73 (calc-set-language nil
)
74 (message "Normal language mode")))
76 (defun calc-flat-language ()
79 (calc-set-language 'flat
)
80 (message "Flat language mode (all stack entries shown on one line)")))
82 (defun calc-big-language ()
85 (calc-set-language 'big
)
86 (message "\"Big\" language mode")))
88 (defun calc-unformatted-language ()
91 (calc-set-language 'unform
)
92 (message "Unformatted language mode")))
95 (defun calc-c-language ()
98 (calc-set-language 'c
)
99 (message "`C' language mode")))
101 (put 'c
'math-oper-table
102 '( ( "u!" calcFunc-lnot -
1 1000 )
103 ( "~" calcFunc-not -
1 1000 )
104 ( "u+" ident -
1 197 )
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 )
130 ( "::" calcFunc-condition
45 46 ))) ; should support full assignments
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
)
139 ( atanh . calcFunc-arctanh
)))
141 (put 'c
'math-variable-table
145 (put 'c
'math-vector-brackets
"{}")
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
))))))
153 (put 'c
'math-compose-subscr
156 (let ((args (cdr (cdr a
))))
158 (math-compose-expr (nth 1 a
) 1000)
160 (math-compose-vector args
", " 0)
163 (add-to-list 'calc-lang-slash-idiv
'c
)
164 (add-to-list 'calc-lang-allow-underscores
'c
)
165 (add-to-list 'calc-lang-c-type-hex
'c
)
166 (add-to-list 'calc-lang-brackets-are-subscripts
'c
)
168 (defun calc-pascal-language (n)
171 (and n
(setq n
(prefix-numeric-value n
)))
172 (calc-set-language 'pascal n
)
173 (message (if (and n
(/= n
0))
175 "Pascal language mode (all uppercase)"
176 "Pascal language mode (all lowercase)")
177 "Pascal language mode"))))
179 (put 'pascal
'math-oper-table
180 '( ( "not" calcFunc-lnot -
1 1000 )
183 ( "and" calcFunc-and
190 191 )
184 ( "div" calcFunc-idiv
190 191 )
186 ( "u+" ident -
1 185 )
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 )
205 ( "::" calcFunc-condition
45 46 )))
207 (put 'pascal
'math-input-filter
'calc-input-case-filter
)
208 (put 'pascal
'math-output-filter
'calc-output-case-filter
)
210 (put 'pascal
'math-radix-formatter
211 (function (lambda (r s
)
212 (if (= r
16) (format "$%s" s
)
213 (format "%d#%s" r s
)))))
215 (put 'pascal
'math-lang-read-symbol
218 "\\(\\$[0-9a-fA-F]+\\)\\($\\|[^0-9a-zA-Z]\\)"
219 math-exp-str math-exp-pos
)
221 (setq math-exp-token
'number
222 math-expr-data
(math-match-substring math-exp-str
1)
223 math-exp-pos
(match-end 1)))))
225 (put 'pascal
'math-compose-subscr
228 (let ((args (cdr (cdr a
))))
229 (while (eq (car-safe (nth 1 a
)) 'calcFunc-subscr
)
230 (setq args
(append (cdr (cdr (nth 1 a
))) args
)
233 (math-compose-expr (nth 1 a
) 1000)
235 (math-compose-vector args
", " 0)
238 (add-to-list 'calc-lang-allow-underscores
'pascal
)
239 (add-to-list 'calc-lang-brackets-are-subscripts
'pascal
)
241 (defun calc-input-case-filter (str)
242 (cond ((or (null calc-language-option
) (= calc-language-option
0))
247 (defun calc-output-case-filter (str)
248 (cond ((or (null calc-language-option
) (= calc-language-option
0))
250 ((> calc-language-option
0)
256 (defun calc-fortran-language (n)
259 (and n
(setq n
(prefix-numeric-value n
)))
260 (calc-set-language 'fortran n
)
261 (message (if (and n
(/= n
0))
263 "FORTRAN language mode (all uppercase)"
264 "FORTRAN language mode (all lowercase)")
265 "FORTRAN language mode"))))
267 (put 'fortran
'math-oper-table
268 '( ( "u/" (math-parse-fortran-vector) -
1 1 )
269 ( "/" (math-parse-fortran-vector-end) 1 -
1 )
271 ( "u+" ident -
1 191 )
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 )
291 ( "::" calcFunc-condition
45 46 )))
293 (put 'fortran
'math-vector-brackets
"//")
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
)
308 ( real . calcFunc-re
)))
310 (put 'fortran
'math-input-filter
'calc-input-case-filter
)
312 (put 'fortran
'math-output-filter
'calc-output-case-filter
)
314 (put 'fortran
'math-lang-read-symbol
316 (eq (string-match "\\.[a-zA-Z][a-zA-Z][a-zA-Z]?\\."
317 math-exp-str math-exp-pos
) math-exp-pos
)
318 (setq math-exp-token
'punc
319 math-expr-data
(upcase (math-match-substring math-exp-str
0))
320 math-exp-pos
(match-end 0)))))
322 (put 'fortran
'math-compose-subscr
325 (let ((args (cdr (cdr a
))))
326 (while (eq (car-safe (nth 1 a
)) 'calcFunc-subscr
)
327 (setq args
(append (cdr (cdr (nth 1 a
))) args
)
330 (math-compose-expr (nth 1 a
) 1000)
332 (math-compose-vector args
", " 0)
335 (add-to-list 'calc-lang-slash-idiv
'fortran
)
336 (add-to-list 'calc-lang-allow-underscores
'fortran
)
337 (add-to-list 'calc-lang-parens-are-subscripts
'fortran
)
339 ;; The next few variables are local to math-read-exprs in calc-aent.el
340 ;; and math-read-expr in calc-ext.el, but are set in functions they call.
342 (defvar math-exp-token
)
343 (defvar math-expr-data
)
344 (defvar math-exp-old-pos
)
346 (defvar math-parsing-fortran-vector nil
)
347 (defun math-parse-fortran-vector (op)
348 (let ((math-parsing-fortran-vector '(end .
"\000")))
350 (math-read-brackets t
"]")
351 (setq math-exp-token
(car math-parsing-fortran-vector
)
352 math-expr-data
(cdr math-parsing-fortran-vector
)))))
354 (defun math-parse-fortran-vector-end (x op
)
355 (if math-parsing-fortran-vector
357 (setq math-parsing-fortran-vector
(cons math-exp-token math-expr-data
)
359 math-expr-data
"\000")
361 (throw 'syntax
"Unmatched closing `/'")))
363 (defun math-parse-fortran-subscr (sym args
)
364 (setq sym
(math-build-var-name sym
))
366 (setq sym
(list 'calcFunc-subscr sym
(car args
))
371 (defun calc-tex-language (n)
374 (and n
(setq n
(prefix-numeric-value n
)))
375 (calc-set-language 'tex n
)
377 (message "TeX language mode"))
379 (message "TeX language mode with multiline matrices"))
381 (message "TeX language mode with \\hbox{func}(\\hbox{var})"))
384 "TeX language mode with \\hbox{func}(\\hbox{var}) and multiline matrices"))
386 (message "TeX language mode with \\func(\\hbox{var})"))
389 "TeX language mode with \\func(\\hbox{var}) and multiline matrices")))))
391 (defun calc-latex-language (n)
394 (and n
(setq n
(prefix-numeric-value n
)))
395 (calc-set-language 'latex n
)
397 (message "LaTeX language mode"))
399 (message "LaTeX language mode with multiline matrices"))
401 (message "LaTeX language mode with \\text{func}(\\text{var})"))
404 "LaTeX language mode with \\text{func}(\\text{var}) and multiline matrices"))
406 (message "LaTeX language mode with \\func(\\text{var})"))
409 "LaTeX language mode with \\func(\\text{var}) and multiline matrices")))))
411 (put 'tex
'math-oper-table
412 '( ( "\\hat" calcFunc-hat -
1 950 )
413 ( "\\check" calcFunc-check -
1 950 )
414 ( "\\tilde" calcFunc-tilde -
1 950 )
415 ( "\\acute" calcFunc-acute -
1 950 )
416 ( "\\grave" calcFunc-grave -
1 950 )
417 ( "\\dot" calcFunc-dot -
1 950 )
418 ( "\\ddot" calcFunc-dotdot -
1 950 )
419 ( "\\breve" calcFunc-breve -
1 950 )
420 ( "\\bar" calcFunc-bar -
1 950 )
421 ( "\\vec" calcFunc-Vec -
1 950 )
422 ( "\\underline" calcFunc-under -
1 950 )
423 ( "u|" calcFunc-abs -
1 0 )
425 ( "\\lfloor" calcFunc-floor -
1 0 )
426 ( "\\rfloor" closing
0 -
1 )
427 ( "\\lceil" calcFunc-ceil -
1 0 )
428 ( "\\rceil" closing
0 -
1 )
429 ( "\\pm" sdev
300 300 )
430 ( "!" calcFunc-fact
210 -
1 )
432 ( "_" calcFunc-subscr
201 200 )
433 ( "u+" ident -
1 197 )
435 ( "\\times" * 191 190 )
440 ( "\\over" / 170 171 )
442 ( "\\choose" calcFunc-choose
170 171 )
443 ( "\\mod" %
170 171 )
444 ( "<" calcFunc-lt
160 161 )
445 ( ">" calcFunc-gt
160 161 )
446 ( "\\leq" calcFunc-leq
160 161 )
447 ( "\\geq" calcFunc-geq
160 161 )
448 ( "=" calcFunc-eq
160 161 )
449 ( "\\neq" calcFunc-neq
160 161 )
450 ( "\\ne" calcFunc-neq
160 161 )
451 ( "\\lnot" calcFunc-lnot -
1 121 )
452 ( "\\land" calcFunc-land
110 111 )
453 ( "\\lor" calcFunc-lor
100 101 )
454 ( "?" (math-read-if) 91 90 )
455 ( "!!!" calcFunc-pnot -
1 85 )
456 ( "&&&" calcFunc-pand
80 81 )
457 ( "|||" calcFunc-por
75 76 )
458 ( "\\gets" calcFunc-assign
51 50 )
459 ( ":=" calcFunc-assign
51 50 )
460 ( "::" calcFunc-condition
45 46 )
461 ( "\\to" calcFunc-evalto
40 41 )
462 ( "\\to" calcFunc-evalto
40 -
1 )
463 ( "=>" calcFunc-evalto
40 41 )
464 ( "=>" calcFunc-evalto
40 -
1 )))
466 (put 'tex
'math-function-table
467 '( ( \\arccos . calcFunc-arccos
)
468 ( \\arcsin . calcFunc-arcsin
)
469 ( \\arctan . calcFunc-arctan
)
470 ( \\arg . calcFunc-arg
)
471 ( \\cos . calcFunc-cos
)
472 ( \\cosh . calcFunc-cosh
)
473 ( \\cot . calcFunc-cot
)
474 ( \\coth . calcFunc-coth
)
475 ( \\csc . calcFunc-csc
)
476 ( \\det . calcFunc-det
)
477 ( \\exp . calcFunc-exp
)
478 ( \\gcd . calcFunc-gcd
)
479 ( \\ln . calcFunc-ln
)
480 ( \\log . calcFunc-log10
)
481 ( \\max . calcFunc-max
)
482 ( \\min . calcFunc-min
)
483 ( \\sec . calcFunc-sec
)
484 ( \\sin . calcFunc-sin
)
485 ( \\sinh . calcFunc-sinh
)
486 ( \\sqrt . calcFunc-sqrt
)
487 ( \\tan . calcFunc-tan
)
488 ( \\tanh . calcFunc-tanh
)
489 ( \\phi . calcFunc-totient
)
490 ( \\mu . calcFunc-moebius
)))
492 (put 'tex
'math-special-function-table
493 '((calcFunc-sum .
(math-compose-tex-sum "\\sum"))
494 (calcFunc-prod .
(math-compose-tex-sum "\\prod"))
495 (intv . math-compose-tex-intv
)))
497 (put 'tex
'math-variable-table
500 ( \\alpha . var-alpha
)
501 ( \\beta . var-beta
)
502 ( \\gamma . var-gamma
)
503 ( \\Gamma . var-Gamma
)
504 ( \\delta . var-delta
)
505 ( \\Delta . var-Delta
)
506 ( \\epsilon . var-epsilon
)
507 ( \\varepsilon . var-varepsilon
)
508 ( \\zeta . var-zeta
)
510 ( \\theta . var-theta
)
511 ( \\vartheta . var-vartheta
)
512 ( \\Theta . var-Theta
)
513 ( \\iota . var-iota
)
514 ( \\kappa . var-kappa
)
515 ( \\lambda . var-lambda
)
516 ( \\Lambda . var-Lambda
)
522 ( \\varpi . var-varpi
)
525 ( \\varrho . var-varrho
)
526 ( \\sigma . var-sigma
)
527 ( \\sigma . var-varsigma
)
528 ( \\Sigma . var-Sigma
)
530 ( \\upsilon . var-upsilon
)
531 ( \\Upsilon . var-Upsilon
)
533 ( \\varphi . var-varphi
)
538 ( \\omega . var-omega
)
539 ( \\Omega . var-Omega
)
542 ( \\infty . var-inf
)
543 ( \\infty . var-uinf
)
544 ( \\sum .
(math-parse-tex-sum calcFunc-sum
) )
545 ( \\prod .
(math-parse-tex-sum calcFunc-prod
) )))
547 (put 'tex
'math-punc-table
552 (put 'tex
'math-complex-format
'i
)
554 (put 'tex
'math-input-filter
'math-tex-input-filter
)
556 (put 'tex
'math-matrix-formatter
559 (if (and (integerp calc-language-option
)
560 (or (= calc-language-option
0)
561 (> calc-language-option
1)
562 (< calc-language-option -
1)))
563 (append '(vleft 0 "\\matrix{")
564 (math-compose-tex-matrix (cdr a
))
566 (append '(horiz "\\matrix{ ")
567 (math-compose-tex-matrix (cdr a
))
570 (put 'tex
'math-var-formatter
'math-compose-tex-var
)
572 (put 'tex
'math-func-formatter
'math-compose-tex-func
)
574 (put 'tex
'math-dots
"\\ldots")
576 (put 'tex
'math-big-parens
'("\\left( " .
" \\right)"))
578 (put 'tex
'math-evalto
'("\\evalto " .
" \\to "))
580 (defconst math-tex-ignore-words
581 '( ("\\hbox") ("\\mbox") ("\\text") ("\\left") ("\\right")
582 ("\\,") ("\\>") ("\\:") ("\\;") ("\\!") ("\\ ")
583 ("\\quad") ("\\qquad") ("\\hfil") ("\\hfill")
584 ("\\displaystyle") ("\\textstyle") ("\\dsize") ("\\tsize")
585 ("\\scriptstyle") ("\\scriptscriptstyle") ("\\ssize") ("\\sssize")
586 ("\\rm") ("\\bf") ("\\it") ("\\sl")
587 ("\\roman") ("\\bold") ("\\italic") ("\\slanted")
588 ("\\cal") ("\\mit") ("\\Cal") ("\\Bbb") ("\\frak") ("\\goth")
590 ("\\matrix" mat
) ("\\bmatrix" mat
) ("\\pmatrix" mat
)
592 ("\\cr" punc
";") ("\\\\" punc
";") ("\\*" punc
"*")
593 ("\\{" punc
"[") ("\\}" punc
"]")))
595 (defconst math-latex-ignore-words
596 (append math-tex-ignore-words
597 '(("\\begin" begenv
))))
599 (put 'tex
'math-lang-read-symbol
601 (< math-exp-pos
(1- (length math-exp-str
)))
603 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}"
604 math-exp-str math-exp-pos
)
605 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)"
606 math-exp-str math-exp-pos
))
607 (setq math-exp-token
'symbol
608 math-exp-pos
(match-end 0)
609 math-expr-data
(math-restore-dashes
610 (math-match-substring math-exp-str
1)))
611 (let ((code (assoc math-expr-data math-latex-ignore-words
)))
615 ((eq (nth 1 code
) 'punc
)
616 (setq math-exp-token
'punc
617 math-expr-data
(nth 2 code
)))
618 ((and (eq (nth 1 code
) 'mat
)
619 (string-match " *{" math-exp-str math-exp-pos
))
620 (setq math-exp-pos
(match-end 0)
623 (let ((right (string-match "}" math-exp-str math-exp-pos
)))
625 (setq math-exp-str
(copy-sequence math-exp-str
))
626 (aset math-exp-str right ?\
]))))))))))
628 (defun math-compose-tex-matrix (a &optional ltx
)
630 (cons (append (math-compose-vector (cdr (car a
)) " & " 0)
631 (if ltx
'(" \\\\ ") '(" \\cr ")))
632 (math-compose-tex-matrix (cdr a
) ltx
))
633 (list (math-compose-vector (cdr (car a
)) " & " 0))))
635 (defun math-compose-tex-sum (a fn
)
638 (list 'horiz
(nth 1 fn
)
639 "_{" (math-compose-expr (nth 2 a
) 0)
640 "=" (math-compose-expr (nth 3 a
) 0)
641 "}^{" (math-compose-expr (nth 4 a
) 0)
642 "}{" (math-compose-expr (nth 1 a
) 0) "}"))
644 (list 'horiz
(nth 1 fn
)
645 "_{" (math-compose-expr (nth 2 a
) 0)
646 "=" (math-compose-expr (nth 3 a
) 0)
647 "}{" (math-compose-expr (nth 1 a
) 0) "}"))
649 (list 'horiz
(nth 1 fn
)
650 "_{" (math-compose-expr (nth 2 a
) 0)
651 "}{" (math-compose-expr (nth 1 a
) 0) "}"))))
653 (defun math-parse-tex-sum (f val
)
655 (or (equal math-expr-data
"_") (throw 'syntax
"Expected `_'"))
657 (setq save math-exp-old-pos
)
658 (setq low
(math-read-factor))
659 (or (eq (car-safe low
) 'calcFunc-eq
)
661 (setq math-exp-old-pos
(1+ save
))
662 (throw 'syntax
"Expected equation")))
663 (or (equal math-expr-data
"^") (throw 'syntax
"Expected `^'"))
665 (setq high
(math-read-factor))
666 (list (nth 2 f
) (math-read-factor) (nth 1 low
) (nth 2 low
) high
)))
668 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789.
669 (while (string-match "[0-9]\\\\,[0-9]" str
)
670 (setq str
(concat (substring str
0 (1+ (match-beginning 0)))
671 (substring str
(1- (match-end 0))))))
674 ;(defun math-tex-print-sqrt (a)
677 ; (math-compose-expr (nth 1 a) 0)
680 (defun math-compose-tex-intv (a)
682 (if (memq (nth 1 a
) '(0 1)) "(" "[")
683 (math-compose-expr (nth 2 a
) 0)
685 (math-compose-expr (nth 3 a
) 0)
686 (if (memq (nth 1 a
) '(0 2)) ")" "]")))
688 (defun math-compose-tex-var (a prec
)
689 (if (and calc-language-option
690 (not (= calc-language-option
0))
691 (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'"
692 (symbol-name (nth 1 a
))))
693 (if (eq calc-language
'latex
)
694 (format "\\text{%s}" (symbol-name (nth 1 a
)))
695 (format "\\hbox{%s}" (symbol-name (nth 1 a
))))
696 (math-compose-var a
)))
698 (defun math-compose-tex-func (func a
)
700 (if (and calc-language-option
701 (not (= calc-language-option
0))
702 (string-match "\\`[a-zA-Z][a-zA-Z0-9]+\\'" func
))
703 (if (< (prefix-numeric-value calc-language-option
) 0)
704 (setq func
(format "\\%s" func
))
705 (setq func
(if (eq calc-language
'latex
)
706 (format "\\text{%s}" func
)
707 (format "\\hbox{%s}" func
)))))
708 (cond ((or (> (length a
) 2)
709 (not (math-tex-expr-is-flat (nth 1 a
))))
710 (setq left
"\\left( "
712 ((and (eq (aref func
0) ?
\\)
714 (string-match "\\hbox{" func
)
715 (string-match "\\text{" func
)))
717 (or (Math-realp (nth 1 a
))
718 (memq (car (nth 1 a
)) '(var *))))
719 (setq left
"{" right
"}"))
720 (t (setq left calc-function-open
721 right calc-function-close
)))
724 (math-compose-vector (cdr a
) ", " 0)
727 (put 'latex
'math-oper-table
728 (append (get 'tex
'math-oper-table
)
729 '(( "\\Hat" calcFunc-Hat -
1 950 )
730 ( "\\Check" calcFunc-Check -
1 950 )
731 ( "\\Tilde" calcFunc-Tilde -
1 950 )
732 ( "\\Acute" calcFunc-Acute -
1 950 )
733 ( "\\Grave" calcFunc-Grave -
1 950 )
734 ( "\\Dot" calcFunc-Dot -
1 950 )
735 ( "\\Ddot" calcFunc-Dotdot -
1 950 )
736 ( "\\Breve" calcFunc-Breve -
1 950 )
737 ( "\\Bar" calcFunc-Bar -
1 950 )
738 ( "\\Vec" calcFunc-VEC -
1 950 )
739 ( "\\dddot" calcFunc-dddot -
1 950 )
740 ( "\\ddddot" calcFunc-ddddot -
1 950 )
741 ( "\\div" / 170 171 )
742 ( "\\le" calcFunc-leq
160 161 )
743 ( "\\leqq" calcFunc-leq
160 161 )
744 ( "\\leqsland" calcFunc-leq
160 161 )
745 ( "\\ge" calcFunc-geq
160 161 )
746 ( "\\geqq" calcFunc-geq
160 161 )
747 ( "\\geqslant" calcFunc-geq
160 161 )
748 ( "=" calcFunc-eq
160 161 )
749 ( "\\neq" calcFunc-neq
160 161 )
750 ( "\\ne" calcFunc-neq
160 161 )
751 ( "\\lnot" calcFunc-lnot -
1 121 )
752 ( "\\land" calcFunc-land
110 111 )
753 ( "\\lor" calcFunc-lor
100 101 )
754 ( "?" (math-read-if) 91 90 )
755 ( "!!!" calcFunc-pnot -
1 85 )
756 ( "&&&" calcFunc-pand
80 81 )
757 ( "|||" calcFunc-por
75 76 )
758 ( "\\gets" calcFunc-assign
51 50 )
759 ( ":=" calcFunc-assign
51 50 )
760 ( "::" calcFunc-condition
45 46 )
761 ( "\\to" calcFunc-evalto
40 41 )
762 ( "\\to" calcFunc-evalto
40 -
1 )
763 ( "=>" calcFunc-evalto
40 41 )
764 ( "=>" calcFunc-evalto
40 -
1 ))))
766 (put 'latex
'math-function-table
768 (get 'tex
'math-function-table
)
769 '(( \\frac .
(math-latex-parse-frac))
770 ( \\tfrac .
(math-latex-parse-frac))
771 ( \\dfrac .
(math-latex-parse-frac))
772 ( \\binom .
(math-latex-parse-two-args calcFunc-choose
))
773 ( \\tbinom .
(math-latex-parse-two-args calcFunc-choose
))
774 ( \\dbinom .
(math-latex-parse-two-args calcFunc-choose
))
775 ( \\phi . calcFunc-totient
)
776 ( \\mu . calcFunc-moebius
))))
778 (put 'latex
'math-special-function-table
779 '((/ .
(math-compose-latex-frac "\\frac"))
780 (calcFunc-choose .
(math-compose-latex-frac "\\binom"))
781 (calcFunc-sum .
(math-compose-tex-sum "\\sum"))
782 (calcFunc-prod .
(math-compose-tex-sum "\\prod"))
783 (intv . math-compose-tex-intv
)))
785 (put 'latex
'math-variable-table
786 (get 'tex
'math-variable-table
))
788 (put 'latex
'math-punc-table
793 (put 'latex
'math-complex-format
'i
)
795 (put 'latex
'math-matrix-formatter
798 (if (and (integerp calc-language-option
)
799 (or (= calc-language-option
0)
800 (> calc-language-option
1)
801 (< calc-language-option -
1)))
802 (append '(vleft 0 "\\begin{pmatrix}")
803 (math-compose-tex-matrix (cdr a
) t
)
805 (append '(horiz "\\begin{pmatrix} ")
806 (math-compose-tex-matrix (cdr a
) t
)
807 '(" \\end{pmatrix}"))))))
809 (put 'latex
'math-var-formatter
'math-compose-tex-var
)
811 (put 'latex
'math-func-formatter
'math-compose-tex-func
)
813 (put 'latex
'math-dots
"\\ldots")
815 (put 'latex
'math-big-parens
'("\\left( " .
" \\right)"))
817 (put 'latex
'math-evalto
'("\\evalto " .
" \\to "))
819 (put 'latex
'math-lang-read-symbol
821 (< math-exp-pos
(1- (length math-exp-str
)))
823 (or (string-match "\\\\hbox *{\\([a-zA-Z0-9]+\\)}"
824 math-exp-str math-exp-pos
)
825 (string-match "\\\\text *{\\([a-zA-Z0-9]+\\)}"
826 math-exp-str math-exp-pos
)
827 (string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)"
828 math-exp-str math-exp-pos
))
829 (setq math-exp-token
'symbol
830 math-exp-pos
(match-end 0)
831 math-expr-data
(math-restore-dashes
832 (math-match-substring math-exp-str
1)))
833 (let ((code (assoc math-expr-data math-tex-ignore-words
))
838 ((eq (nth 1 code
) 'punc
)
839 (setq math-exp-token
'punc
840 math-expr-data
(nth 2 code
)))
841 ((and (eq (nth 1 code
) 'begenv
)
842 (string-match " *{\\([^}]*\\)}" math-exp-str math-exp-pos
))
843 (setq math-exp-pos
(match-end 0)
844 envname
(match-string 1 math-exp-str
)
847 (cond ((or (string= envname
"matrix")
848 (string= envname
"bmatrix")
849 (string= envname
"smallmatrix")
850 (string= envname
"pmatrix"))
851 (if (string-match (concat "\\\\end{" envname
"}")
852 math-exp-str math-exp-pos
)
854 (replace-match "]" t t math-exp-str
))
855 (error "%s" (concat "No closing \\end{" envname
"}"))))))
856 ((and (eq (nth 1 code
) 'mat
)
857 (string-match " *{" math-exp-str math-exp-pos
))
858 (setq math-exp-pos
(match-end 0)
861 (let ((right (string-match "}" math-exp-str math-exp-pos
)))
863 (setq math-exp-str
(copy-sequence math-exp-str
))
864 (aset math-exp-str right ?\
]))))))))))
866 (defun math-latex-parse-frac (f val
)
868 (setq numer
(car (math-read-expr-list)))
870 (setq denom
(math-read-factor))
871 (if (and (Math-num-integerp numer
)
872 (Math-num-integerp denom
))
873 (list 'frac numer denom
)
874 (list '/ numer denom
))))
876 (defun math-latex-parse-two-args (f val
)
878 (setq first
(car (math-read-expr-list)))
880 (setq second
(math-read-factor))
881 (list (nth 2 f
) first second
)))
883 (defun math-compose-latex-frac (a fn
)
884 (list 'horiz
(nth 1 fn
) "{" (math-compose-expr (nth 1 a
) -
1)
886 (math-compose-expr (nth 2 a
) -
1)
889 (put 'latex
'math-input-filter
'math-tex-input-filter
)
891 (defun calc-eqn-language (n)
894 (calc-set-language 'eqn
)
895 (message "Eqn language mode")))
897 (put 'eqn
'math-oper-table
898 '( ( "prime" (math-parse-eqn-prime) 950 -
1 )
899 ( "prime" calcFunc-Prime
950 -
1 )
900 ( "dot" calcFunc-dot
950 -
1 )
901 ( "dotdot" calcFunc-dotdot
950 -
1 )
902 ( "hat" calcFunc-hat
950 -
1 )
903 ( "tilde" calcFunc-tilde
950 -
1 )
904 ( "vec" calcFunc-Vec
950 -
1 )
905 ( "dyad" calcFunc-dyad
950 -
1 )
906 ( "bar" calcFunc-bar
950 -
1 )
907 ( "under" calcFunc-under
950 -
1 )
908 ( "sub" calcFunc-subscr
931 930 )
910 ( "sqrt" calcFunc-sqrt -
1 910 )
912 ( "u|" calcFunc-abs -
1 0 )
914 ( "left floor" calcFunc-floor -
1 0 )
915 ( "right floor" closing
0 -
1 )
916 ( "left ceil" calcFunc-ceil -
1 0 )
917 ( "right ceil" closing
0 -
1 )
918 ( "+-" sdev
300 300 )
919 ( "!" calcFunc-fact
210 -
1 )
920 ( "u+" ident -
1 197 )
922 ( "times" * 191 190 )
929 ( "<" calcFunc-lt
160 161 )
930 ( ">" calcFunc-gt
160 161 )
931 ( "<=" calcFunc-leq
160 161 )
932 ( ">=" calcFunc-geq
160 161 )
933 ( "=" calcFunc-eq
160 161 )
934 ( "==" calcFunc-eq
160 161 )
935 ( "!=" calcFunc-neq
160 161 )
936 ( "u!" calcFunc-lnot -
1 121 )
937 ( "&&" calcFunc-land
110 111 )
938 ( "||" calcFunc-lor
100 101 )
939 ( "?" (math-read-if) 91 90 )
940 ( "!!!" calcFunc-pnot -
1 85 )
941 ( "&&&" calcFunc-pand
80 81 )
942 ( "|||" calcFunc-por
75 76 )
943 ( "<-" calcFunc-assign
51 50 )
944 ( ":=" calcFunc-assign
51 50 )
945 ( "::" calcFunc-condition
45 46 )
946 ( "->" calcFunc-evalto
40 41 )
947 ( "->" calcFunc-evalto
40 -
1 )
948 ( "=>" calcFunc-evalto
40 41 )
949 ( "=>" calcFunc-evalto
40 -
1 )))
951 (put 'eqn
'math-function-table
952 '( ( arc\ cos . calcFunc-arccos
)
953 ( arc\ cosh . calcFunc-arccosh
)
954 ( arc\ sin . calcFunc-arcsin
)
955 ( arc\ sinh . calcFunc-arcsinh
)
956 ( arc\ tan . calcFunc-arctan
)
957 ( arc\ tanh . calcFunc-arctanh
)
958 ( GAMMA . calcFunc-gamma
)
959 ( phi . calcFunc-totient
)
960 ( mu . calcFunc-moebius
)
961 ( matrix .
(math-parse-eqn-matrix) )))
963 (put 'eqn
'math-special-function-table
964 '((intv . math-compose-eqn-intv
)))
966 (put 'eqn
'math-punc-table
970 (put 'eqn
'math-variable-table
971 '( ( inf . var-uinf
)))
973 (put 'eqn
'math-complex-format
'i
)
975 (put 'eqn
'math-big-parens
'("{left ( " .
" right )}"))
977 (put 'eqn
'math-evalto
'("evalto " .
" -> "))
979 (put 'eqn
'math-matrix-formatter
982 (append '(horiz "matrix { ")
983 (math-compose-eqn-matrix
984 (cdr (math-transpose a
)))
987 (put 'eqn
'math-var-formatter
991 (if (and math-compose-hash-args
992 (let ((p calc-arg-values
))
994 (while (and p
(not (equal (car p
) a
)))
995 (setq p
(and (eq math-compose-hash-args t
) (cdr p
))
998 (if (eq math-compose-hash-args
1)
1001 (if (string-match ".'\\'" (symbol-name (nth 2 a
)))
1003 (list 'calcFunc-Prime
1006 (intern (substring (symbol-name (nth 1 a
)) 0 -
1))
1007 (intern (substring (symbol-name (nth 2 a
)) 0 -
1))))
1009 (symbol-name (nth 1 a
))))))))
1011 (defconst math-eqn-special-funcs
1013 calcFunc-ln calcFunc-exp
1014 calcFunc-sin calcFunc-cos calcFunc-tan
1015 calcFunc-sec calcFunc-csc calcFunc-cot
1016 calcFunc-sinh calcFunc-cosh calcFunc-tanh
1017 calcFunc-sech calcFunc-csch calcFunc-coth
1018 calcFunc-arcsin calcFunc-arccos calcFunc-arctan
1019 calcFunc-arcsinh calcFunc-arccosh calcFunc-arctanh
))
1021 (put 'eqn
'math-func-formatter
1025 (if (string-match "[^']'+\\'" func
)
1026 (let ((n (- (length func
) (match-beginning 0) 1)))
1027 (setq func
(substring func
0 (- n
)))
1028 (while (>= (setq n
(1- n
)) 0)
1029 (setq func
(concat func
" prime")))))
1030 (cond ((or (> (length a
) 2)
1031 (not (math-tex-expr-is-flat (nth 1 a
))))
1032 (setq left
"{left ( "
1036 (memq (car a
) math-eqn-special-funcs
)
1038 (or (Math-realp (nth 1 a
))
1039 (memq (car (nth 1 a
)) '(var *))))
1040 (setq left
"~{" right
"}"))
1044 (list 'horiz func left
1045 (math-compose-vector (cdr a
) " , " 0)
1048 (put 'eqn
'math-lang-read-symbol
1050 (string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)"
1051 math-exp-str math-exp-pos
)
1053 (setq math-exp-str
(copy-sequence math-exp-str
))
1054 (aset math-exp-str
(match-beginning 1) ?\
{)
1055 (if (< (match-end 1) (length math-exp-str
))
1056 (aset math-exp-str
(match-end 1) ?\
}))
1057 (math-read-token)))))
1059 (defconst math-eqn-ignore-words
1060 '( ("roman") ("bold") ("italic") ("mark") ("lineup") ("evalto")
1061 ("left" ("floor") ("ceil"))
1062 ("right" ("floor") ("ceil"))
1063 ("arc" ("sin") ("cos") ("tan") ("sinh") ("cosh") ("tanh"))
1064 ("size" n
) ("font" n
) ("fwd" n
) ("back" n
) ("up" n
) ("down" n
)
1065 ("above" punc
",")))
1067 (put 'eqn
'math-lang-adjust-words
1070 (let ((code (assoc math-expr-data math-eqn-ignore-words
)))
1074 ((consp (nth 1 code
))
1076 (if (assoc math-expr-data
(cdr code
))
1077 (setq math-expr-data
(format "%s %s"
1078 (car code
) math-expr-data
))))
1079 ((eq (nth 1 code
) 'punc
)
1080 (setq math-exp-token
'punc
1081 math-expr-data
(nth 2 code
)))
1084 (math-read-token)))))))
1086 (put 'eqn
'math-lang-read
1087 '((eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^"
1088 math-exp-str math-exp-pos
)
1091 (setq math-exp-token
'punc
1092 math-expr-data
(math-match-substring math-exp-str
0)
1093 math-exp-pos
(match-end 0))
1094 (and (eq (string-match "\\\\dots\\." math-exp-str math-exp-pos
)
1096 (setq math-exp-pos
(match-end 0)))
1097 (if (memq (aref math-expr-data
0) '(?~ ?^
))
1098 (math-read-token)))))
1101 (defun math-compose-eqn-matrix (a)
1104 (cond ((eq calc-matrix-just
'right
) "rcol ")
1105 ((eq calc-matrix-just
'center
) "ccol ")
1108 (list 'break math-compose-level
)
1112 (let ((math-compose-level (1+ math-compose-level
)))
1113 (math-compose-vector (cdr (car a
)) " above " 1000))
1116 (math-compose-eqn-matrix (cdr a
)))))))
1119 (defun math-parse-eqn-matrix (f sym
)
1121 (while (assoc math-expr-data
'(("ccol") ("lcol") ("rcol")))
1123 (or (equal math-expr-data calc-function-open
)
1124 (throw 'syntax
"Expected `{'"))
1126 (setq vec
(cons (cons 'vec
(math-read-expr-list)) vec
))
1127 (or (equal math-expr-data calc-function-close
)
1128 (throw 'syntax
"Expected `}'"))
1130 (or (equal math-expr-data calc-function-close
)
1131 (throw 'syntax
"Expected `}'"))
1133 (math-transpose (cons 'vec
(nreverse vec
)))))
1135 (defun math-parse-eqn-prime (x sym
)
1136 (if (eq (car-safe x
) 'var
)
1137 (if (equal math-expr-data calc-function-open
)
1140 (let ((args (if (or (equal math-expr-data calc-function-close
)
1141 (eq math-exp-token
'end
))
1143 (math-read-expr-list))))
1144 (if (not (or (equal math-expr-data calc-function-close
)
1145 (eq math-exp-token
'end
)))
1146 (throw 'syntax
"Expected `)'"))
1148 (cons (intern (format "calcFunc-%s'" (nth 1 x
))) args
)))
1150 (intern (concat (symbol-name (nth 1 x
)) "'"))
1151 (intern (concat (symbol-name (nth 2 x
)) "'"))))
1152 (list 'calcFunc-Prime x
)))
1154 (defun math-compose-eqn-intv (a)
1156 (if (memq (nth 1 a
) '(0 1)) "(" "[")
1157 (math-compose-expr (nth 2 a
) 0)
1159 (math-compose-expr (nth 3 a
) 0)
1160 (if (memq (nth 1 a
) '(0 2)) ")" "]")))
1163 (defun calc-mathematica-language ()
1166 (calc-set-language 'math
)
1167 (message "Mathematica language mode")))
1169 (put 'math
'math-oper-table
1170 '( ( "[[" (math-read-math-subscr) 250 -
1 )
1171 ( "!" calcFunc-fact
210 -
1 )
1172 ( "!!" calcFunc-dfact
210 -
1 )
1174 ( "u+" ident -
1 197 )
1181 ( "<" calcFunc-lt
160 161 )
1182 ( ">" calcFunc-gt
160 161 )
1183 ( "<=" calcFunc-leq
160 161 )
1184 ( ">=" calcFunc-geq
160 161 )
1185 ( "==" calcFunc-eq
150 151 )
1186 ( "!=" calcFunc-neq
150 151 )
1187 ( "u!" calcFunc-lnot -
1 121 )
1188 ( "&&" calcFunc-land
110 111 )
1189 ( "||" calcFunc-lor
100 101 )
1190 ( "!!!" calcFunc-pnot -
1 85 )
1191 ( "&&&" calcFunc-pand
80 81 )
1192 ( "|||" calcFunc-por
75 76 )
1193 ( ":=" calcFunc-assign
51 50 )
1194 ( "=" calcFunc-assign
51 50 )
1195 ( "->" calcFunc-assign
51 50 )
1196 ( ":>" calcFunc-assign
51 50 )
1197 ( "::" calcFunc-condition
45 46 )
1200 (put 'math
'math-function-table
1201 '( ( Abs . calcFunc-abs
)
1202 ( ArcCos . calcFunc-arccos
)
1203 ( ArcCosh . calcFunc-arccosh
)
1204 ( ArcSin . calcFunc-arcsin
)
1205 ( ArcSinh . calcFunc-arcsinh
)
1206 ( ArcTan . calcFunc-arctan
)
1207 ( ArcTanh . calcFunc-arctanh
)
1208 ( Arg . calcFunc-arg
)
1209 ( Binomial . calcFunc-choose
)
1210 ( Ceiling . calcFunc-ceil
)
1211 ( Conjugate . calcFunc-conj
)
1212 ( Cos . calcFunc-cos
)
1213 ( Cosh . calcFunc-cosh
)
1214 ( Cot . calcFunc-cot
)
1215 ( Coth . calcFunc-coth
)
1216 ( Csc . calcFunc-csc
)
1217 ( Csch . calcFunc-csch
)
1218 ( D . calcFunc-deriv
)
1219 ( Dt . calcFunc-tderiv
)
1220 ( Det . calcFunc-det
)
1221 ( Exp . calcFunc-exp
)
1222 ( EulerPhi . calcFunc-totient
)
1223 ( Floor . calcFunc-floor
)
1224 ( Gamma . calcFunc-gamma
)
1225 ( GCD . calcFunc-gcd
)
1226 ( If . calcFunc-if
)
1227 ( Im . calcFunc-im
)
1228 ( Inverse . calcFunc-inv
)
1229 ( Integrate . calcFunc-integ
)
1230 ( Join . calcFunc-vconcat
)
1231 ( LCM . calcFunc-lcm
)
1232 ( Log . calcFunc-ln
)
1233 ( Max . calcFunc-max
)
1234 ( Min . calcFunc-min
)
1235 ( Mod . calcFunc-mod
)
1236 ( MoebiusMu . calcFunc-moebius
)
1237 ( Random . calcFunc-random
)
1238 ( Round . calcFunc-round
)
1239 ( Re . calcFunc-re
)
1240 ( Sec . calcFunc-sec
)
1241 ( Sech . calcFunc-sech
)
1242 ( Sign . calcFunc-sign
)
1243 ( Sin . calcFunc-sin
)
1244 ( Sinh . calcFunc-sinh
)
1245 ( Sqrt . calcFunc-sqrt
)
1246 ( Tan . calcFunc-tan
)
1247 ( Tanh . calcFunc-tanh
)
1248 ( Transpose . calcFunc-trn
)
1249 ( Length . calcFunc-vlen
)
1252 (put 'math
'math-variable-table
1256 ( GoldenRatio . var-phi
)
1257 ( EulerGamma . var-gamma
)
1258 ( Infinity . var-inf
)
1259 ( ComplexInfinity . var-uinf
)
1260 ( Indeterminate . var-nan
)
1263 (put 'math
'math-vector-brackets
"{}")
1264 (put 'math
'math-complex-format
'I
)
1265 (put 'math
'math-function-open
"[")
1266 (put 'math
'math-function-close
"]")
1268 (put 'math
'math-radix-formatter
1269 (function (lambda (r s
) (format "%d^^%s" r s
))))
1271 (put 'math
'math-lang-read
1272 '((eq (string-match "\\[\\[\\|->\\|:>" math-exp-str math-exp-pos
)
1274 (setq math-exp-token
'punc
1275 math-expr-data
(math-match-substring math-exp-str
0)
1276 math-exp-pos
(match-end 0))))
1278 (put 'math
'math-compose-subscr
1282 (math-compose-expr (nth 1 a
) 1000)
1284 (math-compose-expr (nth 2 a
) 0)
1287 (defun math-read-math-subscr (x op
)
1288 (let ((idx (math-read-expr-level 0)))
1289 (or (and (equal math-expr-data
"]")
1292 (equal math-expr-data
"]")))
1293 (throw 'syntax
"Expected ']]'"))
1295 (list 'calcFunc-subscr x idx
)))
1298 (defun calc-maple-language ()
1301 (calc-set-language 'maple
)
1302 (message "Maple language mode")))
1304 (put 'maple
'math-oper-table
1305 '( ( "matrix" ident -
1 300 )
1306 ( "MATRIX" ident -
1 300 )
1307 ( "!" calcFunc-fact
210 -
1 )
1310 ( "u+" ident -
1 197 )
1314 ( "intersect" calcFunc-vint
191 192 )
1317 ( "union" calcFunc-vunion
180 181 )
1318 ( "minus" calcFunc-vdiff
180 181 )
1320 ( ".." (math-read-maple-dots) 165 165 )
1321 ( "\\dots" (math-read-maple-dots) 165 165 )
1322 ( "<" calcFunc-lt
160 160 )
1323 ( ">" calcFunc-gt
160 160 )
1324 ( "<=" calcFunc-leq
160 160 )
1325 ( ">=" calcFunc-geq
160 160 )
1326 ( "=" calcFunc-eq
160 160 )
1327 ( "<>" calcFunc-neq
160 160 )
1328 ( "not" calcFunc-lnot -
1 121 )
1329 ( "and" calcFunc-land
110 111 )
1330 ( "or" calcFunc-lor
100 101 )
1331 ( "!!!" calcFunc-pnot -
1 85 )
1332 ( "&&&" calcFunc-pand
80 81 )
1333 ( "|||" calcFunc-por
75 76 )
1334 ( ":=" calcFunc-assign
51 50 )
1335 ( "::" calcFunc-condition
45 46 )
1338 (put 'maple
'math-function-table
1339 '( ( bernoulli . calcFunc-bern
)
1340 ( binomial . calcFunc-choose
)
1341 ( diff . calcFunc-deriv
)
1342 ( GAMMA . calcFunc-gamma
)
1343 ( ifactor . calcFunc-prfac
)
1344 ( igcd . calcFunc-gcd
)
1345 ( ilcm . calcFunc-lcm
)
1346 ( int . calcFunc-integ
)
1349 ( iquo . calcFunc-idiv
)
1350 ( isprime . calcFunc-prime
)
1351 ( length . calcFunc-vlen
)
1352 ( member . calcFunc-in
)
1353 ( crossprod . calcFunc-cross
)
1354 ( inverse . calcFunc-inv
)
1355 ( trace . calcFunc-tr
)
1356 ( transpose . calcFunc-trn
)
1357 ( vectdim . calcFunc-vlen
)
1360 (put 'maple
'math-special-function-table
1361 '((intv . math-compose-maple-intv
)))
1363 (put 'maple
'math-variable-table
1367 ( infinity . var-inf
)
1368 ( infinity . var-uinf
)
1369 ( infinity . var-nan
)
1372 (put 'maple
'math-complex-format
'I
)
1374 (put 'maple
'math-matrix-formatter
1379 math-comp-left-bracket
1380 (math-compose-vector (cdr a
)
1381 (concat math-comp-comma
" ")
1382 math-comp-vector-prec
)
1383 math-comp-right-bracket
1386 (put 'maple
'math-compose-subscr
1389 (let ((args (cdr (cdr a
))))
1391 (math-compose-expr (nth 1 a
) 1000)
1393 (math-compose-vector args
", " 0)
1396 (add-to-list 'calc-lang-allow-underscores
'maple
)
1397 (add-to-list 'calc-lang-brackets-are-subscripts
'maple
)
1399 (defun math-compose-maple-intv (a)
1401 (math-compose-expr (nth 2 a
) 0)
1403 (math-compose-expr (nth 3 a
) 0)))
1405 (defun math-read-maple-dots (x op
)
1406 (list 'intv
3 x
(math-read-expr-level (nth 3 op
))))
1409 ;; The variable math-read-big-lines is local to math-read-big-expr in
1410 ;; calc-ext.el, but is used by math-read-big-rec, math-read-big-char,
1411 ;; math-read-big-emptyp, math-read-big-error and math-read-big-balance,
1412 ;; which are called (directly and indirectly) by math-read-big-expr.
1413 ;; It is also local to math-read-big-bigp in calc-ext.el, which calls
1414 ;; math-read-big-balance.
1415 (defvar math-read-big-lines
)
1417 ;; The variables math-read-big-baseline and math-read-big-h2 are
1418 ;; local to math-read-big-expr in calc-ext.el, but used by
1419 ;; math-read-big-rec.
1420 (defvar math-read-big-baseline
)
1421 (defvar math-read-big-h2
)
1423 ;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2
1424 ;; are local to math-read-big-rec, but are used by math-read-big-char,
1425 ;; math-read-big-emptyp and math-read-big-balance which are called by
1426 ;; math-read-big-rec.
1427 ;; math-rb-h2 is also local to math-read-big-bigp in calc-ext.el,
1428 ;; which calls math-read-big-balance.
1434 (defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2
1435 &optional baseline prec short
)
1436 (or prec
(setq prec
0))
1438 ;; Clip whitespace above or below.
1439 (while (and (< math-rb-v1 math-rb-v2
)
1440 (math-read-big-emptyp math-rb-h1 math-rb-v1 math-rb-h2
(1+ math-rb-v1
)))
1441 (setq math-rb-v1
(1+ math-rb-v1
)))
1442 (while (and (< math-rb-v1 math-rb-v2
)
1443 (math-read-big-emptyp math-rb-h1
(1- math-rb-v2
) math-rb-h2 math-rb-v2
))
1444 (setq math-rb-v2
(1- math-rb-v2
)))
1446 ;; If formula is a single line high, normal parser can handle it.
1447 (if (<= math-rb-v2
(1+ math-rb-v1
))
1448 (if (or (<= math-rb-v2 math-rb-v1
)
1449 (> math-rb-h1
(length (setq math-rb-v2
1450 (nth math-rb-v1 math-read-big-lines
)))))
1451 (math-read-big-error math-rb-h1 math-rb-v1
)
1452 (setq math-read-big-baseline math-rb-v1
1453 math-read-big-h2 math-rb-h2
1454 math-rb-v2
(nth math-rb-v1 math-read-big-lines
)
1455 math-rb-h2
(math-read-expr
1456 (substring math-rb-v2 math-rb-h1
1457 (min math-rb-h2
(length math-rb-v2
)))))
1458 (if (eq (car-safe math-rb-h2
) 'error
)
1459 (math-read-big-error (+ math-rb-h1
(nth 1 math-rb-h2
))
1460 math-rb-v1
(nth 2 math-rb-h2
))
1463 ;; Clip whitespace at left or right.
1464 (while (and (< math-rb-h1 math-rb-h2
)
1465 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) math-rb-v2
))
1466 (setq math-rb-h1
(1+ math-rb-h1
)))
1467 (while (and (< math-rb-h1 math-rb-h2
)
1468 (math-read-big-emptyp (1- math-rb-h2
) math-rb-v1 math-rb-h2 math-rb-v2
))
1469 (setq math-rb-h2
(1- math-rb-h2
)))
1471 ;; Scan to find widest left-justified "----" in the region.
1474 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines
))
1478 other-char line len h
)
1479 (while (< v math-rb-v2
)
1481 len
(min math-rb-h2
(length line
)))
1482 (and (< math-rb-h1 len
)
1483 (/= (aref line math-rb-h1
) ?\
)
1484 (if (and (= (aref line math-rb-h1
) ?\-
)
1485 ;; Make sure it's not a minus sign.
1486 (or (and (< (1+ math-rb-h1
) len
)
1487 (= (aref line
(1+ math-rb-h1
)) ?\-
))
1488 (/= (math-read-big-char math-rb-h1
(1- v
)) ?\
)
1489 (/= (math-read-big-char math-rb-h1
(1+ v
)) ?\
)))
1492 (while (and (< (setq h
(1+ h
)) len
)
1493 (= (aref line h
) ?\-
)))
1497 (or other-v
(setq other-v v other-char
(aref line math-rb-h1
)))))
1501 (cond ((not (setq v other-v
))
1502 (math-read-big-error math-rb-h1 math-rb-v1
)) ; Should never happen!
1508 (let ((num (math-read-big-rec math-rb-h1 math-rb-v1 h v
))
1509 (den (math-read-big-rec math-rb-h1
(1+ v
) h math-rb-v2
)))
1510 (setq p
(if (and (math-integerp num
) (math-integerp den
))
1511 (math-make-frac num den
)
1512 (list '/ num den
)))))
1514 ;; Big radical sign.
1516 (or (= (math-read-big-char (1+ math-rb-h1
) v
) ?\|
)
1517 (math-read-big-error (1+ math-rb-h1
) v
"Malformed root sign"))
1518 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
1519 (while (= (math-read-big-char (1+ math-rb-h1
) (setq v
(1- v
))) ?\|
))
1520 (or (= (math-read-big-char (setq h
(+ math-rb-h1
2)) v
) ?\_
)
1521 (math-read-big-error h v
"Malformed root sign"))
1522 (while (= (math-read-big-char (setq h
(1+ h
)) v
) ?\_
))
1523 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
1524 (math-read-big-emptyp math-rb-h1
(1+ other-v
) h math-rb-v2 nil t
)
1525 (setq p
(list 'calcFunc-sqrt
(math-read-big-rec
1526 (+ math-rb-h1
2) (1+ v
)
1527 h
(1+ other-v
) baseline
))
1528 v math-read-big-baseline
))
1530 ;; Small radical sign.
1531 ((and (= other-char ?V
)
1532 (= (math-read-big-char (1+ math-rb-h1
) (1- v
)) ?\_
))
1533 (setq h
(1+ math-rb-h1
))
1534 (math-read-big-emptyp math-rb-h1 math-rb-v1 h
(1- v
) nil t
)
1535 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)
1536 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
1537 (while (= (math-read-big-char (setq h
(1+ h
)) (1- v
)) ?\_
))
1538 (setq p
(list 'calcFunc-sqrt
(math-read-big-rec
1539 (1+ math-rb-h1
) v h
(1+ v
) t
))
1540 v math-read-big-baseline
))
1542 ;; Binomial coefficient.
1543 ((and (= other-char ?\
()
1544 (= (math-read-big-char (1+ math-rb-h1
) v
) ?\
)
1545 (= (string-match "( *)" (nth v math-read-big-lines
)
1546 math-rb-h1
) math-rb-h1
))
1547 (setq h
(match-end 0))
1548 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
1549 (math-read-big-emptyp math-rb-h1
(1+ v
) (1+ math-rb-h1
) math-rb-v2 nil t
)
1550 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
1551 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
1552 (setq p
(list 'calcFunc-choose
1553 (math-read-big-rec (1+ math-rb-h1
) math-rb-v1
(1- h
) v
)
1554 (math-read-big-rec (1+ math-rb-h1
) (1+ v
)
1555 (1- h
) math-rb-v2
))))
1559 (setq p
(list 'neg
(math-read-big-rec (1+ math-rb-h1
) math-rb-v1
1560 math-rb-h2 math-rb-v2 v
250 t
))
1561 v math-read-big-baseline
1562 h math-read-big-h2
))
1566 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
1567 (math-read-big-emptyp math-rb-h1
(1+ v
) (1+ math-rb-h1
) math-rb-v2 nil t
)
1568 (setq h
(math-read-big-balance (1+ math-rb-h1
) v
"(" t
))
1569 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
1570 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
1571 (let ((sep (math-read-big-char (1- h
) v
))
1576 (math-read-big-error (1- h
) v
"Expected `)'"))
1578 (setq p
(math-read-big-rec
1579 (1+ math-rb-h1
) math-rb-v1
(1- h
) math-rb-v2 v
))
1580 (setq hmid
(math-read-big-balance h v
"(")
1582 (math-read-big-rec h math-rb-v1
(1- hmid
) math-rb-v2 v
))
1585 (setq p
(cons 'intv
(cons (if (= (math-read-big-char
1590 ((= (math-read-big-char (1- h
) v
) ?\
])
1591 (math-read-big-error (1- h
) v
"Expected `)'"))
1593 (or (and (math-realp (car p
)) (math-realp (nth 1 p
)))
1594 (math-read-big-error
1595 math-rb-h1 v
"Complex components must be real"))
1596 (setq p
(cons 'cplx p
)))
1598 (or (and (math-realp (car p
)) (math-anglep (nth 1 p
)))
1599 (math-read-big-error
1600 math-rb-h1 v
"Complex components must be real"))
1601 (setq p
(cons 'polar p
)))))))
1604 ((and (= other-char ?\
[)
1605 (or (= (math-read-big-char (setq h math-rb-h1
) (1+ v
)) ?\
[)
1606 (= (math-read-big-char (setq h
(1+ h
)) v
) ?\
[)
1607 (and (= (math-read-big-char h v
) ?\
)
1608 (= (math-read-big-char (setq h
(1+ h
)) v
) ?\
[)))
1609 (= (math-read-big-char h
(1+ v
)) ?\
[))
1610 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
1616 (setq h
(math-read-big-balance (1+ hleft
) v
"["))
1619 (math-read-big-error hright v
"Expected `]'"))
1621 (setq p
(cons (math-read-big-rec
1622 hleft v h
(1+ v
)) p
))
1623 (and (memq (math-read-big-char h v
) '(?\ ?\
,))
1624 (= (math-read-big-char hleft
(1+ v
)) ?\
[)))
1626 (or (= hleft math-rb-h1
)
1628 (if (= (math-read-big-char h v
) ?\
)
1630 (and (= (math-read-big-char h v
) ?\
])
1632 (math-read-big-error (1- h
) v
"Expected `]'"))
1633 (if (= (math-read-big-char h vtop
) ?\
,)
1635 (math-read-big-emptyp math-rb-h1
(1+ v
) (1- h
) math-rb-v2 nil t
)
1636 (setq v
(+ vtop
(/ (- v vtop
) 2))
1637 p
(cons 'vec
(nreverse p
)))))
1641 (math-read-big-emptyp math-rb-h1 math-rb-v1
(1+ math-rb-h1
) v nil t
)
1642 (math-read-big-emptyp math-rb-h1
(1+ v
) (1+ math-rb-h1
) math-rb-v2 nil t
)
1646 (setq widest
(math-read-big-balance h v
"[" t
))
1647 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
1648 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
1649 (setq p
(cons (math-read-big-rec
1650 h math-rb-v1
(1- widest
) math-rb-v2 v
) p
)
1652 (= (math-read-big-char (1- h
) v
) ?\
,)))
1653 (setq widest
(math-read-big-char (1- h
) v
))
1654 (if (or (memq widest
'(?\
; ?\)))
1655 (and (eq widest ?\.
) (cdr p
)))
1656 (math-read-big-error (1- h
) v
"Expected `]'"))
1659 widest
(math-read-big-balance h v
"[")
1660 p
(nconc p
(list (math-read-big-rec
1661 h math-rb-v1
(1- widest
) math-rb-v2 v
)))
1663 p
(cons 'intv
(cons (if (= (math-read-big-char (1- h
) v
)
1667 (setq p
(cons 'vec
(nreverse p
)))))
1671 (setq line
(nth v math-read-big-lines
))
1672 (string-match ">" line math-rb-h1
)
1673 (setq h
(match-end 0))
1674 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
1675 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)
1676 (setq p
(math-read-big-rec math-rb-h1 v h
(1+ v
) v
)))
1678 ;; Variable name or function call.
1679 ((or (and (>= other-char ?a
) (<= other-char ?z
))
1680 (and (>= other-char ?A
) (<= other-char ?Z
)))
1681 (setq line
(nth v math-read-big-lines
))
1682 (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1
)
1683 (setq h
(match-end 1)
1684 widest
(match-end 0)
1685 p
(math-match-substring line
1))
1686 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
1687 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)
1688 (if (= (math-read-big-char widest v
) ?\
()
1690 (setq line
(if (string-match "-" p
)
1692 (intern (concat "calcFunc-" p
)))
1695 (math-read-big-emptyp widest math-rb-v1 h v nil t
)
1696 (math-read-big-emptyp widest
(1+ v
) h math-rb-v2 nil t
)
1698 (setq widest
(math-read-big-balance h v
"(" t
))
1699 (math-read-big-emptyp (1- h
) math-rb-v1 h v nil t
)
1700 (math-read-big-emptyp (1- h
) (1+ v
) h math-rb-v2 nil t
)
1701 (setq p
(cons (math-read-big-rec
1702 h math-rb-v1
(1- widest
) math-rb-v2 v
) p
)
1704 (= (math-read-big-char (1- h
) v
) ?\
,)))
1705 (or (= (math-read-big-char (1- h
) v
) ?\
))
1706 (math-read-big-error (1- h
) v
"Expected `)'"))
1707 (setq p
(cons line
(nreverse p
))))
1709 (intern (math-remove-dashes p
))
1710 (if (string-match "-" p
)
1712 (intern (concat "var-" p
)))))))
1716 (setq line
(nth v math-read-big-lines
))
1717 (or (= (string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\([0-9]+\\(#\\|\\^\\^\\)[0-9a-zA-Z:]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" line math-rb-h1
) math-rb-h1
)
1718 (math-read-big-error h v
"Expected a number"))
1719 (setq h
(match-end 0)
1720 p
(math-read-number (math-match-substring line
0)))
1721 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t
)
1722 (math-read-big-emptyp math-rb-h1
(1+ v
) h math-rb-v2 nil t
)))
1724 ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2;
1728 (math-read-big-error math-rb-h1 v
"Inconsistent baseline in formula"))
1731 ;; Look for superscripts or subscripts.
1732 (setq line
(nth baseline math-read-big-lines
)
1733 len
(min math-rb-h2
(length line
))
1735 (while (and (< widest len
)
1736 (= (aref line widest
) ?\
))
1737 (setq widest
(1+ widest
)))
1738 (and (>= widest len
) (setq widest math-rb-h2
))
1739 (if (math-read-big-emptyp h v widest math-rb-v2
)
1740 (if (math-read-big-emptyp h math-rb-v1 widest v
)
1742 (setq p
(list '^ p
(math-read-big-rec h math-rb-v1 widest v
))
1744 (if (math-read-big-emptyp h math-rb-v1 widest v
)
1745 (setq p
(list 'calcFunc-subscr p
1746 (math-read-big-rec h v widest math-rb-v2
))
1749 ;; Look for an operator name and grab additional terms.
1750 (while (and (< h len
)
1751 (if (setq widest
(and (math-read-big-emptyp
1752 h math-rb-v1
(1+ h
) v
)
1753 (math-read-big-emptyp
1754 h
(1+ v
) (1+ h
) math-rb-v2
)
1755 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h
)
1756 (assoc (math-match-substring line
0)
1757 (math-standard-ops))))
1758 (and (>= (nth 2 widest
) prec
)
1759 (setq h
(match-end 0)))
1760 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h
)
1762 (setq widest
'("2x" * 196 195)))))
1763 (cond ((eq (nth 3 widest
) -
1)
1764 (setq p
(list (nth 1 widest
) p
)))
1765 ((equal (car widest
) "?")
1766 (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2
1767 math-rb-v2 baseline nil t
)))
1768 (or (= (math-read-big-char math-read-big-h2 baseline
) ?\
:)
1769 (math-read-big-error math-read-big-h2 baseline
"Expected `:'"))
1770 (setq p
(list (nth 1 widest
) p y
1772 (1+ math-read-big-h2
) math-rb-v1 math-rb-h2 math-rb-v2
1773 baseline
(nth 3 widest
) t
))
1774 h math-read-big-h2
)))
1776 (setq p
(list (nth 1 widest
) p
1777 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2
1778 baseline
(nth 3 widest
) t
))
1779 h math-read-big-h2
))))
1781 ;; Return all relevant information to caller.
1782 (setq math-read-big-baseline baseline
1784 (or short
(= math-read-big-h2 math-rb-h2
)
1785 (math-read-big-error h baseline
))
1788 (defun math-read-big-char (h v
)
1789 (or (and (>= h math-rb-h1
)
1793 (let ((line (nth v math-read-big-lines
)))
1799 (defun math-read-big-emptyp (eh1 ev1 eh2 ev2
&optional what error
)
1800 (and (< ev1 math-rb-v1
) (setq ev1 math-rb-v1
))
1801 (and (< eh1 math-rb-h1
) (setq eh1 math-rb-h1
))
1802 (and (> ev2 math-rb-v2
) (setq ev2 math-rb-v2
))
1803 (and (> eh2 math-rb-h2
) (setq eh2 math-rb-h2
))
1804 (or what
(setq what ?\
))
1805 (let ((p (nthcdr ev1 math-read-big-lines
))
1807 (while (and (< ev1 ev2
)
1809 (setq h
(min eh2
(length (car p
))))
1810 (while (and (>= (setq h
(1- h
)) eh1
)
1811 (= (aref (car p
) h
) what
)))
1812 (and error
(>= h eh1
)
1813 (math-read-big-error h ev1
(if (stringp error
)
1815 "Whitespace expected")))
1821 ;; math-read-big-err-msg is local to math-read-big-expr in calc-ext.el,
1822 ;; but is used by math-read-big-error which is called (indirectly) by
1823 ;; math-read-big-expr.
1824 (defvar math-read-big-err-msg
)
1826 (defun math-read-big-error (h v
&optional msg
)
1828 (p math-read-big-lines
))
1830 (setq pos
(+ pos
1 (length (car p
)))
1833 (setq h
(+ pos
(min h
(length (car p
))))
1834 math-read-big-err-msg
(list 'error h
(or msg
"Syntax error")))
1835 (throw 'syntax nil
)))
1837 (defun math-read-big-balance (h v what
&optional commas
)
1838 (let* ((line (nth v math-read-big-lines
))
1839 (len (min math-rb-h2
(length line
)))
1844 (math-read-big-error nil v
(format "Unmatched `%s'" what
))
1846 (if (memq (aref line h
) '(?\
( ?\
[))
1847 (setq count
(1+ count
))
1848 (if (if (and commas
(= count
1))
1849 (or (memq (aref line h
) '(?\
) ?\
] ?\
, ?\
;))
1850 (and (eq (aref line h
) ?\.
)
1852 (eq (aref line
(1+ h
)) ?\.
)))
1853 (memq (aref line h
) '(?\
) ?\
])))
1854 (setq count
(1- count
))))
1858 (provide 'calc-lang
)
1860 ;;; arch-tag: 483bfe15-f290-4fef-bb7d-ce65be687f2e
1861 ;;; calc-lang.el ends here