4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"
|
0
|
2 |
|
|
3 |
PPPredicateParser subclass:#PPPredicateSequenceParser
|
|
4 |
instanceVariableNames:'size'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitParser-Parsers'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPPredicateSequenceParser class methodsFor:'instance creation'!
|
|
12 |
|
46
|
13 |
on: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
|
0
|
14 |
^ self new initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
|
|
15 |
!
|
|
16 |
|
|
17 |
on: aBlock message: aString size: anInteger
|
46
|
18 |
^ self on: aBlock message: aString negated: [ :each | (aBlock value: each) not ] message: 'no ' , aString size: anInteger
|
0
|
19 |
! !
|
|
20 |
|
178
|
21 |
!PPPredicateSequenceParser methodsFor:'*petitanalyzer-matching'!
|
|
22 |
|
|
23 |
match: aParser inContext: aDictionary seen: anIdentitySet
|
|
24 |
^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self size = aParser size ]
|
|
25 |
! !
|
|
26 |
|
0
|
27 |
!PPPredicateSequenceParser methodsFor:'accessing'!
|
|
28 |
|
|
29 |
size
|
|
30 |
"Answer the sequence size of the receiver."
|
|
31 |
|
|
32 |
^ size
|
|
33 |
! !
|
|
34 |
|
|
35 |
!PPPredicateSequenceParser methodsFor:'initialization'!
|
|
36 |
|
|
37 |
initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger
|
|
38 |
predicate := aBlock.
|
|
39 |
predicateMessage := aString.
|
|
40 |
negated := aNegatedBlock.
|
|
41 |
negatedMessage := aNegatedString.
|
46
|
42 |
size := anInteger
|
0
|
43 |
! !
|
|
44 |
|
|
45 |
!PPPredicateSequenceParser methodsFor:'operators'!
|
|
46 |
|
|
47 |
negate
|
|
48 |
"Answer a parser that is the negation of the receiving predicate parser."
|
46
|
49 |
|
|
50 |
^ self class
|
0
|
51 |
on: negated message: negatedMessage
|
|
52 |
negated: predicate message: predicateMessage
|
|
53 |
size: size
|
|
54 |
! !
|
|
55 |
|
|
56 |
!PPPredicateSequenceParser methodsFor:'parsing'!
|
|
57 |
|
|
58 |
parseOn: aStream
|
|
59 |
| position result |
|
|
60 |
position := aStream position.
|
|
61 |
result := aStream next: size.
|
|
62 |
(result size = size and: [ predicate value: result ])
|
|
63 |
ifTrue: [ ^ result ].
|
|
64 |
aStream position: position.
|
|
65 |
^ PPFailure message: predicateMessage at: aStream position
|
|
66 |
! !
|
|
67 |
|
|
68 |
!PPPredicateSequenceParser class methodsFor:'documentation'!
|
|
69 |
|
46
|
70 |
version
|
178
|
71 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPredicateSequenceParser.st,v 1.4 2014-03-04 14:33:22 cg Exp $'
|
46
|
72 |
!
|
|
73 |
|
|
74 |
version_CVS
|
178
|
75 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPredicateSequenceParser.st,v 1.4 2014-03-04 14:33:22 cg Exp $'
|
46
|
76 |
!
|
|
77 |
|
0
|
78 |
version_SVN
|
178
|
79 |
^ '$Id: PPPredicateSequenceParser.st,v 1.4 2014-03-04 14:33:22 cg Exp $'
|
0
|
80 |
! !
|
178
|
81 |
|