PPPredicateSequenceParser.st
changeset 4 90de244a7fa2
parent 0 739fe9b7253e
child 46 da93c6223037
equal deleted inserted replaced
3:e1b11f74e142 4:90de244a7fa2
     1 "{ Package: 'squeak:petitparser' }"
     1 "{ Package: 'stx:goodies/petitparser' }"
     2 
     2 
     3 PPPredicateParser subclass:#PPPredicateSequenceParser
     3 PPPredicateParser subclass:#PPPredicateSequenceParser
     4 	instanceVariableNames:'size'
     4 	instanceVariableNames:'size'
     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.
    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:
    11 Instance Variables:
    12 	size	<Integer>	The number of elements to consume.'
    12 	size    <Integer>       The number of elements to consume.'
    13 !
    13 !
    14 
    14 
    15 
    15 
    16 !PPPredicateSequenceParser class methodsFor:'instance creation'!
    16 !PPPredicateSequenceParser class methodsFor:'instance creation'!
    17 
    17 
    18 on: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger 
    18 on: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    19 	^ self new initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    19 	^ self new initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    20 !
    20 !
    21 
    21 
    22 on: aBlock message: aString size: anInteger
    22 on: aBlock message: aString size: anInteger
    23 	^ self on: aBlock message: aString negated: [ :each | (aBlock value: each) not ] message: 'no ' , aString size: anInteger 
    23 	^ self on: aBlock message: aString negated: [ :each | (aBlock value: each) not ] message: 'no ' , aString size: anInteger
    24 ! !
    24 ! !
    25 
    25 
    26 !PPPredicateSequenceParser methodsFor:'accessing'!
    26 !PPPredicateSequenceParser methodsFor:'accessing'!
    27 
    27 
    28 size
    28 size
    36 initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    36 initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
    37 	predicate := aBlock.
    37 	predicate := aBlock.
    38 	predicateMessage := aString.
    38 	predicateMessage := aString.
    39 	negated := aNegatedBlock.
    39 	negated := aNegatedBlock.
    40 	negatedMessage := aNegatedString.
    40 	negatedMessage := aNegatedString.
    41 	size := anInteger 
    41 	size := anInteger
    42 ! !
    42 ! !
    43 
    43 
    44 !PPPredicateSequenceParser methodsFor:'operators'!
    44 !PPPredicateSequenceParser methodsFor:'operators'!
    45 
    45 
    46 negate
    46 negate
    47 	"Answer a parser that is the negation of the receiving predicate parser."
    47 	"Answer a parser that is the negation of the receiving predicate parser."
    48 	
    48 
    49 	^ self class 
    49 	^ self class
    50 		on: negated message: negatedMessage
    50 		on: negated message: negatedMessage
    51 		negated: predicate message: predicateMessage
    51 		negated: predicate message: predicateMessage
    52 		size: size
    52 		size: size
    53 ! !
    53 ! !
    54 
    54 
    65 ! !
    65 ! !
    66 
    66 
    67 !PPPredicateSequenceParser class methodsFor:'documentation'!
    67 !PPPredicateSequenceParser class methodsFor:'documentation'!
    68 
    68 
    69 version_SVN
    69 version_SVN
    70     ^ '$Id: PPPredicateSequenceParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
    70     ^ '$Id: PPPredicateSequenceParser.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
    71 ! !
    71 ! !