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