author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 30 Jan 2013 11:15:09 +0000 | |
branch | jv |
changeset 12401 | 4714b9640528 |
parent 12287 | 400a99059170 |
parent 12098 | 6ec9402ca9b6 |
child 12431 | 9f0c59c742d5 |
permissions | -rw-r--r-- |
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 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
65 |
|
10021 | 66 |
!SyntaxElement class methodsFor:'instance creation'! |
67 |
||
68 |
from: start to: stop |
|
69 |
||
70 |
^self new |
|
71 |
start: start; |
|
72 |
stop: stop. |
|
73 |
||
74 |
"Created: / 14-02-2010 / 13:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
75 |
! |
|
76 |
||
77 |
from: start to: stop type: type |
|
78 |
||
79 |
^self new |
|
80 |
start: start; |
|
81 |
stop: stop; |
|
82 |
type: type |
|
83 |
||
84 |
"Created: / 14-02-2010 / 14:09:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
85 |
! |
|
86 |
||
87 |
from: start to: stop type: type value: value |
|
88 |
||
89 |
^self new |
|
90 |
start: start; |
|
91 |
stop: stop; |
|
92 |
type: type; |
|
93 |
value: value |
|
94 |
||
95 |
"Created: / 14-02-2010 / 17:41:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
96 |
! ! |
|
97 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
98 |
|
10021 | 99 |
!SyntaxElement methodsFor:'accessing'! |
100 |
||
10632 | 101 |
firstElementInChain |
102 |
|first prev| |
|
103 |
||
104 |
first := self. |
|
105 |
[ (prev := first previousElement) notNil ] whileTrue:[ |
|
106 |
first := prev. |
|
107 |
]. |
|
108 |
^ first |
|
109 |
||
110 |
"Created: / 21-08-2011 / 09:51:35 / cg" |
|
111 |
! |
|
112 |
||
12098 | 113 |
lastElementInChain |
114 |
|last next| |
|
115 |
||
116 |
last := self. |
|
117 |
[ (next := last nextElement) notNil ] whileTrue:[ |
|
118 |
last := next. |
|
119 |
]. |
|
120 |
^ last |
|
121 |
! |
|
122 |
||
10021 | 123 |
next |
124 |
^ next |
|
125 |
! |
|
126 |
||
127 |
next:aSyntaxElement |
|
128 |
next := aSyntaxElement. |
|
129 |
next prev: self. |
|
130 |
||
131 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
132 |
! |
|
133 |
||
10632 | 134 |
nextElement |
135 |
^ next |
|
136 |
||
137 |
"Created: / 21-08-2011 / 09:47:11 / cg" |
|
138 |
! |
|
139 |
||
140 |
nextElement:aSyntaxElement |
|
141 |
next := aSyntaxElement. |
|
142 |
next prev: self. |
|
143 |
||
144 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
145 |
"Created: / 21-08-2011 / 09:47:15 / cg" |
|
146 |
! |
|
147 |
||
10021 | 148 |
prev |
149 |
^ prev |
|
150 |
! |
|
151 |
||
152 |
prev:aSyntaxElement |
|
153 |
prev := aSyntaxElement. |
|
154 |
! |
|
155 |
||
10632 | 156 |
previousElement |
157 |
^ prev |
|
158 |
||
159 |
"Created: / 21-08-2011 / 09:47:23 / cg" |
|
160 |
! |
|
161 |
||
162 |
previousElement:aSyntaxElement |
|
163 |
prev := aSyntaxElement. |
|
164 |
||
165 |
"Created: / 21-08-2011 / 09:47:28 / cg" |
|
166 |
! |
|
167 |
||
10021 | 168 |
start |
169 |
^ start |
|
170 |
! |
|
171 |
||
172 |
start:anInteger |
|
173 |
start := anInteger. |
|
174 |
! |
|
175 |
||
176 |
stop |
|
177 |
^ stop |
|
178 |
! |
|
179 |
||
180 |
stop:anInteger |
|
181 |
stop := anInteger. |
|
182 |
! |
|
183 |
||
184 |
type |
|
185 |
^ type |
|
186 |
! |
|
187 |
||
188 |
type:aSymbol |
|
189 |
type := aSymbol. |
|
190 |
! |
|
191 |
||
192 |
value |
|
193 |
^ value |
|
194 |
! |
|
195 |
||
196 |
value:anObject |
|
197 |
value := anObject. |
|
198 |
! ! |
|
199 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
200 |
|
10021 | 201 |
!SyntaxElement methodsFor:'comparing'! |
202 |
||
203 |
< anObject |
|
204 |
anObject isNumber ifTrue:[^stop < anObject]. |
|
205 |
anObject class == self class ifFalse:[^false]. |
|
206 |
||
207 |
^stop < anObject start |
|
208 |
||
209 |
"Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11699 | 210 |
"Modified (format): / 27-07-2012 / 21:53:22 / cg" |
10021 | 211 |
! |
212 |
||
213 |
= anObject |
|
214 |
anObject class == self class ifFalse:[^false]. |
|
215 |
||
216 |
^start == (anObject start) and: |
|
217 |
[stop == (anObject stop) and: |
|
218 |
[type == (anObject type)]]. |
|
219 |
||
220 |
"Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11699 | 221 |
"Modified (format): / 27-07-2012 / 21:53:24 / cg" |
10021 | 222 |
! |
223 |
||
224 |
hash |
|
225 |
^start hash bitXor:[stop hash bitXor:[type hash]]. |
|
226 |
||
227 |
"Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11699 | 228 |
"Modified (format): / 27-07-2012 / 21:53:28 / cg" |
10021 | 229 |
! ! |
230 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
231 |
|
10021 | 232 |
!SyntaxElement methodsFor:'double dispatching'! |
233 |
||
234 |
lessFromInteger:anInteger |
|
235 |
^stop < anInteger |
|
236 |
||
237 |
"Created: / 14-02-2010 / 13:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11699 | 238 |
"Modified (format): / 27-07-2012 / 21:53:33 / cg" |
10021 | 239 |
! ! |
240 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
241 |
|
10021 | 242 |
!SyntaxElement methodsFor:'printing & storing'! |
243 |
||
244 |
printOn:aStream |
|
245 |
"append a printed representation if the receiver to the argument, aStream" |
|
246 |
||
247 |
super printOn:aStream. |
|
10632 | 248 |
aStream nextPutAll:'('. |
10021 | 249 |
type printOn: aStream. |
10632 | 250 |
aStream nextPutAll:' -> '. |
10021 | 251 |
value printOn:aStream. |
252 |
aStream nextPut:$). |
|
253 |
||
254 |
"Modified: / 25-06-2010 / 13:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10632 | 255 |
"Modified: / 21-08-2011 / 09:33:51 / cg" |
256 |
! ! |
|
257 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
258 |
|
10632 | 259 |
!SyntaxElement methodsFor:'queries'! |
260 |
||
261 |
isSelector |
|
262 |
^ type == #selector |
|
263 |
||
264 |
"Created: / 21-08-2011 / 09:09:19 / cg" |
|
265 |
! |
|
266 |
||
267 |
isSelf |
|
268 |
^ type == #self |
|
269 |
||
270 |
"Created: / 21-08-2011 / 09:31:20 / cg" |
|
271 |
! |
|
272 |
||
273 |
isVariable |
|
274 |
^ type == #variable |
|
275 |
||
276 |
"Created: / 21-08-2011 / 09:09:00 / cg" |
|
277 |
! |
|
278 |
||
279 |
isVariableOrSelf |
|
280 |
^ self isVariable or:[self isSelf] |
|
281 |
||
282 |
"Created: / 21-08-2011 / 09:31:33 / cg" |
|
10021 | 283 |
! ! |
284 |
||
12401
4714b9640528
Merged 235b77901045 and 8332590c5a41 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
285 |
|
10021 | 286 |
!SyntaxElement class methodsFor:'documentation'! |
287 |
||
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
288 |
version |
12287 | 289 |
^ '$Id: SyntaxElement.st 8048 2012-09-07 17:28:09Z vranyj1 $' |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
290 |
! |
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12125
diff
changeset
|
291 |
|
10021 | 292 |
version_CVS |
12098 | 293 |
^ '$Header: /cvs/stx/stx/libtool/SyntaxElement.st,v 1.5 2013-01-11 09:56:30 cg Exp $' |
10021 | 294 |
! |
295 |
||
296 |
version_SVN |
|
297 |
^ '§Id: SyntaxElement.st 7582 2010-06-25 13:26:33Z vranyj1 §' |
|
298 |
! ! |
|
12098 | 299 |