compiler/PEGFsaPredicateTransition.st
changeset 515 b5316ef15274
child 524 f6f68d32de73
equal deleted inserted replaced
502:1e45d3c96ec5 515:b5316ef15274
       
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PEGFsaTransition subclass:#PEGFsaPredicateTransition
       
     6 	instanceVariableNames:'predicate'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitCompiler-FSA'
       
    10 !
       
    11 
       
    12 !PEGFsaPredicateTransition methodsFor:'accessing'!
       
    13 
       
    14 predicate
       
    15     ^ predicate
       
    16 !
       
    17 
       
    18 predicate: anObject
       
    19     predicate := anObject
       
    20 ! !
       
    21 
       
    22 !PEGFsaPredicateTransition methodsFor:'comparing'!
       
    23 
       
    24 equals: anotherTransition
       
    25     (super equals: anotherTransition) ifFalse: [ ^ false ].
       
    26     (predicate asString = anotherTransition predicate asString) ifFalse: [ ^ false ].
       
    27 
       
    28     ^ true
       
    29 ! !
       
    30 
       
    31 !PEGFsaPredicateTransition methodsFor:'gt'!
       
    32 
       
    33 gtName
       
    34     | gtName |
       
    35     gtName := self predicate asString.
       
    36     priority < 0 ifTrue: [ gtName := gtName, ',', priority asString ].
       
    37     ^ gtName
       
    38 ! !
       
    39 
       
    40 !PEGFsaPredicateTransition methodsFor:'set operations'!
       
    41 
       
    42 intersection: transition
       
    43     | intersection |
       
    44     intersection := Array new: 255 withAll: false.
       
    45     ^ intersection
       
    46 ! !
       
    47 
       
    48 !PEGFsaPredicateTransition methodsFor:'testing'!
       
    49 
       
    50 accepts: character
       
    51     self assert: character isCharacter.
       
    52     ^ self acceptsCodePoint: character codePoint
       
    53 !
       
    54 
       
    55 acceptsCodePoint: codePoint
       
    56     self assert: codePoint isInteger.
       
    57     ^ predicate value: codePoint
       
    58 !
       
    59 
       
    60 isCharacterTransition
       
    61     ^ false
       
    62 !
       
    63 
       
    64 isEOF
       
    65     ^ false
       
    66 !
       
    67 
       
    68 isPredicateTransition
       
    69     ^ true
       
    70 !
       
    71 
       
    72 overlapsWith: transition
       
    73     ^ false
       
    74 ! !
       
    75