4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"
|
0
|
2 |
|
|
3 |
PPListParser subclass:#PPSequenceParser
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitParser-Parsers'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPSequenceParser methodsFor:'operations'!
|
|
12 |
|
|
13 |
, aRule
|
|
14 |
^ self copyWith: aRule
|
|
15 |
!
|
|
16 |
|
|
17 |
map: aBlock
|
|
18 |
^ self ==> [ :nodes | aBlock valueWithArguments: nodes ]
|
|
19 |
!
|
|
20 |
|
|
21 |
permutation: anArrayOfIntegers
|
|
22 |
"Answer a permutation of the receivers sequence."
|
12
|
23 |
|
0
|
24 |
anArrayOfIntegers do: [ :index |
|
|
25 |
(index isInteger and: [ index between: 1 and: parsers size ])
|
|
26 |
ifFalse: [ self error: 'Invalid permutation index: ' , index printString ] ].
|
|
27 |
^ self ==> [ :nodes | anArrayOfIntegers collect: [ :index | nodes at: index ] ]
|
|
28 |
! !
|
|
29 |
|
|
30 |
!PPSequenceParser methodsFor:'parsing'!
|
|
31 |
|
|
32 |
parseOn: aStream
|
|
33 |
"This is optimized code that avoids unnecessary block activations, do not change."
|
12
|
34 |
|
0
|
35 |
| start elements element |
|
|
36 |
start := aStream position.
|
|
37 |
elements := Array new: parsers size.
|
|
38 |
1 to: parsers size do: [ :index |
|
12
|
39 |
element := (parsers at: index)
|
0
|
40 |
parseOn: aStream.
|
|
41 |
element isPetitFailure ifTrue: [
|
|
42 |
aStream position: start.
|
|
43 |
^ element ].
|
|
44 |
elements at: index put: element ].
|
|
45 |
^ elements
|
|
46 |
! !
|
|
47 |
|
|
48 |
!PPSequenceParser class methodsFor:'documentation'!
|
|
49 |
|
12
|
50 |
version
|
|
51 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPSequenceParser.st,v 1.3 2012-05-04 21:59:14 vrany Exp $'
|
|
52 |
!
|
|
53 |
|
|
54 |
version_CVS
|
|
55 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPSequenceParser.st,v 1.3 2012-05-04 21:59:14 vrany Exp $'
|
|
56 |
!
|
|
57 |
|
0
|
58 |
version_SVN
|
12
|
59 |
^ '§Id: PPSequenceParser.st 2 2010-12-17 18:44:23Z vranyj1 §'
|
0
|
60 |
! !
|