]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-lang.el
; Remove extraneous "coding: utf-8" specifications in Elisp files
[gnu-emacs] / lisp / calc / calc-lang.el
index 8b55fabe7b6811d207760fa9bd5504ad16704a90..94366060a41bae476196d0719f71f90e26392700 100644 (file)
@@ -1,7 +1,6 @@
 ;;; calc-lang.el --- calc language functions
 
-;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2015 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
@@ -95,7 +94,7 @@
   (interactive)
   (calc-wrapper
    (calc-set-language 'c)
-   (message "`C' language mode")))
+   (message "C language mode")))
 
 (put 'c 'math-oper-table
   '( ( "u!"    calcFunc-lnot -1 1000 )
      ( asin       . calcFunc-arcsin )
      ( asinh      . calcFunc-arcsinh )
      ( atan       . calcFunc-arctan )
-     ( atan2      . calcFunc-arctan2 )
-     ( atanh      . calcFunc-arctanh )))
+     ( atan2       . calcFunc-arctan2 )
+     ( atanh       . calcFunc-arctanh )
+     ( fma         . (math-C-parse-fma))
+     ( fmax        . calcFunc-max )
+     ( j0          . (math-C-parse-bess))
+     ( jn          . calcFunc-besJ )
+     ( j1          . (math-C-parse-bess))
+     ( yn          . calcFunc-besY )
+     ( y0          . (math-C-parse-bess))
+     ( y1          . (math-C-parse-bess))
+     ( tgamma      . calcFunc-gamma )))
+
+(defun math-C-parse-bess (f val)
+  "Parse C's j0, j1, y0, y1 functions."
+  (let ((args (math-read-expr-list)))
+    (math-read-token)
+    (append
+     (cond ((eq val 'j0) '(calcFunc-besJ 0))
+           ((eq val 'j1) '(calcFunc-besJ 1))
+           ((eq val 'y0) '(calcFunc-besY 0))
+           ((eq val 'y1) '(calcFunc-besY 1)))
+     args)))
+
+(defun math-C-parse-fma (f val)
+  "Parse C's fma function fma(x,y,z) => (x * y + z)."
+  (let ((args (math-read-expr-list)))
+    (math-read-token)
+    (list 'calcFunc-add
+          (list 'calcFunc-mul
+                (nth 0 args)
+                (nth 1 args))
+          (nth 2 args))))
+
 
 (put 'c 'math-variable-table
   '( ( M_PI       . var-pi )
   (interactive)
   (calc-wrapper
    (calc-set-language 'yacas)
-   (message "`Yacas' language mode")))
+   (message "Yacas language mode")))
 
 (put 'yacas 'math-vector-brackets "{}")
 
   (interactive)
   (calc-wrapper
    (calc-set-language 'maxima)
-   (message "`Maxima' language mode")))
+   (message "Maxima language mode")))
 
 (put 'maxima 'math-oper-table
      '(("+"    +               100  100)
   (interactive)
   (calc-wrapper
    (calc-set-language 'giac)
-   (message "`Giac' language mode")))
+   (message "Giac language mode")))
 
 (put 'giac 'math-oper-table
   '( ( "["    (math-read-giac-subscr) 250 -1 )
@@ -1787,7 +1817,7 @@ order to Calc's."
 (defun math-read-giac-subscr (x op)
   (let ((idx (math-read-expr-level 0)))
     (or (equal math-expr-data "]")
-       (throw 'syntax "Expected ']'"))
+       (throw 'syntax "Expected `]'"))
     (math-read-token)
     (list 'calcFunc-subscr x (calc-normalize (list '+ idx 1)))))
 
@@ -1924,7 +1954,7 @@ order to Calc's."
             (progn
               (math-read-token)
               (equal math-expr-data "]")))
-       (throw 'syntax "Expected ']]'"))
+       (throw 'syntax "Expected `]]'"))
     (math-read-token)
     (list 'calcFunc-subscr x idx)))
 
@@ -2402,7 +2432,8 @@ order to Calc's."
               (let ((y (math-read-big-rec h math-rb-v1 math-rb-h2
                                            math-rb-v2 baseline nil t)))
                 (or (= (math-read-big-char math-read-big-h2 baseline) ?\:)
-                    (math-read-big-error math-read-big-h2 baseline "Expected `:'"))
+                    (math-read-big-error math-read-big-h2 baseline
+                                          "Expected `:'"))
                 (setq p (list (nth 1 widest) p y
                               (math-read-big-rec
                                 (1+ math-read-big-h2) math-rb-v1 math-rb-h2 math-rb-v2
@@ -2477,7 +2508,8 @@ order to Calc's."
     (while (> count 0)
       (if (>= h len)
          (if what
-             (math-read-big-error nil v (format "Unmatched `%s'" what))
+             (math-read-big-error nil v (format-message
+                                          "Unmatched `%s'" what))
            (setq count 0))
        (if (memq (aref line h) '(?\( ?\[))
            (setq count (1+ count))
@@ -2493,9 +2525,4 @@ order to Calc's."
 
 (provide 'calc-lang)
 
-;; Local variables:
-;; coding: utf-8
-;; End:
-
-;; arch-tag: 483bfe15-f290-4fef-bb7d-ce65be687f2e
 ;;; calc-lang.el ends here