1. Phil Hargett
  2. HH-Parse

Source

HH-Parse / ast.lisp

(in-package :hh-parse)

;; printing

(defmethod print-object ((obj ast-node) stream)
  (print-unreadable-object (obj stream :type t :identity t)
    (with-slots (value children) obj
      (format stream "~@[Value=~s~] ~@[Children=~s~]" value children))))

(defgeneric ast-node-type (node)
  (:documentation "Return the symbolic name for the node's type (corresponds to a rule name in 
   the original grammar")
  (:method ((node ast-node))
    (class-name (class-of node))))

(defgeneric ast-node-value (node)
  (:documentation "Return the nodes value")
  (:method ((node ast-node))
    (slot-value node 'value)))