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,182 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-UNICODE; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-unicode/build/util.lisp,v 1.12 2008/07/21 14:23:09 edi Exp $
3
+
4
+ ;;; Copyright (c) 2008, Dr. Edmund Weitz. All rights reserved.
5
+
6
+ ;;; Redistribution and use in source and binary forms, with or without
7
+ ;;; modification, are permitted provided that the following conditions
8
+ ;;; are met:
9
+
10
+ ;;; * Redistributions of source code must retain the above copyright
11
+ ;;; notice, this list of conditions and the following disclaimer.
12
+
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.
17
+
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.
29
+
30
+ (in-package :cl-unicode)
31
+
32
+ (defvar *this-file* (load-time-value
33
+ (or #.*compile-file-pathname* *load-pathname*))
34
+ "The location of this source file. Needed to find the data files.")
35
+
36
+ (defvar *char-database* nil
37
+ "This will be a vector of CHAR-INFO objects which keeps track of the
38
+ information parsed from the Unicode files while the build process
39
+ runs. This \"database\" is not used by CL-UNICODE itself. It only
40
+ serves as a temporary storage during the build process.")
41
+
42
+ (defun make-empty-char-database ()
43
+ "Creates and returns an array of length +CODE-POINT-LIMIT+
44
+ initialized with NILs."
45
+ (make-array +code-point-limit+ :initial-element nil))
46
+
47
+ (defun initialize-property-symbols ()
48
+ "Clears the hash table *CANONICAL-NAMES* and initializes it with
49
+ certain values which might otherwise not be seen when the Unicode
50
+ files are parsed."
51
+ (clrhash *canonical-names*)
52
+ (dolist (name '("Cn" "AL" "R" "L" "Decimal" "Digit" "Numeric" "BidiMirrored" "NoncharacterCodePoint"))
53
+ (register-property-symbol name)))
54
+
55
+ (defun extract-variables (bindings)
56
+ "Helper function for the WITH-UNICODE-FILE macro. Collects the
57
+ variables from the list BINDINGS where atoms as well as the first
58
+ element of BINDINGS are left as is and lists are replaced with their
59
+ first elements. The symbol _ \(underline) is skipped, i.e. not
60
+ returned."
61
+ (cons (first bindings)
62
+ (loop for binding in (rest bindings)
63
+ unless (eq binding '_)
64
+ when (listp binding)
65
+ collect (first binding)
66
+ else collect binding)))
67
+
68
+ (defun extract-types (bindings)
69
+ "Helper function for the WITH-UNICODE-FILE macro. Collects the type
70
+ spec from the list BINDINGS where it is assumed the for lists the type
71
+ spec is the second element and for atoms the type spec is defaulted to
72
+ STRING. The first argument of BINDINGS is skipped, and the type spec
73
+ NIL is included whenever the symbol _ \(underline) is seen."
74
+ (loop for binding in (rest bindings)
75
+ when (eq binding '_)
76
+ collect nil
77
+ else when (listp binding)
78
+ collect (second binding)
79
+ else collect 'string))
80
+
81
+ (defun extract-defaults (bindings)
82
+ "Helper function for the WITH-UNICODE-FILE macro. Collects the
83
+ default values from the list BINDINGS where it is assumed the for
84
+ lists the default value is the third element and for atoms the default
85
+ value is :ERROR \(meaning to signal an error). The first argument of
86
+ BINDINGS is skipped, and the default value NIL is included whenever
87
+ the symbol _ \(underline) is seen."
88
+ (loop for binding in (rest bindings)
89
+ when (eq binding '_)
90
+ collect nil
91
+ else when (and (listp binding) (cddr binding))
92
+ collect (third binding)
93
+ else collect :error))
94
+
95
+ (defun code-point-range-start (range)
96
+ "Returns the first code point of the code point \"range\" RANGE
97
+ where RANGE is either an integer denoting one code point or a cons of
98
+ the form (A . B) denoting the code points from A to B \(inclusive)."
99
+ (cond ((atom range) range)
100
+ (t (car range))))
101
+
102
+ (defun parse-code-point (string)
103
+ "Parses a string which is supposed to be the hexadecimal
104
+ representation of one code point or a range of code points \(written
105
+ with two dots between them like \"0AE0..0AF3\"). Returns a single
106
+ integer \(for one code point) or a cons of two integers \(for a
107
+ range)."
108
+ (destructuring-bind (first &optional second)
109
+ (mapcar 'parse-hex (ppcre:split "\\.\\." string))
110
+ (if second (cons first second) first)))
111
+
112
+ (defgeneric parse-value (value type default)
113
+ (:documentation "Parses the string VALUE coming from a Unicode data
114
+ file and converts it according to the type spec TYPE \(a symbol
115
+ denoting a type which is not necessarily a Lisp type). If VALUE is
116
+ the empty string, DEFAULT is returned instead unless DEFAULT is :ERROR
117
+ in which case an error is signalled.")
118
+ (:method (value type default)
119
+ "The default method for unrecognized type specs."
120
+ (error "Don't know how to parse type ~S." type))
121
+ (:method :around (value type default)
122
+ "The method to take care of default values."
123
+ (cond ((and (string= value "") (eq default :error))
124
+ (error "No value and no default provided"))
125
+ ((string= value "") default)
126
+ (t (call-next-method)))))
127
+
128
+ (defmethod parse-value (value (type (eql 'string)) default)
129
+ "The method for strings simply returns VALUE."
130
+ value)
131
+
132
+ (defmethod parse-value (value (type (eql 'boolean)) default)
133
+ "The method for BOOLEAN only accepts the strings \"Y\" and \"N\"."
134
+ (cond ((string= value "Y") t)
135
+ ((string= value "N") nil)
136
+ (t (error "Expected boolean, but got ~S." value))))
137
+
138
+ (defmethod parse-value (value (type (eql 'symbol)) default)
139
+ "The method for symbol which converts the string to a \"property
140
+ symbol\" \(see PROPERTY-SYMBOL) and registers it \(see
141
+ REGISTER-PROPERTY-SYMBOL)."
142
+ (register-property-symbol value))
143
+
144
+ (defmethod parse-value (value (type (eql 'integer)) default)
145
+ "The method for \(decimal) integers."
146
+ (parse-integer value))
147
+
148
+ (defmethod parse-value (value (type (eql 'hex)) default)
149
+ "The method for hexadecimal integers."
150
+ (parse-hex value))
151
+
152
+ (defmethod parse-value (value (type (eql 'rational)) default)
153
+ "The method for rationals which are written like Lisp rationals."
154
+ (destructuring-bind (numerator &optional (denominator 1))
155
+ (mapcar 'parse-integer (ppcre:split "/" value))
156
+ (/ numerator denominator)))
157
+
158
+ (defmethod parse-value (value (type (eql 'age)) default)
159
+ "The method for Unicode \"age\" values which are converted to a
160
+ list of two integers, the major and minor version."
161
+ (destructuring-bind (major minor)
162
+ (mapcar 'parse-integer (ppcre:split "\\." value))
163
+ (list major minor)))
164
+
165
+ (defun parse-one-line (parts &optional types defaults)
166
+ "Parses one line of a Unicode data file and returns a list of Lisp
167
+ objects as determined by TYPES and DEFAULTS. It is assumed that the
168
+ line was already split into a list PARTS of individual strings, one
169
+ for each value/object. The elements of TYPES and DEFAULTS are
170
+ interpreted as by PARSE-VALUE except that we skip one element of PARTS
171
+ for each NIL in TYPES. The first element of PARTS is always
172
+ interpreted as a code point \(range), i.e. TYPES and DEFAULTS only
173
+ apply to the rest of PARTS.
174
+
175
+ Note that a call like \(PARSE-ONE-LINE PARTS) means that just the code
176
+ point part is parsed and returned."
177
+ (cons (parse-code-point (first parts))
178
+ (loop for part in (rest parts)
179
+ for type in types
180
+ for default in defaults
181
+ when type
182
+ collect (parse-value part type default))))
@@ -0,0 +1,90 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-unicode/cl-unicode.asd,v 1.22 2008/07/24 14:56:31 edi Exp $
3
+
4
+ ;;; Copyright (c) 2008, Dr. Edmund Weitz. All rights reserved.
5
+
6
+ ;;; Redistribution and use in source and binary forms, with or without
7
+ ;;; modification, are permitted provided that the following conditions
8
+ ;;; are met:
9
+
10
+ ;;; * Redistributions of source code must retain the above copyright
11
+ ;;; notice, this list of conditions and the following disclaimer.
12
+
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.
17
+
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.
29
+
30
+ (in-package :cl-user)
31
+
32
+ (defpackage :cl-unicode-asd
33
+ (:use :cl :asdf))
34
+
35
+ (in-package :cl-unicode-asd)
36
+
37
+ (defsystem :build-cl-unicode
38
+ :serial t
39
+ ;; FLEXI-STREAMS is only needed to /build/ CL-UNICODE
40
+ :depends-on (:flexi-streams)
41
+ :components ((:file "packages")
42
+ (:file "specials")
43
+ (:file "util")
44
+ (:module "build"
45
+ :serial t
46
+ :components ((:file "util")
47
+ (:file "char-info")
48
+ (:file "read")
49
+ (:file "dump")))))
50
+
51
+ (defclass generated-cl-source-file (cl-source-file)
52
+ ()
53
+ (:documentation "A subclass of CL-SOURCE-FILE for source files which
54
+ might have to be generated by loading the BUILD-CL-UNICODE system
55
+ first."))
56
+
57
+ (defmethod perform ((operation compile-op) (component generated-cl-source-file))
58
+ "A method which makes sure that the files of type
59
+ GENERATED-CL-SOURCE-FILE actually exist before we try to compile
60
+ them."
61
+ (unless (every 'probe-file (input-files operation component))
62
+ (operate 'load-op :build-cl-unicode))
63
+ (call-next-method))
64
+
65
+ (defsystem :cl-unicode
66
+ :version "0.1.1"
67
+ :serial t
68
+ :depends-on (:cl-ppcre)
69
+ :components ((:file "packages")
70
+ (:file "specials")
71
+ (:file "util")
72
+ (:file "conditions")
73
+ (:generated-cl-source-file "lists")
74
+ (:generated-cl-source-file "hash-tables")
75
+ (:file "api")
76
+ (:generated-cl-source-file "methods")
77
+ (:file "test-functions")
78
+ (:file "derived")
79
+ (:file "alias")))
80
+
81
+ (defsystem :cl-unicode-test
82
+ :depends-on (:cl-unicode)
83
+ :components ((:module "test"
84
+ :serial t
85
+ :components ((:file "packages")
86
+ (:file "tests")))))
87
+
88
+ (defmethod perform ((o test-op) (c (eql (find-system :cl-unicode))))
89
+ (operate 'load-op :cl-unicode-test)
90
+ (funcall (intern (symbol-name :run-all-tests) (find-package :cl-unicode-test))))
@@ -0,0 +1,54 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-UNICODE; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-unicode/conditions.lisp,v 1.3 2008/07/22 02:42:13 edi Exp $
3
+
4
+ ;;; Copyright (c) 2008, Dr. Edmund Weitz. All rights reserved.
5
+
6
+ ;;; Redistribution and use in source and binary forms, with or without
7
+ ;;; modification, are permitted provided that the following conditions
8
+ ;;; are met:
9
+
10
+ ;;; * Redistributions of source code must retain the above copyright
11
+ ;;; notice, this list of conditions and the following disclaimer.
12
+
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.
17
+
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.
29
+
30
+ (in-package :cl-unicode)
31
+
32
+ (define-condition unicode-error (error)
33
+ ()
34
+ (:documentation "All errors signalled by CL-UNICODE are of this type."))
35
+
36
+ (define-condition simple-unicode-error (unicode-error simple-condition)
37
+ ()
38
+ (:documentation "A subclass of UNICODE-ERROR where the caller can
39
+ supply a format control and format arguments."))
40
+
41
+ (defun signal-unicode-error (format-control &rest format-arguments)
42
+ "Utility function to signal conditions of type SIMPLE-UNICODE-ERROR."
43
+ (error 'simple-unicode-error
44
+ :format-control format-control
45
+ :format-arguments format-arguments))
46
+
47
+ (define-condition character-not-found (unicode-error reader-error)
48
+ ((name :initarg :name))
49
+ (:report (lambda (condition stream)
50
+ (with-slots (name)
51
+ condition
52
+ (format stream "There is no character named ~S." name))))
53
+ (:documentation "Error signalled by UNICODE-NAME-READER if a
54
+ character wasn't found."))
@@ -0,0 +1,120 @@
1
+ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-UNICODE; Base: 10 -*-
2
+ ;;; $Header: /usr/local/cvsrep/cl-unicode/derived.lisp,v 1.14 2008/07/20 21:01:08 edi Exp $
3
+
4
+ ;;; Copyright (c) 2008, Dr. Edmund Weitz. All rights reserved.
5
+
6
+ ;;; Redistribution and use in source and binary forms, with or without
7
+ ;;; modification, are permitted provided that the following conditions
8
+ ;;; are met:
9
+
10
+ ;;; * Redistributions of source code must retain the above copyright
11
+ ;;; notice, this list of conditions and the following disclaimer.
12
+
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.
17
+
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.
29
+
30
+ (in-package :cl-unicode)
31
+
32
+ (defconstant +xid-difference+
33
+ ;; the usual mumbo jumbo for SBCL...
34
+ (if (boundp '+xid-difference+)
35
+ (symbol-value '+xid-difference+)
36
+ '(#x37a
37
+ (#x309b . #x309c)
38
+ (#xfc5e . #xfc63)
39
+ (#xfdfa . #xfdfb)
40
+ #xfe70
41
+ #xfe72
42
+ #xfe74
43
+ #xfe76
44
+ #xfe78
45
+ #xfe7a
46
+ #xfe7c
47
+ #xfe7e)))
48
+
49
+ (defvar *derived-map*
50
+ `(("Any")
51
+ ("LC" "Lu" "Ll" "Lt")
52
+ ("L" "LC" "Lm" "Lo")
53
+ ("M" "Mn" "Mc" "Me")
54
+ ("N" "Nd" "Nl" "No")
55
+ ("P" "Pc" "Pd" "Ps" "Pe" "Pi" "Pf" "Po")
56
+ ("S" "Sm" "Sc" "Sk" "So")
57
+ ("Z" "Zs" "Zl" "Zp")
58
+ ("C" "Cc" "Cf" "Cs" "Co" "Cn")
59
+ ("Math" "Sm" "OtherMath")
60
+ ("Alphabetic" "L" "Nl" "OtherAlphabetic")
61
+ ("Lowercase" "Ll" "OtherLowercase")
62
+ ("Uppercase" "Lu" "OtherUppercase")
63
+ ("GraphemeExtend" "Me" "Mn" "OtherGraphemeExtend")
64
+ ("GraphemeBase" ("C" "Zl" "Zp" "GraphemeExtend"))
65
+ ("IDStart" "L" "Nl" "OtherIDStart" ("PatternSyntax" "PatternWhiteSpace"))
66
+ ("IDContinue" "IDStart" "Mn" "Mc" "Nd" "Pc" "OtherIDContinue" ("PatternSyntax" "PatternWhiteSpace"))
67
+ ("XIDStart" "IDStart" (,@+xid-difference+ #xe33 #xeb3 (#xff9e . #xff9f)))
68
+ ("XIDContinue" "IDContinue" ,+xid-difference+)
69
+ ("DefaultIgnorableCodePoint" "OtherDefaultIgnorableCodePoint" "Cf" "VariationSelector"
70
+ ("WhiteSpace" (#xfff9 . #xfffb) (#x600 . #x603) #x6dd #x70f))))
71
+
72
+ ;; todo: xid_start, xid_continue,
73
+
74
+ (defun build-derived-test-function (property-designators)
75
+ (labels ((build-test-function (designator)
76
+ (etypecase designator
77
+ (string
78
+ (let ((test-function (gethash (gethash designator *property-map*) *property-tests*)))
79
+ (assert test-function (designator)
80
+ "Unknown property name ~S." designator)
81
+ test-function))
82
+ (integer
83
+ (lambda (c)
84
+ (= (ensure-code-point c) designator)))
85
+ (cons
86
+ (let ((from (car designator))
87
+ (to (car designator)))
88
+ (assert (and (typep from 'integer) (typep to 'integer)) (designator)
89
+ "Car and cdr of ~S must both be integers." designator)
90
+ (lambda (c)
91
+ (<= from (ensure-code-point c) to))))))
92
+ (collect-test-functions (designators)
93
+ (loop for designator in designators
94
+ collect (build-test-function designator))))
95
+ (let ((positive-test-functions
96
+ (collect-test-functions (remove-if-not 'atom property-designators)))
97
+ (negative-test-functions
98
+ (collect-test-functions (find-if-not 'atom property-designators))))
99
+ (cond (negative-test-functions
100
+ (lambda (c)
101
+ (and (or (null positive-test-functions)
102
+ (loop for test-function in positive-test-functions
103
+ thereis (funcall (the function test-function) c)))
104
+ (not (loop for test-function in negative-test-functions
105
+ thereis (funcall (the function test-function) c))))))
106
+ (t
107
+ (lambda (c)
108
+ (or (null positive-test-functions)
109
+ (loop for test-function in positive-test-functions
110
+ thereis (funcall (the function test-function) c)))))))))
111
+
112
+ (defun build-derived-test-functions ()
113
+ (loop for (name . property-names) in *derived-map*
114
+ for symbol = (register-property-symbol name) do
115
+ (assert (null (gethash symbol *property-tests*)) (name)
116
+ "There is already a property named ~S." name)
117
+ (setf (gethash symbol *property-tests*)
118
+ (build-derived-test-function property-names)
119
+ (gethash name *property-map*)
120
+ symbol)))