10021
|
1 |
"
|
10068
|
2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
3 |
All Rights Reserved
|
10021
|
4 |
|
10068
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
10021
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
|
28 |
Magnitude subclass:#SyntaxElement
|
|
29 |
instanceVariableNames:'start stop type value next prev'
|
|
30 |
classVariableNames:''
|
|
31 |
poolDictionaries:''
|
|
32 |
category:'Interface-CodeView-Syntax'
|
|
33 |
!
|
|
34 |
|
|
35 |
!SyntaxElement class methodsFor:'documentation'!
|
|
36 |
|
|
37 |
copyright
|
|
38 |
"
|
10068
|
39 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
40 |
All Rights Reserved
|
|
41 |
|
|
42 |
Permission is hereby granted, free of charge, to any person
|
|
43 |
obtaining a copy of this software and associated documentation
|
|
44 |
files (the 'Software'), to deal in the Software without
|
|
45 |
restriction, including without limitation the rights to use,
|
|
46 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
47 |
copies of the Software, and to permit persons to whom the
|
|
48 |
Software is furnished to do so, subject to the following
|
|
49 |
conditions:
|
10021
|
50 |
|
10068
|
51 |
The above copyright notice and this permission notice shall be
|
|
52 |
included in all copies or substantial portions of the Software.
|
|
53 |
|
|
54 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
55 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
56 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
57 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
58 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
59 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
60 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
61 |
OTHER DEALINGS IN THE SOFTWARE.
|
10021
|
62 |
"
|
|
63 |
! !
|
|
64 |
|
|
65 |
!SyntaxElement class methodsFor:'instance creation'!
|
|
66 |
|
|
67 |
from: start to: stop
|
|
68 |
|
|
69 |
^self new
|
|
70 |
start: start;
|
|
71 |
stop: stop.
|
|
72 |
|
|
73 |
"Created: / 14-02-2010 / 13:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
74 |
!
|
|
75 |
|
|
76 |
from: start to: stop type: type
|
|
77 |
|
|
78 |
^self new
|
|
79 |
start: start;
|
|
80 |
stop: stop;
|
|
81 |
type: type
|
|
82 |
|
|
83 |
"Created: / 14-02-2010 / 14:09:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
84 |
!
|
|
85 |
|
|
86 |
from: start to: stop type: type value: value
|
|
87 |
|
|
88 |
^self new
|
|
89 |
start: start;
|
|
90 |
stop: stop;
|
|
91 |
type: type;
|
|
92 |
value: value
|
|
93 |
|
|
94 |
"Created: / 14-02-2010 / 17:41:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
12909
|
95 |
!
|
|
96 |
|
|
97 |
from: start to: stop type: type value: value assigned:assigned
|
|
98 |
|
|
99 |
^self new
|
|
100 |
start: start;
|
|
101 |
stop: stop;
|
|
102 |
type: type;
|
|
103 |
value: value;
|
|
104 |
assigned: assigned
|
|
105 |
|
|
106 |
"Created: / 14-02-2010 / 17:41:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10021
|
107 |
! !
|
|
108 |
|
|
109 |
!SyntaxElement methodsFor:'accessing'!
|
|
110 |
|
10632
|
111 |
firstElementInChain
|
|
112 |
|first prev|
|
|
113 |
|
|
114 |
first := self.
|
|
115 |
[ (prev := first previousElement) notNil ] whileTrue:[
|
|
116 |
first := prev.
|
|
117 |
].
|
|
118 |
^ first
|
|
119 |
|
|
120 |
"Created: / 21-08-2011 / 09:51:35 / cg"
|
|
121 |
!
|
|
122 |
|
12098
|
123 |
lastElementInChain
|
|
124 |
|last next|
|
|
125 |
|
|
126 |
last := self.
|
|
127 |
[ (next := last nextElement) notNil ] whileTrue:[
|
|
128 |
last := next.
|
|
129 |
].
|
|
130 |
^ last
|
|
131 |
!
|
|
132 |
|
10021
|
133 |
next
|
|
134 |
^ next
|
|
135 |
!
|
|
136 |
|
|
137 |
next:aSyntaxElement
|
|
138 |
next := aSyntaxElement.
|
|
139 |
next prev: self.
|
|
140 |
|
|
141 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
142 |
!
|
|
143 |
|
10632
|
144 |
nextElement
|
|
145 |
^ next
|
|
146 |
|
|
147 |
"Created: / 21-08-2011 / 09:47:11 / cg"
|
|
148 |
!
|
|
149 |
|
|
150 |
nextElement:aSyntaxElement
|
|
151 |
next := aSyntaxElement.
|
|
152 |
next prev: self.
|
|
153 |
|
|
154 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
155 |
"Created: / 21-08-2011 / 09:47:15 / cg"
|
|
156 |
!
|
|
157 |
|
10021
|
158 |
prev
|
|
159 |
^ prev
|
|
160 |
!
|
|
161 |
|
|
162 |
prev:aSyntaxElement
|
|
163 |
prev := aSyntaxElement.
|
|
164 |
!
|
|
165 |
|
10632
|
166 |
previousElement
|
|
167 |
^ prev
|
|
168 |
|
|
169 |
"Created: / 21-08-2011 / 09:47:23 / cg"
|
|
170 |
!
|
|
171 |
|
|
172 |
previousElement:aSyntaxElement
|
|
173 |
prev := aSyntaxElement.
|
|
174 |
|
|
175 |
"Created: / 21-08-2011 / 09:47:28 / cg"
|
|
176 |
!
|
|
177 |
|
10021
|
178 |
start
|
|
179 |
^ start
|
|
180 |
!
|
|
181 |
|
|
182 |
start:anInteger
|
|
183 |
start := anInteger.
|
|
184 |
!
|
|
185 |
|
|
186 |
stop
|
|
187 |
^ stop
|
|
188 |
!
|
|
189 |
|
|
190 |
stop:anInteger
|
|
191 |
stop := anInteger.
|
|
192 |
!
|
|
193 |
|
|
194 |
type
|
|
195 |
^ type
|
|
196 |
!
|
|
197 |
|
|
198 |
type:aSymbol
|
|
199 |
type := aSymbol.
|
|
200 |
!
|
|
201 |
|
|
202 |
value
|
|
203 |
^ value
|
|
204 |
!
|
|
205 |
|
|
206 |
value:anObject
|
|
207 |
value := anObject.
|
|
208 |
! !
|
|
209 |
|
|
210 |
!SyntaxElement methodsFor:'comparing'!
|
|
211 |
|
|
212 |
< anObject
|
|
213 |
anObject isNumber ifTrue:[^stop < anObject].
|
12909
|
214 |
"/ anObject class == self class ifFalse:[^false].
|
10021
|
215 |
|
12909
|
216 |
^stop < anObject stop
|
10021
|
217 |
|
|
218 |
"Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
219 |
"Modified (format): / 27-07-2012 / 21:53:22 / cg"
|
10021
|
220 |
!
|
|
221 |
|
|
222 |
= anObject
|
|
223 |
anObject class == self class ifFalse:[^false].
|
|
224 |
|
|
225 |
^start == (anObject start) and:
|
|
226 |
[stop == (anObject stop) and:
|
|
227 |
[type == (anObject type)]].
|
|
228 |
|
|
229 |
"Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
230 |
"Modified (format): / 27-07-2012 / 21:53:24 / cg"
|
10021
|
231 |
!
|
|
232 |
|
|
233 |
hash
|
|
234 |
^start hash bitXor:[stop hash bitXor:[type hash]].
|
|
235 |
|
|
236 |
"Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
237 |
"Modified (format): / 27-07-2012 / 21:53:28 / cg"
|
10021
|
238 |
! !
|
|
239 |
|
|
240 |
!SyntaxElement methodsFor:'double dispatching'!
|
|
241 |
|
|
242 |
lessFromInteger:anInteger
|
|
243 |
^stop < anInteger
|
|
244 |
|
|
245 |
"Created: / 14-02-2010 / 13:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
11699
|
246 |
"Modified (format): / 27-07-2012 / 21:53:33 / cg"
|
10021
|
247 |
! !
|
|
248 |
|
|
249 |
!SyntaxElement methodsFor:'printing & storing'!
|
|
250 |
|
|
251 |
printOn:aStream
|
|
252 |
"append a printed representation if the receiver to the argument, aStream"
|
|
253 |
|
|
254 |
super printOn:aStream.
|
10632
|
255 |
aStream nextPutAll:'('.
|
10021
|
256 |
type printOn: aStream.
|
10632
|
257 |
aStream nextPutAll:' -> '.
|
10021
|
258 |
value printOn:aStream.
|
12909
|
259 |
aStream nextPut:$[.
|
|
260 |
start printOn:aStream.
|
|
261 |
aStream nextPutAll:' .. '.
|
|
262 |
stop printOn:aStream.
|
|
263 |
aStream nextPut:$].
|
10021
|
264 |
aStream nextPut:$).
|
|
265 |
|
|
266 |
"Modified: / 25-06-2010 / 13:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10632
|
267 |
"Modified: / 21-08-2011 / 09:33:51 / cg"
|
|
268 |
! !
|
|
269 |
|
|
270 |
!SyntaxElement methodsFor:'queries'!
|
|
271 |
|
12985
|
272 |
assigned
|
|
273 |
^ false.
|
|
274 |
!
|
|
275 |
|
10632
|
276 |
isSelector
|
|
277 |
^ type == #selector
|
|
278 |
|
|
279 |
"Created: / 21-08-2011 / 09:09:19 / cg"
|
|
280 |
!
|
|
281 |
|
|
282 |
isSelf
|
|
283 |
^ type == #self
|
|
284 |
|
|
285 |
"Created: / 21-08-2011 / 09:31:20 / cg"
|
|
286 |
!
|
|
287 |
|
|
288 |
isVariable
|
12909
|
289 |
^ false
|
10632
|
290 |
!
|
|
291 |
|
|
292 |
isVariableOrSelf
|
|
293 |
^ self isVariable or:[self isSelf]
|
|
294 |
|
|
295 |
"Created: / 21-08-2011 / 09:31:33 / cg"
|
10021
|
296 |
! !
|
|
297 |
|
|
298 |
!SyntaxElement class methodsFor:'documentation'!
|
|
299 |
|
|
300 |
version_CVS
|
12985
|
301 |
^ '$Header: /cvs/stx/stx/libtool/SyntaxElement.st,v 1.7 2013-06-24 13:43:05 cg Exp $'
|
10021
|
302 |
!
|
|
303 |
|
|
304 |
version_SVN
|
12985
|
305 |
^ '$Id: SyntaxElement.st,v 1.7 2013-06-24 13:43:05 cg Exp $'
|
10021
|
306 |
! !
|
12098
|
307 |
|