PPCharSetPredicate.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PPCharSetPredicate.st	Thu Aug 18 20:56:17 2011 +0200
@@ -0,0 +1,43 @@
+"{ Package: 'squeak:petitparser' }"
+
+Object subclass:#PPCharSetPredicate
+	instanceVariableNames:'block classification'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitParser-Tools'
+!
+
+
+!PPCharSetPredicate class methodsFor:'instance creation'!
+
+on: aBlock
+	^ self basicNew initializeOn: aBlock
+! !
+
+!PPCharSetPredicate methodsFor:'evaluating'!
+
+value: aCharacter
+	| index |
+	index := aCharacter asInteger.
+	index == 0
+		ifTrue: [ ^ block value: aCharacter ].
+	index > 255
+		ifTrue: [ ^ block value: aCharacter ].
+	^ classification at: index
+! !
+
+!PPCharSetPredicate methodsFor:'initialization'!
+
+initializeOn: aBlock
+	block := aBlock.
+	classification := Array new: 255.
+	1 to: classification size do: [ :index |
+		classification at: index put: (block
+			value: (Character value: index)) ]
+! !
+
+!PPCharSetPredicate class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id: PPCharSetPredicate.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
+! !