next up previous contents
Next: Error reporting Up: The matcher API Previous: The matcher class   Contents


The fun-matcher class

To make it simpler in some cases to write matchers, there is a matcher class called fun-matcher which only requires a function which it calls on a node and which returns a boolean.

Slots:

fun, initarg :fun--a function designator for the matcher function, which is called on an xmls node and returns a boolean to indicate whether or not the node is matched.

how-many, initarg :how-many--a symbol indicating how many times the matcher can match children of its parent tag. One of:

  1. :one--matches one
  2. :one-or-more--matches one or more
  3. :zero-or-more--matches zero or more
  4. :zero-or-one--matches zero or one (an optional matcher, in other words)

name, initarg :name--a string or other data type specifying the name of the matcher, used in error reporting and debugging.

Example:

(make-instance 'fun-matcher
               :fun #'(lambda (node)
                        (string= node "foo"))
               :how-many :one-or-more
               :name "foo-string")



root 2004-10-26