emacs-elsa/Elsa

Bool-vector type not supported by elsa-reader

Opened this issue · 3 comments

When processing ansi-color.el, e.g.

(elsa-process-file "/opt/homebrew/Cellar/emacs-mac/emacs-29.1-mac-10.0/share/emacs/29.1/lisp/ansi-color.el.gz")

A bool vector #&8"\0" at line 975 is not recognized, leading to an error "Invalid form" is thrown

(t (error "Invalid form")))))

It seems that bool-vector-p can be used to check whether it's a bool vector, and the corresponding type does exist in Elsa:

(defclass elsa-type-bool-vector (elsa-type elsa-simple-type eieio-singleton) ())

However, I lack the knowledge to add the elsa-form- class and the reader for it.

It seems easier than I initially expected, so I took a stab. #229

Being new to ELisp, I have a remotely related and probably dumb question: How come the elsa-form-*-p predicates work without being explicitly defined? What keyword should I search if I would like to learn more on this?

The predicates come from the defclass. For example

(defclass elsa-form-number (elsa-form-atom)
  ((value :type number :initarg :value)))

expands to

(progn
  (defalias 'elsa-form-number-p
    (eieio-make-class-predicate 'elsa-form-number))
  (defalias 'elsa-form-number--eieio-childp
    (eieio-make-child-predicate 'elsa-form-number))
  (define-symbol-prop 'elsa-form-number 'cl-deftype-satisfies
    (function elsa-form-number--eieio-childp))
  (eieio-defclass-internal 'elsa-form-number
                           '(elsa-form-atom)
                           '((value :type number :initarg :value))
                           'nil)
  (defun elsa-form-number
      (&rest slots)
    "Create a new object of class type `elsa-form-number'."
    (declare
     (compiler-macro
      (lambda
        (whole)
        (if
            (not
             (stringp
              (car slots)))
            whole
          (macroexp-warn-and-return
           (format "Obsolete name arg %S to constructor %S"
                   (car slots)
                   (car whole))
           `(,(car whole)
             (identity ,(car slots))
             ,@(cdr slots)))))))
    (apply
     (function make-instance)
     'elsa-form-number slots)))

There's a package called macrostep which you can use to expand macros.

Thank you! This is very helpful!