PPPredicateSequenceParser.st
changeset 46 da93c6223037
parent 4 90de244a7fa2
child 178 992088772705
equal deleted inserted replaced
45:ca9fad0faa21 46:da93c6223037
     5 	classVariableNames:''
     5 	classVariableNames:''
     6 	poolDictionaries:''
     6 	poolDictionaries:''
     7 	category:'PetitParser-Parsers'
     7 	category:'PetitParser-Parsers'
     8 !
     8 !
     9 
     9 
    10 PPPredicateSequenceParser comment:'A parser that accepts if a given predicate on an arbitrary number of elements of the input sequence holds.
       
    11 Instance Variables:
       
    12 	size    <Integer>       The number of elements to consume.'
       
    13 !
       
    14 
       
    15 
    10 
    16 !PPPredicateSequenceParser class methodsFor:'instance creation'!
    11 !PPPredicateSequenceParser class methodsFor:'instance creation'!
    17 
    12 
    18 on: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    13 on: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger 
    19 	^ self new initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    14 	^ self new initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    20 !
    15 !
    21 
    16 
    22 on: aBlock message: aString size: anInteger
    17 on: aBlock message: aString size: anInteger
    23 	^ self on: aBlock message: aString negated: [ :each | (aBlock value: each) not ] message: 'no ' , aString size: anInteger
    18 	^ self on: aBlock message: aString negated: [ :each | (aBlock value: each) not ] message: 'no ' , aString size: anInteger 
    24 ! !
    19 ! !
    25 
    20 
    26 !PPPredicateSequenceParser methodsFor:'accessing'!
    21 !PPPredicateSequenceParser methodsFor:'accessing'!
    27 
    22 
    28 size
    23 size
    36 initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    31 initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    37 	predicate := aBlock.
    32 	predicate := aBlock.
    38 	predicateMessage := aString.
    33 	predicateMessage := aString.
    39 	negated := aNegatedBlock.
    34 	negated := aNegatedBlock.
    40 	negatedMessage := aNegatedString.
    35 	negatedMessage := aNegatedString.
    41 	size := anInteger
    36 	size := anInteger 
    42 ! !
    37 ! !
    43 
    38 
    44 !PPPredicateSequenceParser methodsFor:'operators'!
    39 !PPPredicateSequenceParser methodsFor:'operators'!
    45 
    40 
    46 negate
    41 negate
    47 	"Answer a parser that is the negation of the receiving predicate parser."
    42 	"Answer a parser that is the negation of the receiving predicate parser."
    48 
    43 	
    49 	^ self class
    44 	^ self class 
    50 		on: negated message: negatedMessage
    45 		on: negated message: negatedMessage
    51 		negated: predicate message: predicateMessage
    46 		negated: predicate message: predicateMessage
    52 		size: size
    47 		size: size
    53 ! !
    48 ! !
    54 
    49 
    64 	^ PPFailure message: predicateMessage at: aStream position
    59 	^ PPFailure message: predicateMessage at: aStream position
    65 ! !
    60 ! !
    66 
    61 
    67 !PPPredicateSequenceParser class methodsFor:'documentation'!
    62 !PPPredicateSequenceParser class methodsFor:'documentation'!
    68 
    63 
       
    64 version
       
    65     ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPredicateSequenceParser.st,v 1.3 2012-05-04 22:08:28 vrany Exp $'
       
    66 !
       
    67 
       
    68 version_CVS
       
    69     ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPredicateSequenceParser.st,v 1.3 2012-05-04 22:08:28 vrany Exp $'
       
    70 !
       
    71 
    69 version_SVN
    72 version_SVN
    70     ^ '$Id: PPPredicateSequenceParser.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
    73     ^ '§Id: PPPredicateSequenceParser.st 2 2010-12-17 18:44:23Z vranyj1 §'
    71 ! !
    74 ! !