Function: math-read-brackets

math-read-brackets is an autoloaded and byte-compiled function defined in calc-vec.el.gz.

Signature

(math-read-brackets SPACE-SEP RB-CLOSE)

Source Code

;; Defined in /usr/src/emacs/lisp/calc/calc-vec.el.gz
(defun math-read-brackets (space-sep rb-close)
  (let ((math-rb-close rb-close))
  (and space-sep (setq space-sep (not (math-check-for-commas))))
  (math-read-token)
  (while (eq math-exp-token 'space)
    (math-read-token))
  (if (or (equal math-expr-data math-rb-close)
	  (eq math-exp-token 'end))
      (progn
	(math-read-token)
	'(vec))
    (let ((save-exp-pos math-exp-pos)
	  (save-exp-old-pos math-exp-old-pos)
	  (save-exp-token math-exp-token)
	  (save-exp-data math-expr-data)
	  (vals (let ((math-exp-keep-spaces space-sep))
		  (if (or (equal math-expr-data "\\dots")
			  (equal math-expr-data "\\ldots"))
		      '(vec (neg (var inf var-inf)))
		    (catch 'syntax (math-read-vector))))))
      (if (stringp vals)
	  (if space-sep
	      (let ((error-exp-pos math-exp-pos)
		    (error-exp-old-pos math-exp-old-pos)
		    vals2)
		(setq math-exp-pos save-exp-pos
		      math-exp-old-pos save-exp-old-pos
		      math-exp-token save-exp-token
		      math-expr-data save-exp-data)
		(let ((math-exp-keep-spaces nil))
		  (setq vals2 (catch 'syntax (math-read-vector))))
		(if (and (not (stringp vals2))
			 (or (assoc math-expr-data '(("\\ldots") ("\\dots") (";")))
			     (equal math-expr-data math-rb-close)
			     (eq math-exp-token 'end)))
		    (setq space-sep nil
			  vals vals2)
		  (setq math-exp-pos error-exp-pos
			math-exp-old-pos error-exp-old-pos)
		  (throw 'syntax vals)))
	    (throw 'syntax vals)))
      (if (or (equal math-expr-data "\\dots")
	      (equal math-expr-data "\\ldots"))
	  (progn
	    (math-read-token)
	    (setq vals (if (> (length vals) 2)
			   (cons 'calcFunc-mul (cdr vals)) (nth 1 vals)))
	    (let ((exp2 (if (or (equal math-expr-data math-rb-close)
				(equal math-expr-data ")")
				(eq math-exp-token 'end))
			    '(var inf var-inf)
			  (math-read-expr-level 0))))
	      (setq vals
		    (list 'intv
			  (if (equal math-expr-data ")") 2 3)
			  vals
			  exp2)))
	    (if (not (or (equal math-expr-data math-rb-close)
			 (equal math-expr-data ")")
			 (eq math-exp-token 'end)))
		(throw 'syntax "Expected `]'")))
	(if (equal math-expr-data ";")
	    (let ((math-exp-keep-spaces space-sep))
	      (setq vals (cons 'vec (math-read-matrix (list vals))))))
	(if (not (or (equal math-expr-data math-rb-close)
		     (eq math-exp-token 'end)))
	    (throw 'syntax "Expected `]'")))
      (or (eq math-exp-token 'end)
	  (math-read-token))
      vals))))