author | Claus Gittinger <cg@exept.de> |
Tue, 14 Mar 2017 20:30:21 +0100 | |
changeset 17465 | 27a2e4012a0a |
parent 16783 | 59290ab0bc72 |
child 16797 | 4f240085a622 |
permissions | -rw-r--r-- |
13864 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libtool' }" |
|
13 |
||
15171 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
13864 | 16 |
SortedCollection subclass:#ParseTreeIndex |
14192 | 17 |
instanceVariableNames:'tree source' |
13864 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-CodeView-Syntax' |
|
21 |
! |
|
22 |
||
15315
caa632247421
class: ParseTreeIndex::Element
Stefan Vogel <sv@exept.de>
parents:
15171
diff
changeset
|
23 |
SyntaxElement subclass:#Element |
15469 | 24 |
instanceVariableNames:'' |
13864 | 25 |
classVariableNames:'' |
26 |
poolDictionaries:'' |
|
27 |
privateIn:ParseTreeIndex |
|
28 |
! |
|
29 |
||
30 |
!ParseTreeIndex class methodsFor:'documentation'! |
|
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
35 |
All Rights Reserved |
|
36 |
||
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
48 |
For given parse tree, a ParseTreeIndex provides an |
|
49 |
fast access to individual (leave) nodes by keeping |
|
50 |
an index. Used by CodeView2 for various queries |
|
51 |
||
52 |
Experimental |
|
53 |
||
54 |
[author:] |
|
55 |
Jan Vrany <jan.vrany@fit.cvut.cz> |
|
56 |
||
57 |
[instance variables:] |
|
58 |
||
59 |
[class variables:] |
|
60 |
||
61 |
[see also:] |
|
62 |
||
63 |
" |
|
64 |
! ! |
|
65 |
||
66 |
!ParseTreeIndex methodsFor:'accessing'! |
|
67 |
||
14192 | 68 |
source |
69 |
^ source |
|
70 |
! |
|
71 |
||
72 |
source:something |
|
73 |
source := something. |
|
74 |
! |
|
75 |
||
13864 | 76 |
tree |
77 |
^ tree |
|
78 |
! |
|
79 |
||
80 |
tree:aParseNode |
|
81 |
tree := aParseNode. |
|
82 |
! ! |
|
83 |
||
84 |
!ParseTreeIndex methodsFor:'utilities'! |
|
85 |
||
86 |
newElementFor: aParseNode |
|
87 |
||
88 |
^(Element new node: aParseNode) |
|
89 |
||
90 |
"Created: / 16-02-2012 / 21:00:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
91 |
! ! |
|
92 |
||
93 |
!ParseTreeIndex::Element class methodsFor:'documentation'! |
|
94 |
||
95 |
copyright |
|
96 |
" |
|
97 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
|
98 |
All Rights Reserved |
|
99 |
||
100 |
Permission is hereby granted, free of charge, to any person |
|
101 |
obtaining a copy of this software and associated documentation |
|
102 |
files (the 'Software'), to deal in the Software without |
|
103 |
restriction, including without limitation the rights to use, |
|
104 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
105 |
copies of the Software, and to permit persons to whom the |
|
106 |
Software is furnished to do so, subject to the following |
|
107 |
conditions: |
|
108 |
||
109 |
The above copyright notice and this permission notice shall be |
|
110 |
included in all copies or substantial portions of the Software. |
|
111 |
||
112 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
113 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
114 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
115 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
116 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
117 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
118 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
119 |
OTHER DEALINGS IN THE SOFTWARE. |
|
120 |
" |
|
121 |
! ! |
|
122 |
||
123 |
!ParseTreeIndex::Element methodsFor:'accessing'! |
|
124 |
||
125 |
assigned |
|
14055
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
126 |
| p | |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
127 |
|
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
128 |
^ node isVariableNode |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
129 |
and:[(p := node parent) notNil |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
130 |
and:[p isAssignment |
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
131 |
and:[p variable == node]]]. |
13864 | 132 |
|
133 |
"Created: / 01-07-2013 / 21:53:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14055
d5de1e564e5d
Fixed ParseTreeIndex::Element
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13940
diff
changeset
|
134 |
"Modified: / 25-02-2014 / 20:52:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13864 | 135 |
! |
136 |
||
137 |
name |
|
138 |
^node isVariable ifTrue:[node name] ifFalse:[nil] |
|
139 |
||
140 |
"Created: / 01-07-2013 / 21:56:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
141 |
! |
|
142 |
||
143 |
start |
|
144 |
^ node startPosition |
|
145 |
||
146 |
"Modified: / 16-02-2012 / 20:56:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
stop |
|
150 |
^ node endPosition |
|
151 |
||
152 |
"Modified: / 16-02-2012 / 20:56:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14507 | 153 |
! |
154 |
||
155 |
value |
|
156 |
^node name |
|
13864 | 157 |
! ! |
158 |
||
159 |
!ParseTreeIndex::Element methodsFor:'comparing'! |
|
160 |
||
161 |
< anObject |
|
162 |
||
163 |
anObject isNumber ifTrue:[^self stop < anObject]. |
|
164 |
anObject class == self class ifFalse:[^false]. |
|
165 |
||
166 |
^self stop < anObject start |
|
167 |
||
168 |
"Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
169 |
! |
|
170 |
||
171 |
= anObject |
|
172 |
||
173 |
anObject class == self class ifFalse:[^false]. |
|
174 |
||
175 |
^self start == (anObject start) and: |
|
176 |
[self stop == (anObject stop) and: |
|
177 |
[self node class == (anObject node class)]]. |
|
178 |
||
179 |
"Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
180 |
! |
|
181 |
||
182 |
hash |
|
183 |
||
184 |
^self start hash bitXor:[self stop hash bitXor:[node class hash]]. |
|
185 |
||
186 |
"Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
187 |
! ! |
|
188 |
||
189 |
!ParseTreeIndex::Element methodsFor:'printing & storing'! |
|
190 |
||
191 |
printOn:aStream |
|
16783 | 192 |
"append a printed representation of the receiver to the argument, aStream" |
13864 | 193 |
|
194 |
super printOn:aStream. |
|
195 |
aStream nextPutAll:'('. |
|
196 |
node class name printOn: aStream. |
|
197 |
aStream nextPut:$). |
|
198 |
||
199 |
"Modified: / 21-08-2011 / 09:33:51 / cg" |
|
200 |
"Modified: / 16-02-2012 / 19:23:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
201 |
! ! |
|
202 |
||
203 |
!ParseTreeIndex::Element methodsFor:'testing'! |
|
204 |
||
205 |
isSelector |
|
206 |
^ node class == SelectorNode |
|
207 |
||
208 |
"Created: / 21-08-2011 / 09:09:19 / cg" |
|
209 |
"Modified: / 16-02-2012 / 21:04:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
210 |
! |
|
211 |
||
212 |
isSelf |
|
213 |
^ node isSelf |
|
214 |
||
215 |
"Created: / 21-08-2011 / 09:31:20 / cg" |
|
216 |
"Modified: / 16-02-2012 / 19:25:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
217 |
! ! |
|
218 |
||
219 |
!ParseTreeIndex class methodsFor:'documentation'! |
|
220 |
||
221 |
version |
|
16783 | 222 |
^ '$Header$' |
13864 | 223 |
! |
224 |
||
225 |
version_CVS |
|
16783 | 226 |
^ '$Header$' |
13864 | 227 |
! ! |
228 |