author | Jan Vrany <jan.vrany@labware.com> |
Wed, 10 Jun 2020 21:33:27 +0100 | |
changeset 650 | 4c6ed0a28d18 |
parent 377 | 6112a403a52d |
permissions | -rw-r--r-- |
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 |
|
0 | 22 |
!PPPredicateSequenceParser methodsFor:'accessing'! |
23 |
||
24 |
size |
|
25 |
"Answer the sequence size of the receiver." |
|
26 |
||
27 |
^ size |
|
28 |
! ! |
|
29 |
||
30 |
!PPPredicateSequenceParser methodsFor:'initialization'! |
|
31 |
||
32 |
initializeOn: aBlock message: aString negated: aNegatedBlock message: aNegatedString size: anInteger |
|
33 |
predicate := aBlock. |
|
34 |
predicateMessage := aString. |
|
35 |
negated := aNegatedBlock. |
|
36 |
negatedMessage := aNegatedString. |
|
46 | 37 |
size := anInteger |
0 | 38 |
! ! |
39 |
||
40 |
!PPPredicateSequenceParser methodsFor:'operators'! |
|
41 |
||
42 |
negate |
|
43 |
"Answer a parser that is the negation of the receiving predicate parser." |
|
46 | 44 |
|
45 |
^ self class |
|
0 | 46 |
on: negated message: negatedMessage |
47 |
negated: predicate message: predicateMessage |
|
48 |
size: size |
|
49 |
! ! |
|
50 |
||
51 |
!PPPredicateSequenceParser methodsFor:'parsing'! |
|
52 |
||
377
6112a403a52d
Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
53 |
parseOn: aPPContext |
6112a403a52d
Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
54 |
| memento result | |
6112a403a52d
Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
55 |
memento := aPPContext remember. |
6112a403a52d
Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
56 |
result := aPPContext stream next: size. |
0 | 57 |
(result size = size and: [ predicate value: result ]) |
58 |
ifTrue: [ ^ result ]. |
|
377
6112a403a52d
Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
59 |
aPPContext restore: memento. |
6112a403a52d
Updated to latest version from Moose repository.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
178
diff
changeset
|
60 |
^ PPFailure message: predicateMessage context: aPPContext |
0 | 61 |
! ! |
62 |
||
63 |
!PPPredicateSequenceParser class methodsFor:'documentation'! |
|
64 |
||
46 | 65 |
version |
178 | 66 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPredicateSequenceParser.st,v 1.4 2014-03-04 14:33:22 cg Exp $' |
46 | 67 |
! |
68 |
||
69 |
version_CVS |
|
178 | 70 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPPredicateSequenceParser.st,v 1.4 2014-03-04 14:33:22 cg Exp $' |
46 | 71 |
! |
72 |
||
0 | 73 |
version_SVN |
178 | 74 |
^ '$Id: PPPredicateSequenceParser.st,v 1.4 2014-03-04 14:33:22 cg Exp $' |
0 | 75 |
! ! |
178 | 76 |