fare-quasiquote-matcher.lisp 842 Bytes
Newer Older
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
;;; -*- Mode: Lisp ; Base: 10 ; Syntax: ANSI-Common-Lisp -*-
;;; fare-matcher implementation of fare-quasiquote
;;; Copyright (c) 2002-2012 Fahree Wreido <fare@tunes.org>

#+xcvb (module (:depends-on ("quasiquote" "/fare-matcher")))

(in-package :fare-quasiquote)

(declaim (optimize (speed 1) (safety 3) (debug 3)))

(eval-when (:compile-toplevel :load-toplevel :execute)

;; the below instruction enables pattern-matching for the simplifier.
(fare-matcher:copy-function-matcher
 list  cl:list
 list* cl:list*
 cons  cl:cons
 quote cl:quote
 vector cl:vector)

(fare-matcher:define-symbol-matcher knil
  '#'(lambda (form)
       (or (null form)
	   (and (quotep form) (null (single-arg form)))
	   (m%fail))))

(fare-matcher:define-macro-matcher quasiquote
  #'(lambda (x) (fare-matcher:pattern-matcher (quasiquote-expand x))))

);eval-when