author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 29 Jan 2012 15:33:37 +0000 | |
branch | jv |
changeset 12125 | 0c49a3b13e43 |
parent 12123 | 4bde08cebd48 |
child 12128 | a7ff7d66ee85 |
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 |
||
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>" |
|
95 |
! ! |
|
96 |
||
97 |
!SyntaxElement methodsFor:'accessing'! |
|
98 |
||
12125 | 99 |
firstElementInChain |
100 |
|first prev| |
|
101 |
||
102 |
first := self. |
|
103 |
[ (prev := first previousElement) notNil ] whileTrue:[ |
|
104 |
first := prev. |
|
105 |
]. |
|
106 |
^ first |
|
107 |
||
108 |
"Created: / 21-08-2011 / 09:51:35 / cg" |
|
109 |
! |
|
110 |
||
10021 | 111 |
next |
112 |
^ next |
|
113 |
! |
|
114 |
||
115 |
next:aSyntaxElement |
|
116 |
next := aSyntaxElement. |
|
117 |
next prev: self. |
|
118 |
||
119 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
120 |
! |
|
121 |
||
12125 | 122 |
nextElement |
123 |
^ next |
|
124 |
||
125 |
"Created: / 21-08-2011 / 09:47:11 / cg" |
|
126 |
! |
|
127 |
||
128 |
nextElement:aSyntaxElement |
|
129 |
next := aSyntaxElement. |
|
130 |
next prev: self. |
|
131 |
||
132 |
"Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
133 |
"Created: / 21-08-2011 / 09:47:15 / cg" |
|
134 |
! |
|
135 |
||
10021 | 136 |
prev |
137 |
^ prev |
|
138 |
! |
|
139 |
||
140 |
prev:aSyntaxElement |
|
141 |
prev := aSyntaxElement. |
|
142 |
! |
|
143 |
||
12125 | 144 |
previousElement |
145 |
^ prev |
|
146 |
||
147 |
"Created: / 21-08-2011 / 09:47:23 / cg" |
|
148 |
! |
|
149 |
||
150 |
previousElement:aSyntaxElement |
|
151 |
prev := aSyntaxElement. |
|
152 |
||
153 |
"Created: / 21-08-2011 / 09:47:28 / cg" |
|
154 |
! |
|
155 |
||
10021 | 156 |
start |
157 |
^ start |
|
158 |
! |
|
159 |
||
160 |
start:anInteger |
|
161 |
start := anInteger. |
|
162 |
! |
|
163 |
||
164 |
stop |
|
165 |
^ stop |
|
166 |
! |
|
167 |
||
168 |
stop:anInteger |
|
169 |
stop := anInteger. |
|
170 |
! |
|
171 |
||
172 |
type |
|
173 |
^ type |
|
174 |
! |
|
175 |
||
176 |
type:aSymbol |
|
177 |
type := aSymbol. |
|
178 |
! |
|
179 |
||
180 |
value |
|
181 |
^ value |
|
182 |
! |
|
183 |
||
184 |
value:anObject |
|
185 |
value := anObject. |
|
186 |
! ! |
|
187 |
||
188 |
!SyntaxElement methodsFor:'comparing'! |
|
189 |
||
190 |
< anObject |
|
191 |
||
192 |
anObject isNumber ifTrue:[^stop < anObject]. |
|
193 |
anObject class == self class ifFalse:[^false]. |
|
194 |
||
195 |
^stop < anObject start |
|
196 |
||
197 |
"Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
198 |
! |
|
199 |
||
200 |
= anObject |
|
201 |
||
202 |
anObject class == self class ifFalse:[^false]. |
|
203 |
||
204 |
^start == (anObject start) and: |
|
205 |
[stop == (anObject stop) and: |
|
206 |
[type == (anObject type)]]. |
|
207 |
||
208 |
"Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
209 |
! |
|
210 |
||
211 |
hash |
|
212 |
||
213 |
^start hash bitXor:[stop hash bitXor:[type hash]]. |
|
214 |
||
215 |
"Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
216 |
! ! |
|
217 |
||
218 |
!SyntaxElement methodsFor:'double dispatching'! |
|
219 |
||
220 |
lessFromInteger:anInteger |
|
221 |
||
222 |
^stop < anInteger |
|
223 |
||
224 |
"Created: / 14-02-2010 / 13:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
225 |
! ! |
|
226 |
||
227 |
!SyntaxElement methodsFor:'printing & storing'! |
|
228 |
||
229 |
printOn:aStream |
|
230 |
"append a printed representation if the receiver to the argument, aStream" |
|
231 |
||
232 |
super printOn:aStream. |
|
12125 | 233 |
aStream nextPutAll:'('. |
10021 | 234 |
type printOn: aStream. |
12125 | 235 |
aStream nextPutAll:' -> '. |
10021 | 236 |
value printOn:aStream. |
237 |
aStream nextPut:$). |
|
238 |
||
239 |
"Modified: / 25-06-2010 / 13:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
12125 | 240 |
"Modified: / 21-08-2011 / 09:33:51 / cg" |
241 |
! ! |
|
242 |
||
243 |
!SyntaxElement methodsFor:'queries'! |
|
244 |
||
245 |
isSelector |
|
246 |
^ type == #selector |
|
247 |
||
248 |
"Created: / 21-08-2011 / 09:09:19 / cg" |
|
249 |
! |
|
250 |
||
251 |
isSelf |
|
252 |
^ type == #self |
|
253 |
||
254 |
"Created: / 21-08-2011 / 09:31:20 / cg" |
|
255 |
! |
|
256 |
||
257 |
isVariable |
|
258 |
^ type == #variable |
|
259 |
||
260 |
"Created: / 21-08-2011 / 09:09:00 / cg" |
|
261 |
! |
|
262 |
||
263 |
isVariableOrSelf |
|
264 |
^ self isVariable or:[self isSelf] |
|
265 |
||
266 |
"Created: / 21-08-2011 / 09:31:33 / cg" |
|
10021 | 267 |
! ! |
268 |
||
269 |
!SyntaxElement class methodsFor:'documentation'! |
|
270 |
||
271 |
version_CVS |
|
12125 | 272 |
^ '§Header: /cvs/stx/stx/libtool/SyntaxElement.st,v 1.3 2011/08/21 10:25:36 cg Exp §' |
10021 | 273 |
! |
274 |
||
275 |
version_SVN |
|
12123
4bde08cebd48
trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
10632
diff
changeset
|
276 |
^ '$Id: SyntaxElement.st 7582 2010-06-25 13:26:33Z vranyj1 $' |
12125 | 277 |
! ! |