compiler/PEGFsaPredicateTransition.st
changeset 515 b5316ef15274
child 524 f6f68d32de73
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PEGFsaPredicateTransition.st	Mon Aug 17 12:13:16 2015 +0100
@@ -0,0 +1,75 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+"{ NameSpace: Smalltalk }"
+
+PEGFsaTransition subclass:#PEGFsaPredicateTransition
+	instanceVariableNames:'predicate'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-FSA'
+!
+
+!PEGFsaPredicateTransition methodsFor:'accessing'!
+
+predicate
+    ^ predicate
+!
+
+predicate: anObject
+    predicate := anObject
+! !
+
+!PEGFsaPredicateTransition methodsFor:'comparing'!
+
+equals: anotherTransition
+    (super equals: anotherTransition) ifFalse: [ ^ false ].
+    (predicate asString = anotherTransition predicate asString) ifFalse: [ ^ false ].
+
+    ^ true
+! !
+
+!PEGFsaPredicateTransition methodsFor:'gt'!
+
+gtName
+    | gtName |
+    gtName := self predicate asString.
+    priority < 0 ifTrue: [ gtName := gtName, ',', priority asString ].
+    ^ gtName
+! !
+
+!PEGFsaPredicateTransition methodsFor:'set operations'!
+
+intersection: transition
+    | intersection |
+    intersection := Array new: 255 withAll: false.
+    ^ intersection
+! !
+
+!PEGFsaPredicateTransition methodsFor:'testing'!
+
+accepts: character
+    self assert: character isCharacter.
+    ^ self acceptsCodePoint: character codePoint
+!
+
+acceptsCodePoint: codePoint
+    self assert: codePoint isInteger.
+    ^ predicate value: codePoint
+!
+
+isCharacterTransition
+    ^ false
+!
+
+isEOF
+    ^ false
+!
+
+isPredicateTransition
+    ^ true
+!
+
+overlapsWith: transition
+    ^ false
+! !
+