equal
deleted
inserted
replaced
1 "{ Package: 'squeak:petitparser' }" |
1 "{ Package: 'stx:goodies/petitparser' }" |
2 |
2 |
3 Object subclass:#PPToken |
3 Object subclass:#PPToken |
4 instanceVariableNames:'collection start stop' |
4 instanceVariableNames:'collection start stop' |
5 classVariableNames:'' |
5 classVariableNames:'' |
6 poolDictionaries:'' |
6 poolDictionaries:'' |
7 category:'PetitParser-Core' |
7 category:'PetitParser-Core' |
8 ! |
8 ! |
9 |
9 |
10 PPToken comment:'PPToken represents a parsed part of the input stream. Contrary to a simple String it remembers where it came from, the original collection and its start and stop position. |
10 PPToken comment:'PPToken represents a parsed part of the input stream. Contrary to a simple String it remembers where it came from, the original collection and its start and stop position. |
11 Instance Variables: |
11 Instance Variables: |
12 collection <SequenceableCollection> The collection this token comes from. |
12 collection <SequenceableCollection> The collection this token comes from. |
13 start <Integer> The start position in the collection. |
13 start <Integer> The start position in the collection. |
14 stop <Integer> The stop position in the collection.' |
14 stop <Integer> The stop position in the collection.' |
15 ! |
15 ! |
16 |
16 |
17 |
17 |
18 !PPToken class methodsFor:'instance creation'! |
18 !PPToken class methodsFor:'instance creation'! |
19 |
19 |
24 on: aSequenceableCollection |
24 on: aSequenceableCollection |
25 ^ self on: aSequenceableCollection start: 1 stop: aSequenceableCollection size |
25 ^ self on: aSequenceableCollection start: 1 stop: aSequenceableCollection size |
26 ! |
26 ! |
27 |
27 |
28 on: aSequenceableCollection start: aStartInteger stop: aStopInteger |
28 on: aSequenceableCollection start: aStartInteger stop: aStopInteger |
29 ^ self basicNew |
29 ^ self basicNew |
30 initializeOn: aSequenceableCollection |
30 initializeOn: aSequenceableCollection |
31 start: aStartInteger stop: aStopInteger |
31 start: aStartInteger stop: aStopInteger |
32 ! ! |
32 ! ! |
33 |
33 |
34 !PPToken methodsFor:'accessing'! |
34 !PPToken methodsFor:'accessing'! |
51 ^ start |
51 ^ start |
52 ! |
52 ! |
53 |
53 |
54 stop |
54 stop |
55 "Answer the stop position of this token in the underlying collection." |
55 "Answer the stop position of this token in the underlying collection." |
56 |
56 |
57 ^ stop |
57 ^ stop |
58 ! |
58 ! |
59 |
59 |
60 value |
60 value |
61 "Answer the contents of this token." |
61 "Answer the contents of this token." |
105 |
105 |
106 !PPToken methodsFor:'querying'! |
106 !PPToken methodsFor:'querying'! |
107 |
107 |
108 column |
108 column |
109 "Answer the column number of this token in the underlying collection." |
109 "Answer the column number of this token in the underlying collection." |
110 |
110 |
111 | position | |
111 | position | |
112 position := 0. |
112 position := 0. |
113 (self newline , [ :stream | |
113 (self newline , [ :stream | |
114 start <= stream position |
114 start <= stream position |
115 ifTrue: [ ^ start - position ]. |
115 ifTrue: [ ^ start - position ]. |
119 ^ start - position |
119 ^ start - position |
120 ! |
120 ! |
121 |
121 |
122 line |
122 line |
123 "Answer the line number of this token in the underlying collection." |
123 "Answer the line number of this token in the underlying collection." |
124 |
124 |
125 | line | |
125 | line | |
126 line := 1. |
126 line := 1. |
127 (self newline , [ :stream | |
127 (self newline , [ :stream | |
128 start <= stream position |
128 start <= stream position |
129 ifTrue: [ ^ line ]. |
129 ifTrue: [ ^ line ]. |
134 ! ! |
134 ! ! |
135 |
135 |
136 !PPToken class methodsFor:'documentation'! |
136 !PPToken class methodsFor:'documentation'! |
137 |
137 |
138 version_SVN |
138 version_SVN |
139 ^ '$Id: PPToken.st,v 1.1 2011-08-18 18:56:17 cg Exp $' |
139 ^ '$Id: PPToken.st,v 1.2 2012-01-13 11:22:50 cg Exp $' |
140 ! ! |
140 ! ! |