/usr/share/maxima/5.32.1/src/defcal.lisp is in maxima-src 5.32.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; The data in this file contains enhancments. ;;;;;
;;; ;;;;;
;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;
;;; All rights reserved ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; (c) Copyright 1980 Massachusetts Institute of Technology ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(in-package :maxima)
(macsyma-module defcal macro)
;; Compile-time support for defining things which dispatch
;; off the property list. The Macsyma parser uses this.
(defun make-parser-fun-def (op p bvl body)
;; Used by the Parser at compile time.
(if (not (consp op))
`(,(symbolconc 'def- p '-fun) ,op ,bvl
,(car bvl)
;; so compiler won't warn about
;; unused lambda variable.
. ,body)
`(progn
,(make-parser-fun-def (car op) p bvl body)
,@(mapcar #'(lambda (x)
`(inherit-propl ',x ',(car op) (,(symbolconc p '-propl))))
(cdr op)))))
;;; The tokenizer use the famous CSTR to represent the possible extended token
;;; symbols. The derivation of the name and implementation is obscure, but I've
;;; heard it has something to do with an early Fortran compiler written in Lisp.
;;; -GJC
;;; (CSTRSETUP <description>)
;;;
;;; <description> ::= (<descriptor> <descriptor> ...)
;;; <descriptor> ::= <name> ! (<name> <translation>)
;;;
;;; If no translation is supplied, $<name> is the default.
;;;
;;; Sets up a CSTR [Command STRucture] object which may be used
;;; in conjunction with the CEQ predicate to determine if the
;;; LINBUF cursor is currently pointing at any keyword in that
;;; structure.
;;;
;;; Note: Names containing shorter names as initial segments
;;; must follow the shorter names in arg to CSTRSETUP.
(defvar symbols-defined () "For safe keeping.")
(defvar macsyma-operators ())
(eval-when (:execute :compile-toplevel :load-toplevel)
(defun *define-initial-symbols (l)
(setq symbols-defined
(sort (copy-list l) #'(lambda (x y) (< (flatc x) (flatc y)))))
(setq macsyma-operators (cstrsetup symbols-defined))))
(defmacro define-initial-symbols (&rest l)
(let ((symbols-defined ())
(macsyma-operators ()))
(*define-initial-symbols l)
`(progn
(declare-top (special symbols-defined macsyma-operators))
(setq symbols-defined (copy-list ',symbols-defined))
(setq macsyma-operators (subst () () ',macsyma-operators)))))
(defun undefine-symbol (opr)
(*define-initial-symbols (delete opr symbols-defined :test #'equal)))
(defun define-symbol (x)
(*define-initial-symbols (cons x symbols-defined))
(symbolconc '$ (maybe-invert-string-case x)))
(defun cstrsetup (arg)
(do ((arg arg (cdr arg))
(tree nil))
((null arg) (list* () '(ans ()) tree))
(if (atom (car arg))
(setq tree (add2cstr (car arg)
tree
(symbolconc '$
(if (stringp (car arg))
(maybe-invert-string-case (car arg))
(car arg)))))
(setq tree (add2cstr (caar arg) tree (cadar arg))))))
;;; (ADD2CSTR <name> <tree> <translation>)
;;;
;;; Adds the information <name> -> <translation> to a
;;; CSTR-style <tree>.
(defun add2cstr (x tree ans)
(add2cstr1 (nconc (exploden x) (ncons (list 'ans ans))) tree))
;;; (ADD2CSTR1 <translation-info> <tree>)
;;;
;;; Helping function for ADD2CSTR. Puts information about a
;;; keyword into the <tree>
(defun add2cstr1 (x tree)
(cond ((null tree) x)
((atom (car tree))
(cond ((equal (car tree) (car x))
(rplacd tree (add2cstr1 (cdr x) (cdr tree))))
(t (list tree (cond ((atom (car x)) x)
((equal (caar x) 'ans) (car x))
(t x))))))
((equal (caar tree) (car x))
(rplacd (car tree) (add2cstr1 (cdr x) (cdar tree)))
tree)
((null (cdr tree))
(rplacd tree (list x))
tree)
(t (rplacd tree (add2cstr1 x (cdr tree)))
tree)))
|