aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/calc/calc-vec.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/calc/calc-vec.el')
-rw-r--r--lisp/calc/calc-vec.el104
1 files changed, 52 insertions, 52 deletions
diff --git a/lisp/calc/calc-vec.el b/lisp/calc/calc-vec.el
index 51d7450278e..a78f98ec3cc 100644
--- a/lisp/calc/calc-vec.el
+++ b/lisp/calc/calc-vec.el
@@ -1466,103 +1466,103 @@
1466(defun math-read-brackets (space-sep close) 1466(defun math-read-brackets (space-sep close)
1467 (and space-sep (setq space-sep (not (math-check-for-commas)))) 1467 (and space-sep (setq space-sep (not (math-check-for-commas))))
1468 (math-read-token) 1468 (math-read-token)
1469 (while (eq exp-token 'space) 1469 (while (eq math-exp-token 'space)
1470 (math-read-token)) 1470 (math-read-token))
1471 (if (or (equal exp-data close) 1471 (if (or (equal math-expr-data close)
1472 (eq exp-token 'end)) 1472 (eq math-exp-token 'end))
1473 (progn 1473 (progn
1474 (math-read-token) 1474 (math-read-token)
1475 '(vec)) 1475 '(vec))
1476 (let ((save-exp-pos exp-pos) 1476 (let ((save-exp-pos math-exp-pos)
1477 (save-exp-old-pos exp-old-pos) 1477 (save-exp-old-pos math-exp-old-pos)
1478 (save-exp-token exp-token) 1478 (save-exp-token math-exp-token)
1479 (save-exp-data exp-data) 1479 (save-exp-data math-expr-data)
1480 (vals (let ((exp-keep-spaces space-sep)) 1480 (vals (let ((math-exp-keep-spaces space-sep))
1481 (if (or (equal exp-data "\\dots") 1481 (if (or (equal math-expr-data "\\dots")
1482 (equal exp-data "\\ldots")) 1482 (equal math-expr-data "\\ldots"))
1483 '(vec (neg (var inf var-inf))) 1483 '(vec (neg (var inf var-inf)))
1484 (catch 'syntax (math-read-vector)))))) 1484 (catch 'syntax (math-read-vector))))))
1485 (if (stringp vals) 1485 (if (stringp vals)
1486 (if space-sep 1486 (if space-sep
1487 (let ((error-exp-pos exp-pos) 1487 (let ((error-exp-pos math-exp-pos)
1488 (error-exp-old-pos exp-old-pos) 1488 (error-exp-old-pos math-exp-old-pos)
1489 vals2) 1489 vals2)
1490 (setq exp-pos save-exp-pos 1490 (setq math-exp-pos save-exp-pos
1491 exp-old-pos save-exp-old-pos 1491 math-exp-old-pos save-exp-old-pos
1492 exp-token save-exp-token 1492 math-exp-token save-exp-token
1493 exp-data save-exp-data) 1493 math-expr-data save-exp-data)
1494 (let ((exp-keep-spaces nil)) 1494 (let ((math-exp-keep-spaces nil))
1495 (setq vals2 (catch 'syntax (math-read-vector)))) 1495 (setq vals2 (catch 'syntax (math-read-vector))))
1496 (if (and (not (stringp vals2)) 1496 (if (and (not (stringp vals2))
1497 (or (assoc exp-data '(("\\ldots") ("\\dots") (";"))) 1497 (or (assoc math-expr-data '(("\\ldots") ("\\dots") (";")))
1498 (equal exp-data close) 1498 (equal math-expr-data close)
1499 (eq exp-token 'end))) 1499 (eq math-exp-token 'end)))
1500 (setq space-sep nil 1500 (setq space-sep nil
1501 vals vals2) 1501 vals vals2)
1502 (setq exp-pos error-exp-pos 1502 (setq math-exp-pos error-exp-pos
1503 exp-old-pos error-exp-old-pos) 1503 math-exp-old-pos error-exp-old-pos)
1504 (throw 'syntax vals))) 1504 (throw 'syntax vals)))
1505 (throw 'syntax vals))) 1505 (throw 'syntax vals)))
1506 (if (or (equal exp-data "\\dots") 1506 (if (or (equal math-expr-data "\\dots")
1507 (equal exp-data "\\ldots")) 1507 (equal math-expr-data "\\ldots"))
1508 (progn 1508 (progn
1509 (math-read-token) 1509 (math-read-token)
1510 (setq vals (if (> (length vals) 2) 1510 (setq vals (if (> (length vals) 2)
1511 (cons 'calcFunc-mul (cdr vals)) (nth 1 vals))) 1511 (cons 'calcFunc-mul (cdr vals)) (nth 1 vals)))
1512 (let ((exp2 (if (or (equal exp-data close) 1512 (let ((exp2 (if (or (equal math-expr-data close)
1513 (equal exp-data ")") 1513 (equal math-expr-data ")")
1514 (eq exp-token 'end)) 1514 (eq math-exp-token 'end))
1515 '(var inf var-inf) 1515 '(var inf var-inf)
1516 (math-read-expr-level 0)))) 1516 (math-read-expr-level 0))))
1517 (setq vals 1517 (setq vals
1518 (list 'intv 1518 (list 'intv
1519 (if (equal exp-data ")") 2 3) 1519 (if (equal math-expr-data ")") 2 3)
1520 vals 1520 vals
1521 exp2))) 1521 exp2)))
1522 (if (not (or (equal exp-data close) 1522 (if (not (or (equal math-expr-data close)
1523 (equal exp-data ")") 1523 (equal math-expr-data ")")
1524 (eq exp-token 'end))) 1524 (eq math-exp-token 'end)))
1525 (throw 'syntax "Expected `]'"))) 1525 (throw 'syntax "Expected `]'")))
1526 (if (equal exp-data ";") 1526 (if (equal math-expr-data ";")
1527 (let ((exp-keep-spaces space-sep)) 1527 (let ((math-exp-keep-spaces space-sep))
1528 (setq vals (cons 'vec (math-read-matrix (list vals)))))) 1528 (setq vals (cons 'vec (math-read-matrix (list vals))))))
1529 (if (not (or (equal exp-data close) 1529 (if (not (or (equal math-expr-data close)
1530 (eq exp-token 'end))) 1530 (eq math-exp-token 'end)))
1531 (throw 'syntax "Expected `]'"))) 1531 (throw 'syntax "Expected `]'")))
1532 (or (eq exp-token 'end) 1532 (or (eq math-exp-token 'end)
1533 (math-read-token)) 1533 (math-read-token))
1534 vals))) 1534 vals)))
1535 1535
1536(defun math-check-for-commas (&optional balancing) 1536(defun math-check-for-commas (&optional balancing)
1537 (let ((count 0) 1537 (let ((count 0)
1538 (pos (1- exp-pos))) 1538 (pos (1- math-exp-pos)))
1539 (while (and (>= count 0) 1539 (while (and (>= count 0)
1540 (setq pos (string-match 1540 (setq pos (string-match
1541 (if balancing "[],[{}()<>]" "[],[{}()]") 1541 (if balancing "[],[{}()<>]" "[],[{}()]")
1542 exp-str (1+ pos))) 1542 math-exp-str (1+ pos)))
1543 (or (/= (aref exp-str pos) ?,) (> count 0) balancing)) 1543 (or (/= (aref math-exp-str pos) ?,) (> count 0) balancing))
1544 (cond ((memq (aref exp-str pos) '(?\[ ?\{ ?\( ?\<)) 1544 (cond ((memq (aref math-exp-str pos) '(?\[ ?\{ ?\( ?\<))
1545 (setq count (1+ count))) 1545 (setq count (1+ count)))
1546 ((memq (aref exp-str pos) '(?\] ?\} ?\) ?\>)) 1546 ((memq (aref math-exp-str pos) '(?\] ?\} ?\) ?\>))
1547 (setq count (1- count))))) 1547 (setq count (1- count)))))
1548 (if balancing 1548 (if balancing
1549 pos 1549 pos
1550 (and pos (= (aref exp-str pos) ?,))))) 1550 (and pos (= (aref math-exp-str pos) ?,)))))
1551 1551
1552(defun math-read-vector () 1552(defun math-read-vector ()
1553 (let* ((val (list (math-read-expr-level 0))) 1553 (let* ((val (list (math-read-expr-level 0)))
1554 (last val)) 1554 (last val))
1555 (while (progn 1555 (while (progn
1556 (while (eq exp-token 'space) 1556 (while (eq math-exp-token 'space)
1557 (math-read-token)) 1557 (math-read-token))
1558 (and (not (eq exp-token 'end)) 1558 (and (not (eq math-exp-token 'end))
1559 (not (equal exp-data ";")) 1559 (not (equal math-expr-data ";"))
1560 (not (equal exp-data close)) 1560 (not (equal math-expr-data close))
1561 (not (equal exp-data "\\dots")) 1561 (not (equal math-expr-data "\\dots"))
1562 (not (equal exp-data "\\ldots")))) 1562 (not (equal math-expr-data "\\ldots"))))
1563 (if (equal exp-data ",") 1563 (if (equal math-expr-data ",")
1564 (math-read-token)) 1564 (math-read-token))
1565 (while (eq exp-token 'space) 1565 (while (eq math-exp-token 'space)
1566 (math-read-token)) 1566 (math-read-token))
1567 (let ((rest (list (math-read-expr-level 0)))) 1567 (let ((rest (list (math-read-expr-level 0))))
1568 (setcdr last rest) 1568 (setcdr last rest)
@@ -1570,9 +1570,9 @@
1570 (cons 'vec val))) 1570 (cons 'vec val)))
1571 1571
1572(defun math-read-matrix (mat) 1572(defun math-read-matrix (mat)
1573 (while (equal exp-data ";") 1573 (while (equal math-expr-data ";")
1574 (math-read-token) 1574 (math-read-token)
1575 (while (eq exp-token 'space) 1575 (while (eq math-exp-token 'space)
1576 (math-read-token)) 1576 (math-read-token))
1577 (setq mat (nconc mat (list (math-read-vector))))) 1577 (setq mat (nconc mat (list (math-read-vector)))))
1578 mat) 1578 mat)