1 ;;; calc-lang.el --- calc language functions
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainer: Jay Belanger <belanger@truman.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
12 ;; accepts responsibility to anyone for the consequences of using it
13 ;; or for whether it serves any particular purpose or works at all,
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
15 ;; License for full details.
17 ;; Everyone is granted permission to copy, modify and redistribute
18 ;; GNU Emacs, but only under the conditions described in the
19 ;; GNU Emacs General Public License. A copy of this license is
20 ;; supposed to have been given to you along with GNU Emacs so you
21 ;; can know your rights and responsibilities. It should be in a
22 ;; file named COPYING. Among other things, the copyright notice
23 ;; and this notice must be preserved on all copies.
29 ;; This file is autoloaded from calc-ext.el.
34 ;;; Alternate entry/display languages.
36 (defun calc-set-language (lang &optional option no-refresh)
37 (setq math-expr-opers (or (get lang 'math-oper-table) math-standard-opers)
38 math-expr-function-mapping (get lang 'math-function-table)
39 math-expr-special-function-mapping (get lang 'math-special-function-table)
40 math-expr-variable-mapping (get lang 'math-variable-table)
41 calc-language-input-filter (get lang 'math-input-filter)
42 calc-language-output-filter (get lang 'math-output-filter)
43 calc-vector-brackets (or (get lang 'math-vector-brackets) "[]")
44 calc-complex-format (get lang 'math-complex-format)
45 calc-radix-formatter (get lang 'math-radix-formatter)
46 calc-function-open (or (get lang 'math-function-open) "(")
47 calc-function-close (or (get lang 'math-function-close) ")"))
49 (setq calc-language lang
50 calc-language-option option)
51 (calc-change-mode '(calc-language calc-language-option)
52 (list lang option) t)))
54 (defun calc-normal-language ()
57 (calc-set-language nil)
58 (message "Normal language mode")))
60 (defun calc-flat-language ()
63 (calc-set-language 'flat)
64 (message "Flat language mode (all stack entries shown on one line)")))
66 (defun calc-big-language ()
69 (calc-set-language 'big)
70 (message "\"Big\" language mode")))
72 (defun calc-unformatted-language ()
75 (calc-set-language 'unform)
76 (message "Unformatted language mode")))
79 (defun calc-c-language ()
82 (calc-set-language 'c)
83 (message "`C' language mode")))
85 (put 'c 'math-oper-table
86 '( ( "u+" ident -1 1000 )
88 ( "u!" calcFunc-lnot -1 1000 )
89 ( "~" calcFunc-not -1 1000 )
95 ( "<<" calcFunc-lsh 170 171 )
96 ( ">>" calcFunc-rsh 170 171 )
97 ( "<" calcFunc-lt 160 161 )
98 ( ">" calcFunc-gt 160 161 )
99 ( "<=" calcFunc-leq 160 161 )
100 ( ">=" calcFunc-geq 160 161 )
101 ( "==" calcFunc-eq 150 151 )
102 ( "!=" calcFunc-neq 150 151 )
103 ( "&" calcFunc-and 140 141 )
104 ( "^" calcFunc-xor 131 130 )
105 ( "|" calcFunc-or 120 121 )
106 ( "&&" calcFunc-land 110 111 )
107 ( "||" calcFunc-lor 100 101 )
108 ( "?" (math-read-if) 91 90 )
109 ( "!!!" calcFunc-pnot -1 88 )
110 ( "&&&" calcFunc-pand 85 86 )
111 ( "|||" calcFunc-por 75 76 )
112 ( "=" calcFunc-assign 51 50 )
113 ( ":=" calcFunc-assign 51 50 )
114 ( "::" calcFunc-condition 45 46 ))) ; should support full assignments
116 (put 'c 'math-function-table
117 '( ( acos . calcFunc-arccos )
118 ( acosh . calcFunc-arccosh )
119 ( asin . calcFunc-arcsin )
120 ( asinh . calcFunc-arcsinh )
121 ( atan . calcFunc-arctan )
122 ( atan2 . calcFunc-arctan2 )
123 ( atanh . calcFunc-arctanh )))
125 (put 'c 'math-variable-table
129 (put 'c 'math-vector-brackets "{}")
131 (put 'c 'math-radix-formatter
132 (function (lambda (r s)
133 (if (= r 16) (format "0x%s" s)
134 (if (= r 8) (format "0%s" s)
135 (format "%d#%s" r s))))))
138 (defun calc-pascal-language (n)
141 (and n (setq n (prefix-numeric-value n)))
142 (calc-set-language 'pascal n)
143 (message (if (and n (/= n 0))
145 "Pascal language mode (all uppercase)"
146 "Pascal language mode (all lowercase)")
147 "Pascal language mode"))))
149 (put 'pascal 'math-oper-table
150 '( ( "not" calcFunc-lnot -1 1000 )
153 ( "and" calcFunc-and 190 191 )
154 ( "div" calcFunc-idiv 190 191 )
156 ( "u+" ident -1 185 )
160 ( "or" calcFunc-or 180 181 )
161 ( "xor" calcFunc-xor 180 181 )
162 ( "shl" calcFunc-lsh 180 181 )
163 ( "shr" calcFunc-rsh 180 181 )
164 ( "in" calcFunc-in 160 161 )
165 ( "<" calcFunc-lt 160 161 )
166 ( ">" calcFunc-gt 160 161 )
167 ( "<=" calcFunc-leq 160 161 )
168 ( ">=" calcFunc-geq 160 161 )
169 ( "=" calcFunc-eq 160 161 )
170 ( "<>" calcFunc-neq 160 161 )
171 ( "!!!" calcFunc-pnot -1 85 )
172 ( "&&&" calcFunc-pand 80 81 )
173 ( "|||" calcFunc-por 75 76 )
174 ( ":=" calcFunc-assign 51 50 )
175 ( "::" calcFunc-condition 45 46 )))
177 (put 'pascal 'math-input-filter 'calc-input-case-filter)
178 (put 'pascal 'math-output-filter 'calc-output-case-filter)
180 (put 'pascal 'math-radix-formatter
181 (function (lambda (r s)
182 (if (= r 16) (format "$%s" s)
183 (format "%d#%s" r s)))))
185 (defun calc-input-case-filter (str)
186 (cond ((or (null calc-language-option) (= calc-language-option 0))
191 (defun calc-output-case-filter (str)
192 (cond ((or (null calc-language-option) (= calc-language-option 0))
194 ((> calc-language-option 0)
200 (defun calc-fortran-language (n)
203 (and n (setq n (prefix-numeric-value n)))
204 (calc-set-language 'fortran n)
205 (message (if (and n (/= n 0))
207 "FORTRAN language mode (all uppercase)"
208 "FORTRAN language mode (all lowercase)")
209 "FORTRAN language mode"))))
211 (put 'fortran 'math-oper-table
212 '( ( "u/" (math-parse-fortran-vector) -1 1 )
213 ( "/" (math-parse-fortran-vector-end) 1 -1 )
215 ( "u+" ident -1 191 )
221 ( ".LT." calcFunc-lt 160 161 )
222 ( ".GT." calcFunc-gt 160 161 )
223 ( ".LE." calcFunc-leq 160 161 )
224 ( ".GE." calcFunc-geq 160 161 )
225 ( ".EQ." calcFunc-eq 160 161 )
226 ( ".NE." calcFunc-neq 160 161 )
227 ( ".NOT." calcFunc-lnot -1 121 )
228 ( ".AND." calcFunc-land 110 111 )
229 ( ".OR." calcFunc-lor 100 101 )
230 ( "!!!" calcFunc-pnot -1 85 )
231 ( "&&&" calcFunc-pand 80 81 )
232 ( "|||" calcFunc-por 75 76 )
233 ( "=" calcFunc-assign 51 50 )
234 ( ":=" calcFunc-assign 51 50 )
235 ( "::" calcFunc-condition 45 46 )))
237 (put 'fortran 'math-vector-brackets "//")
239 (put 'fortran 'math-function-table
240 '( ( acos . calcFunc-arccos )
241 ( acosh . calcFunc-arccosh )
242 ( aimag . calcFunc-im )
243 ( aint . calcFunc-ftrunc )
244 ( asin . calcFunc-arcsin )
245 ( asinh . calcFunc-arcsinh )
246 ( atan . calcFunc-arctan )
247 ( atan2 . calcFunc-arctan2 )
248 ( atanh . calcFunc-arctanh )
249 ( conjg . calcFunc-conj )
250 ( log . calcFunc-ln )
251 ( nint . calcFunc-round )
252 ( real . calcFunc-re )))
254 (put 'fortran 'math-input-filter 'calc-input-case-filter)
255 (put 'fortran 'math-output-filter 'calc-output-case-filter)
257 ;; The next few variables are local to math-read-exprs in calc-aent.el
258 ;; and math-read-expr in calc-ext.el, but are set in functions they call.
260 (defvar math-exp-token)
261 (defvar math-expr-data)
262 (defvar math-exp-old-pos)
264 (defvar math-parsing-fortran-vector nil)
265 (defun math-parse-fortran-vector (op)
266 (let ((math-parsing-fortran-vector '(end . "\000")))
268 (math-read-brackets t "]")
269 (setq math-exp-token (car math-parsing-fortran-vector)
270 math-expr-data (cdr math-parsing-fortran-vector)))))
272 (defun math-parse-fortran-vector-end (x op)
273 (if math-parsing-fortran-vector
275 (setq math-parsing-fortran-vector (cons math-exp-token math-expr-data)
277 math-expr-data "\000")
279 (throw 'syntax "Unmatched closing `/'")))
281 (defun math-parse-fortran-subscr (sym args)
282 (setq sym (math-build-var-name sym))
284 (setq sym (list 'calcFunc-subscr sym (car args))
289 (defun calc-tex-language (n)
292 (and n (setq n (prefix-numeric-value n)))
293 (calc-set-language 'tex n)
294 (message (if (and n (/= n 0))
296 "TeX language mode with \\hbox{func}(\\hbox{var})"
297 "TeX language mode with \\func{\\hbox{var}}")
298 "TeX language mode"))))
300 (defun calc-latex-language (n)
303 (and n (setq n (prefix-numeric-value n)))
304 (calc-set-language 'latex n)
306 (message "LaTeX language mode"))
308 (message "LaTeX language mode with multiline matrices"))
310 (message "LaTeX language mode with \\text{func}(\\text{var})"))
313 "LaTeX language mode with \\text{func}(\\text{var}) and multiline matrices"))
315 (message "LaTeX language mode with \\func(\\text{var})"))
318 "LaTeX language mode with \\func(\\text{var}) and multiline matrices")))))
320 (put 'tex 'math-oper-table
321 '( ( "u+" ident -1 1000 )
323 ( "\\hat" calcFunc-hat -1 950 )
324 ( "\\check" calcFunc-check -1 950 )
325 ( "\\tilde" calcFunc-tilde -1 950 )
326 ( "\\acute" calcFunc-acute -1 950 )
327 ( "\\grave" calcFunc-grave -1 950 )
328 ( "\\dot" calcFunc-dot -1 950 )
329 ( "\\ddot" calcFunc-dotdot -1 950 )
330 ( "\\breve" calcFunc-breve -1 950 )
331 ( "\\bar" calcFunc-bar -1 950 )
332 ( "\\vec" calcFunc-Vec -1 950 )
333 ( "\\underline" calcFunc-under -1 950 )
334 ( "u|" calcFunc-abs -1 0 )
336 ( "\\lfloor" calcFunc-floor -1 0 )
337 ( "\\rfloor" closing 0 -1 )
338 ( "\\lceil" calcFunc-ceil -1 0 )
339 ( "\\rceil" closing 0 -1 )
340 ( "\\pm" sdev 300 300 )
341 ( "!" calcFunc-fact 210 -1 )
343 ( "_" calcFunc-subscr 201 200 )
344 ( "\\times" * 191 190 )
349 ( "\\over" / 170 171 )
351 ( "\\choose" calcFunc-choose 170 171 )
352 ( "\\mod" % 170 171 )
353 ( "<" calcFunc-lt 160 161 )
354 ( ">" calcFunc-gt 160 161 )
355 ( "\\leq" calcFunc-leq 160 161 )
356 ( "\\geq" calcFunc-geq 160 161 )
357 ( "=" calcFunc-eq 160 161 )
358 ( "\\neq" calcFunc-neq 160 161 )
359 ( "\\ne" calcFunc-neq 160 161 )
360 ( "\\lnot" calcFunc-lnot -1 121 )
361 ( "\\land" calcFunc-land 110 111 )
362 ( "\\lor" calcFunc-lor 100 101 )
363 ( "?" (math-read-if) 91 90 )
364 ( "!!!" calcFunc-pnot -1 85 )
365 ( "&&&" calcFunc-pand 80 81 )
366 ( "|||" calcFunc-por 75 76 )
367 ( "\\gets" calcFunc-assign 51 50 )
368 ( ":=" calcFunc-assign 51 50 )
369 ( "::" calcFunc-condition 45 46 )
370 ( "\\to" calcFunc-evalto 40 41 )
371 ( "\\to" calcFunc-evalto 40 -1 )
372 ( "=>" calcFunc-evalto 40 41 )
373 ( "=>" calcFunc-evalto 40 -1 )))
375 (put 'tex 'math-function-table
376 '( ( \\arccos . calcFunc-arccos )
377 ( \\arcsin . calcFunc-arcsin )
378 ( \\arctan . calcFunc-arctan )
379 ( \\arg . calcFunc-arg )
380 ( \\cos . calcFunc-cos )
381 ( \\cosh . calcFunc-cosh )
382 ( \\det . calcFunc-det )
383 ( \\exp . calcFunc-exp )
384 ( \\gcd . calcFunc-gcd )
385 ( \\ln . calcFunc-ln )
386 ( \\log . calcFunc-log10 )
387 ( \\max . calcFunc-max )
388 ( \\min . calcFunc-min )
389 ( \\tan . calcFunc-tan )
390 ( \\sin . calcFunc-sin )
391 ( \\sinh . calcFunc-sinh )
392 ( \\sqrt . calcFunc-sqrt )
393 ( \\tanh . calcFunc-tanh )
394 ( \\phi . calcFunc-totient )
395 ( \\mu . calcFunc-moebius )))
397 (put 'tex 'math-variable-table
399 ( \\infty . var-inf )
400 ( \\infty . var-uinf )
402 ( \\gamma . var-gamma )
403 ( \\sum . (math-parse-tex-sum calcFunc-sum) )
404 ( \\prod . (math-parse-tex-sum calcFunc-prod) )))
406 (put 'tex 'math-complex-format 'i)
408 (defun math-parse-tex-sum (f val)
410 (or (equal math-expr-data "_") (throw 'syntax "Expected `_'"))
412 (setq save math-exp-old-pos)
413 (setq low (math-read-factor))
414 (or (eq (car-safe low) 'calcFunc-eq)
416 (setq math-exp-old-pos (1+ save))
417 (throw 'syntax "Expected equation")))
418 (or (equal math-expr-data "^") (throw 'syntax "Expected `^'"))
420 (setq high (math-read-factor))
421 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high)))
423 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789.
424 (while (string-match "[0-9]\\\\,[0-9]" str)
425 (setq str (concat (substring str 0 (1+ (match-beginning 0)))
426 (substring str (1- (match-end 0))))))
428 (put 'tex 'math-input-filter 'math-tex-input-filter)
430 (put 'latex 'math-oper-table
431 (append (get 'tex 'math-oper-table)
432 '(( "\\Hat" calcFunc-Hat -1 950 )
433 ( "\\Check" calcFunc-Check -1 950 )
434 ( "\\Tilde" calcFunc-Tilde -1 950 )
435 ( "\\Acute" calcFunc-Acute -1 950 )
436 ( "\\Grave" calcFunc-Grave -1 950 )
437 ( "\\Dot" calcFunc-Dot -1 950 )
438 ( "\\Ddot" calcFunc-Dotdot -1 950 )
439 ( "\\Breve" calcFunc-Breve -1 950 )
440 ( "\\Bar" calcFunc-Bar -1 950 )
441 ( "\\Vec" calcFunc-VEC -1 950 )
442 ( "\\dddot" calcFunc-dddot -1 950 )
443 ( "\\ddddot" calcFunc-ddddot -1 950 )
445 ( "\\le" calcFunc-leq 160 161 )
446 ( "\\leqq" calcFunc-leq 160 161 )
447 ( "\\leqsland" calcFunc-leq 160 161 )
448 ( "\\ge" calcFunc-geq 160 161 )
449 ( "\\geqq" calcFunc-geq 160 161 )
450 ( "\\geqslant" 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 )
467 ( "=>" calcFunc-evalto 40 -1 ))))
469 (put 'latex 'math-function-table
471 (get 'tex 'math-function-table)
472 '(( \\frac . (math-latex-parse-frac /))
473 ( \\tfrac . (math-latex-parse-frac /))
474 ( \\dfrac . (math-latex-parse-frac /))
475 ( \\binom . (math-latex-parse-frac calcFunc-choose))
476 ( \\tbinom . (math-latex-parse-frac calcFunc-choose))
477 ( \\dbinom . (math-latex-parse-frac calcFunc-choose))
478 ( \\phi . calcFunc-totient )
479 ( \\mu . calcFunc-moebius ))))
481 (put 'latex 'math-special-function-table
482 '((/ . (math-latex-print-frac "\\frac"))
483 (calcFunc-choose . (math-latex-print-frac "\\binom"))))
485 (put 'latex 'math-variable-table
486 (get 'tex 'math-variable-table))
488 (put 'latex 'math-complex-format 'i)
490 (defun math-latex-parse-frac (f val)
492 (setq args (math-read-expr-list))
494 (setq margs (math-read-factor))
495 (list (nth 2 f) (car args) margs)))
497 (defun math-latex-print-frac (a fn)
498 (list 'horiz (nth 1 fn) "{" (math-compose-expr (nth 1 a) -1)
500 (math-compose-expr (nth 2 a) -1)
503 (put 'latex 'math-input-filter 'math-tex-input-filter)
505 (defun calc-eqn-language (n)
508 (calc-set-language 'eqn)
509 (message "Eqn language mode")))
511 (put 'eqn 'math-oper-table
512 '( ( "u+" ident -1 1000 )
514 ( "prime" (math-parse-eqn-prime) 950 -1 )
515 ( "prime" calcFunc-Prime 950 -1 )
516 ( "dot" calcFunc-dot 950 -1 )
517 ( "dotdot" calcFunc-dotdot 950 -1 )
518 ( "hat" calcFunc-hat 950 -1 )
519 ( "tilde" calcFunc-tilde 950 -1 )
520 ( "vec" calcFunc-Vec 950 -1 )
521 ( "dyad" calcFunc-dyad 950 -1 )
522 ( "bar" calcFunc-bar 950 -1 )
523 ( "under" calcFunc-under 950 -1 )
524 ( "sub" calcFunc-subscr 931 930 )
526 ( "sqrt" calcFunc-sqrt -1 910 )
528 ( "u|" calcFunc-abs -1 0 )
530 ( "left floor" calcFunc-floor -1 0 )
531 ( "right floor" closing 0 -1 )
532 ( "left ceil" calcFunc-ceil -1 0 )
533 ( "right ceil" closing 0 -1 )
534 ( "+-" sdev 300 300 )
535 ( "!" calcFunc-fact 210 -1 )
536 ( "times" * 191 190 )
543 ( "<" calcFunc-lt 160 161 )
544 ( ">" calcFunc-gt 160 161 )
545 ( "<=" calcFunc-leq 160 161 )
546 ( ">=" calcFunc-geq 160 161 )
547 ( "=" calcFunc-eq 160 161 )
548 ( "==" calcFunc-eq 160 161 )
549 ( "!=" calcFunc-neq 160 161 )
550 ( "u!" calcFunc-lnot -1 121 )
551 ( "&&" calcFunc-land 110 111 )
552 ( "||" calcFunc-lor 100 101 )
553 ( "?" (math-read-if) 91 90 )
554 ( "!!!" calcFunc-pnot -1 85 )
555 ( "&&&" calcFunc-pand 80 81 )
556 ( "|||" calcFunc-por 75 76 )
557 ( "<-" calcFunc-assign 51 50 )
558 ( ":=" calcFunc-assign 51 50 )
559 ( "::" calcFunc-condition 45 46 )
560 ( "->" calcFunc-evalto 40 41 )
561 ( "->" calcFunc-evalto 40 -1 )
562 ( "=>" calcFunc-evalto 40 41 )
563 ( "=>" calcFunc-evalto 40 -1 )))
565 (put 'eqn 'math-function-table
566 '( ( arc\ cos . calcFunc-arccos )
567 ( arc\ cosh . calcFunc-arccosh )
568 ( arc\ sin . calcFunc-arcsin )
569 ( arc\ sinh . calcFunc-arcsinh )
570 ( arc\ tan . calcFunc-arctan )
571 ( arc\ tanh . calcFunc-arctanh )
572 ( GAMMA . calcFunc-gamma )
573 ( phi . calcFunc-totient )
574 ( mu . calcFunc-moebius )
575 ( matrix . (math-parse-eqn-matrix) )))
577 (put 'eqn 'math-variable-table
578 '( ( inf . var-uinf )))
580 (put 'eqn 'math-complex-format 'i)
582 (defun math-parse-eqn-matrix (f sym)
584 (while (assoc math-expr-data '(("ccol") ("lcol") ("rcol")))
586 (or (equal math-expr-data calc-function-open)
587 (throw 'syntax "Expected `{'"))
589 (setq vec (cons (cons 'vec (math-read-expr-list)) vec))
590 (or (equal math-expr-data calc-function-close)
591 (throw 'syntax "Expected `}'"))
593 (or (equal math-expr-data calc-function-close)
594 (throw 'syntax "Expected `}'"))
596 (math-transpose (cons 'vec (nreverse vec)))))
598 (defun math-parse-eqn-prime (x sym)
599 (if (eq (car-safe x) 'var)
600 (if (equal math-expr-data calc-function-open)
603 (let ((args (if (or (equal math-expr-data calc-function-close)
604 (eq math-exp-token 'end))
606 (math-read-expr-list))))
607 (if (not (or (equal math-expr-data calc-function-close)
608 (eq math-exp-token 'end)))
609 (throw 'syntax "Expected `)'"))
611 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args)))
613 (intern (concat (symbol-name (nth 1 x)) "'"))
614 (intern (concat (symbol-name (nth 2 x)) "'"))))
615 (list 'calcFunc-Prime x)))
618 (defun calc-mathematica-language ()
621 (calc-set-language 'math)
622 (message "Mathematica language mode")))
624 (put 'math 'math-oper-table
625 '( ( "[[" (math-read-math-subscr) 250 -1 )
626 ( "!" calcFunc-fact 210 -1 )
627 ( "!!" calcFunc-dfact 210 -1 )
629 ( "u+" ident -1 197 )
636 ( "<" calcFunc-lt 160 161 )
637 ( ">" calcFunc-gt 160 161 )
638 ( "<=" calcFunc-leq 160 161 )
639 ( ">=" calcFunc-geq 160 161 )
640 ( "==" calcFunc-eq 150 151 )
641 ( "!=" calcFunc-neq 150 151 )
642 ( "u!" calcFunc-lnot -1 121 )
643 ( "&&" calcFunc-land 110 111 )
644 ( "||" calcFunc-lor 100 101 )
645 ( "!!!" calcFunc-pnot -1 85 )
646 ( "&&&" calcFunc-pand 80 81 )
647 ( "|||" calcFunc-por 75 76 )
648 ( ":=" calcFunc-assign 51 50 )
649 ( "=" calcFunc-assign 51 50 )
650 ( "->" calcFunc-assign 51 50 )
651 ( ":>" calcFunc-assign 51 50 )
652 ( "::" calcFunc-condition 45 46 )
655 (put 'math 'math-function-table
656 '( ( Abs . calcFunc-abs )
657 ( ArcCos . calcFunc-arccos )
658 ( ArcCosh . calcFunc-arccosh )
659 ( ArcSin . calcFunc-arcsin )
660 ( ArcSinh . calcFunc-arcsinh )
661 ( ArcTan . calcFunc-arctan )
662 ( ArcTanh . calcFunc-arctanh )
663 ( Arg . calcFunc-arg )
664 ( Binomial . calcFunc-choose )
665 ( Ceiling . calcFunc-ceil )
666 ( Conjugate . calcFunc-conj )
667 ( Cos . calcFunc-cos )
668 ( Cosh . calcFunc-cosh )
669 ( D . calcFunc-deriv )
670 ( Dt . calcFunc-tderiv )
671 ( Det . calcFunc-det )
672 ( Exp . calcFunc-exp )
673 ( EulerPhi . calcFunc-totient )
674 ( Floor . calcFunc-floor )
675 ( Gamma . calcFunc-gamma )
676 ( GCD . calcFunc-gcd )
679 ( Inverse . calcFunc-inv )
680 ( Integrate . calcFunc-integ )
681 ( Join . calcFunc-vconcat )
682 ( LCM . calcFunc-lcm )
683 ( Log . calcFunc-ln )
684 ( Max . calcFunc-max )
685 ( Min . calcFunc-min )
686 ( Mod . calcFunc-mod )
687 ( MoebiusMu . calcFunc-moebius )
688 ( Random . calcFunc-random )
689 ( Round . calcFunc-round )
691 ( Sign . calcFunc-sign )
692 ( Sin . calcFunc-sin )
693 ( Sinh . calcFunc-sinh )
694 ( Sqrt . calcFunc-sqrt )
695 ( Tan . calcFunc-tan )
696 ( Tanh . calcFunc-tanh )
697 ( Transpose . calcFunc-trn )
698 ( Length . calcFunc-vlen )
701 (put 'math 'math-variable-table
705 ( GoldenRatio . var-phi )
706 ( EulerGamma . var-gamma )
707 ( Infinity . var-inf )
708 ( ComplexInfinity . var-uinf )
709 ( Indeterminate . var-nan )
712 (put 'math 'math-vector-brackets "{}")
713 (put 'math 'math-complex-format 'I)
714 (put 'math 'math-function-open "[")
715 (put 'math 'math-function-close "]")
717 (put 'math 'math-radix-formatter
718 (function (lambda (r s) (format "%d^^%s" r s))))
720 (defun math-read-math-subscr (x op)
721 (let ((idx (math-read-expr-level 0)))
722 (or (and (equal math-expr-data "]")
725 (equal math-expr-data "]")))
726 (throw 'syntax "Expected ']]'"))
728 (list 'calcFunc-subscr x idx)))
731 (defun calc-maple-language ()
734 (calc-set-language 'maple)
735 (message "Maple language mode")))
737 (put 'maple 'math-oper-table
738 '( ( "matrix" ident -1 300 )
739 ( "MATRIX" ident -1 300 )
740 ( "!" calcFunc-fact 210 -1 )
743 ( "u+" ident -1 197 )
747 ( "intersect" calcFunc-vint 191 192 )
750 ( "union" calcFunc-vunion 180 181 )
751 ( "minus" calcFunc-vdiff 180 181 )
753 ( ".." (math-read-maple-dots) 165 165 )
754 ( "\\dots" (math-read-maple-dots) 165 165 )
755 ( "<" calcFunc-lt 160 160 )
756 ( ">" calcFunc-gt 160 160 )
757 ( "<=" calcFunc-leq 160 160 )
758 ( ">=" calcFunc-geq 160 160 )
759 ( "=" calcFunc-eq 160 160 )
760 ( "<>" calcFunc-neq 160 160 )
761 ( "not" calcFunc-lnot -1 121 )
762 ( "and" calcFunc-land 110 111 )
763 ( "or" calcFunc-lor 100 101 )
764 ( "!!!" calcFunc-pnot -1 85 )
765 ( "&&&" calcFunc-pand 80 81 )
766 ( "|||" calcFunc-por 75 76 )
767 ( ":=" calcFunc-assign 51 50 )
768 ( "::" calcFunc-condition 45 46 )
771 (put 'maple 'math-function-table
772 '( ( bernoulli . calcFunc-bern )
773 ( binomial . calcFunc-choose )
774 ( diff . calcFunc-deriv )
775 ( GAMMA . calcFunc-gamma )
776 ( ifactor . calcFunc-prfac )
777 ( igcd . calcFunc-gcd )
778 ( ilcm . calcFunc-lcm )
779 ( int . calcFunc-integ )
782 ( iquo . calcFunc-idiv )
783 ( isprime . calcFunc-prime )
784 ( length . calcFunc-vlen )
785 ( member . calcFunc-in )
786 ( crossprod . calcFunc-cross )
787 ( inverse . calcFunc-inv )
788 ( trace . calcFunc-tr )
789 ( transpose . calcFunc-trn )
790 ( vectdim . calcFunc-vlen )
793 (put 'maple 'math-variable-table
797 ( infinity . var-inf )
798 ( infinity . var-uinf )
799 ( infinity . var-nan )
802 (put 'maple 'math-complex-format 'I)
804 (defun math-read-maple-dots (x op)
805 (list 'intv 3 x (math-read-expr-level (nth 3 op))))
808 ;; The variable math-read-big-lines is local to math-read-big-expr in
809 ;; calc-ext.el, but is used by math-read-big-rec, math-read-big-char,
810 ;; math-read-big-emptyp, math-read-big-error and math-read-big-balance,
811 ;; which are called (directly and indirectly) by math-read-big-expr.
812 ;; It is also local to math-read-big-bigp in calc-ext.el, which calls
813 ;; math-read-big-balance.
814 (defvar math-read-big-lines)
816 ;; The variables math-read-big-baseline and math-read-big-h2 are
817 ;; local to math-read-big-expr in calc-ext.el, but used by
818 ;; math-read-big-rec.
819 (defvar math-read-big-baseline)
820 (defvar math-read-big-h2)
822 ;; The variables math-rb-h1, math-rb-h2, math-rb-v1 and math-rb-v2
823 ;; are local to math-read-big-rec, but are used by math-read-big-char,
824 ;; math-read-big-emptyp and math-read-big-balance which are called by
825 ;; math-read-big-rec.
826 ;; math-rb-h2 is also local to math-read-big-bigp in calc-ext.el,
827 ;; which calls math-read-big-balance.
833 (defun math-read-big-rec (math-rb-h1 math-rb-v1 math-rb-h2 math-rb-v2
834 &optional baseline prec short)
835 (or prec (setq prec 0))
837 ;; Clip whitespace above or below.
838 (while (and (< math-rb-v1 math-rb-v2)
839 (math-read-big-emptyp math-rb-h1 math-rb-v1 math-rb-h2 (1+ math-rb-v1)))
840 (setq math-rb-v1 (1+ math-rb-v1)))
841 (while (and (< math-rb-v1 math-rb-v2)
842 (math-read-big-emptyp math-rb-h1 (1- math-rb-v2) math-rb-h2 math-rb-v2))
843 (setq math-rb-v2 (1- math-rb-v2)))
845 ;; If formula is a single line high, normal parser can handle it.
846 (if (<= math-rb-v2 (1+ math-rb-v1))
847 (if (or (<= math-rb-v2 math-rb-v1)
848 (> math-rb-h1 (length (setq math-rb-v2
849 (nth math-rb-v1 math-read-big-lines)))))
850 (math-read-big-error math-rb-h1 math-rb-v1)
851 (setq math-read-big-baseline math-rb-v1
852 math-read-big-h2 math-rb-h2
853 math-rb-v2 (nth math-rb-v1 math-read-big-lines)
854 math-rb-h2 (math-read-expr
855 (substring math-rb-v2 math-rb-h1
856 (min math-rb-h2 (length math-rb-v2)))))
857 (if (eq (car-safe math-rb-h2) 'error)
858 (math-read-big-error (+ math-rb-h1 (nth 1 math-rb-h2))
859 math-rb-v1 (nth 2 math-rb-h2))
862 ;; Clip whitespace at left or right.
863 (while (and (< math-rb-h1 math-rb-h2)
864 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) math-rb-v2))
865 (setq math-rb-h1 (1+ math-rb-h1)))
866 (while (and (< math-rb-h1 math-rb-h2)
867 (math-read-big-emptyp (1- math-rb-h2) math-rb-v1 math-rb-h2 math-rb-v2))
868 (setq math-rb-h2 (1- math-rb-h2)))
870 ;; Scan to find widest left-justified "----" in the region.
873 (lines-v1 (nthcdr math-rb-v1 math-read-big-lines))
877 other-char line len h)
878 (while (< v math-rb-v2)
880 len (min math-rb-h2 (length line)))
881 (and (< math-rb-h1 len)
882 (/= (aref line math-rb-h1) ?\ )
883 (if (and (= (aref line math-rb-h1) ?\-)
884 ;; Make sure it's not a minus sign.
885 (or (and (< (1+ math-rb-h1) len)
886 (= (aref line (1+ math-rb-h1)) ?\-))
887 (/= (math-read-big-char math-rb-h1 (1- v)) ?\ )
888 (/= (math-read-big-char math-rb-h1 (1+ v)) ?\ )))
891 (while (and (< (setq h (1+ h)) len)
892 (= (aref line h) ?\-)))
896 (or other-v (setq other-v v other-char (aref line math-rb-h1)))))
900 (cond ((not (setq v other-v))
901 (math-read-big-error math-rb-h1 math-rb-v1)) ; Should never happen!
907 (let ((num (math-read-big-rec math-rb-h1 math-rb-v1 h v))
908 (den (math-read-big-rec math-rb-h1 (1+ v) h math-rb-v2)))
909 (setq p (if (and (math-integerp num) (math-integerp den))
910 (math-make-frac num den)
911 (list '/ num den)))))
915 (or (= (math-read-big-char (1+ math-rb-h1) v) ?\|)
916 (math-read-big-error (1+ math-rb-h1) v "Malformed root sign"))
917 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
918 (while (= (math-read-big-char (1+ math-rb-h1) (setq v (1- v))) ?\|))
919 (or (= (math-read-big-char (setq h (+ math-rb-h1 2)) v) ?\_)
920 (math-read-big-error h v "Malformed root sign"))
921 (while (= (math-read-big-char (setq h (1+ h)) v) ?\_))
922 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
923 (math-read-big-emptyp math-rb-h1 (1+ other-v) h math-rb-v2 nil t)
924 (setq p (list 'calcFunc-sqrt (math-read-big-rec
925 (+ math-rb-h1 2) (1+ v)
926 h (1+ other-v) baseline))
927 v math-read-big-baseline))
929 ;; Small radical sign.
930 ((and (= other-char ?V)
931 (= (math-read-big-char (1+ math-rb-h1) (1- v)) ?\_))
932 (setq h (1+ math-rb-h1))
933 (math-read-big-emptyp math-rb-h1 math-rb-v1 h (1- v) nil t)
934 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
935 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
936 (while (= (math-read-big-char (setq h (1+ h)) (1- v)) ?\_))
937 (setq p (list 'calcFunc-sqrt (math-read-big-rec
938 (1+ math-rb-h1) v h (1+ v) t))
939 v math-read-big-baseline))
941 ;; Binomial coefficient.
942 ((and (= other-char ?\()
943 (= (math-read-big-char (1+ math-rb-h1) v) ?\ )
944 (= (string-match "( *)" (nth v math-read-big-lines)
945 math-rb-h1) math-rb-h1))
946 (setq h (match-end 0))
947 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
948 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t)
949 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
950 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
951 (setq p (list 'calcFunc-choose
952 (math-read-big-rec (1+ math-rb-h1) math-rb-v1 (1- h) v)
953 (math-read-big-rec (1+ math-rb-h1) (1+ v)
954 (1- h) math-rb-v2))))
958 (setq p (list 'neg (math-read-big-rec (1+ math-rb-h1) math-rb-v1
959 math-rb-h2 math-rb-v2 v 250 t))
960 v math-read-big-baseline
965 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
966 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t)
967 (setq h (math-read-big-balance (1+ math-rb-h1) v "(" t))
968 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
969 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
970 (let ((sep (math-read-big-char (1- h) v))
975 (math-read-big-error (1- h) v "Expected `)'"))
977 (setq p (math-read-big-rec
978 (1+ math-rb-h1) math-rb-v1 (1- h) math-rb-v2 v))
979 (setq hmid (math-read-big-balance h v "(")
981 (math-read-big-rec h math-rb-v1 (1- hmid) math-rb-v2 v))
984 (setq p (cons 'intv (cons (if (= (math-read-big-char
989 ((= (math-read-big-char (1- h) v) ?\])
990 (math-read-big-error (1- h) v "Expected `)'"))
992 (or (and (math-realp (car p)) (math-realp (nth 1 p)))
994 math-rb-h1 v "Complex components must be real"))
995 (setq p (cons 'cplx p)))
997 (or (and (math-realp (car p)) (math-anglep (nth 1 p)))
999 math-rb-h1 v "Complex components must be real"))
1000 (setq p (cons 'polar p)))))))
1003 ((and (= other-char ?\[)
1004 (or (= (math-read-big-char (setq h math-rb-h1) (1+ v)) ?\[)
1005 (= (math-read-big-char (setq h (1+ h)) v) ?\[)
1006 (and (= (math-read-big-char h v) ?\ )
1007 (= (math-read-big-char (setq h (1+ h)) v) ?\[)))
1008 (= (math-read-big-char h (1+ v)) ?\[))
1009 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
1015 (setq h (math-read-big-balance (1+ hleft) v "["))
1018 (math-read-big-error hright v "Expected `]'"))
1020 (setq p (cons (math-read-big-rec
1021 hleft v h (1+ v)) p))
1022 (and (memq (math-read-big-char h v) '(?\ ?\,))
1023 (= (math-read-big-char hleft (1+ v)) ?\[)))
1025 (or (= hleft math-rb-h1)
1027 (if (= (math-read-big-char h v) ?\ )
1029 (and (= (math-read-big-char h v) ?\])
1031 (math-read-big-error (1- h) v "Expected `]'"))
1032 (if (= (math-read-big-char h vtop) ?\,)
1034 (math-read-big-emptyp math-rb-h1 (1+ v) (1- h) math-rb-v2 nil t)
1035 (setq v (+ vtop (/ (- v vtop) 2))
1036 p (cons 'vec (nreverse p)))))
1040 (math-read-big-emptyp math-rb-h1 math-rb-v1 (1+ math-rb-h1) v nil t)
1041 (math-read-big-emptyp math-rb-h1 (1+ v) (1+ math-rb-h1) math-rb-v2 nil t)
1045 (setq widest (math-read-big-balance h v "[" t))
1046 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
1047 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
1048 (setq p (cons (math-read-big-rec
1049 h math-rb-v1 (1- widest) math-rb-v2 v) p)
1051 (= (math-read-big-char (1- h) v) ?\,)))
1052 (setq widest (math-read-big-char (1- h) v))
1053 (if (or (memq widest '(?\; ?\)))
1054 (and (eq widest ?\.) (cdr p)))
1055 (math-read-big-error (1- h) v "Expected `]'"))
1058 widest (math-read-big-balance h v "[")
1059 p (nconc p (list (math-read-big-rec
1060 h math-rb-v1 (1- widest) math-rb-v2 v)))
1062 p (cons 'intv (cons (if (= (math-read-big-char (1- h) v)
1066 (setq p (cons 'vec (nreverse p)))))
1070 (setq line (nth v math-read-big-lines))
1071 (string-match ">" line math-rb-h1)
1072 (setq h (match-end 0))
1073 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
1074 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
1075 (setq p (math-read-big-rec math-rb-h1 v h (1+ v) v)))
1077 ;; Variable name or function call.
1078 ((or (and (>= other-char ?a) (<= other-char ?z))
1079 (and (>= other-char ?A) (<= other-char ?Z)))
1080 (setq line (nth v math-read-big-lines))
1081 (string-match "\\([a-zA-Z'_]+\\) *" line math-rb-h1)
1082 (setq h (match-end 1)
1083 widest (match-end 0)
1084 p (math-match-substring line 1))
1085 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
1086 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)
1087 (if (= (math-read-big-char widest v) ?\()
1089 (setq line (if (string-match "-" p)
1091 (intern (concat "calcFunc-" p)))
1094 (math-read-big-emptyp widest math-rb-v1 h v nil t)
1095 (math-read-big-emptyp widest (1+ v) h math-rb-v2 nil t)
1097 (setq widest (math-read-big-balance h v "(" t))
1098 (math-read-big-emptyp (1- h) math-rb-v1 h v nil t)
1099 (math-read-big-emptyp (1- h) (1+ v) h math-rb-v2 nil t)
1100 (setq p (cons (math-read-big-rec
1101 h math-rb-v1 (1- widest) math-rb-v2 v) p)
1103 (= (math-read-big-char (1- h) v) ?\,)))
1104 (or (= (math-read-big-char (1- h) v) ?\))
1105 (math-read-big-error (1- h) v "Expected `)'"))
1106 (setq p (cons line (nreverse p))))
1108 (intern (math-remove-dashes p))
1109 (if (string-match "-" p)
1111 (intern (concat "var-" p)))))))
1115 (setq line (nth v math-read-big-lines))
1116 (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)
1117 (math-read-big-error h v "Expected a number"))
1118 (setq h (match-end 0)
1119 p (math-read-number (math-match-substring line 0)))
1120 (math-read-big-emptyp math-rb-h1 math-rb-v1 h v nil t)
1121 (math-read-big-emptyp math-rb-h1 (1+ v) h math-rb-v2 nil t)))
1123 ;; Now left term is bounded by math-rb-h1, math-rb-v1, h, math-rb-v2;
1127 (math-read-big-error math-rb-h1 v "Inconsistent baseline in formula"))
1130 ;; Look for superscripts or subscripts.
1131 (setq line (nth baseline math-read-big-lines)
1132 len (min math-rb-h2 (length line))
1134 (while (and (< widest len)
1135 (= (aref line widest) ?\ ))
1136 (setq widest (1+ widest)))
1137 (and (>= widest len) (setq widest math-rb-h2))
1138 (if (math-read-big-emptyp h v widest math-rb-v2)
1139 (if (math-read-big-emptyp h math-rb-v1 widest v)
1141 (setq p (list '^ p (math-read-big-rec h math-rb-v1 widest v))
1143 (if (math-read-big-emptyp h math-rb-v1 widest v)
1144 (setq p (list 'calcFunc-subscr p
1145 (math-read-big-rec h v widest math-rb-v2))
1148 ;; Look for an operator name and grab additional terms.
1149 (while (and (< h len)
1150 (if (setq widest (and (math-read-big-emptyp
1151 h math-rb-v1 (1+ h) v)
1152 (math-read-big-emptyp
1153 h (1+ v) (1+ h) math-rb-v2)
1154 (string-match "<=\\|>=\\|\\+/-\\|!=\\|&&\\|||\\|:=\\|=>\\|." line h)
1155 (assoc (math-match-substring line 0)
1156 math-standard-opers)))
1157 (and (>= (nth 2 widest) prec)
1158 (setq h (match-end 0)))
1159 (and (not (eq (string-match ",\\|;\\|\\.\\.\\|)\\|\\]\\|:" line h)
1161 (setq widest '("2x" * 196 195)))))
1162 (cond ((eq (nth 3 widest) -1)
1163 (setq p (list (nth 1 widest) p)))
1164 ((equal (car widest) "?")
1165 (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2
1166 math-rb-v2 baseline nil t)))
1167 (or (= (math-read-big-char math-read-big-h2 baseline) ?\:)
1168 (math-read-big-error math-read-big-h2 baseline "Expected `:'"))
1169 (setq p (list (nth 1 widest) p y
1171 (1+ math-read-big-h2) math-rb-v1 math-rb-h2 math-rb-v2
1172 baseline (nth 3 widest) t))
1173 h math-read-big-h2)))
1175 (setq p (list (nth 1 widest) p
1176 (math-read-big-rec h math-rb-v1 math-rb-h2 math-rb-v2
1177 baseline (nth 3 widest) t))
1178 h math-read-big-h2))))
1180 ;; Return all relevant information to caller.
1181 (setq math-read-big-baseline baseline
1183 (or short (= math-read-big-h2 math-rb-h2)
1184 (math-read-big-error h baseline))
1187 (defun math-read-big-char (h v)
1188 (or (and (>= h math-rb-h1)
1192 (let ((line (nth v math-read-big-lines)))
1198 (defun math-read-big-emptyp (eh1 ev1 eh2 ev2 &optional what error)
1199 (and (< ev1 math-rb-v1) (setq ev1 math-rb-v1))
1200 (and (< eh1 math-rb-h1) (setq eh1 math-rb-h1))
1201 (and (> ev2 math-rb-v2) (setq ev2 math-rb-v2))
1202 (and (> eh2 math-rb-h2) (setq eh2 math-rb-h2))
1203 (or what (setq what ?\ ))
1204 (let ((p (nthcdr ev1 math-read-big-lines))
1206 (while (and (< ev1 ev2)
1208 (setq h (min eh2 (length (car p))))
1209 (while (and (>= (setq h (1- h)) eh1)
1210 (= (aref (car p) h) what)))
1211 (and error (>= h eh1)
1212 (math-read-big-error h ev1 (if (stringp error)
1214 "Whitespace expected")))
1220 ;; math-read-big-err-msg is local to math-read-big-expr in calc-ext.el,
1221 ;; but is used by math-read-big-error which is called (indirectly) by
1222 ;; math-read-big-expr.
1223 (defvar math-read-big-err-msg)
1225 (defun math-read-big-error (h v &optional msg)
1227 (p math-read-big-lines))
1229 (setq pos (+ pos 1 (length (car p)))
1232 (setq h (+ pos (min h (length (car p))))
1233 math-read-big-err-msg (list 'error h (or msg "Syntax error")))
1234 (throw 'syntax nil)))
1236 (defun math-read-big-balance (h v what &optional commas)
1237 (let* ((line (nth v math-read-big-lines))
1238 (len (min math-rb-h2 (length line)))
1243 (math-read-big-error nil v (format "Unmatched `%s'" what))
1245 (if (memq (aref line h) '(?\( ?\[))
1246 (setq count (1+ count))
1247 (if (if (and commas (= count 1))
1248 (or (memq (aref line h) '(?\) ?\] ?\, ?\;))
1249 (and (eq (aref line h) ?\.)
1251 (eq (aref line (1+ h)) ?\.)))
1252 (memq (aref line h) '(?\) ?\])))
1253 (setq count (1- count))))
1257 (provide 'calc-lang)
1259 ;;; arch-tag: 483bfe15-f290-4fef-bb7d-ce65be687f2e
1260 ;;; calc-lang.el ends here