Mercurial > emacs
comparison lisp/calc/calc-lang.el @ 58107:cfad3432f125
(math-parse-fortran-vector, math-parse-fortran-vector-end,
math-parse-tex-sum, math-parse-eqn-matrix, math-parse-eqn-prime,
math-read-math-subscr): Use declared variable math-expr-data.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Tue, 09 Nov 2004 20:32:13 +0000 |
parents | 695cf19ef79e |
children | 3089957051ea |
comparison
equal
deleted
inserted
replaced
58106:54e2af9e210d | 58107:cfad3432f125 |
---|---|
262 (defun math-parse-fortran-vector (op) | 262 (defun math-parse-fortran-vector (op) |
263 (let ((math-parsing-fortran-vector '(end . "\000"))) | 263 (let ((math-parsing-fortran-vector '(end . "\000"))) |
264 (prog1 | 264 (prog1 |
265 (math-read-brackets t "]") | 265 (math-read-brackets t "]") |
266 (setq exp-token (car math-parsing-fortran-vector) | 266 (setq exp-token (car math-parsing-fortran-vector) |
267 exp-data (cdr math-parsing-fortran-vector))))) | 267 math-expr-data (cdr math-parsing-fortran-vector))))) |
268 | 268 |
269 (defun math-parse-fortran-vector-end (x op) | 269 (defun math-parse-fortran-vector-end (x op) |
270 (if math-parsing-fortran-vector | 270 (if math-parsing-fortran-vector |
271 (progn | 271 (progn |
272 (setq math-parsing-fortran-vector (cons exp-token exp-data) | 272 (setq math-parsing-fortran-vector (cons exp-token math-expr-data) |
273 exp-token 'end | 273 exp-token 'end |
274 exp-data "\000") | 274 math-expr-data "\000") |
275 x) | 275 x) |
276 (throw 'syntax "Unmatched closing `/'"))) | 276 (throw 'syntax "Unmatched closing `/'"))) |
277 | 277 |
278 (defun math-parse-fortran-subscr (sym args) | 278 (defun math-parse-fortran-subscr (sym args) |
279 (setq sym (math-build-var-name sym)) | 279 (setq sym (math-build-var-name sym)) |
382 | 382 |
383 (put 'tex 'math-complex-format 'i) | 383 (put 'tex 'math-complex-format 'i) |
384 | 384 |
385 (defun math-parse-tex-sum (f val) | 385 (defun math-parse-tex-sum (f val) |
386 (let (low high save) | 386 (let (low high save) |
387 (or (equal exp-data "_") (throw 'syntax "Expected `_'")) | 387 (or (equal math-expr-data "_") (throw 'syntax "Expected `_'")) |
388 (math-read-token) | 388 (math-read-token) |
389 (setq save exp-old-pos) | 389 (setq save exp-old-pos) |
390 (setq low (math-read-factor)) | 390 (setq low (math-read-factor)) |
391 (or (eq (car-safe low) 'calcFunc-eq) | 391 (or (eq (car-safe low) 'calcFunc-eq) |
392 (progn | 392 (progn |
393 (setq exp-old-pos (1+ save)) | 393 (setq exp-old-pos (1+ save)) |
394 (throw 'syntax "Expected equation"))) | 394 (throw 'syntax "Expected equation"))) |
395 (or (equal exp-data "^") (throw 'syntax "Expected `^'")) | 395 (or (equal math-expr-data "^") (throw 'syntax "Expected `^'")) |
396 (math-read-token) | 396 (math-read-token) |
397 (setq high (math-read-factor)) | 397 (setq high (math-read-factor)) |
398 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high))) | 398 (list (nth 2 f) (math-read-factor) (nth 1 low) (nth 2 low) high))) |
399 | 399 |
400 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789. | 400 (defun math-tex-input-filter (str) ; allow parsing of 123\,456\,789. |
482 | 482 |
483 (put 'eqn 'math-complex-format 'i) | 483 (put 'eqn 'math-complex-format 'i) |
484 | 484 |
485 (defun math-parse-eqn-matrix (f sym) | 485 (defun math-parse-eqn-matrix (f sym) |
486 (let ((vec nil)) | 486 (let ((vec nil)) |
487 (while (assoc exp-data '(("ccol") ("lcol") ("rcol"))) | 487 (while (assoc math-expr-data '(("ccol") ("lcol") ("rcol"))) |
488 (math-read-token) | 488 (math-read-token) |
489 (or (equal exp-data calc-function-open) | 489 (or (equal math-expr-data calc-function-open) |
490 (throw 'syntax "Expected `{'")) | 490 (throw 'syntax "Expected `{'")) |
491 (math-read-token) | 491 (math-read-token) |
492 (setq vec (cons (cons 'vec (math-read-expr-list)) vec)) | 492 (setq vec (cons (cons 'vec (math-read-expr-list)) vec)) |
493 (or (equal exp-data calc-function-close) | 493 (or (equal math-expr-data calc-function-close) |
494 (throw 'syntax "Expected `}'")) | 494 (throw 'syntax "Expected `}'")) |
495 (math-read-token)) | 495 (math-read-token)) |
496 (or (equal exp-data calc-function-close) | 496 (or (equal math-expr-data calc-function-close) |
497 (throw 'syntax "Expected `}'")) | 497 (throw 'syntax "Expected `}'")) |
498 (math-read-token) | 498 (math-read-token) |
499 (math-transpose (cons 'vec (nreverse vec))))) | 499 (math-transpose (cons 'vec (nreverse vec))))) |
500 | 500 |
501 (defun math-parse-eqn-prime (x sym) | 501 (defun math-parse-eqn-prime (x sym) |
502 (if (eq (car-safe x) 'var) | 502 (if (eq (car-safe x) 'var) |
503 (if (equal exp-data calc-function-open) | 503 (if (equal math-expr-data calc-function-open) |
504 (progn | 504 (progn |
505 (math-read-token) | 505 (math-read-token) |
506 (let ((args (if (or (equal exp-data calc-function-close) | 506 (let ((args (if (or (equal math-expr-data calc-function-close) |
507 (eq exp-token 'end)) | 507 (eq exp-token 'end)) |
508 nil | 508 nil |
509 (math-read-expr-list)))) | 509 (math-read-expr-list)))) |
510 (if (not (or (equal exp-data calc-function-close) | 510 (if (not (or (equal math-expr-data calc-function-close) |
511 (eq exp-token 'end))) | 511 (eq exp-token 'end))) |
512 (throw 'syntax "Expected `)'")) | 512 (throw 'syntax "Expected `)'")) |
513 (math-read-token) | 513 (math-read-token) |
514 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args))) | 514 (cons (intern (format "calcFunc-%s'" (nth 1 x))) args))) |
515 (list 'var | 515 (list 'var |
620 (put 'math 'math-radix-formatter | 620 (put 'math 'math-radix-formatter |
621 (function (lambda (r s) (format "%d^^%s" r s)))) | 621 (function (lambda (r s) (format "%d^^%s" r s)))) |
622 | 622 |
623 (defun math-read-math-subscr (x op) | 623 (defun math-read-math-subscr (x op) |
624 (let ((idx (math-read-expr-level 0))) | 624 (let ((idx (math-read-expr-level 0))) |
625 (or (and (equal exp-data "]") | 625 (or (and (equal math-expr-data "]") |
626 (progn | 626 (progn |
627 (math-read-token) | 627 (math-read-token) |
628 (equal exp-data "]"))) | 628 (equal math-expr-data "]"))) |
629 (throw 'syntax "Expected ']]'")) | 629 (throw 'syntax "Expected ']]'")) |
630 (math-read-token) | 630 (math-read-token) |
631 (list 'calcFunc-subscr x idx))) | 631 (list 'calcFunc-subscr x idx))) |
632 | 632 |
633 | 633 |