464 |
(let ((exp-pos 0) |
(let ((exp-pos 0) |
465 |
(exp-old-pos 0) |
(exp-old-pos 0) |
466 |
(exp-keep-spaces nil) |
(exp-keep-spaces nil) |
467 |
exp-token exp-data) |
exp-token math-expr-data) |
468 |
(if calc-language-input-filter |
(if calc-language-input-filter |
469 |
(setq exp-str (funcall calc-language-input-filter exp-str))) |
(setq exp-str (funcall calc-language-input-filter exp-str))) |
470 |
(while (setq exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)" exp-str)) |
(while (setq exp-token (string-match "\\.\\.\\([^.]\\|.[^.]\\)" exp-str)) |
483 |
(let* ((exp-keep-spaces nil) |
(let* ((exp-keep-spaces nil) |
484 |
(val (list (math-read-expr-level 0))) |
(val (list (math-read-expr-level 0))) |
485 |
(last val)) |
(last val)) |
486 |
(while (equal exp-data ",") |
(while (equal math-expr-data ",") |
487 |
(math-read-token) |
(math-read-token) |
488 |
(let ((rest (list (math-read-expr-level 0)))) |
(let ((rest (list (math-read-expr-level 0)))) |
489 |
(setcdr last rest) |
(setcdr last rest) |
545 |
(if (>= exp-pos (length exp-str)) |
(if (>= exp-pos (length exp-str)) |
546 |
(setq exp-old-pos exp-pos |
(setq exp-old-pos exp-pos |
547 |
exp-token 'end |
exp-token 'end |
548 |
exp-data "\000") |
math-expr-data "\000") |
549 |
(let ((ch (aref exp-str exp-pos))) |
(let ((ch (aref exp-str exp-pos))) |
550 |
(setq exp-old-pos exp-pos) |
(setq exp-old-pos exp-pos) |
551 |
(cond ((memq ch '(32 10 9)) |
(cond ((memq ch '(32 10 9)) |
552 |
(setq exp-pos (1+ exp-pos)) |
(setq exp-pos (1+ exp-pos)) |
553 |
(if exp-keep-spaces |
(if exp-keep-spaces |
554 |
(setq exp-token 'space |
(setq exp-token 'space |
555 |
exp-data " ") |
math-expr-data " ") |
556 |
(math-read-token))) |
(math-read-token))) |
557 |
((and (memq ch calc-user-token-chars) |
((and (memq ch calc-user-token-chars) |
558 |
(let ((case-fold-search nil)) |
(let ((case-fold-search nil)) |
559 |
(eq (string-match calc-user-tokens exp-str exp-pos) |
(eq (string-match calc-user-tokens exp-str exp-pos) |
560 |
exp-pos))) |
exp-pos))) |
561 |
(setq exp-token 'punc |
(setq exp-token 'punc |
562 |
exp-data (math-match-substring exp-str 0) |
math-expr-data (math-match-substring exp-str 0) |
563 |
exp-pos (match-end 0))) |
exp-pos (match-end 0))) |
564 |
((or (and (>= ch ?a) (<= ch ?z)) |
((or (and (>= ch ?a) (<= ch ?z)) |
565 |
(and (>= ch ?A) (<= ch ?Z))) |
(and (>= ch ?A) (<= ch ?Z))) |
569 |
exp-str exp-pos) |
exp-str exp-pos) |
570 |
(setq exp-token 'symbol |
(setq exp-token 'symbol |
571 |
exp-pos (match-end 0) |
exp-pos (match-end 0) |
572 |
exp-data (math-restore-dashes |
math-expr-data (math-restore-dashes |
573 |
(math-match-substring exp-str 0))) |
(math-match-substring exp-str 0))) |
574 |
(if (eq calc-language 'eqn) |
(if (eq calc-language 'eqn) |
575 |
(let ((code (assoc exp-data math-eqn-ignore-words))) |
(let ((code (assoc math-expr-data math-eqn-ignore-words))) |
576 |
(cond ((null code)) |
(cond ((null code)) |
577 |
((null (cdr code)) |
((null (cdr code)) |
578 |
(math-read-token)) |
(math-read-token)) |
579 |
((consp (nth 1 code)) |
((consp (nth 1 code)) |
580 |
(math-read-token) |
(math-read-token) |
581 |
(if (assoc exp-data (cdr code)) |
(if (assoc math-expr-data (cdr code)) |
582 |
(setq exp-data (format "%s %s" |
(setq math-expr-data (format "%s %s" |
583 |
(car code) exp-data)))) |
(car code) math-expr-data)))) |
584 |
((eq (nth 1 code) 'punc) |
((eq (nth 1 code) 'punc) |
585 |
(setq exp-token 'punc |
(setq exp-token 'punc |
586 |
exp-data (nth 2 code))) |
math-expr-data (nth 2 code))) |
587 |
(t |
(t |
588 |
(math-read-token) |
(math-read-token) |
589 |
(math-read-token)))))) |
(math-read-token)))))) |
602 |
(string-match "0[xX][0-9a-fA-F]+" exp-str exp-pos)) |
(string-match "0[xX][0-9a-fA-F]+" exp-str exp-pos)) |
603 |
(string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" exp-str exp-pos)) |
(string-match "_?\\([0-9]+.?0*@ *\\)?\\([0-9]+.?0*' *\\)?\\(0*\\([2-9]\\|1[0-4]\\)\\(#\\|\\^\\^\\)[0-9a-dA-D.]+[eE][-+_]?[0-9]+\\|0*\\([2-9]\\|[0-2][0-9]\\|3[0-6]\\)\\(#\\|\\^\\^\\)[0-9a-zA-Z:.]+\\|[0-9]+:[0-9:]+\\|[0-9.]+\\([eE][-+_]?[0-9]+\\)?\"?\\)?" exp-str exp-pos)) |
604 |
(setq exp-token 'number |
(setq exp-token 'number |
605 |
exp-data (math-match-substring exp-str 0) |
math-expr-data (math-match-substring exp-str 0) |
606 |
exp-pos (match-end 0))) |
exp-pos (match-end 0))) |
607 |
((eq ch ?\$) |
((eq ch ?\$) |
608 |
(if (and (eq calc-language 'pascal) |
(if (and (eq calc-language 'pascal) |
611 |
exp-str exp-pos) |
exp-str exp-pos) |
612 |
exp-pos)) |
exp-pos)) |
613 |
(setq exp-token 'number |
(setq exp-token 'number |
614 |
exp-data (math-match-substring exp-str 1) |
math-expr-data (math-match-substring exp-str 1) |
615 |
exp-pos (match-end 1)) |
exp-pos (match-end 1)) |
616 |
(if (eq (string-match "\\$\\([1-9][0-9]*\\)" exp-str exp-pos) |
(if (eq (string-match "\\$\\([1-9][0-9]*\\)" exp-str exp-pos) |
617 |
exp-pos) |
exp-pos) |
618 |
(setq exp-data (- (string-to-int (math-match-substring |
(setq math-expr-data (- (string-to-int (math-match-substring |
619 |
exp-str 1)))) |
exp-str 1)))) |
620 |
(string-match "\\$+" exp-str exp-pos) |
(string-match "\\$+" exp-str exp-pos) |
621 |
(setq exp-data (- (match-end 0) (match-beginning 0)))) |
(setq math-expr-data (- (match-end 0) (match-beginning 0)))) |
622 |
(setq exp-token 'dollar |
(setq exp-token 'dollar |
623 |
exp-pos (match-end 0)))) |
exp-pos (match-end 0)))) |
624 |
((eq ch ?\#) |
((eq ch ?\#) |
625 |
(if (eq (string-match "#\\([1-9][0-9]*\\)" exp-str exp-pos) |
(if (eq (string-match "#\\([1-9][0-9]*\\)" exp-str exp-pos) |
626 |
exp-pos) |
exp-pos) |
627 |
(setq exp-data (string-to-int |
(setq math-expr-data (string-to-int |
628 |
(math-match-substring exp-str 1)) |
(math-match-substring exp-str 1)) |
629 |
exp-pos (match-end 0)) |
exp-pos (match-end 0)) |
630 |
(setq exp-data 1 |
(setq math-expr-data 1 |
631 |
exp-pos (1+ exp-pos))) |
exp-pos (1+ exp-pos))) |
632 |
(setq exp-token 'hash)) |
(setq exp-token 'hash)) |
633 |
((eq (string-match "~=\\|<=\\|>=\\|<>\\|/=\\|\\+/-\\|\\\\dots\\|\\\\ldots\\|\\*\\*\\|<<\\|>>\\|==\\|!=\\|&&&\\||||\\|!!!\\|&&\\|||\\|!!\\|:=\\|::\\|=>" |
((eq (string-match "~=\\|<=\\|>=\\|<>\\|/=\\|\\+/-\\|\\\\dots\\|\\\\ldots\\|\\*\\*\\|<<\\|>>\\|==\\|!=\\|&&&\\||||\\|!!!\\|&&\\|||\\|!!\\|:=\\|::\\|=>" |
634 |
exp-str exp-pos) |
exp-str exp-pos) |
635 |
exp-pos) |
exp-pos) |
636 |
(setq exp-token 'punc |
(setq exp-token 'punc |
637 |
exp-data (math-match-substring exp-str 0) |
math-expr-data (math-match-substring exp-str 0) |
638 |
exp-pos (match-end 0))) |
exp-pos (match-end 0))) |
639 |
((and (eq ch ?\") |
((and (eq ch ?\") |
640 |
(string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)" exp-str exp-pos)) |
(string-match "\\(\"\\([^\"\\]\\|\\\\.\\)*\\)\\(\"\\|\\'\\)" exp-str exp-pos)) |
646 |
(aset exp-str (match-end 1) ?\})) |
(aset exp-str (match-end 1) ?\})) |
647 |
(math-read-token)) |
(math-read-token)) |
648 |
(setq exp-token 'string |
(setq exp-token 'string |
649 |
exp-data (math-match-substring exp-str 1) |
math-expr-data (math-match-substring exp-str 1) |
650 |
exp-pos (match-end 0)))) |
exp-pos (match-end 0)))) |
651 |
((and (= ch ?\\) (eq calc-language 'tex) |
((and (= ch ?\\) (eq calc-language 'tex) |
652 |
(< exp-pos (1- (length exp-str)))) |
(< exp-pos (1- (length exp-str)))) |
654 |
(string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" exp-str exp-pos)) |
(string-match "\\(\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\)" exp-str exp-pos)) |
655 |
(setq exp-token 'symbol |
(setq exp-token 'symbol |
656 |
exp-pos (match-end 0) |
exp-pos (match-end 0) |
657 |
exp-data (math-restore-dashes |
math-expr-data (math-restore-dashes |
658 |
(math-match-substring exp-str 1))) |
(math-match-substring exp-str 1))) |
659 |
(let ((code (assoc exp-data math-tex-ignore-words))) |
(let ((code (assoc math-expr-data math-tex-ignore-words))) |
660 |
(cond ((null code)) |
(cond ((null code)) |
661 |
((null (cdr code)) |
((null (cdr code)) |
662 |
(math-read-token)) |
(math-read-token)) |
663 |
((eq (nth 1 code) 'punc) |
((eq (nth 1 code) 'punc) |
664 |
(setq exp-token 'punc |
(setq exp-token 'punc |
665 |
exp-data (nth 2 code))) |
math-expr-data (nth 2 code))) |
666 |
((and (eq (nth 1 code) 'mat) |
((and (eq (nth 1 code) 'mat) |
667 |
(string-match " *{" exp-str exp-pos)) |
(string-match " *{" exp-str exp-pos)) |
668 |
(setq exp-pos (match-end 0) |
(setq exp-pos (match-end 0) |
669 |
exp-token 'punc |
exp-token 'punc |
670 |
exp-data "[") |
math-expr-data "[") |
671 |
(let ((right (string-match "}" exp-str exp-pos))) |
(let ((right (string-match "}" exp-str exp-pos))) |
672 |
(and right |
(and right |
673 |
(setq exp-str (copy-sequence exp-str)) |
(setq exp-str (copy-sequence exp-str)) |
676 |
(eq (string-match "\\.[a-zA-Z][a-zA-Z][a-zA-Z]?\\." |
(eq (string-match "\\.[a-zA-Z][a-zA-Z][a-zA-Z]?\\." |
677 |
exp-str exp-pos) exp-pos)) |
exp-str exp-pos) exp-pos)) |
678 |
(setq exp-token 'punc |
(setq exp-token 'punc |
679 |
exp-data (upcase (math-match-substring exp-str 0)) |
math-expr-data (upcase (math-match-substring exp-str 0)) |
680 |
exp-pos (match-end 0))) |
exp-pos (match-end 0))) |
681 |
((and (eq calc-language 'math) |
((and (eq calc-language 'math) |
682 |
(eq (string-match "\\[\\[\\|->\\|:>" exp-str exp-pos) |
(eq (string-match "\\[\\[\\|->\\|:>" exp-str exp-pos) |
683 |
exp-pos)) |
exp-pos)) |
684 |
(setq exp-token 'punc |
(setq exp-token 'punc |
685 |
exp-data (math-match-substring exp-str 0) |
math-expr-data (math-match-substring exp-str 0) |
686 |
exp-pos (match-end 0))) |
exp-pos (match-end 0))) |
687 |
((and (eq calc-language 'eqn) |
((and (eq calc-language 'eqn) |
688 |
(eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^" |
(eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^" |
689 |
exp-str exp-pos) |
exp-str exp-pos) |
690 |
exp-pos)) |
exp-pos)) |
691 |
(setq exp-token 'punc |
(setq exp-token 'punc |
692 |
exp-data (math-match-substring exp-str 0) |
math-expr-data (math-match-substring exp-str 0) |
693 |
exp-pos (match-end 0)) |
exp-pos (match-end 0)) |
694 |
(and (eq (string-match "\\\\dots\\." exp-str exp-pos) exp-pos) |
(and (eq (string-match "\\\\dots\\." exp-str exp-pos) exp-pos) |
695 |
(setq exp-pos (match-end 0))) |
(setq exp-pos (match-end 0))) |
696 |
(if (memq (aref exp-data 0) '(?~ ?^)) |
(if (memq (aref math-expr-data 0) '(?~ ?^)) |
697 |
(math-read-token))) |
(math-read-token))) |
698 |
((eq (string-match "%%.*$" exp-str exp-pos) exp-pos) |
((eq (string-match "%%.*$" exp-str exp-pos) exp-pos) |
699 |
(setq exp-pos (match-end 0)) |
(setq exp-pos (match-end 0)) |
706 |
(if (and (eq ch ?\&) (eq calc-language 'tex)) |
(if (and (eq ch ?\&) (eq calc-language 'tex)) |
707 |
(setq ch ?\,)) |
(setq ch ?\,)) |
708 |
(setq exp-token 'punc |
(setq exp-token 'punc |
709 |
exp-data (char-to-string ch) |
math-expr-data (char-to-string ch) |
710 |
exp-pos (1+ exp-pos))))))) |
exp-pos (1+ exp-pos))))))) |
711 |
|
|
712 |
|
|
716 |
(setq op (calc-check-user-syntax x exp-prec)) |
(setq op (calc-check-user-syntax x exp-prec)) |
717 |
(setq x op |
(setq x op |
718 |
op '("2x" ident 999999 -1))) |
op '("2x" ident 999999 -1))) |
719 |
(and (setq op (assoc exp-data math-expr-opers)) |
(and (setq op (assoc math-expr-data math-expr-opers)) |
720 |
(/= (nth 2 op) -1) |
(/= (nth 2 op) -1) |
721 |
(or (and (setq op2 (assoc |
(or (and (setq op2 (assoc |
722 |
exp-data |
math-expr-data |
723 |
(cdr (memq op math-expr-opers)))) |
(cdr (memq op math-expr-opers)))) |
724 |
(eq (= (nth 3 op) -1) |
(eq (= (nth 3 op) -1) |
725 |
(/= (nth 3 op2) -1)) |
(/= (nth 3 op2) -1)) |
729 |
t)) |
t)) |
730 |
(and (or (eq (nth 2 op) -1) |
(and (or (eq (nth 2 op) -1) |
731 |
(memq exp-token '(symbol number dollar hash)) |
(memq exp-token '(symbol number dollar hash)) |
732 |
(equal exp-data "(") |
(equal math-expr-data "(") |
733 |
(and (equal exp-data "[") |
(and (equal math-expr-data "[") |
734 |
(not (eq calc-language 'math)) |
(not (eq calc-language 'math)) |
735 |
(not (and exp-keep-spaces |
(not (and exp-keep-spaces |
736 |
(eq (car-safe x) 'vec))))) |
(eq (car-safe x) 'vec))))) |
737 |
(or (not (setq op (assoc exp-data math-expr-opers))) |
(or (not (setq op (assoc math-expr-data math-expr-opers))) |
738 |
(/= (nth 2 op) -1)) |
(/= (nth 2 op) -1)) |
739 |
(or (not calc-user-parse-table) |
(or (not calc-user-parse-table) |
740 |
(not (eq exp-token 'symbol)) |
(not (eq exp-token 'symbol)) |
744 |
(car (car (car p))))) |
(car (car (car p))))) |
745 |
(not (equal |
(not (equal |
746 |
(nth 1 (car (car p))) |
(nth 1 (car (car p))) |
747 |
exp-data)))) |
math-expr-data)))) |
748 |
(setq p (cdr p))) |
(setq p (cdr p))) |
749 |
(not p))) |
(not p))) |
750 |
(setq op (assoc "2x" math-expr-opers)))) |
(setq op (assoc "2x" math-expr-opers)))) |
751 |
(not (and exp-term (equal exp-data exp-term))) |
(not (and exp-term (equal math-expr-data exp-term))) |
752 |
(>= (nth 2 op) exp-prec)) |
(>= (nth 2 op) exp-prec)) |
753 |
(if (not (equal (car op) "2x")) |
(if (not (equal (car op) "2x")) |
754 |
(math-read-token)) |
(math-read-token)) |
787 |
(if x |
(if x |
788 |
(and (integerp (car rule)) |
(and (integerp (car rule)) |
789 |
(>= (car rule) prec) |
(>= (car rule) prec) |
790 |
(equal exp-data |
(equal math-expr-data |
791 |
(car (setq rule (cdr rule))))) |
(car (setq rule (cdr rule))))) |
792 |
(equal exp-data (car rule))))) |
(equal math-expr-data (car rule))))) |
793 |
(let ((save-exp-pos exp-pos) |
(let ((save-exp-pos exp-pos) |
794 |
(save-exp-old-pos exp-old-pos) |
(save-exp-old-pos exp-old-pos) |
795 |
(save-exp-token exp-token) |
(save-exp-token exp-token) |
796 |
(save-exp-data exp-data)) |
(save-exp-data math-expr-data)) |
797 |
(or (not (listp |
(or (not (listp |
798 |
(setq matches (calc-match-user-syntax rule)))) |
(setq matches (calc-match-user-syntax rule)))) |
799 |
(let ((args (progn |
(let ((args (progn |
858 |
match args matches))) |
match args matches))) |
859 |
(setq exp-old-pos save-exp-old-pos |
(setq exp-old-pos save-exp-old-pos |
860 |
exp-token save-exp-token |
exp-token save-exp-token |
861 |
exp-data save-exp-data |
math-expr-data save-exp-data |
862 |
exp-pos save-exp-pos))))))) |
exp-pos save-exp-pos))))))) |
863 |
(setq p (cdr p))) |
(setq p (cdr p))) |
864 |
(and p match))) |
(and p match))) |
868 |
(save-exp-pos exp-pos) |
(save-exp-pos exp-pos) |
869 |
(save-exp-old-pos exp-old-pos) |
(save-exp-old-pos exp-old-pos) |
870 |
(save-exp-token exp-token) |
(save-exp-token exp-token) |
871 |
(save-exp-data exp-data)) |
(save-exp-data math-expr-data)) |
872 |
(while (and p |
(while (and p |
873 |
(cond ((stringp (car p)) |
(cond ((stringp (car p)) |
874 |
(and (equal exp-data (car p)) |
(and (equal math-expr-data (car p)) |
875 |
(progn |
(progn |
876 |
(math-read-token) |
(math-read-token) |
877 |
t))) |
t))) |
918 |
(setq exp-pos save-exp-pos |
(setq exp-pos save-exp-pos |
919 |
exp-old-pos save-exp-old-pos |
exp-old-pos save-exp-old-pos |
920 |
exp-token save-exp-token |
exp-token save-exp-token |
921 |
exp-data save-exp-data |
math-expr-data save-exp-data |
922 |
matches "Failed")) |
matches "Failed")) |
923 |
matches)) |
matches)) |
924 |
|
|
940 |
|
|
941 |
(defun math-read-if (cond op) |
(defun math-read-if (cond op) |
942 |
(let ((then (math-read-expr-level 0))) |
(let ((then (math-read-expr-level 0))) |
943 |
(or (equal exp-data ":") |
(or (equal math-expr-data ":") |
944 |
(throw 'syntax "Expected ':'")) |
(throw 'syntax "Expected ':'")) |
945 |
(math-read-token) |
(math-read-token) |
946 |
(list 'calcFunc-if cond then (math-read-expr-level (nth 3 op))))) |
(list 'calcFunc-if cond then (math-read-expr-level (nth 3 op))))) |
947 |
|
|
948 |
(defun math-factor-after () |
(defun math-factor-after () |
949 |
(let ((exp-pos exp-pos) |
(let ((exp-pos exp-pos) |
950 |
exp-old-pos exp-token exp-data) |
exp-old-pos exp-token math-expr-data) |
951 |
(math-read-token) |
(math-read-token) |
952 |
(or (memq exp-token '(number symbol dollar hash string)) |
(or (memq exp-token '(number symbol dollar hash string)) |
953 |
(and (assoc exp-data '(("-") ("+") ("!") ("|") ("/"))) |
(and (assoc math-expr-data '(("-") ("+") ("!") ("|") ("/"))) |
954 |
(assoc (concat "u" exp-data) math-expr-opers)) |
(assoc (concat "u" math-expr-data) math-expr-opers)) |
955 |
(eq (nth 2 (assoc exp-data math-expr-opers)) -1) |
(eq (nth 2 (assoc math-expr-data math-expr-opers)) -1) |
956 |
(assoc exp-data '(("(") ("[") ("{")))))) |
(assoc math-expr-data '(("(") ("[") ("{")))))) |
957 |
|
|
958 |
(defun math-read-factor () |
(defun math-read-factor () |
959 |
(let (op) |
(let (op) |
960 |
(cond ((eq exp-token 'number) |
(cond ((eq exp-token 'number) |
961 |
(let ((num (math-read-number exp-data))) |
(let ((num (math-read-number math-expr-data))) |
962 |
(if (not num) |
(if (not num) |
963 |
(progn |
(progn |
964 |
(setq exp-old-pos exp-pos) |
(setq exp-old-pos exp-pos) |
971 |
((and calc-user-parse-table |
((and calc-user-parse-table |
972 |
(setq op (calc-check-user-syntax))) |
(setq op (calc-check-user-syntax))) |
973 |
op) |
op) |
974 |
((or (equal exp-data "-") |
((or (equal math-expr-data "-") |
975 |
(equal exp-data "+") |
(equal math-expr-data "+") |
976 |
(equal exp-data "!") |
(equal math-expr-data "!") |
977 |
(equal exp-data "|") |
(equal math-expr-data "|") |
978 |
(equal exp-data "/")) |
(equal math-expr-data "/")) |
979 |
(setq exp-data (concat "u" exp-data)) |
(setq math-expr-data (concat "u" math-expr-data)) |
980 |
(math-read-factor)) |
(math-read-factor)) |
981 |
((and (setq op (assoc exp-data math-expr-opers)) |
((and (setq op (assoc math-expr-data math-expr-opers)) |
982 |
(eq (nth 2 op) -1)) |
(eq (nth 2 op) -1)) |
983 |
(if (consp (nth 1 op)) |
(if (consp (nth 1 op)) |
984 |
(funcall (car (nth 1 op)) op) |
(funcall (car (nth 1 op)) op) |
991 |
(math-neg val)) |
(math-neg val)) |
992 |
(t (list (nth 1 op) val)))))) |
(t (list (nth 1 op) val)))))) |
993 |
((eq exp-token 'symbol) |
((eq exp-token 'symbol) |
994 |
(let ((sym (intern exp-data))) |
(let ((sym (intern math-expr-data))) |
995 |
(math-read-token) |
(math-read-token) |
996 |
(if (equal exp-data calc-function-open) |
(if (equal math-expr-data calc-function-open) |
997 |
(let ((f (assq sym math-expr-function-mapping))) |
(let ((f (assq sym math-expr-function-mapping))) |
998 |
(math-read-token) |
(math-read-token) |
999 |
(if (consp (cdr f)) |
(if (consp (cdr f)) |
1000 |
(funcall (car (cdr f)) f sym) |
(funcall (car (cdr f)) f sym) |
1001 |
(let ((args (if (or (equal exp-data calc-function-close) |
(let ((args (if (or (equal math-expr-data calc-function-close) |
1002 |
(eq exp-token 'end)) |
(eq exp-token 'end)) |
1003 |
nil |
nil |
1004 |
(math-read-expr-list)))) |
(math-read-expr-list)))) |
1005 |
(if (not (or (equal exp-data calc-function-close) |
(if (not (or (equal math-expr-data calc-function-close) |
1006 |
(eq exp-token 'end))) |
(eq exp-token 'end))) |
1007 |
(throw 'syntax "Expected `)'")) |
(throw 'syntax "Expected `)'")) |
1008 |
(math-read-token) |
(math-read-token) |
1045 |
4)) |
4)) |
1046 |
(cdr v)))))) |
(cdr v)))))) |
1047 |
(while (and (memq calc-language '(c pascal maple)) |
(while (and (memq calc-language '(c pascal maple)) |
1048 |
(equal exp-data "[")) |
(equal math-expr-data "[")) |
1049 |
(math-read-token) |
(math-read-token) |
1050 |
(setq val (append (list 'calcFunc-subscr val) |
(setq val (append (list 'calcFunc-subscr val) |
1051 |
(math-read-expr-list))) |
(math-read-expr-list))) |
1052 |
(if (equal exp-data "]") |
(if (equal math-expr-data "]") |
1053 |
(math-read-token) |
(math-read-token) |
1054 |
(throw 'syntax "Expected ']'"))) |
(throw 'syntax "Expected ']'"))) |
1055 |
val))))) |
val))))) |
1056 |
((eq exp-token 'dollar) |
((eq exp-token 'dollar) |
1057 |
(let ((abs (if (> exp-data 0) exp-data (- exp-data)))) |
(let ((abs (if (> math-expr-data 0) math-expr-data (- math-expr-data)))) |
1058 |
(if (>= (length calc-dollar-values) abs) |
(if (>= (length calc-dollar-values) abs) |
1059 |
(let ((num exp-data)) |
(let ((num math-expr-data)) |
1060 |
(math-read-token) |
(math-read-token) |
1061 |
(setq calc-dollar-used (max calc-dollar-used num)) |
(setq calc-dollar-used (max calc-dollar-used num)) |
1062 |
(math-check-complete (nth (1- abs) calc-dollar-values))) |
(math-check-complete (nth (1- abs) calc-dollar-values))) |
1067 |
(or calc-hashes-used |
(or calc-hashes-used |
1068 |
(throw 'syntax "#'s not allowed in this context")) |
(throw 'syntax "#'s not allowed in this context")) |
1069 |
(calc-extensions) |
(calc-extensions) |
1070 |
(if (<= exp-data (length calc-arg-values)) |
(if (<= math-expr-data (length calc-arg-values)) |
1071 |
(let ((num exp-data)) |
(let ((num math-expr-data)) |
1072 |
(math-read-token) |
(math-read-token) |
1073 |
(setq calc-hashes-used (max calc-hashes-used num)) |
(setq calc-hashes-used (max calc-hashes-used num)) |
1074 |
(nth (1- num) calc-arg-values)) |
(nth (1- num) calc-arg-values)) |
1075 |
(throw 'syntax "Too many # arguments"))) |
(throw 'syntax "Too many # arguments"))) |
1076 |
((equal exp-data "(") |
((equal math-expr-data "(") |
1077 |
(let* ((exp (let ((exp-keep-spaces nil)) |
(let* ((exp (let ((exp-keep-spaces nil)) |
1078 |
(math-read-token) |
(math-read-token) |
1079 |
(if (or (equal exp-data "\\dots") |
(if (or (equal math-expr-data "\\dots") |
1080 |
(equal exp-data "\\ldots")) |
(equal math-expr-data "\\ldots")) |
1081 |
'(neg (var inf var-inf)) |
'(neg (var inf var-inf)) |
1082 |
(math-read-expr-level 0))))) |
(math-read-expr-level 0))))) |
1083 |
(let ((exp-keep-spaces nil)) |
(let ((exp-keep-spaces nil)) |
1084 |
(cond |
(cond |
1085 |
((equal exp-data ",") |
((equal math-expr-data ",") |
1086 |
(progn |
(progn |
1087 |
(math-read-token) |
(math-read-token) |
1088 |
(let ((exp2 (math-read-expr-level 0))) |
(let ((exp2 (math-read-expr-level 0))) |
1090 |
(if (and exp2 (Math-realp exp) (Math-realp exp2)) |
(if (and exp2 (Math-realp exp) (Math-realp exp2)) |
1091 |
(math-normalize (list 'cplx exp exp2)) |
(math-normalize (list 'cplx exp exp2)) |
1092 |
(list '+ exp (list '* exp2 '(var i var-i)))))))) |
(list '+ exp (list '* exp2 '(var i var-i)))))))) |
1093 |
((equal exp-data ";") |
((equal math-expr-data ";") |
1094 |
(progn |
(progn |
1095 |
(math-read-token) |
(math-read-token) |
1096 |
(let ((exp2 (math-read-expr-level 0))) |
(let ((exp2 (math-read-expr-level 0))) |
1103 |
(list '* |
(list '* |
1104 |
(math-to-radians-2 exp2) |
(math-to-radians-2 exp2) |
1105 |
'(var i var-i))))))))) |
'(var i var-i))))))))) |
1106 |
((or (equal exp-data "\\dots") |
((or (equal math-expr-data "\\dots") |
1107 |
(equal exp-data "\\ldots")) |
(equal math-expr-data "\\ldots")) |
1108 |
(progn |
(progn |
1109 |
(math-read-token) |
(math-read-token) |
1110 |
(let ((exp2 (if (or (equal exp-data ")") |
(let ((exp2 (if (or (equal math-expr-data ")") |
1111 |
(equal exp-data "]") |
(equal math-expr-data "]") |
1112 |
(eq exp-token 'end)) |
(eq exp-token 'end)) |
1113 |
'(var inf var-inf) |
'(var inf var-inf) |
1114 |
(math-read-expr-level 0)))) |
(math-read-expr-level 0)))) |
1115 |
(setq exp |
(setq exp |
1116 |
(list 'intv |
(list 'intv |
1117 |
(if (equal exp-data ")") 0 1) |
(if (equal math-expr-data ")") 0 1) |
1118 |
exp |
exp |
1119 |
exp2))))))) |
exp2))))))) |
1120 |
(if (not (or (equal exp-data ")") |
(if (not (or (equal math-expr-data ")") |
1121 |
(and (equal exp-data "]") (eq (car-safe exp) 'intv)) |
(and (equal math-expr-data "]") (eq (car-safe exp) 'intv)) |
1122 |
(eq exp-token 'end))) |
(eq exp-token 'end))) |
1123 |
(throw 'syntax "Expected `)'")) |
(throw 'syntax "Expected `)'")) |
1124 |
(math-read-token) |
(math-read-token) |
1126 |
((eq exp-token 'string) |
((eq exp-token 'string) |
1127 |
(calc-extensions) |
(calc-extensions) |
1128 |
(math-read-string)) |
(math-read-string)) |
1129 |
((equal exp-data "[") |
((equal math-expr-data "[") |
1130 |
(calc-extensions) |
(calc-extensions) |
1131 |
(math-read-brackets t "]")) |
(math-read-brackets t "]")) |
1132 |
((equal exp-data "{") |
((equal math-expr-data "{") |
1133 |
(calc-extensions) |
(calc-extensions) |
1134 |
(math-read-brackets nil "}")) |
(math-read-brackets nil "}")) |
1135 |
((equal exp-data "<") |
((equal math-expr-data "<") |
1136 |
(calc-extensions) |
(calc-extensions) |
1137 |
(math-read-angle-brackets)) |
(math-read-angle-brackets)) |
1138 |
(t (throw 'syntax "Expected a number"))))) |
(t (throw 'syntax "Expected a number"))))) |