1 ;;; -*- mode: scheme; coding: utf-8; -*-
3 ;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
5 ;;; This library is free software; you can redistribute it and/or modify it
6 ;;; under the terms of the GNU Lesser General Public License as published by
7 ;;; the Free Software Foundation; either version 3 of the License, or (at
8 ;;; your option) any later version.
10 ;;; This library is distributed in the hope that it will be useful, but
11 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
13 ;;; General Public License for more details.
15 ;;; You should have received a copy of the GNU Lesser General Public License
16 ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 (define-module (sxml match)
22 #:use-module (srfi srfi-1)
23 #:use-module (srfi srfi-11))
28 ;;; This module provides an SXML pattern matcher, written by Jim Bender. This
29 ;;; allows application code to match on SXML nodes and attributes without having
30 ;;; to deal with the details of s-expression matching, without worrying about
31 ;;; the order of attributes, etc.
33 ;;; It is fully documented in the Guile Reference Manual.
40 ;;; PLT compatibility layer.
43 (define-syntax-rule (syntax-object->datum stx)
46 (define-syntax-rule (void)
49 (define %call/ec-prompt
52 (define-syntax-rule (call/ec proc)
53 ;; aka. `call-with-escape-continuation'
54 (call-with-prompt %call/ec-prompt
57 (apply abort-to-prompt
58 %call/ec-prompt args))))
60 (apply values args))))
62 (define-syntax-rule (let/ec cont body ...)
63 (call/ec (lambda (cont) body ...)))
65 (define (raise-syntax-error x msg obj sub)
66 (throw 'sxml-match-error x msg obj sub))
69 (syntax-rules (provide require)
70 ((_ name lang (provide p_ ...) (require r_ ...)
76 ;;; Include upstream source file.
79 ;; This file was taken from
80 ;; <http://planet.plt-scheme.org/package-source/jim/sxml-match.plt/1/1/> on
81 ;; 2010-05-24. It was written by Jim Bender <benderjg2@aol.com> and released
82 ;; under the MIT/X11 license
83 ;; <http://www.gnu.org/licenses/license-list.html#X11License>.
85 ;; Modified the `sxml-match1' macro to allow multiple-value returns (upstream
88 (include-from-path "sxml/sxml-match.ss")
90 ;;; match.scm ends here