4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"
|
0
|
2 |
|
|
3 |
ReadStream subclass:#PPStream
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitParser-Core'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPStream methodsFor:'accessing'!
|
|
12 |
|
42
|
13 |
next: anInteger
|
0
|
14 |
"Answer up to anInteger elements of my collection. Overridden for efficiency."
|
|
15 |
|
|
16 |
| answer endPosition |
|
|
17 |
endPosition := position + anInteger min: readLimit.
|
|
18 |
answer := collection copyFrom: position + 1 to: endPosition.
|
|
19 |
position := endPosition.
|
|
20 |
^ answer
|
|
21 |
!
|
|
22 |
|
|
23 |
peek
|
|
24 |
"An improved version of peek, that is slightly faster than the built in version."
|
|
25 |
|
|
26 |
^ self atEnd ifFalse: [ collection at: position + 1 ]
|
|
27 |
!
|
|
28 |
|
|
29 |
position: anInteger
|
|
30 |
"The receiver does not check for invalid arguments passed to this method, as it is solely used with valid indexes for backtracking."
|
|
31 |
|
|
32 |
position := anInteger
|
|
33 |
!
|
|
34 |
|
|
35 |
uncheckedPeek
|
|
36 |
"An unchecked version of peek that throws an error if we try to peek over the end of the stream, even faster than #peek."
|
|
37 |
|
|
38 |
^ collection at: position + 1
|
|
39 |
! !
|
|
40 |
|
|
41 |
!PPStream methodsFor:'converting'!
|
|
42 |
|
|
43 |
asPetitStream
|
|
44 |
^ self
|
|
45 |
! !
|
|
46 |
|
|
47 |
!PPStream methodsFor:'printing'!
|
|
48 |
|
|
49 |
printOn: aStream
|
|
50 |
collection isString
|
|
51 |
ifFalse: [ ^ super printOn: aStream ].
|
|
52 |
aStream
|
|
53 |
nextPutAll: (collection copyFrom: 1 to: position);
|
|
54 |
nextPutAll: '·';
|
|
55 |
nextPutAll: (collection copyFrom: position + 1 to: readLimit)
|
|
56 |
! !
|
|
57 |
|
|
58 |
!PPStream class methodsFor:'documentation'!
|
|
59 |
|
42
|
60 |
version
|
|
61 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPStream.st,v 1.3 2012-05-04 22:06:11 vrany Exp $'
|
|
62 |
!
|
|
63 |
|
|
64 |
version_CVS
|
|
65 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPStream.st,v 1.3 2012-05-04 22:06:11 vrany Exp $'
|
|
66 |
!
|
|
67 |
|
0
|
68 |
version_SVN
|
42
|
69 |
^ '§Id: PPStream.st 2 2010-12-17 18:44:23Z vranyj1 §'
|
0
|
70 |
! !
|