clucumber 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +4 -9
  3. data/lib/clucumber/clucumber-bootstrap.lisp +32 -0
  4. data/lib/clucumber/vendor/cl-interpol/alias.lisp +55 -0
  5. data/lib/clucumber/vendor/cl-interpol/cl-interpol.asd +56 -0
  6. data/lib/clucumber/vendor/cl-interpol/load.lisp +53 -0
  7. data/lib/clucumber/vendor/cl-interpol/packages.lisp +40 -0
  8. data/lib/clucumber/vendor/cl-interpol/read.lisp +716 -0
  9. data/lib/clucumber/vendor/cl-interpol/specials.lisp +113 -0
  10. data/lib/clucumber/vendor/cl-interpol/test/packages.lisp +34 -0
  11. data/lib/clucumber/vendor/cl-interpol/test/tests.lisp +128 -0
  12. data/lib/clucumber/vendor/cl-interpol/test.lisp +177 -0
  13. data/lib/clucumber/vendor/cl-interpol/test2.lisp +6254 -0
  14. data/lib/clucumber/vendor/cl-interpol/unicode.lisp +13912 -0
  15. data/lib/clucumber/vendor/cl-interpol/util.lisp +122 -0
  16. data/lib/clucumber/vendor/cl-ppcre/api.lisp +1262 -0
  17. data/lib/clucumber/vendor/cl-ppcre/charmap.lisp +152 -0
  18. data/lib/clucumber/vendor/cl-ppcre/charset.lisp +242 -0
  19. data/lib/clucumber/vendor/cl-ppcre/chartest.lisp +98 -0
  20. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-test.asd +34 -0
  21. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/packages.lisp +38 -0
  22. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/resolver.lisp +61 -0
  23. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode.asd +58 -0
  24. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre.asd +79 -0
  25. data/lib/clucumber/vendor/cl-ppcre/closures.lisp +471 -0
  26. data/lib/clucumber/vendor/cl-ppcre/convert.lisp +875 -0
  27. data/lib/clucumber/vendor/cl-ppcre/errors.lisp +84 -0
  28. data/lib/clucumber/vendor/cl-ppcre/lexer.lisp +737 -0
  29. data/lib/clucumber/vendor/cl-ppcre/lispworks-defsystem.lisp +57 -0
  30. data/lib/clucumber/vendor/cl-ppcre/load.lisp +67 -0
  31. data/lib/clucumber/vendor/cl-ppcre/optimize.lisp +578 -0
  32. data/lib/clucumber/vendor/cl-ppcre/packages.lisp +68 -0
  33. data/lib/clucumber/vendor/cl-ppcre/parser.lisp +319 -0
  34. data/lib/clucumber/vendor/cl-ppcre/ppcre-tests.lisp +269 -0
  35. data/lib/clucumber/vendor/cl-ppcre/regex-class-util.lisp +555 -0
  36. data/lib/clucumber/vendor/cl-ppcre/regex-class.lisp +259 -0
  37. data/lib/clucumber/vendor/cl-ppcre/repetition-closures.lisp +833 -0
  38. data/lib/clucumber/vendor/cl-ppcre/scanner.lisp +506 -0
  39. data/lib/clucumber/vendor/cl-ppcre/specials.lisp +172 -0
  40. data/lib/clucumber/vendor/cl-ppcre/test/packages.lisp +37 -0
  41. data/lib/clucumber/vendor/cl-ppcre/test/perl-tests.lisp +150 -0
  42. data/lib/clucumber/vendor/cl-ppcre/test/tests.lisp +159 -0
  43. data/lib/clucumber/vendor/cl-ppcre/test/unicode-tests.lisp +80 -0
  44. data/lib/clucumber/vendor/cl-ppcre/util.lisp +201 -0
  45. data/lib/clucumber/vendor/cl-unicode/alias.lisp +135 -0
  46. data/lib/clucumber/vendor/cl-unicode/api.lisp +412 -0
  47. data/lib/clucumber/vendor/cl-unicode/build/char-info.lisp +133 -0
  48. data/lib/clucumber/vendor/cl-unicode/build/dump.lisp +239 -0
  49. data/lib/clucumber/vendor/cl-unicode/build/read.lisp +280 -0
  50. data/lib/clucumber/vendor/cl-unicode/build/util.lisp +182 -0
  51. data/lib/clucumber/vendor/cl-unicode/cl-unicode.asd +90 -0
  52. data/lib/clucumber/vendor/cl-unicode/conditions.lisp +54 -0
  53. data/lib/clucumber/vendor/cl-unicode/derived.lisp +120 -0
  54. data/lib/clucumber/vendor/cl-unicode/hash-tables.lisp +20 -0
  55. data/lib/clucumber/vendor/cl-unicode/lists.lisp +10 -0
  56. data/lib/clucumber/vendor/cl-unicode/methods.lisp +15 -0
  57. data/lib/clucumber/vendor/cl-unicode/packages.lisp +76 -0
  58. data/lib/clucumber/vendor/cl-unicode/specials.lisp +135 -0
  59. data/lib/clucumber/vendor/cl-unicode/test/packages.lisp +34 -0
  60. data/lib/clucumber/vendor/cl-unicode/test/tests.lisp +150 -0
  61. data/lib/clucumber/vendor/cl-unicode/test-functions.lisp +94 -0
  62. data/lib/clucumber/vendor/cl-unicode/util.lisp +274 -0
  63. data/lib/clucumber/vendor/lift/compare/fiveam-tests.lisp +14 -0
  64. data/lib/clucumber/vendor/lift/compare/lift-tests.lisp +13 -0
  65. data/lib/clucumber/vendor/lift/compare/rt-tests.lisp +16 -0
  66. data/lib/clucumber/vendor/lift/compare/xlunit-tests.lisp +15 -0
  67. data/lib/clucumber/vendor/lift/dev/changes.lisp +61 -0
  68. data/lib/clucumber/vendor/lift/dev/config.lisp +354 -0
  69. data/lib/clucumber/vendor/lift/dev/copy-file.lisp +117 -0
  70. data/lib/clucumber/vendor/lift/dev/introspection.lisp +232 -0
  71. data/lib/clucumber/vendor/lift/dev/lift-interface.lisp +56 -0
  72. data/lib/clucumber/vendor/lift/dev/lift-notes.lisp +202 -0
  73. data/lib/clucumber/vendor/lift/dev/lift-randomized.lisp +45 -0
  74. data/lib/clucumber/vendor/lift/dev/lift.lisp +2383 -0
  75. data/lib/clucumber/vendor/lift/dev/macros.lisp +229 -0
  76. data/lib/clucumber/vendor/lift/dev/measuring.lisp +156 -0
  77. data/lib/clucumber/vendor/lift/dev/packages.lisp +161 -0
  78. data/lib/clucumber/vendor/lift/dev/port.lisp +151 -0
  79. data/lib/clucumber/vendor/lift/dev/prototypes.lisp +282 -0
  80. data/lib/clucumber/vendor/lift/dev/random-testing.lisp +124 -0
  81. data/lib/clucumber/vendor/lift/dev/report-locations.lisp +13 -0
  82. data/lib/clucumber/vendor/lift/dev/reports.lisp +916 -0
  83. data/lib/clucumber/vendor/lift/dev/utilities.lisp +242 -0
  84. data/lib/clucumber/vendor/lift/docs/package.lisp +6 -0
  85. data/lib/clucumber/vendor/lift/docs/setup.lisp +17 -0
  86. data/lib/clucumber/vendor/lift/examples/basic-examples.lisp +289 -0
  87. data/lib/clucumber/vendor/lift/examples/random-testing.lisp +32 -0
  88. data/lib/clucumber/vendor/lift/lift-documentation.asd +28 -0
  89. data/lib/clucumber/vendor/lift/lift-test.asd +35 -0
  90. data/lib/clucumber/vendor/lift/lift.asd +77 -0
  91. data/lib/clucumber/vendor/lift/test/equality-tests.lisp +40 -0
  92. data/lib/clucumber/vendor/lift/test/finding-tests.lisp +32 -0
  93. data/lib/clucumber/vendor/lift/test/lift-test.lisp +783 -0
  94. data/lib/clucumber/vendor/lift/test/order-of-operations.lisp +54 -0
  95. data/lib/clucumber/vendor/lift/test/packages.lisp +17 -0
  96. data/lib/clucumber/vendor/lift/test/test-config-files.lisp +20 -0
  97. data/lib/clucumber/vendor/lift/test/test-dynamic-variables.lisp +57 -0
  98. data/lib/clucumber/vendor/lift/test/test-maximum-problems.lisp +74 -0
  99. data/lib/clucumber/vendor/lift/test/test-prototypes.lisp +278 -0
  100. data/lib/clucumber/vendor/lift/test/test-timeout.lisp +37 -0
  101. data/lib/clucumber/vendor/lift/test/tests-in-progress.lisp +62 -0
  102. data/lib/clucumber/vendor/lift/test/testsuite-expects.lisp +60 -0
  103. data/lib/clucumber/vendor/lift/timeout/package.lisp +13 -0
  104. data/lib/clucumber/vendor/lift/timeout/with-timeout.lisp +123 -0
  105. data/lib/clucumber/vendor/lift/website/stuff/Temp.lisp +34 -0
  106. data/lib/clucumber/vendor/st-json/st-json.asd +3 -0
  107. data/lib/clucumber/vendor/st-json/st-json.lisp +310 -0
  108. data/lib/clucumber/vendor/trivial-backtrace/dev/backtrace.lisp +127 -0
  109. data/lib/clucumber/vendor/trivial-backtrace/dev/fallback.lisp +10 -0
  110. data/lib/clucumber/vendor/trivial-backtrace/dev/map-backtrace.lisp +103 -0
  111. data/lib/clucumber/vendor/trivial-backtrace/dev/mucking.lisp +75 -0
  112. data/lib/clucumber/vendor/trivial-backtrace/dev/packages.lisp +13 -0
  113. data/lib/clucumber/vendor/trivial-backtrace/dev/utilities.lisp +104 -0
  114. data/lib/clucumber/vendor/trivial-backtrace/test/packages.lisp +5 -0
  115. data/lib/clucumber/vendor/trivial-backtrace/test/test-setup.lisp +4 -0
  116. data/lib/clucumber/vendor/trivial-backtrace/test/tests.lisp +16 -0
  117. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace-test.asd +22 -0
  118. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace.asd +35 -0
  119. data/lib/clucumber/vendor/usocket/backend/allegro.lisp +199 -0
  120. data/lib/clucumber/vendor/usocket/backend/armedbear.lisp +491 -0
  121. data/lib/clucumber/vendor/usocket/backend/clisp.lisp +260 -0
  122. data/lib/clucumber/vendor/usocket/backend/cmucl.lisp +266 -0
  123. data/lib/clucumber/vendor/usocket/backend/lispworks.lisp +741 -0
  124. data/lib/clucumber/vendor/usocket/backend/mcl.lisp +369 -0
  125. data/lib/clucumber/vendor/usocket/backend/openmcl.lisp +206 -0
  126. data/lib/clucumber/vendor/usocket/backend/sbcl.lisp +424 -0
  127. data/lib/clucumber/vendor/usocket/backend/scl.lisp +261 -0
  128. data/lib/clucumber/vendor/usocket/condition.lisp +227 -0
  129. data/lib/clucumber/vendor/usocket/package.lisp +82 -0
  130. data/lib/clucumber/vendor/usocket/server.lisp +45 -0
  131. data/lib/clucumber/vendor/usocket/test/package.lisp +13 -0
  132. data/lib/clucumber/vendor/usocket/test/test-usocket.lisp +166 -0
  133. data/lib/clucumber/vendor/usocket/usocket-test.asd +26 -0
  134. data/lib/clucumber/vendor/usocket/usocket.asd +37 -0
  135. data/lib/clucumber/vendor/usocket/usocket.lisp +542 -0
  136. data/lib/clucumber/vendor/usocket/vendor/kqueue.lisp +1 -0
  137. data/lib/clucumber/vendor/usocket/vendor/split-sequence.lisp +245 -0
  138. data/lib/clucumber.rb +29 -7
  139. metadata +151 -5
@@ -0,0 +1,58 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-ppcre/cl-ppcre-unicode.asd,v 1.15 2009/09/17 19:17:30 edi Exp $
3
+
4
+ ;;; This ASDF system definition was kindly provided by Marco Baringer.
5
+
6
+ ;;; Copyright (c) 2002-2009, Dr. Edmund Weitz. All rights reserved.
7
+
8
+ ;;; Redistribution and use in source and binary forms, with or without
9
+ ;;; modification, are permitted provided that the following conditions
10
+ ;;; are met:
11
+
12
+ ;;; * Redistributions of source code must retain the above copyright
13
+ ;;; notice, this list of conditions and the following disclaimer.
14
+
15
+ ;;; * Redistributions in binary form must reproduce the above
16
+ ;;; copyright notice, this list of conditions and the following
17
+ ;;; disclaimer in the documentation and/or other materials
18
+ ;;; provided with the distribution.
19
+
20
+ ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
21
+ ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
24
+ ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26
+ ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ (in-package :cl-user)
33
+
34
+ (defpackage :cl-ppcre-unicode-asd
35
+ (:use :cl :asdf))
36
+
37
+ (in-package :cl-ppcre-unicode-asd)
38
+
39
+ (defsystem :cl-ppcre-unicode
40
+ :components ((:module "cl-ppcre-unicode"
41
+ :serial t
42
+ :components ((:file "packages")
43
+ (:file "resolver"))))
44
+ :depends-on (:cl-ppcre :cl-unicode))
45
+
46
+ (defsystem :cl-ppcre-unicode-test
47
+ :depends-on (:cl-ppcre-unicode :cl-ppcre-test)
48
+ :components ((:module "test"
49
+ :serial t
50
+ :components ((:file "unicode-tests")))))
51
+
52
+ (defmethod perform ((o test-op) (c (eql (find-system :cl-ppcre-unicode))))
53
+ ;; we must load CL-PPCRE explicitly so that the CL-PPCRE-TEST system
54
+ ;; will be found
55
+ (operate 'load-op :cl-ppcre)
56
+ (operate 'load-op :cl-ppcre-unicode-test)
57
+ (funcall (intern (symbol-name :run-all-tests) (find-package :cl-ppcre-test))
58
+ :more-tests (intern (symbol-name :unicode-test) (find-package :cl-ppcre-test))))
@@ -0,0 +1,79 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-ppcre/cl-ppcre.asd,v 1.49 2009/10/28 07:36:15 edi Exp $
3
+
4
+ ;;; This ASDF system definition was kindly provided by Marco Baringer.
5
+
6
+ ;;; Copyright (c) 2002-2009, Dr. Edmund Weitz. All rights reserved.
7
+
8
+ ;;; Redistribution and use in source and binary forms, with or without
9
+ ;;; modification, are permitted provided that the following conditions
10
+ ;;; are met:
11
+
12
+ ;;; * Redistributions of source code must retain the above copyright
13
+ ;;; notice, this list of conditions and the following disclaimer.
14
+
15
+ ;;; * Redistributions in binary form must reproduce the above
16
+ ;;; copyright notice, this list of conditions and the following
17
+ ;;; disclaimer in the documentation and/or other materials
18
+ ;;; provided with the distribution.
19
+
20
+ ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
21
+ ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
24
+ ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26
+ ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
+ ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ (in-package :cl-user)
33
+
34
+ (defpackage :cl-ppcre-asd
35
+ (:use :cl :asdf))
36
+
37
+ (in-package :cl-ppcre-asd)
38
+
39
+ (defsystem :cl-ppcre
40
+ :version "2.0.3"
41
+ :serial t
42
+ :components ((:file "packages")
43
+ (:file "specials")
44
+ (:file "util")
45
+ (:file "errors")
46
+ (:file "charset")
47
+ (:file "charmap")
48
+ (:file "chartest")
49
+ #-:use-acl-regexp2-engine
50
+ (:file "lexer")
51
+ #-:use-acl-regexp2-engine
52
+ (:file "parser")
53
+ #-:use-acl-regexp2-engine
54
+ (:file "regex-class")
55
+ #-:use-acl-regexp2-engine
56
+ (:file "regex-class-util")
57
+ #-:use-acl-regexp2-engine
58
+ (:file "convert")
59
+ #-:use-acl-regexp2-engine
60
+ (:file "optimize")
61
+ #-:use-acl-regexp2-engine
62
+ (:file "closures")
63
+ #-:use-acl-regexp2-engine
64
+ (:file "repetition-closures")
65
+ #-:use-acl-regexp2-engine
66
+ (:file "scanner")
67
+ (:file "api")))
68
+
69
+ (defsystem :cl-ppcre-test
70
+ :depends-on (:cl-ppcre :flexi-streams)
71
+ :components ((:module "test"
72
+ :serial t
73
+ :components ((:file "packages")
74
+ (:file "tests")
75
+ (:file "perl-tests")))))
76
+
77
+ (defmethod perform ((o test-op) (c (eql (find-system :cl-ppcre))))
78
+ (operate 'load-op :cl-ppcre-test)
79
+ (funcall (intern (symbol-name :run-all-tests) (find-package :cl-ppcre-test))))
@@ -0,0 +1,471 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-PPCRE; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-ppcre/closures.lisp,v 1.45 2009/09/17 19:17:30 edi Exp $
3
+
4
+ ;;; Here we create the closures which together build the final
5
+ ;;; scanner.
6
+
7
+ ;;; Copyright (c) 2002-2009, Dr. Edmund Weitz. All rights reserved.
8
+
9
+ ;;; Redistribution and use in source and binary forms, with or without
10
+ ;;; modification, are permitted provided that the following conditions
11
+ ;;; are met:
12
+
13
+ ;;; * Redistributions of source code must retain the above copyright
14
+ ;;; notice, this list of conditions and the following disclaimer.
15
+
16
+ ;;; * Redistributions in binary form must reproduce the above
17
+ ;;; copyright notice, this list of conditions and the following
18
+ ;;; disclaimer in the documentation and/or other materials
19
+ ;;; provided with the distribution.
20
+
21
+ ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
22
+ ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+ ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25
+ ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27
+ ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+ ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29
+ ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
+ ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31
+ ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+
33
+ (in-package :cl-ppcre)
34
+
35
+ (declaim (inline *string*= *string*-equal))
36
+ (defun *string*= (string2 start1 end1 start2 end2)
37
+ "Like STRING=, i.e. compares the special string *STRING* from START1
38
+ to END1 with STRING2 from START2 to END2. Note that there's no
39
+ boundary check - this has to be implemented by the caller."
40
+ (declare #.*standard-optimize-settings*)
41
+ (declare (fixnum start1 end1 start2 end2))
42
+ (loop for string1-idx of-type fixnum from start1 below end1
43
+ for string2-idx of-type fixnum from start2 below end2
44
+ always (char= (schar *string* string1-idx)
45
+ (schar string2 string2-idx))))
46
+
47
+ (defun *string*-equal (string2 start1 end1 start2 end2)
48
+ "Like STRING-EQUAL, i.e. compares the special string *STRING* from
49
+ START1 to END1 with STRING2 from START2 to END2. Note that there's no
50
+ boundary check - this has to be implemented by the caller."
51
+ (declare #.*standard-optimize-settings*)
52
+ (declare (fixnum start1 end1 start2 end2))
53
+ (loop for string1-idx of-type fixnum from start1 below end1
54
+ for string2-idx of-type fixnum from start2 below end2
55
+ always (char-equal (schar *string* string1-idx)
56
+ (schar string2 string2-idx))))
57
+
58
+ (defgeneric create-matcher-aux (regex next-fn)
59
+ (declare #.*standard-optimize-settings*)
60
+ (:documentation "Creates a closure which takes one parameter,
61
+ START-POS, and tests whether REGEX can match *STRING* at START-POS
62
+ such that the call to NEXT-FN after the match would succeed."))
63
+
64
+ (defmethod create-matcher-aux ((seq seq) next-fn)
65
+ (declare #.*standard-optimize-settings*)
66
+ ;; the closure for a SEQ is a chain of closures for the elements of
67
+ ;; this sequence which call each other in turn; the last closure
68
+ ;; calls NEXT-FN
69
+ (loop for element in (reverse (elements seq))
70
+ for curr-matcher = next-fn then next-matcher
71
+ for next-matcher = (create-matcher-aux element curr-matcher)
72
+ finally (return next-matcher)))
73
+
74
+ (defmethod create-matcher-aux ((alternation alternation) next-fn)
75
+ (declare #.*standard-optimize-settings*)
76
+ ;; first create closures for all alternations of ALTERNATION
77
+ (let ((all-matchers (mapcar #'(lambda (choice)
78
+ (create-matcher-aux choice next-fn))
79
+ (choices alternation))))
80
+ ;; now create a closure which checks if one of the closures
81
+ ;; created above can succeed
82
+ (lambda (start-pos)
83
+ (declare (fixnum start-pos))
84
+ (loop for matcher in all-matchers
85
+ thereis (funcall (the function matcher) start-pos)))))
86
+
87
+ (defmethod create-matcher-aux ((register register) next-fn)
88
+ (declare #.*standard-optimize-settings*)
89
+ ;; the position of this REGISTER within the whole regex; we start to
90
+ ;; count at 0
91
+ (let ((num (num register)))
92
+ (declare (fixnum num))
93
+ ;; STORE-END-OF-REG is a thin wrapper around NEXT-FN which will
94
+ ;; update the corresponding values of *REGS-START* and *REGS-END*
95
+ ;; after the inner matcher has succeeded
96
+ (flet ((store-end-of-reg (start-pos)
97
+ (declare (fixnum start-pos)
98
+ (function next-fn))
99
+ (setf (svref *reg-starts* num) (svref *regs-maybe-start* num)
100
+ (svref *reg-ends* num) start-pos)
101
+ (funcall next-fn start-pos)))
102
+ ;; the inner matcher is a closure corresponding to the regex
103
+ ;; wrapped by this REGISTER
104
+ (let ((inner-matcher (create-matcher-aux (regex register)
105
+ #'store-end-of-reg)))
106
+ (declare (function inner-matcher))
107
+ ;; here comes the actual closure for REGISTER
108
+ (lambda (start-pos)
109
+ (declare (fixnum start-pos))
110
+ ;; remember the old values of *REGS-START* and friends in
111
+ ;; case we cannot match
112
+ (let ((old-*reg-starts* (svref *reg-starts* num))
113
+ (old-*regs-maybe-start* (svref *regs-maybe-start* num))
114
+ (old-*reg-ends* (svref *reg-ends* num)))
115
+ ;; we cannot use *REGS-START* here because Perl allows
116
+ ;; regular expressions like /(a|\1x)*/
117
+ (setf (svref *regs-maybe-start* num) start-pos)
118
+ (let ((next-pos (funcall inner-matcher start-pos)))
119
+ (unless next-pos
120
+ ;; restore old values on failure
121
+ (setf (svref *reg-starts* num) old-*reg-starts*
122
+ (svref *regs-maybe-start* num) old-*regs-maybe-start*
123
+ (svref *reg-ends* num) old-*reg-ends*))
124
+ next-pos)))))))
125
+
126
+ (defmethod create-matcher-aux ((lookahead lookahead) next-fn)
127
+ (declare #.*standard-optimize-settings*)
128
+ ;; create a closure which just checks for the inner regex and
129
+ ;; doesn't care about NEXT-FN
130
+ (let ((test-matcher (create-matcher-aux (regex lookahead) #'identity)))
131
+ (declare (function next-fn test-matcher))
132
+ (if (positivep lookahead)
133
+ ;; positive look-ahead: check success of inner regex, then call
134
+ ;; NEXT-FN
135
+ (lambda (start-pos)
136
+ (and (funcall test-matcher start-pos)
137
+ (funcall next-fn start-pos)))
138
+ ;; negative look-ahead: check failure of inner regex, then call
139
+ ;; NEXT-FN
140
+ (lambda (start-pos)
141
+ (and (not (funcall test-matcher start-pos))
142
+ (funcall next-fn start-pos))))))
143
+
144
+ (defmethod create-matcher-aux ((lookbehind lookbehind) next-fn)
145
+ (declare #.*standard-optimize-settings*)
146
+ (let ((len (len lookbehind))
147
+ ;; create a closure which just checks for the inner regex and
148
+ ;; doesn't care about NEXT-FN
149
+ (test-matcher (create-matcher-aux (regex lookbehind) #'identity)))
150
+ (declare (function next-fn test-matcher)
151
+ (fixnum len))
152
+ (if (positivep lookbehind)
153
+ ;; positive look-behind: check success of inner regex (if we're
154
+ ;; far enough from the start of *STRING*), then call NEXT-FN
155
+ (lambda (start-pos)
156
+ (declare (fixnum start-pos))
157
+ (and (>= (- start-pos (or *real-start-pos* *start-pos*)) len)
158
+ (funcall test-matcher (- start-pos len))
159
+ (funcall next-fn start-pos)))
160
+ ;; negative look-behind: check failure of inner regex (if we're
161
+ ;; far enough from the start of *STRING*), then call NEXT-FN
162
+ (lambda (start-pos)
163
+ (declare (fixnum start-pos))
164
+ (and (or (< (- start-pos (or *real-start-pos* *start-pos*)) len)
165
+ (not (funcall test-matcher (- start-pos len))))
166
+ (funcall next-fn start-pos))))))
167
+
168
+ (defmacro insert-char-class-tester ((char-class chr-expr) &body body)
169
+ "Utility macro to replace each occurence of '\(CHAR-CLASS-TEST)
170
+ within BODY with the correct test (corresponding to CHAR-CLASS)
171
+ against CHR-EXPR."
172
+ (with-rebinding (char-class)
173
+ (with-unique-names (test-function)
174
+ (flet ((substitute-char-class-tester (new)
175
+ (subst new '(char-class-test) body
176
+ :test #'equalp)))
177
+ `(let ((,test-function (test-function ,char-class)))
178
+ ,@(substitute-char-class-tester
179
+ `(funcall ,test-function ,chr-expr)))))))
180
+
181
+ (defmethod create-matcher-aux ((char-class char-class) next-fn)
182
+ (declare #.*standard-optimize-settings*)
183
+ (declare (function next-fn))
184
+ ;; insert a test against the current character within *STRING*
185
+ (insert-char-class-tester (char-class (schar *string* start-pos))
186
+ (lambda (start-pos)
187
+ (declare (fixnum start-pos))
188
+ (and (< start-pos *end-pos*)
189
+ (char-class-test)
190
+ (funcall next-fn (1+ start-pos))))))
191
+
192
+ (defmethod create-matcher-aux ((str str) next-fn)
193
+ (declare #.*standard-optimize-settings*)
194
+ (declare (fixnum *end-string-pos*)
195
+ (function next-fn)
196
+ ;; this special value is set by CREATE-SCANNER when the
197
+ ;; closures are built
198
+ (special end-string))
199
+ (let* ((len (len str))
200
+ (case-insensitive-p (case-insensitive-p str))
201
+ (start-of-end-string-p (start-of-end-string-p str))
202
+ (skip (skip str))
203
+ (str (str str))
204
+ (chr (schar str 0))
205
+ (end-string (and end-string (str end-string)))
206
+ (end-string-len (if end-string
207
+ (length end-string)
208
+ nil)))
209
+ (declare (fixnum len))
210
+ (cond ((and start-of-end-string-p case-insensitive-p)
211
+ ;; closure for the first STR which belongs to the constant
212
+ ;; string at the end of the regular expression;
213
+ ;; case-insensitive version
214
+ (lambda (start-pos)
215
+ (declare (fixnum start-pos end-string-len))
216
+ (let ((test-end-pos (+ start-pos end-string-len)))
217
+ (declare (fixnum test-end-pos))
218
+ ;; either we're at *END-STRING-POS* (which means that
219
+ ;; it has already been confirmed that end-string
220
+ ;; starts here) or we really have to test
221
+ (and (or (= start-pos *end-string-pos*)
222
+ (and (<= test-end-pos *end-pos*)
223
+ (*string*-equal end-string start-pos test-end-pos
224
+ 0 end-string-len)))
225
+ (funcall next-fn (+ start-pos len))))))
226
+ (start-of-end-string-p
227
+ ;; closure for the first STR which belongs to the constant
228
+ ;; string at the end of the regular expression;
229
+ ;; case-sensitive version
230
+ (lambda (start-pos)
231
+ (declare (fixnum start-pos end-string-len))
232
+ (let ((test-end-pos (+ start-pos end-string-len)))
233
+ (declare (fixnum test-end-pos))
234
+ ;; either we're at *END-STRING-POS* (which means that
235
+ ;; it has already been confirmed that end-string
236
+ ;; starts here) or we really have to test
237
+ (and (or (= start-pos *end-string-pos*)
238
+ (and (<= test-end-pos *end-pos*)
239
+ (*string*= end-string start-pos test-end-pos
240
+ 0 end-string-len)))
241
+ (funcall next-fn (+ start-pos len))))))
242
+ (skip
243
+ ;; a STR which can be skipped because some other function
244
+ ;; has already confirmed that it matches
245
+ (lambda (start-pos)
246
+ (declare (fixnum start-pos))
247
+ (funcall next-fn (+ start-pos len))))
248
+ ((and (= len 1) case-insensitive-p)
249
+ ;; STR represent exactly one character; case-insensitive
250
+ ;; version
251
+ (lambda (start-pos)
252
+ (declare (fixnum start-pos))
253
+ (and (< start-pos *end-pos*)
254
+ (char-equal (schar *string* start-pos) chr)
255
+ (funcall next-fn (1+ start-pos)))))
256
+ ((= len 1)
257
+ ;; STR represent exactly one character; case-sensitive
258
+ ;; version
259
+ (lambda (start-pos)
260
+ (declare (fixnum start-pos))
261
+ (and (< start-pos *end-pos*)
262
+ (char= (schar *string* start-pos) chr)
263
+ (funcall next-fn (1+ start-pos)))))
264
+ (case-insensitive-p
265
+ ;; general case, case-insensitive version
266
+ (lambda (start-pos)
267
+ (declare (fixnum start-pos))
268
+ (let ((next-pos (+ start-pos len)))
269
+ (declare (fixnum next-pos))
270
+ (and (<= next-pos *end-pos*)
271
+ (*string*-equal str start-pos next-pos 0 len)
272
+ (funcall next-fn next-pos)))))
273
+ (t
274
+ ;; general case, case-sensitive version
275
+ (lambda (start-pos)
276
+ (declare (fixnum start-pos))
277
+ (let ((next-pos (+ start-pos len)))
278
+ (declare (fixnum next-pos))
279
+ (and (<= next-pos *end-pos*)
280
+ (*string*= str start-pos next-pos 0 len)
281
+ (funcall next-fn next-pos))))))))
282
+
283
+ (declaim (inline word-boundary-p))
284
+ (defun word-boundary-p (start-pos)
285
+ "Check whether START-POS is a word-boundary within *STRING*."
286
+ (declare #.*standard-optimize-settings*)
287
+ (declare (fixnum start-pos))
288
+ (let ((1-start-pos (1- start-pos))
289
+ (*start-pos* (or *real-start-pos* *start-pos*)))
290
+ ;; either the character before START-POS is a word-constituent and
291
+ ;; the character at START-POS isn't...
292
+ (or (and (or (= start-pos *end-pos*)
293
+ (and (< start-pos *end-pos*)
294
+ (not (word-char-p (schar *string* start-pos)))))
295
+ (and (< 1-start-pos *end-pos*)
296
+ (<= *start-pos* 1-start-pos)
297
+ (word-char-p (schar *string* 1-start-pos))))
298
+ ;; ...or vice versa
299
+ (and (or (= start-pos *start-pos*)
300
+ (and (< 1-start-pos *end-pos*)
301
+ (<= *start-pos* 1-start-pos)
302
+ (not (word-char-p (schar *string* 1-start-pos)))))
303
+ (and (< start-pos *end-pos*)
304
+ (word-char-p (schar *string* start-pos)))))))
305
+
306
+ (defmethod create-matcher-aux ((word-boundary word-boundary) next-fn)
307
+ (declare #.*standard-optimize-settings*)
308
+ (declare (function next-fn))
309
+ (if (negatedp word-boundary)
310
+ (lambda (start-pos)
311
+ (and (not (word-boundary-p start-pos))
312
+ (funcall next-fn start-pos)))
313
+ (lambda (start-pos)
314
+ (and (word-boundary-p start-pos)
315
+ (funcall next-fn start-pos)))))
316
+
317
+ (defmethod create-matcher-aux ((everything everything) next-fn)
318
+ (declare #.*standard-optimize-settings*)
319
+ (declare (function next-fn))
320
+ (if (single-line-p everything)
321
+ ;; closure for single-line-mode: we really match everything, so we
322
+ ;; just advance the index into *STRING* by one and carry on
323
+ (lambda (start-pos)
324
+ (declare (fixnum start-pos))
325
+ (and (< start-pos *end-pos*)
326
+ (funcall next-fn (1+ start-pos))))
327
+ ;; not single-line-mode, so we have to make sure we don't match
328
+ ;; #\Newline
329
+ (lambda (start-pos)
330
+ (declare (fixnum start-pos))
331
+ (and (< start-pos *end-pos*)
332
+ (char/= (schar *string* start-pos) #\Newline)
333
+ (funcall next-fn (1+ start-pos))))))
334
+
335
+ (defmethod create-matcher-aux ((anchor anchor) next-fn)
336
+ (declare #.*standard-optimize-settings*)
337
+ (declare (function next-fn))
338
+ (let ((startp (startp anchor))
339
+ (multi-line-p (multi-line-p anchor)))
340
+ (cond ((no-newline-p anchor)
341
+ ;; this must be an end-anchor and it must be modeless, so
342
+ ;; we just have to check whether START-POS equals
343
+ ;; *END-POS*
344
+ (lambda (start-pos)
345
+ (declare (fixnum start-pos))
346
+ (and (= start-pos *end-pos*)
347
+ (funcall next-fn start-pos))))
348
+ ((and startp multi-line-p)
349
+ ;; a start-anchor in multi-line-mode: check if we're at
350
+ ;; *START-POS* or if the last character was #\Newline
351
+ (lambda (start-pos)
352
+ (declare (fixnum start-pos))
353
+ (let ((*start-pos* (or *real-start-pos* *start-pos*)))
354
+ (and (or (= start-pos *start-pos*)
355
+ (and (<= start-pos *end-pos*)
356
+ (> start-pos *start-pos*)
357
+ (char= #\Newline
358
+ (schar *string* (1- start-pos)))))
359
+ (funcall next-fn start-pos)))))
360
+ (startp
361
+ ;; a start-anchor which is not in multi-line-mode, so just
362
+ ;; check whether we're at *START-POS*
363
+ (lambda (start-pos)
364
+ (declare (fixnum start-pos))
365
+ (and (= start-pos (or *real-start-pos* *start-pos*))
366
+ (funcall next-fn start-pos))))
367
+ (multi-line-p
368
+ ;; an end-anchor in multi-line-mode: check if we're at
369
+ ;; *END-POS* or if the character we're looking at is
370
+ ;; #\Newline
371
+ (lambda (start-pos)
372
+ (declare (fixnum start-pos))
373
+ (and (or (= start-pos *end-pos*)
374
+ (and (< start-pos *end-pos*)
375
+ (char= #\Newline
376
+ (schar *string* start-pos))))
377
+ (funcall next-fn start-pos))))
378
+ (t
379
+ ;; an end-anchor which is not in multi-line-mode, so just
380
+ ;; check if we're at *END-POS* or if we're looking at
381
+ ;; #\Newline and there's nothing behind it
382
+ (lambda (start-pos)
383
+ (declare (fixnum start-pos))
384
+ (and (or (= start-pos *end-pos*)
385
+ (and (= start-pos (1- *end-pos*))
386
+ (char= #\Newline
387
+ (schar *string* start-pos))))
388
+ (funcall next-fn start-pos)))))))
389
+
390
+ (defmethod create-matcher-aux ((back-reference back-reference) next-fn)
391
+ (declare #.*standard-optimize-settings*)
392
+ (declare (function next-fn))
393
+ ;; the position of the corresponding REGISTER within the whole
394
+ ;; regex; we start to count at 0
395
+ (let ((num (num back-reference)))
396
+ (if (case-insensitive-p back-reference)
397
+ ;; the case-insensitive version
398
+ (lambda (start-pos)
399
+ (declare (fixnum start-pos))
400
+ (let ((reg-start (svref *reg-starts* num))
401
+ (reg-end (svref *reg-ends* num)))
402
+ ;; only bother to check if the corresponding REGISTER as
403
+ ;; matched successfully already
404
+ (and reg-start
405
+ (let ((next-pos (+ start-pos (- (the fixnum reg-end)
406
+ (the fixnum reg-start)))))
407
+ (declare (fixnum next-pos))
408
+ (and
409
+ (<= next-pos *end-pos*)
410
+ (*string*-equal *string* start-pos next-pos
411
+ reg-start reg-end)
412
+ (funcall next-fn next-pos))))))
413
+ ;; the case-sensitive version
414
+ (lambda (start-pos)
415
+ (declare (fixnum start-pos))
416
+ (let ((reg-start (svref *reg-starts* num))
417
+ (reg-end (svref *reg-ends* num)))
418
+ ;; only bother to check if the corresponding REGISTER as
419
+ ;; matched successfully already
420
+ (and reg-start
421
+ (let ((next-pos (+ start-pos (- (the fixnum reg-end)
422
+ (the fixnum reg-start)))))
423
+ (declare (fixnum next-pos))
424
+ (and
425
+ (<= next-pos *end-pos*)
426
+ (*string*= *string* start-pos next-pos
427
+ reg-start reg-end)
428
+ (funcall next-fn next-pos)))))))))
429
+
430
+ (defmethod create-matcher-aux ((branch branch) next-fn)
431
+ (declare #.*standard-optimize-settings*)
432
+ (let* ((test (test branch))
433
+ (then-matcher (create-matcher-aux (then-regex branch) next-fn))
434
+ (else-matcher (create-matcher-aux (else-regex branch) next-fn)))
435
+ (declare (function then-matcher else-matcher))
436
+ (cond ((numberp test)
437
+ (lambda (start-pos)
438
+ (declare (fixnum test))
439
+ (if (and (< test (length *reg-starts*))
440
+ (svref *reg-starts* test))
441
+ (funcall then-matcher start-pos)
442
+ (funcall else-matcher start-pos))))
443
+ (t
444
+ (let ((test-matcher (create-matcher-aux test #'identity)))
445
+ (declare (function test-matcher))
446
+ (lambda (start-pos)
447
+ (if (funcall test-matcher start-pos)
448
+ (funcall then-matcher start-pos)
449
+ (funcall else-matcher start-pos))))))))
450
+
451
+ (defmethod create-matcher-aux ((standalone standalone) next-fn)
452
+ (declare #.*standard-optimize-settings*)
453
+ (let ((inner-matcher (create-matcher-aux (regex standalone) #'identity)))
454
+ (declare (function next-fn inner-matcher))
455
+ (lambda (start-pos)
456
+ (let ((next-pos (funcall inner-matcher start-pos)))
457
+ (and next-pos
458
+ (funcall next-fn next-pos))))))
459
+
460
+ (defmethod create-matcher-aux ((filter filter) next-fn)
461
+ (declare #.*standard-optimize-settings*)
462
+ (let ((fn (fn filter)))
463
+ (lambda (start-pos)
464
+ (let ((next-pos (funcall fn start-pos)))
465
+ (and next-pos
466
+ (funcall next-fn next-pos))))))
467
+
468
+ (defmethod create-matcher-aux ((void void) next-fn)
469
+ (declare #.*standard-optimize-settings*)
470
+ ;; optimize away VOIDs: don't create a closure, just return NEXT-FN
471
+ next-fn)