Вопрос

I'm new to Lisp, so I'm guessing I'm missing something simple here. I found some code online that I wanted to play with, and it uses the defgrammar macro. When I write it into my code file, copied exactly from the web to start with, save, and load, it says (with file name omitted):

;; Loading file ...
*** - EVAL: undefined function DEFGRAMMAR

I'm guessing there's some variable I have to flip, like for printing circular lists, or some add-on or something I have to install, but I don't really know what I'm looking for. Any suggestions?

By the way, I'm using GNU CLisp 2.49.

The code I'm trying to use is:

(load "rdp")
(use-package "COM.INFORMATIMAGO.RDP")
(defgrammar binary-tree
:terminals ((label   "[^(),][^(),]*"))
:start tree
:rules ((--> tree
             (opt node)
             :action (if (null $1)
                         (make-empty-binary-tree)
                         $1)) ; it's identity, but make-empty-binary-tree
                                    ; could be defined otherwise.
        (--> node
             label (opt children)
             :action (make-binary-tree :label (read-from-string (second $1))
                                       :left (first $2) :right (second $2)))
        (--> children
             "(" tree "," tree ")"
             :action (list $2 $4))))


(defun binary-tree-from-string (string)
  (parse-binary-tree string))

Looking at it, I'm guessing I need "rdp"?

Это было полезно?

Решение

What's the code you want to play with, could you paste it here? defgrammar is not a built-in function. You should find the definition of defgrammar function. Load it first then re-evaluate your example.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top