Coverage report: /home/ellis/comp/ext/cl-ppcre/errors.lisp

KindCoveredAll%
expression028 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; $Header: /usr/local/cvsrep/cl-ppcre/errors.lisp,v 1.22 2009/09/17 19:17:31 edi Exp $
2
 
3
 ;;; Copyright (c) 2002-2009, Dr. Edmund Weitz. All rights reserved.
4
 
5
 ;;; Redistribution and use in source and binary forms, with or without
6
 ;;; modification, are permitted provided that the following conditions
7
 ;;; are met:
8
 
9
 ;;;   * Redistributions of source code must retain the above copyright
10
 ;;;     notice, this list of conditions and the following disclaimer.
11
 
12
 ;;;   * Redistributions in binary form must reproduce the above
13
 ;;;     copyright notice, this list of conditions and the following
14
 ;;;     disclaimer in the documentation and/or other materials
15
 ;;;     provided with the distribution.
16
 
17
 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
18
 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 ;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21
 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23
 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 
29
 (in-package :cl-ppcre)
30
 
31
 (defvar *syntax-error-string* nil
32
   "The string which caused the syntax error.")
33
 
34
 (define-condition ppcre-error (simple-error)
35
   ()
36
   (:documentation "All errors signaled by CL-PPCRE are of
37
 this type."))
38
 
39
 (define-condition ppcre-syntax-error (ppcre-error)
40
   ((string :initarg :string
41
            :reader ppcre-syntax-error-string)
42
    (pos :initarg :pos
43
         :reader ppcre-syntax-error-pos))
44
   (:default-initargs
45
       :pos nil
46
       :string *syntax-error-string*)
47
   (:report (lambda (condition stream)
48
              (format stream "~?~@[ at position ~A~]~@[ in string ~S~]"
49
                      (simple-condition-format-control condition)
50
                      (simple-condition-format-arguments condition)
51
                      (ppcre-syntax-error-pos condition)
52
                      (ppcre-syntax-error-string condition))))
53
   (:documentation "Signaled if CL-PPCRE's parser encounters an error
54
 when trying to parse a regex string or to convert a parse tree into
55
 its internal representation."))
56
 
57
 (setf (documentation 'ppcre-syntax-error-string 'function)
58
       "Returns the string the parser was parsing when the error was
59
 encountered \(or NIL if the error happened while trying to convert a
60
 parse tree).")
61
 
62
 (setf (documentation 'ppcre-syntax-error-pos 'function)
63
       "Returns the position within the string where the error occurred
64
 \(or NIL if the error happened while trying to convert a parse tree")
65
 
66
 (define-condition ppcre-invocation-error (ppcre-error)
67
   ()
68
   (:documentation "Signaled when CL-PPCRE functions are
69
 invoked with wrong arguments."))
70
 
71
 (defmacro signal-syntax-error* (pos format-control &rest format-arguments)
72
   `(error 'ppcre-syntax-error
73
           :pos ,pos
74
           :format-control ,format-control
75
           :format-arguments (list ,@format-arguments)))
76
 
77
 (defmacro signal-syntax-error (format-control &rest format-arguments)
78
   `(signal-syntax-error* nil ,format-control ,@format-arguments))
79
 
80
 (defmacro signal-invocation-error (format-control &rest format-arguments)
81
   `(error 'ppcre-invocation-error
82
           :format-control ,format-control
83
           :format-arguments (list ,@format-arguments)))