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

KindCoveredAll%
expression969 13.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/specials.lisp,v 1.43 2009/10/28 07:36:15 edi Exp $
2
 
3
 ;;; globally declared special variables
4
 
5
 ;;; Copyright (c) 2002-2009, Dr. Edmund Weitz. All rights reserved.
6
 
7
 ;;; Redistribution and use in source and binary forms, with or without
8
 ;;; modification, are permitted provided that the following conditions
9
 ;;; are met:
10
 
11
 ;;;   * Redistributions of source code must retain the above copyright
12
 ;;;     notice, this list of conditions and the following disclaimer.
13
 
14
 ;;;   * Redistributions in binary form must reproduce the above
15
 ;;;     copyright notice, this list of conditions and the following
16
 ;;;     disclaimer in the documentation and/or other materials
17
 ;;;     provided with the distribution.
18
 
19
 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
20
 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
 ;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23
 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25
 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
 
31
 (in-package :cl-ppcre)
32
 
33
 ;;; special variables used to effect declarations
34
 
35
 (defvar *standard-optimize-settings*
36
   '(optimize
37
     speed
38
     (space 0)
39
     (debug 1)
40
     (compilation-speed 0))
41
   "The standard optimize settings used by most declaration expressions.")
42
 
43
 (defvar *special-optimize-settings*
44
   '(optimize speed space)
45
   "Special optimize settings used only by a few declaration expressions.")
46
 
47
 ;;; special variables used by the lexer/parser combo
48
 
49
 (defvar *extended-mode-p* nil
50
   "Whether the parser will start in extended mode.")
51
 (declaim (boolean *extended-mode-p*))
52
 
53
 ;;; special variables used by the SCAN function and the matchers
54
 
55
 (defvar *regex-char-code-limit* char-code-limit
56
   "The upper exclusive bound on the char-codes of characters which can
57
 occur in character classes.  Change this value BEFORE creating
58
 scanners if you don't need the \(full) Unicode support of
59
 implementations like AllegroCL, CLISP, LispWorks, or SBCL.")
60
 (declaim (fixnum *regex-char-code-limit*))
61
   
62
 (defvar *string* (make-sequence 'simple-string 0)
63
   "The string which is currently scanned by SCAN.
64
 Will always be coerced to a SIMPLE-STRING.")
65
 
66
 (declaim (simple-string *string*))
67
 
68
 (defvar *start-pos* 0
69
   "Where to start scanning within *STRING*.")
70
 (declaim (fixnum *start-pos*))
71
 
72
 (defvar *real-start-pos* nil
73
   "The real start of *STRING*. This is for repeated scans and is only used internally.")
74
 (declaim (type (or null fixnum) *real-start-pos*))
75
 
76
 (defvar *end-pos* 0
77
   "Where to stop scanning within *STRING*.")
78
 (declaim (fixnum *end-pos*))
79
 
80
 (defvar *reg-starts* (make-array 0)
81
   "An array which holds the start positions
82
 of the current register candidates.")
83
 (declaim (simple-vector *reg-starts*))
84
   
85
 (defvar *regs-maybe-start* (make-array 0)
86
   "An array which holds the next start positions
87
 of the current register candidates.")
88
 (declaim (simple-vector *regs-maybe-start*))
89
 
90
 (defvar *reg-ends* (make-array 0)
91
   "An array which holds the end positions
92
 of the current register candidates.")
93
 (declaim (simple-vector *reg-ends*))
94
 
95
 (defvar *end-string-pos* nil
96
   "Start of the next possible end-string candidate.")
97
 
98
 (defvar *rep-num* 0
99
   "Counts the number of \"complicated\" repetitions while the matchers
100
 are built.")
101
 (declaim (fixnum *rep-num*))
102
 
103
 (defvar *zero-length-num* 0
104
   "Counts the number of repetitions the inner regexes of which may
105
 have zero-length while the matchers are built.")
106
 (declaim (fixnum *zero-length-num*))
107
 
108
 (defvar *repeat-counters* (make-array 0
109
                                       :initial-element 0
110
                                       :element-type 'fixnum)
111
   "An array to keep track of how often
112
 repetitive patterns have been tested already.")
113
 (declaim (type (array fixnum (*)) *repeat-counters*))
114
 
115
 (defvar *last-pos-stores* (make-array 0)
116
   "An array to keep track of the last positions
117
 where we saw repetitive patterns.
118
 Only used for patterns which might have zero length.")
119
 (declaim (simple-vector *last-pos-stores*))
120
 
121
 (defvar *use-bmh-matchers* nil
122
   "Whether the scanners created by CREATE-SCANNER should use the \(fast
123
 but large) Boyer-Moore-Horspool matchers.")
124
 
125
 (defvar *optimize-char-classes* nil
126
   "Whether character classes should be compiled into look-ups into
127
 O\(1) data structures.  This is usually fast but will be costly in
128
 terms of scanner creation time and might be costly in terms of size if
129
 *REGEX-CHAR-CODE-LIMIT* is high.  This value will be used as the :KIND
130
 keyword argument to CREATE-OPTIMIZED-TEST-FUNCTION - see there for the
131
 possible non-NIL values.")
132
 
133
 (defvar *property-resolver* nil
134
   "Should be NIL or a designator for a function which accepts strings
135
 and returns unary character test functions or NIL.  This 'resolver' is
136
 intended to handle `character properties' like \\p{IsAlpha}.  If
137
 *PROPERTY-RESOLVER* is NIL, then the parser will simply treat \\p and
138
 \\P as #\\p and #\\P as in older versions of CL-PPCRE.")
139
 
140
 (defvar *allow-quoting* nil
141
   "Whether the parser should support Perl's \\Q and \\E.")
142
 
143
 (defvar *allow-named-registers* nil
144
   "Whether the parser should support AllegroCL's named registers
145
 \(?<name>\"<regex>\") and back-reference \\k<name> syntax.")
146
 
147
 (pushnew :cl-ppcre *features*)
148
 
149
 ;; stuff for Nikodemus Siivola's HYPERDOC
150
 ;; see <http://common-lisp.net/project/hyperdoc/>
151
 ;; and <http://www.cliki.net/hyperdoc>
152
 ;; also used by LW-ADD-ONS
153
 
154
 (defvar *hyperdoc-base-uri* "http://weitz.de/cl-ppcre/")
155
 
156
 (let ((exported-symbols-alist
157
        (loop for symbol being the external-symbols of :cl-ppcre
158
              collect (cons symbol
159
                            (concatenate 'string
160
                                         "#"
161
                                         (string-downcase symbol))))))
162
   (defun hyperdoc-lookup (symbol type)
163
     (declare (ignore type))
164
     (cdr (assoc symbol
165
                 exported-symbols-alist
166
                 :test #'eq))))
167