21 ^ self ==> [ :nodes | aBlock valueWithArguments: nodes ] |
21 ^ self ==> [ :nodes | aBlock valueWithArguments: nodes ] |
22 ! |
22 ! |
23 |
23 |
24 permutation: anArrayOfIntegers |
24 permutation: anArrayOfIntegers |
25 "Answer a permutation of the receivers sequence." |
25 "Answer a permutation of the receivers sequence." |
26 |
26 |
27 anArrayOfIntegers do: [ :index | |
27 anArrayOfIntegers do: [ :index | |
28 (index isInteger and: [ index between: 1 and: parsers size ]) |
28 (index isInteger and: [ index between: 1 and: parsers size ]) |
29 ifFalse: [ self error: 'Invalid permutation index: ' , index printString ] ]. |
29 ifFalse: [ self error: 'Invalid permutation index: ' , index printString ] ]. |
30 ^ self ==> [ :nodes | anArrayOfIntegers collect: [ :index | nodes at: index ] ] |
30 ^ self ==> [ :nodes | anArrayOfIntegers collect: [ :index | nodes at: index ] ] |
31 ! ! |
31 ! ! |
32 |
32 |
33 !PPSequenceParser methodsFor:'parsing'! |
33 !PPSequenceParser methodsFor:'parsing'! |
34 |
34 |
35 parseOn: aStream |
35 parseOn: aStream |
36 "This is optimized code that avoids unnecessary block activations, do not change." |
36 "This is optimized code that avoids unnecessary block activations, do not change." |
37 |
37 |
38 | start elements element | |
38 | start elements element | |
39 start := aStream position. |
39 start := aStream position. |
40 elements := Array new: parsers size. |
40 elements := Array new: parsers size. |
41 1 to: parsers size do: [ :index | |
41 1 to: parsers size do: [ :index | |
42 element := (parsers at: index) |
42 element := (parsers at: index) |
43 parseOn: aStream. |
43 parseOn: aStream. |
44 element isPetitFailure ifTrue: [ |
44 element isPetitFailure ifTrue: [ |
45 aStream position: start. |
45 aStream position: start. |
46 ^ element ]. |
46 ^ element ]. |
47 elements at: index put: element ]. |
47 elements at: index put: element ]. |