author | Claus Gittinger <cg@exept.de> |
Wed, 11 Jan 2006 16:35:29 +0100 | |
changeset 1650 | 71fcb0a081ff |
parent 1647 | 89f03e0bc836 |
child 1653 | db35fa50902a |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
1576 | 3 |
All Rights Reserved |
0 | 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 |
||
1043 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
0 | 15 |
Scanner subclass:#Parser |
1579 | 16 |
instanceVariableNames:'classToCompileFor selfValue contextToEvaluateIn selector |
17 |
methodArgs methodArgNames methodVars methodVarNames tree |
|
18 |
currentBlock parseForCode readInstVars readClassVars readGlobals |
|
19 |
usedInstVars usedClassVars usedVars modifiedInstVars |
|
20 |
modifiedClassVars modifiedGlobals usesSuper usedGlobals |
|
21 |
usedSymbols messagesSent messagesSentToSelf messagesSentToSuper |
|
22 |
localVarDefPosition evalExitBlock selfNode superNode nilNode |
|
23 |
hasPrimitiveCode hasNonOptionalPrimitiveCode primitiveNr |
|
24 |
primitiveResource logged warnedUndefVars warnedUnknownNamespaces |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
25 |
correctedSource foldConstants lineNumberInfo currentNamespace |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
26 |
currentUsedNamespaces methodNode alreadyWarnedClassInstVarRefs |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
27 |
localBlockVarDefPosition endOfSelectorPosition |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
28 |
beginOfBodyPosition startOfBlockPosition primitiveContextInfo |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
29 |
usedLocalVars modifiedLocalVars alreadyWarnedUninitializedVars |
1579 | 30 |
alreadyWarnedUnimplementedSelectors returnedValues currentPackage |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
31 |
doItTemporaries inFunctionCallArgument |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
32 |
didWarnAboutSTXNameSpaceUse didWarnAboutSTXHereExtensionUsed |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
33 |
parenthesisLevel' |
1579 | 34 |
classVariableNames:'PrevClass PrevInstVarNames PrevClassVarNames |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
35 |
PrevClassInstVarNames LazyCompilation FoldConstants |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
36 |
LineNumberInfo SuppressDoItCompilation ParseErrorSignal |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
37 |
RestartCompilationSignal' |
1579 | 38 |
poolDictionaries:'' |
39 |
category:'System-Compiler' |
|
0 | 40 |
! |
41 |
||
1423 | 42 |
ProceedableError subclass:#ParseError |
1579 | 43 |
instanceVariableNames:'errorMessage startPosition endPosition lineNumber' |
44 |
classVariableNames:'' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:Parser |
|
971 | 47 |
! |
48 |
||
1647 | 49 |
Notification subclass:#ParseWarning |
50 |
instanceVariableNames:'errorMessage startPosition endPosition lineNumber' |
|
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:Parser |
|
54 |
! |
|
55 |
||
971 | 56 |
Parser::ParseError subclass:#UndefinedSuperclassError |
1579 | 57 |
instanceVariableNames:'' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:Parser |
|
971 | 61 |
! |
62 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
63 |
Notification subclass:#UndefinedVariableNotification |
1579 | 64 |
instanceVariableNames:'parser' |
65 |
classVariableNames:'' |
|
66 |
poolDictionaries:'' |
|
67 |
privateIn:Parser |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
68 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
69 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
70 |
!Parser class methodsFor:'documentation'! |
19 | 71 |
|
20 | 72 |
copyright |
73 |
" |
|
74 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1576 | 75 |
All Rights Reserved |
20 | 76 |
|
77 |
This software is furnished under a license and may be used |
|
78 |
only in accordance with the terms of that license and with the |
|
79 |
inclusion of the above copyright notice. This software may not |
|
80 |
be provided or otherwise made available to, or used by, any |
|
81 |
other person. No title to or ownership of the software is |
|
82 |
hereby transferred. |
|
83 |
" |
|
84 |
! |
|
85 |
||
19 | 86 |
documentation |
87 |
" |
|
88 |
Parser is used for both parsing and evaluating smalltalk expressions; |
|
89 |
it first builds a parseTree which is then interpreted (evaluate) or |
|
90 |
compiled. Compilation is done in the subclass ByteCodeCompiler and/or |
|
91 |
the (planned) MachineCodeCompiler. |
|
92 |
||
173
247ae4b8af76
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
171
diff
changeset
|
93 |
methods of main interest are: |
755 | 94 |
Parser evaluateExpression:... |
19 | 95 |
|
96 |
and: |
|
755 | 97 |
Parser parseExpression:... |
98 |
Parser parseMethod:... |
|
19 | 99 |
|
100 |
there is protocol to parse complete methods, selector specs, body only etc. |
|
101 |
||
102 |
Parser is also used to find the referenced/modified inst/classvars of |
|
103 |
a method - this is done by sending parseXXX message to a parser and asking |
|
104 |
the parser for referencedXVars or modifiedXVars (see SystemBrowser). |
|
105 |
||
106 |
You can also use parsers for all kinds of other things (ChangesBrowser for |
|
107 |
example analyzes the expressions in the changelist ...) by looking at the |
|
108 |
parsers tree. (Although this is somewhat dangerous, since it exports the |
|
755 | 109 |
compilers internals ... better style is to add specialized query methods here) |
19 | 110 |
|
111 |
One instance of Parser is created to parse one method or expression - i.e. |
|
112 |
its not suggested to reuse parsers. |
|
113 |
||
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
114 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
115 |
Constant folding: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
116 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
117 |
The parser has various modes for constant folding; by default, only numeric |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
118 |
expressions involving integers and floats are constant folded |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
119 |
(i.e. something like 'Float pi sin' or '1.5 + 0.3' will be reduced to a constant). |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
120 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
121 |
Constant folding can be turned off completely (setting FoldConstants to nil) |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
122 |
to ``secure folding'', which only folds constant numbers (#level1) or to #full. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
123 |
In full mode, more constant expressions are folded (for example: '1.0 @ 1.0' is |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
124 |
reduced to a constant point), but the resulting code may not be compatible with other |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
125 |
smalltalk systems (consider the case, where the point is modified using #x: or #y: messages). |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
126 |
Therefore, this mode is a bit dangerous and disabled by default. |
755 | 127 |
The current implementation, base upon a global constant-folding setting is somewhat stupid |
128 |
and intermediate - a better solution would be to allow the optimization to be controlled |
|
129 |
by a method-pragma, since it may make sense to disable optimization on a method level, |
|
130 |
if its known that the used constant objects are subject of modifications as described above. |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
131 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
132 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
133 |
Immutable arrays: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
134 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
135 |
Immutable arrays are experimental and being evaluated. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
136 |
Consider the case of a method returning '#(1 2 3 4)', and that array being modified |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
137 |
by some other method (using #at:put:). Since the array-return is actually a return of |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
138 |
a reference to the compiler created array, the next invokation of the method will |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
139 |
return the modified array. These are hard to find bugs. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
140 |
By an option, the compiler can generate immutable arrays, which dont allow modification |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
141 |
of its elements. For clean code, you should enable this option during development. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
142 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
143 |
As mentioned above, this is experimental. If it is reported to be a useful feature, |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
144 |
the immutable feature will be extended to strings, point-literals etc. in a future version |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
145 |
of st/x. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
146 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
147 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
148 |
|
260 | 149 |
[Instance variables:] |
150 |
||
755 | 151 |
classToCompileFor <Class> the class (or nil) we are compiling for |
152 |
||
153 |
selfValue <any> value to use as self when interpreting |
|
154 |
||
155 |
contextToEvaluateIn <Context> the context (or nil) when interpreting |
|
156 |
||
157 |
selector <Symbol> the selector of the parsed method |
|
158 |
(valid after parseMethodSpecification) |
|
159 |
methodArgs internal |
|
160 |
||
161 |
methodArgNames <Collection> the names of the arguments |
|
162 |
(valid after parseMethodSpecification) |
|
163 |
||
164 |
methodVars internal |
|
165 |
||
166 |
methodVarNames <Collection> the names of the method locals |
|
167 |
(valid after parseMethodBodyVarSpec) |
|
168 |
||
169 |
tree <ParseTree> the parse tree - valid after parsing |
|
170 |
||
171 |
currentBlock if currently parsing for a block |
|
172 |
||
173 |
usedInstVars set of all accessed instances variables |
|
174 |
(valid after parsing) |
|
175 |
||
176 |
usedClassVars same for classVars |
|
177 |
||
178 |
usedVars all used variables (inst, class & globals) |
|
179 |
||
180 |
modifiedInstVars set of all modified instance variables |
|
181 |
||
182 |
modifiedClassVars same for clasVars |
|
183 |
||
184 |
localVarDefPosition <Integer> the character offset of the local variable |
|
185 |
def. (i.e. the first '|' if any) |
|
186 |
Not yet used - prepared for automatic add of |
|
187 |
undefined variables |
|
188 |
||
189 |
evalExitBlock internal for interpretation |
|
190 |
||
191 |
selfNode <Node> cached one-and-only 'self' node |
|
192 |
superNode <Node> cached one-and-only 'super' node |
|
193 |
||
194 |
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code |
|
195 |
hasNonOptionalPrimitiveCode |
|
196 |
<Boolean> true, if it contains ST/X style primitive code |
|
197 |
which is NOT flagged by the OPTIONAL directive. |
|
198 |
||
199 |
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil) |
|
200 |
||
201 |
logged |
|
202 |
||
203 |
warnedUndefVars <Set> set of all variables which the parser has |
|
204 |
already output a warning (to avoid multiple |
|
205 |
warnings about the same variable) |
|
260 | 206 |
|
207 |
[Class variables:] |
|
208 |
||
755 | 209 |
PrevClass <Class> class, of which properties are |
210 |
cached in: |
|
211 |
||
212 |
PrevInstVarNames <Collection> instance variablenames of cached class |
|
213 |
PrevClassVarNames <Collection> class variablenames of cached class |
|
214 |
PrevClassInstVarNames <Collection> class instance variablenames of cached class |
|
215 |
||
216 |
LazyCompilation <Boolean> EXPERIMENTAL: lazy compilation |
|
217 |
||
218 |
ArraysAreImmutable <Boolean> if true, create array literals |
|
219 |
as instances of ImmutableArray, |
|
220 |
which cannot be stored into. |
|
221 |
Default is false, for compatibility. |
|
222 |
Can be turned on while developping |
|
223 |
new code to make certain that side |
|
224 |
effects are avoided. |
|
225 |
||
1615 | 226 |
StringsAreImmutable <Boolean> same as above for string literals |
227 |
||
755 | 228 |
WarnST80Directives <Boolean> if true, give warnings about |
229 |
ST-80 directives (resource defs) |
|
230 |
which are ignored in st/x. |
|
231 |
defaults to false. |
|
232 |
||
233 |
FoldConstants <Symbol> controls how constant folding should be |
|
234 |
done. |
|
235 |
Can be one of: |
|
236 |
nil - no constant folding |
|
237 |
#level1 - numeric optimizations only |
|
238 |
#level2 - secure optimizations only |
|
239 |
#full - full folding |
|
240 |
||
241 |
level1: arithmetic on constant numbers |
|
242 |
||
243 |
level2: above PLUS array conversions with #asFloatArray, |
|
244 |
#asDoubleArray, string concatenation |
|
245 |
||
246 |
full: constant points. |
|
260 | 247 |
|
248 |
[see also:] |
|
755 | 249 |
ByteCodeCompiler Scanner ObjectFileLoader |
250 |
Workspace |
|
251 |
SystemBrowser |
|
263 | 252 |
|
253 |
[author:] |
|
755 | 254 |
Claus Gittinger |
19 | 255 |
" |
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
256 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
257 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
258 |
examples |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
259 |
" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
260 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
261 |
Parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
262 |
evaluate:'1+2*3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
263 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
264 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
265 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
266 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
267 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
268 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
269 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
270 |
Parser undefinedVariableNotification handle:[:ex | |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
271 |
|badName| |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
272 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
273 |
badName := ex variableName. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
274 |
ex proceedWith:(ConstantNode value:5). |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
275 |
] do:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
276 |
^ self compilerClass |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
277 |
evaluate:'foo * 3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
278 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
279 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
280 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
281 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
282 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
283 |
] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
284 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
285 |
" |
141 | 286 |
! ! |
287 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
288 |
!Parser class methodsFor:'instance creation'! |
141 | 289 |
|
290 |
for:aStringOrStream in:aClass |
|
291 |
"return a new parser, reading code for aClass from aStringOrStream" |
|
292 |
||
293 |
|parser| |
|
294 |
||
295 |
parser := self for:aStringOrStream. |
|
296 |
parser setClassToCompileFor:aClass. |
|
297 |
^ parser |
|
298 |
! ! |
|
299 |
||
1419 | 300 |
!Parser class methodsFor:'Compatibility-ST80'! |
540 | 301 |
|
302 |
parse:aString class:aClass |
|
303 |
"same as #parseMethod:in: for ST80 compatibility." |
|
304 |
||
305 |
|parser| |
|
306 |
||
307 |
parser := self parseMethod:aString in:aClass. |
|
308 |
parser notNil ifTrue:[^ parser tree]. |
|
309 |
^ nil |
|
310 |
||
311 |
"Modified: 19.6.1997 / 16:34:57 / cg" |
|
312 |
! ! |
|
313 |
||
1419 | 314 |
!Parser class methodsFor:'Compatibility-Squeak'! |
920 | 315 |
|
316 |
evaluate:someString for:aReceiver logged:logged |
|
317 |
^ self evaluate:someString receiver:aReceiver logged:logged |
|
318 |
||
319 |
||
320 |
||
321 |
! ! |
|
322 |
||
1062 | 323 |
!Parser class methodsFor:'Signal constants'! |
324 |
||
325 |
parseErrorSignal |
|
326 |
^ ParseErrorSignal |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
327 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
328 |
|
1468 | 329 |
restartCompilationSignal |
330 |
^ RestartCompilationSignal |
|
331 |
||
332 |
"Created: / 15.11.2001 / 22:57:05 / cg" |
|
333 |
! |
|
334 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
335 |
undefinedVariableNotification |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
336 |
^ UndefinedVariableNotification |
1062 | 337 |
! ! |
338 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
339 |
!Parser class methodsFor:'changes'! |
141 | 340 |
|
341 |
flushNameCache |
|
342 |
"unconditional flush name caches" |
|
343 |
||
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
344 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
345 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
346 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
347 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
348 |
PrevClass := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
349 |
PrevInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
350 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
351 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
352 |
] valueUninterruptably |
141 | 353 |
|
354 |
"Parser flushNameCache" |
|
355 |
! |
|
356 |
||
357 |
update:something with:someArgument from:changedObject |
|
358 |
"aClass has changed its definition - flush name caches if we have to" |
|
359 |
||
360 |
(changedObject == PrevClass) ifTrue:[ |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
361 |
something == #definition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
362 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
363 |
] |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
364 |
]. |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
365 |
(changedObject == Smalltalk) ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
366 |
something == #classDefinition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
367 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
368 |
] |
141 | 369 |
] |
370 |
! ! |
|
371 |
||
717 | 372 |
!Parser class methodsFor:'class initialization'! |
373 |
||
374 |
initialize |
|
375 |
LazyCompilation := false. "/ usually set to true in your .rc file |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
376 |
|
717 | 377 |
FoldConstants := #level1. |
378 |
LineNumberInfo := false. |
|
379 |
||
1062 | 380 |
ParseErrorSignal isNil ifTrue:[ |
1380 | 381 |
ParseErrorSignal := ParseError. |
1062 | 382 |
ParseErrorSignal notifierString:'parse error'. |
1380 | 383 |
|
384 |
"/ ParseErrorSignal := Error newSignalMayProceed:true. |
|
385 |
"/ ParseErrorSignal notifierString:'parse error'. |
|
386 |
"/ ParseErrorSignal nameClass:self message:#parseErrorSignal. |
|
1062 | 387 |
]. |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
388 |
RestartCompilationSignal := Signal new. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
389 |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
390 |
Smalltalk addDependent:self. |
1062 | 391 |
|
717 | 392 |
" |
393 |
self initialize |
|
394 |
" |
|
395 |
||
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
396 |
"Modified: / 15.11.2001 / 22:54:09 / cg" |
717 | 397 |
! ! |
398 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
399 |
!Parser class methodsFor:'controlling compilation'! |
141 | 400 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
401 |
allowArrayIndexSyntaxExtension |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
402 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
403 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
404 |
^ ParserFlags allowArrayIndexSyntaxExtension |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
405 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
406 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
407 |
allowArrayIndexSyntaxExtension:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
408 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
409 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
410 |
ParserFlags allowArrayIndexSyntaxExtension:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
411 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
412 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
413 |
self allowArrayIndexSyntaxExtension:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
414 |
self allowArrayIndexSyntaxExtension:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
415 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
416 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
417 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
418 |
allowFunctionCallSyntaxForBlockEvaluation |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
419 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
420 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
421 |
^ ParserFlags allowFunctionCallSyntaxForBlockEvaluation |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
422 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
423 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
424 |
allowFunctionCallSyntaxForBlockEvaluation:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
425 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
426 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
427 |
ParserFlags allowFunctionCallSyntaxForBlockEvaluation:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
428 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
429 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
430 |
self allowFunctionCallSyntaxForBlockEvaluation:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
431 |
self allowFunctionCallSyntaxForBlockEvaluation:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
432 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
433 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
434 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
435 |
allowReservedWordsAsSelectors |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
436 |
"return true, if self, super, thisContext, nil, true and false are to be allowed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
437 |
as unary message selectors." |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
438 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
439 |
^ ParserFlags allowReservedWordsAsSelectors |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
440 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
441 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
442 |
allowReservedWordsAsSelectors:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
443 |
"enable/disable, if self, super, thisContext, nil, true and false are to be allowed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
444 |
as unary message selectors." |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
445 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
446 |
ParserFlags allowReservedWordsAsSelectors:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
447 |
self setupActions |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
448 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
449 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
450 |
self allowReservedWordsAsSelectors:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
451 |
self allowReservedWordsAsSelectors:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
452 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
453 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
454 |
|
141 | 455 |
arraysAreImmutable |
456 |
"return true if arrays are immutable literals" |
|
457 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
458 |
^ ParserFlags arraysAreImmutable |
141 | 459 |
! |
460 |
||
461 |
arraysAreImmutable:aBoolean |
|
462 |
"turn on/off immutable array literals - default is false for ST-80 compatibilty." |
|
463 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
464 |
ParserFlags arraysAreImmutable:aBoolean. |
141 | 465 |
|
466 |
" |
|
467 |
can be added to your private.rc file: |
|
468 |
||
469 |
Compiler arraysAreImmutable:true |
|
470 |
Compiler arraysAreImmutable:false |
|
471 |
" |
|
472 |
! |
|
473 |
||
474 |
compileLazy |
|
475 |
"return true if compiling lazy" |
|
476 |
||
477 |
^ LazyCompilation. |
|
478 |
! |
|
479 |
||
480 |
compileLazy:aBoolean |
|
481 |
"turn on/off lazy compilation - return previous setting. |
|
482 |
Actually this flag belongs into the ByteCodeCompiler subclass, |
|
483 |
but it also controls the reporting of some errors here; therefore |
|
484 |
its located here" |
|
485 |
||
486 |
|oldLazy| |
|
487 |
||
488 |
oldLazy := LazyCompilation. |
|
489 |
LazyCompilation := aBoolean. |
|
490 |
^ oldLazy |
|
491 |
||
492 |
" |
|
493 |
Compiler compileLazy:false |
|
494 |
Compiler compileLazy:true |
|
495 |
" |
|
496 |
! |
|
497 |
||
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
498 |
foldConstants |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
499 |
"return a symbol describing how constants are to be folded" |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
500 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
501 |
^ FoldConstants |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
502 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
503 |
"Created: 9.2.1996 / 17:40:13 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
504 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
505 |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
506 |
foldConstants:aSymbol |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
507 |
"set the symbol describing how constants are to be folded. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
508 |
It can be: |
1576 | 509 |
nil - no constant folding |
510 |
#level1 - numeric constants only |
|
511 |
#level2 - level1 PLUS array conversions PLUS string concatenation |
|
512 |
#full - level2 PLUS constant points, constant rectangles (dangerous)" |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
513 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
514 |
FoldConstants := aSymbol |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
515 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
516 |
"Created: 9.2.1996 / 17:40:34 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
517 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
518 |
|
141 | 519 |
implicitSelfSends |
520 |
"return true if undefined variables with |
|
521 |
lowercase first character are to be turned |
|
522 |
into implicit self sends" |
|
523 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
524 |
^ ParserFlags implicitSelfSends |
141 | 525 |
! |
526 |
||
527 |
implicitSelfSends:aBoolean |
|
528 |
"turn on/off implicit self sends" |
|
529 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
530 |
ParserFlags implicitSelfSends:aBoolean |
141 | 531 |
|
532 |
" |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
533 |
ParserFlags implicitSelfSends:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
534 |
ParserFlags implicitSelfSends:false |
141 | 535 |
" |
377 | 536 |
! |
537 |
||
538 |
lineNumberInfo |
|
539 |
^ LineNumberInfo |
|
540 |
! |
|
541 |
||
542 |
lineNumberInfo:aBoolean |
|
543 |
LineNumberInfo := aBoolean |
|
752 | 544 |
! |
545 |
||
546 |
stringsAreImmutable |
|
547 |
"return true if strings are immutable literals" |
|
548 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
549 |
^ ParserFlags stringsAreImmutable |
752 | 550 |
|
551 |
"Created: / 3.8.1998 / 14:53:25 / cg" |
|
552 |
! |
|
553 |
||
554 |
stringsAreImmutable:aBoolean |
|
555 |
"turn on/off immutable string literals - default is false for ST-80 compatibilty." |
|
556 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
557 |
ParserFlags stringsAreImmutable:aBoolean. |
752 | 558 |
|
559 |
" |
|
560 |
can be added to your private.rc file: |
|
561 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
562 |
ParserFlags stringsAreImmutable:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
563 |
ParserFlags stringsAreImmutable:false |
752 | 564 |
" |
565 |
||
566 |
"Created: / 3.8.1998 / 14:53:28 / cg" |
|
1160 | 567 |
! |
568 |
||
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
569 |
warnAboutVariableNameConventions |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
570 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
571 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
572 |
^ ParserFlags warnAboutVariableNameConventions |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
573 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
574 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
575 |
warnAboutVariableNameConventions:aBoolean |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
576 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
577 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
578 |
ParserFlags warnAboutVariableNameConventions:aBoolean |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
579 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
580 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
581 |
warnAboutWrongVariableNames |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
582 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
583 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
584 |
^ ParserFlags warnAboutWrongVariableNames |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
585 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
586 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
587 |
warnAboutWrongVariableNames:aBoolean |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
588 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
589 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
590 |
ParserFlags warnAboutWrongVariableNames:aBoolean |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
591 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
592 |
|
1160 | 593 |
warnUnusedVars |
594 |
"controls generation of warning messages about unued method variables" |
|
595 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
596 |
^ ParserFlags warnUnusedVars |
1160 | 597 |
! |
598 |
||
599 |
warnUnusedVars:aBoolean |
|
600 |
"controls generation of warning messages about unued method variables" |
|
601 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
602 |
ParserFlags warnUnusedVars:aBoolean |
19 | 603 |
! ! |
0 | 604 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
605 |
!Parser class methodsFor:'defaults'! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
606 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
607 |
maxLineNumber |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
608 |
"return the maximum lineNumber that is possibly |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
609 |
encoded in a methods byteCode debugging information. |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
610 |
Since lineNumber entries only have 1 byte available, |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
611 |
this is 255 for byteCode methods." |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
612 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
613 |
^ 255 |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
614 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
615 |
"Created: 14.2.1997 / 16:52:54 / cg" |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
616 |
! ! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
617 |
|
1187 | 618 |
!Parser class methodsFor:'error correction'! |
619 |
||
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
620 |
findBest:nMax selectorsFor:aString in:aClassOrNil |
1187 | 621 |
"collect known selectors with their spelling distances to aString; |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
622 |
return the nMax best suggestions. If the argument, aClassOrNil is not nil, |
1187 | 623 |
the message is assumed to be sent to instances of that class (i.e. offer |
624 |
corrections from that hierarchy only)" |
|
625 |
||
1286 | 626 |
|info block lcSelector| |
1187 | 627 |
|
628 |
info := SortedCollection new. |
|
629 |
info sortBlock:[:a :b | a value > b value]. |
|
630 |
||
631 |
lcSelector := aString asLowercase. |
|
632 |
||
633 |
block := [:sym :mthd| |
|
1215 | 634 |
|dist lcSym keepThis| |
1187 | 635 |
|
636 |
lcSym := sym asLowercase. |
|
637 |
(info contains:[:i | i key == sym]) ifFalse:[ |
|
638 |
dist := lcSelector spellAgainst:lcSym. |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
639 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
640 |
(lcSym startsWith:lcSelector) ifTrue:[ |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
641 |
dist := dist + (aString size * 10). |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
642 |
]. |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
643 |
|
1215 | 644 |
(dist > 20) ifTrue:[ |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
645 |
(info contains:[:entry | entry key = sym]) ifFalse:[ |
1215 | 646 |
keepThis := true. |
647 |
info size >= nMax ifTrue:[ |
|
648 |
"will remove last entry anyway - so check if this one will remain ..." |
|
649 |
dist < info last value ifTrue:[ |
|
650 |
keepThis := false. |
|
651 |
] |
|
652 |
]. |
|
653 |
keepThis ifTrue:[ |
|
654 |
"expensive - therefore do this check at last" |
|
655 |
mthd isObsolete ifFalse:[ |
|
656 |
info add:(sym -> dist). |
|
657 |
info size > nMax ifTrue:[ |
|
658 |
info removeLast. |
|
659 |
] |
|
660 |
] |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
661 |
] |
1187 | 662 |
] |
663 |
] |
|
664 |
] |
|
665 |
]. |
|
666 |
||
667 |
aClassOrNil isNil ifTrue:[ |
|
668 |
Smalltalk allClassesDo:[:cls | |
|
669 |
cls methodDictionary keysAndValuesDo:block. |
|
670 |
cls class methodDictionary keysAndValuesDo:block. |
|
671 |
] |
|
672 |
] ifFalse:[ |
|
673 |
aClassOrNil withAllSuperclassesDo:[:cls | |
|
674 |
cls methodDictionary keysAndValuesDo:block. |
|
1323 | 675 |
"/ cls class methodDictionary keysAndValuesDo:block. |
1187 | 676 |
] |
677 |
]. |
|
678 |
||
679 |
^ info asOrderedCollection collect:[:a | a key] |
|
680 |
||
681 |
"Modified: / 19.1.2000 / 16:43:37 / cg" |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
682 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
683 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
684 |
findBestSelectorsFor:aString |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
685 |
"collect known selectors with their spelling distances to aString; |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
686 |
return the 10 best suggestions" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
687 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
688 |
^ self findBestSelectorsFor:aString in:nil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
689 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
690 |
" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
691 |
Parser findBestSelectorsFor:'at' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
692 |
Parser findBestSelectorsFor:'at:pu' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
693 |
" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
694 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
695 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
696 |
findBestSelectorsFor:aString in:aClassOrNil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
697 |
"collect known selectors with their spelling distances to aString; |
1323 | 698 |
return the 15 best suggestions. If the argument, aClassOrNil is not nil, |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
699 |
the message is assumed to be sent to instances of that class (i.e. offer |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
700 |
corrections from that hierarchy only)" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
701 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
702 |
^ self |
1323 | 703 |
findBest:15 selectorsFor:aString in:aClassOrNil |
1187 | 704 |
! ! |
705 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
706 |
!Parser class methodsFor:'evaluating expressions'! |
0 | 707 |
|
19 | 708 |
evaluate:aStringOrStream |
71 | 709 |
"return the result of evaluating an expression in aStringOrStream. |
710 |
No doit-entry is added to the changeLog." |
|
0 | 711 |
|
19 | 712 |
^ self |
1576 | 713 |
evaluate:aStringOrStream |
714 |
in:nil |
|
715 |
receiver:nil |
|
716 |
notifying:nil |
|
717 |
logged:false |
|
718 |
ifFail:nil |
|
719 |
compile:true |
|
19 | 720 |
|
721 |
" |
|
722 |
Compiler evaluate:'1 + 2' |
|
723 |
Compiler evaluate:'''hello world'' asSortedCollection displayString printNL' |
|
724 |
Compiler evaluate:'''hello world'' asSortedCollection printNL' |
|
725 |
" |
|
0 | 726 |
! |
727 |
||
71 | 728 |
evaluate:aStringOrStream compile:compile |
729 |
"return the result of evaluating aString, |
|
730 |
The compile argument specifies if the string should be compiled down to |
|
731 |
bytecode or instead be interpreted from the parseTree. |
|
732 |
The first should be done for doIts etc, where a readable walkback is |
|
733 |
required. |
|
734 |
The latter is better done for constants, styleSheet and resource |
|
735 |
reading and simple sends, where the overhead of compilation is bigger |
|
736 |
than the interpretation overhead." |
|
737 |
||
738 |
^ self |
|
1576 | 739 |
evaluate:aStringOrStream |
740 |
in:nil |
|
741 |
receiver:nil |
|
742 |
notifying:nil |
|
743 |
logged:false |
|
744 |
ifFail:nil |
|
745 |
compile:compile |
|
71 | 746 |
! |
747 |
||
20 | 748 |
evaluate:aStringOrStream ifFail:failBlock |
749 |
"return the result of evaluating an expression in aStringOrStream. |
|
71 | 750 |
In case of any syntax errors, return the value of failBlock. |
751 |
No doit-entry is added to the changeLog." |
|
20 | 752 |
|
753 |
^ self |
|
1576 | 754 |
evaluate:aStringOrStream |
755 |
in:nil |
|
756 |
receiver:nil |
|
757 |
notifying:nil |
|
758 |
logged:false |
|
759 |
ifFail:failBlock |
|
760 |
compile:true |
|
20 | 761 |
" |
762 |
Compiler evaluate:'1 +' ifFail:['oops'] |
|
763 |
" |
|
764 |
! |
|
765 |
||
71 | 766 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock |
767 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
768 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
769 |
No doIt entry is added to the change-file. |
|
770 |
If the failBlock argument is non-nil, it is evaluated if an error occurs." |
|
771 |
||
772 |
^ self |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
773 |
evaluate:aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
774 |
in:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
775 |
receiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
776 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
777 |
logged:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
778 |
ifFail:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
779 |
compile:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
780 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
781 |
"Modified: / 17.1.1998 / 02:54:07 / cg" |
20 | 782 |
! |
783 |
||
784 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
|
785 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
786 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
787 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
788 |
is non-nil, it is evaluated if an error occurs." |
|
789 |
||
71 | 790 |
^ self |
1576 | 791 |
evaluate:aStringOrStream |
792 |
in:aContext |
|
793 |
receiver:anObject |
|
794 |
notifying:requestor |
|
795 |
logged:logged |
|
796 |
ifFail:failBlock |
|
797 |
compile:true |
|
71 | 798 |
! |
799 |
||
800 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
801 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
802 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
803 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
804 |
is non-nil, it is evaluated if an error occurs. |
|
805 |
Finally, compile specifies if the string should be compiled down to |
|
806 |
bytecode or instead be interpreted from the parseTree. |
|
807 |
The first should be done for doIts etc, where a readable walkback is |
|
808 |
required. |
|
809 |
The latter is better done for constants, styleSheet and resource |
|
810 |
reading and simple sends, where the overhead of compilation is bigger |
|
811 |
than the interpretation overhead." |
|
812 |
||
1363 | 813 |
^ self new |
1548 | 814 |
evaluate:aStringOrStream |
815 |
in:aContext |
|
816 |
receiver:anObject |
|
817 |
notifying:requestor |
|
818 |
logged:logged |
|
819 |
ifFail:failBlock |
|
820 |
compile:compile |
|
1561
175735dcd732
do not check for endOfInput if parsing from a Stream
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
821 |
checkForEndOfInput:(aStringOrStream isStream not) |
141 | 822 |
! |
823 |
||
824 |
evaluate:aStringOrStream logged:logged |
|
825 |
"return the result of evaluating an expression in aStringOrStream. |
|
826 |
The argument log controls if an entry is added to the changeLog." |
|
827 |
||
828 |
^ self |
|
1576 | 829 |
evaluate:aStringOrStream |
830 |
in:nil |
|
831 |
receiver:nil |
|
832 |
notifying:nil |
|
833 |
logged:logged |
|
834 |
ifFail:nil |
|
835 |
compile:true |
|
141 | 836 |
" |
837 |
Compiler evaluate:'''some string''' logged:false |
|
838 |
Compiler evaluate:'''some string''' logged:true |
|
839 |
" |
|
840 |
! |
|
841 |
||
842 |
evaluate:aStringOrStream notifying:requestor |
|
843 |
"return the result of evaluating aString, |
|
844 |
errors are reported to requestor" |
|
845 |
||
846 |
^ self |
|
1576 | 847 |
evaluate:aStringOrStream |
848 |
in:nil |
|
849 |
receiver:nil |
|
850 |
notifying:requestor |
|
851 |
logged:false |
|
852 |
ifFail:nil |
|
853 |
compile:true |
|
141 | 854 |
! |
855 |
||
856 |
evaluate:aStringOrStream notifying:requestor compile:compile |
|
857 |
"return the result of evaluating aString, |
|
858 |
errors are reported to requestor. |
|
859 |
The compile argument specifies if the string should be compiled down to |
|
860 |
bytecode or instead be interpreted from the parseTree. |
|
861 |
The first should be done for doIts etc, where a readable walkback is |
|
862 |
required. |
|
863 |
The latter is better done for constants, styleSheet and resource |
|
864 |
reading and simple sends, where the overhead of compilation is bigger |
|
865 |
than the interpretation overhead." |
|
866 |
||
867 |
^ self |
|
1576 | 868 |
evaluate:aStringOrStream |
869 |
in:nil |
|
870 |
receiver:nil |
|
871 |
notifying:requestor |
|
872 |
logged:false |
|
873 |
ifFail:nil |
|
874 |
compile:compile |
|
141 | 875 |
! |
876 |
||
1025
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
877 |
evaluate:aStringOrStream notifying:requestor logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
878 |
"return the result of evaluating aString, |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
879 |
errors are reported to requestor" |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
880 |
|
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
881 |
^ self |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
882 |
evaluate:aStringOrStream |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
883 |
in:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
884 |
receiver:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
885 |
notifying:requestor |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
886 |
logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
887 |
ifFail:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
888 |
compile:true |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
889 |
! |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
890 |
|
572 | 891 |
evaluate:aStringOrStream receiver:anObject |
892 |
"return the result of evaluating aString, |
|
893 |
errors are reported to requestor. Allow access to |
|
894 |
anObject as self and to its instVars " |
|
895 |
||
896 |
^ self |
|
1576 | 897 |
evaluate:aStringOrStream |
898 |
in:nil |
|
899 |
receiver:anObject |
|
900 |
notifying:nil |
|
901 |
logged:false |
|
902 |
ifFail:nil |
|
903 |
compile:true |
|
572 | 904 |
|
905 |
" |
|
906 |
Compiler evaluate:'self x' receiver:(1 @ 2) |
|
907 |
" |
|
908 |
||
909 |
"Created: 1.7.1997 / 19:02:24 / cg" |
|
910 |
"Modified: 1.7.1997 / 19:02:33 / cg" |
|
911 |
! |
|
912 |
||
919 | 913 |
evaluate:aStringOrStream receiver:someOne logged:logged |
914 |
"return the result of evaluating an expression in aStringOrStream. |
|
915 |
The argument log controls if an entry is added to the changeLog." |
|
916 |
||
917 |
^ self |
|
918 |
evaluate:aStringOrStream |
|
919 |
in:nil |
|
920 |
receiver:someOne |
|
921 |
notifying:nil |
|
922 |
logged:logged |
|
923 |
ifFail:nil |
|
924 |
compile:true |
|
925 |
" |
|
926 |
Compiler evaluate:'''some string''' logged:false |
|
927 |
Compiler evaluate:'''some string''' logged:true |
|
928 |
Compiler evaluate:'self class' receiver:nil logged:false |
|
929 |
Compiler evaluate:'self class' receiver:1 logged:false |
|
930 |
" |
|
931 |
! |
|
932 |
||
141 | 933 |
evaluate:aStringOrStream receiver:anObject notifying:requestor |
934 |
"return the result of evaluating aString, |
|
935 |
errors are reported to requestor. Allow access to |
|
936 |
anObject as self and to its instVars (used in the inspector)" |
|
937 |
||
938 |
^ self |
|
1576 | 939 |
evaluate:aStringOrStream |
940 |
in:nil |
|
941 |
receiver:anObject |
|
942 |
notifying:requestor |
|
943 |
logged:false |
|
944 |
ifFail:nil |
|
945 |
compile:true |
|
141 | 946 |
|
947 |
" |
|
948 |
Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil |
|
949 |
" |
|
950 |
! |
|
951 |
||
952 |
evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile |
|
953 |
"return the result of evaluating aString, |
|
954 |
errors are reported to requestor. Allow access to |
|
955 |
anObject as self and to its instVars (used in the inspector). |
|
956 |
The compile argument specifies if the string should be compiled down to |
|
957 |
bytecode or instead be interpreted from the parseTree. |
|
958 |
The first should be done for doIts etc, where a readable walkback is |
|
959 |
required. |
|
960 |
The latter is better done for constants, styleSheet and resource |
|
961 |
reading and simple sends, where the overhead of compilation is bigger |
|
962 |
than the interpretation overhead." |
|
963 |
||
964 |
^ self |
|
1576 | 965 |
evaluate:aStringOrStream |
966 |
in:nil |
|
967 |
receiver:anObject |
|
968 |
notifying:requestor |
|
969 |
logged:false |
|
970 |
ifFail:nil |
|
971 |
compile:compile |
|
1548 | 972 |
! |
973 |
||
974 |
evaluateFrom:aStringOrStream ifFail:failBlock |
|
975 |
"return the result of evaluating an expression from aStringOrStream. |
|
976 |
In case of any syntax errors, return the value of failBlock. |
|
977 |
No doit-entry is added to the changeLog." |
|
978 |
||
979 |
^ self |
|
980 |
evaluateFrom:aStringOrStream |
|
981 |
in:nil |
|
982 |
receiver:nil |
|
983 |
notifying:nil |
|
984 |
logged:false |
|
985 |
ifFail:failBlock |
|
986 |
compile:true |
|
987 |
" |
|
988 |
Compiler evaluate:'1 + 2' ifFail:['oops'] |
|
989 |
" |
|
990 |
! |
|
991 |
||
992 |
evaluateFrom:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
993 |
"return the result of evaluating the next expression from aStringOrStream, errors are reported to requestor. |
|
994 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
995 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
996 |
is non-nil, it is evaluated if an error occurs. |
|
997 |
Finally, compile specifies if the string should be compiled down to |
|
998 |
bytecode or instead be interpreted from the parseTree. |
|
999 |
The first should be done for doIts etc, where a readable walkback is |
|
1000 |
required. |
|
1001 |
The latter is better done for constants, styleSheet and resource |
|
1002 |
reading and simple sends, where the overhead of compilation is bigger |
|
1003 |
than the interpretation overhead." |
|
1004 |
||
1005 |
^ self new |
|
1006 |
evaluate:aStringOrStream |
|
1007 |
in:aContext |
|
1008 |
receiver:anObject |
|
1009 |
notifying:requestor |
|
1010 |
logged:logged |
|
1011 |
ifFail:failBlock |
|
1012 |
compile:compile |
|
1013 |
checkForEndOfInput:false |
|
0 | 1014 |
! ! |
1015 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1016 |
!Parser class methodsFor:'general helpers'! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1017 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1018 |
argAndVarNamesForContext:aContext |
1546 | 1019 |
<resource:#obsolete> |
1446
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
1020 |
self obsoleteMethodWarning. |
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
1021 |
^ aContext argAndVarNames. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1022 |
! ! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1023 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1024 |
!Parser class methodsFor:'parsing'! |
141 | 1025 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1026 |
blockAtLine:line in:aMethod orSource:aString numArgs:nA numVars:nV |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1027 |
"given a lineNr in some method, |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1028 |
return the containing BlockNode or nil. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1029 |
The given lineNr must be within a block for this to work. |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1030 |
This is used by the debugger, to guess reverse from a lineNumber, |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1031 |
to the corresponding block, in order to find out the blocks |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1032 |
variable names (mhmh - all of this wasnt't needed, if blocks stored |
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1033 |
their characterPosition internally)." |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1034 |
|
429 | 1035 |
|compiler tree mSource who mClass blocks |
397 | 1036 |
maxSoFar innerBlock m| |
1037 |
||
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1038 |
(line isNil or:[line == self maxLineNumber]) ifTrue:[ |
815 | 1039 |
^ nil |
457
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1040 |
]. |
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1041 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1042 |
aMethod notNil ifTrue:[ |
815 | 1043 |
m := aMethod. |
1044 |
who := m who. |
|
1045 |
who isNil ifTrue:[ |
|
1046 |
m isWrapped ifTrue:[ |
|
1047 |
m := m wrapper. |
|
1048 |
m notNil ifTrue:[ |
|
1049 |
who := m who. |
|
1050 |
] |
|
1051 |
] |
|
1052 |
]. |
|
1053 |
who notNil ifTrue:[ |
|
1054 |
mClass := who methodClass. |
|
1055 |
mClass isNil ifTrue:[ ^ nil]. |
|
1056 |
]. |
|
1057 |
||
1058 |
mSource := m source. |
|
1059 |
mSource isNil ifTrue:[^ nil]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1060 |
] ifFalse:[ |
815 | 1061 |
aString notNil ifTrue:[ |
1062 |
mSource := aString. |
|
1063 |
mClass := UndefinedObject |
|
1064 |
] ifFalse:[ |
|
1065 |
^ nil |
|
1066 |
] |
|
397 | 1067 |
]. |
1068 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1069 |
"create a compiler, let it parse and create the parsetree" |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1070 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1071 |
compiler := self for:(ReadStream on:mSource) in:mClass. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1072 |
compiler parseForCode. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1073 |
compiler notifying:nil. |
1365 | 1074 |
compiler ignoreWarnings:true. |
1075 |
compiler ignoreErrors:true. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1076 |
compiler lineNumberInfo:#full. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1077 |
|
1515
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1078 |
Notification |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1079 |
handle: |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1080 |
[:ex | |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1081 |
ex proceed |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1082 |
] |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1083 |
do:[ |
1514 | 1084 |
aMethod notNil ifTrue:[ |
1085 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
|
1086 |
^ nil. |
|
1087 |
]. |
|
1088 |
||
1089 |
who notNil ifTrue:[ |
|
1090 |
compiler selector ~~ (who methodSelector) ifTrue:[ |
|
1091 |
^ nil |
|
1092 |
] |
|
1093 |
]. |
|
1094 |
] ifFalse:[ |
|
1095 |
compiler nextToken. |
|
1096 |
]. |
|
1097 |
||
1098 |
tree := compiler parseMethodBody. |
|
1515
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1099 |
]. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1100 |
|
815 | 1101 |
(compiler errorFlag |
1102 |
or:[tree == #Error |
|
1103 |
or:[tree isNil]]) ifTrue:[ |
|
1104 |
^ nil |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1105 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1106 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1107 |
blocks := OrderedCollection new. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1108 |
tree collectBlocksInto:blocks. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1109 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1110 |
blocks := blocks select:[:aBlock | |
815 | 1111 |
line between: aBlock lineNumber and:aBlock endLineNumber |
1112 |
||
1113 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1114 |
blocks size == 1 ifTrue:[ |
815 | 1115 |
^ blocks at:1 |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1116 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1117 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1118 |
nA notNil ifTrue:[ |
815 | 1119 |
blocks := blocks select:[:aBlock | |
1120 |
aBlock numArgs == nA |
|
1121 |
]. |
|
1122 |
blocks size == 1 ifTrue:[ |
|
1123 |
^ blocks at:1 |
|
1124 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1125 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1126 |
nV notNil ifTrue:[ |
815 | 1127 |
blocks := blocks select:[:aBlock | |
1128 |
aBlock numVars == nV |
|
1129 |
]. |
|
1130 |
blocks size == 1 ifTrue:[ |
|
1131 |
^ blocks at:1 |
|
1132 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1133 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1134 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1135 |
"/ look for the inner one |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1136 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1137 |
maxSoFar := 0. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1138 |
blocks do:[:aBlock | |
815 | 1139 |
aBlock lineNumber > maxSoFar ifTrue:[ |
1140 |
innerBlock := aBlock. |
|
1141 |
maxSoFar := aBlock lineNumber |
|
1142 |
] |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1143 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1144 |
^ innerBlock. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1145 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1146 |
"Created: 11.1.1997 / 23:29:13 / cg" |
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1147 |
"Modified: 14.2.1997 / 16:51:25 / cg" |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1148 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1149 |
|
1365 | 1150 |
checkMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
629 | 1151 |
"parse a method in a given class. |
1152 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1153 |
The parser can be queried for selector, receiver, args, locals, |
|
1154 |
used selectors, modified instvars, referenced classvars etc. |
|
1155 |
The noErrors and noWarnings arguments specify if error and warning |
|
1156 |
messages should be sent to the Transcript or suppressed." |
|
1157 |
||
1158 |
|parser tree| |
|
1159 |
||
1160 |
aString isNil ifTrue:[^ nil]. |
|
1161 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1162 |
parser ignoreErrors:ignoreErrors. |
1163 |
parser ignoreWarnings:ignoreWarnings. |
|
629 | 1164 |
tree := parser parseMethod. |
1165 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1166 |
||
1167 |
ReadBeforeWrittenTester searchForReadBeforeWrittenIn:tree |
|
1168 |
||
1169 |
" |
|
1170 |
self |
|
1171 |
checkMethod:'foo |
|
1172 |
|local1 local2 local3| |
|
1173 |
||
1174 |
local1 := local2. |
|
1175 |
^ local3 |
|
1176 |
' |
|
1177 |
in:UndefinedObject |
|
1178 |
ignoreErrors:true |
|
1179 |
ignoreWarnings:true |
|
1180 |
" |
|
1181 |
||
1182 |
"Modified: / 30.10.1997 / 16:38:31 / cg" |
|
1183 |
! |
|
1184 |
||
141 | 1185 |
parseExpression:aString |
1186 |
"parse aString as an expression; |
|
1187 |
Return the parseTree (if ok), nil (for an empty string |
|
258 | 1188 |
or comment only) or #Error (syntactic error). |
1189 |
Error and warning messages are suppressed." |
|
141 | 1190 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1191 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1192 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1193 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1194 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1195 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1196 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1197 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1198 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1199 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1200 |
" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1201 |
Parser parseExpression:'self foo' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1202 |
Parser parseExpression:'self:123' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1203 |
Parser parseExpression:'self:123' onError:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1204 |
" |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1205 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1206 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1207 |
parseExpression:aString inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1208 |
"parse aString as an expression; |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1209 |
Return the parseTree (if ok), nil (for an empty string |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1210 |
or comment only) or #Error (syntactic error). |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1211 |
Error and warning messages are suppressed." |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1212 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1213 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1214 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1215 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1216 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1217 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1218 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1219 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1220 |
inNameSpace:aNameSpaceOrNil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1221 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1222 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1223 |
"Created: 24.6.1997 / 16:44:26 / cg" |
141 | 1224 |
! |
1225 |
||
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1226 |
parseExpression:aString inNameSpace:aNameSpaceOrNil onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1227 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1228 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1229 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1230 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1231 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1232 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1233 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1234 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1235 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1236 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1237 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1238 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1239 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1240 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1241 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1242 |
"Created: 24.6.1997 / 16:44:26 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1243 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1244 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1245 |
parseExpression:aString onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1246 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1247 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1248 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1249 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1250 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1251 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1252 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1253 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1254 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1255 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1256 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1257 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1258 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1259 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1260 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1261 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1262 |
|
141 | 1263 |
parseMethod:aString |
1264 |
"parse a method. |
|
1265 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1266 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1267 |
used selectors etc. |
1268 |
Error and warning messages are sent to the Transcript." |
|
141 | 1269 |
|
1270 |
^ self parseMethod:aString in:nil |
|
1271 |
||
1272 |
" |
|
1273 |
|p| |
|
1274 |
||
1275 |
p := Parser |
|
1576 | 1276 |
parseMethod:' |
1277 |
foo:arg1 bar:arg2 baz:arg3 |
|
1278 |
|l1 l2| |
|
1279 |
l1 := 0. |
|
1280 |
l2 := arg1. |
|
1281 |
^ self'. |
|
141 | 1282 |
|
1283 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1284 |
'args: ' print. p methodArgs printNL. |
|
1285 |
'sel: ' print. p selector printNL. |
|
1286 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1287 |
'locals: ' print. p methodVars printNL. |
|
1288 |
'tree: ' printNL. p tree printAllOn:Stdout. Stdout cr. |
|
1289 |
" |
|
258 | 1290 |
|
1291 |
"Modified: 24.4.1996 / 13:18:02 / cg" |
|
141 | 1292 |
! |
1293 |
||
1294 |
parseMethod:aString in:aClass |
|
1295 |
"parse a method in a given class. |
|
1296 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1297 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1298 |
used selectors, modified instvars, referenced classvars etc. |
1299 |
Error and warning messages are sent to the Transcript." |
|
141 | 1300 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1301 |
^ self |
1576 | 1302 |
parseMethod:aString |
1303 |
in:aClass |
|
1304 |
ignoreErrors:false |
|
1305 |
ignoreWarnings:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1306 |
|
258 | 1307 |
"Modified: 24.4.1996 / 13:18:34 / cg" |
141 | 1308 |
! |
1309 |
||
1365 | 1310 |
parseMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1311 |
"parse a method in a given class. |
1312 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1313 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1314 |
used selectors, modified instvars, referenced classvars etc. |
1315 |
The noErrors and noWarnings arguments specify if error and warning |
|
1316 |
messages should be sent to the Transcript or suppressed." |
|
141 | 1317 |
|
1318 |
|parser tree| |
|
1319 |
||
1320 |
aString isNil ifTrue:[^ nil]. |
|
1321 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1322 |
parser ignoreErrors:ignoreErrors. |
1323 |
parser ignoreWarnings:ignoreWarnings. |
|
141 | 1324 |
tree := parser parseMethod. |
1325 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1326 |
^ parser |
|
258 | 1327 |
|
1328 |
"Modified: 24.4.1996 / 13:19:23 / cg" |
|
141 | 1329 |
! |
1330 |
||
1331 |
parseMethod:aString in:aClass warnings:warnBoolean |
|
1332 |
"parse a method in a given class. |
|
1333 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1334 |
The parser can be queried for selector, receiver, args, locals, |
|
1335 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1336 |
The warnBoolean arguments specifies if warning |
1337 |
messages should be sent to the Transcript or suppressed. |
|
1338 |
||
1339 |
This method is OBSOLETE, and left in for backward compatibility." |
|
1340 |
||
1341 |
self obsoleteMethodWarning. |
|
141 | 1342 |
^ self |
1576 | 1343 |
parseMethod:aString |
1344 |
in:aClass |
|
1345 |
ignoreErrors:false |
|
1346 |
ignoreWarnings:warnBoolean not |
|
258 | 1347 |
|
1348 |
"Modified: 24.4.1996 / 13:28:05 / cg" |
|
141 | 1349 |
! |
1350 |
||
1351 |
parseMethodArgAndVarSpecification:aString |
|
1352 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1353 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1354 |
The parser can be queried for selector, receiver etc. |
1355 |
Error and warning messages are sent to the Transcript. |
|
1356 |
This method is OBSOLETE." |
|
1357 |
||
1358 |
self obsoleteMethodWarning. |
|
141 | 1359 |
^ self parseMethodArgAndVarSpecification:aString in:nil |
1360 |
||
1361 |
" |
|
1362 |
|p| |
|
1363 |
||
1364 |
p := Parser |
|
1576 | 1365 |
parseMethodArgAndVarSpecification:' |
1366 |
foo:arg1 bar:arg2 baz:arg3 |
|
1367 |
|l1 l2|'. |
|
141 | 1368 |
|
1369 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1370 |
'args: ' print. p methodArgs printNL. |
|
1371 |
'sel: ' print. p selector printNL. |
|
1372 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1373 |
'locals: ' print. p methodVars printNL. |
|
1374 |
" |
|
258 | 1375 |
|
1376 |
"Modified: 24.4.1996 / 13:29:43 / cg" |
|
141 | 1377 |
! |
1378 |
||
1379 |
parseMethodArgAndVarSpecification:aString in:aClass |
|
1380 |
"parse a methods selector, arg and var spec in a given class; |
|
1381 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1382 |
The parser can be queried for selector, receiver, args and locals. |
1383 |
Error and warning messages are sent to the Transcript. |
|
1384 |
This method is OBSOLETE." |
|
1385 |
||
1386 |
self obsoleteMethodWarning. |
|
141 | 1387 |
^ self parseMethodArgAndVarSpecification:aString |
1576 | 1388 |
in:aClass |
1389 |
ignoreErrors:false |
|
1390 |
ignoreWarnings:false |
|
1391 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1392 |
|
258 | 1393 |
"Modified: 24.4.1996 / 13:30:03 / cg" |
141 | 1394 |
! |
1395 |
||
1365 | 1396 |
parseMethodArgAndVarSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings parseBody:body |
141 | 1397 |
"parse a methods selector, arg and var spec in a given class; |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1398 |
If parseBody is true, also parse the statements |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1399 |
(for primitives & resourceSpecs). |
258 | 1400 |
The noErrors and noWarnings arguments specify if error and warning |
1401 |
messages should be sent to the Transcript or suppressed. |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1402 |
|
141 | 1403 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
1404 |
The parser can be queried for selector, receiver, args and locals" |
|
19 | 1405 |
|
0 | 1406 |
|parser| |
1407 |
||
141 | 1408 |
aString isNil ifTrue:[^ nil]. |
1409 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1410 |
parser ignoreErrors:ignoreErrors. |
1411 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1412 |
"/ parser nextToken. |
141 | 1413 |
(parser parseMethodSpec == #Error) ifTrue:[^ nil]. |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1414 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1415 |
"/ used to be #parseMethodBodyVarSpec |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1416 |
"/ - now, alternatively parse body for resource & primitive specs .. |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1417 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1418 |
body ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1419 |
parser parseMethodBodyOrEmpty |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1420 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1421 |
parser parseMethodBodyVarSpec |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1422 |
]. |
141 | 1423 |
parser errorFlag ifTrue:[^ nil]. |
0 | 1424 |
^ parser |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1425 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1426 |
"Created: 24.4.1996 / 13:13:06 / cg" |
265 | 1427 |
"Modified: 27.4.1996 / 16:58:02 / cg" |
141 | 1428 |
! |
1429 |
||
1430 |
parseMethodArgAndVarSpecificationSilent:aString |
|
1431 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1432 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1433 |
The parser can be queried for selector, receiver etc. |
|
258 | 1434 |
Like #parseMethodArgAndVarSpecification:, but does NOT |
141 | 1435 |
display error/warning messages on the transcript." |
1436 |
||
1437 |
^ self parseMethodArgAndVarSpecificationSilent:aString in:nil |
|
258 | 1438 |
|
1439 |
"Modified: 24.4.1996 / 13:30:54 / cg" |
|
141 | 1440 |
! |
1441 |
||
1442 |
parseMethodArgAndVarSpecificationSilent:aString in:aClass |
|
1443 |
"parse a methods selector, arg and var spec in a given class; |
|
1444 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1445 |
The parser can be queried for selector, receiver, args and locals. |
|
1446 |
Like #parseMethodArgAndVarSpecification:in:, but does not |
|
1447 |
display error/warning messages on the transcript." |
|
1448 |
||
1449 |
^ self parseMethodArgAndVarSpecification:aString |
|
1576 | 1450 |
in:aClass |
1451 |
ignoreErrors:true |
|
1452 |
ignoreWarnings:true |
|
1453 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1454 |
|
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1455 |
"Modified: 24.4.1996 / 13:14:27 / cg" |
141 | 1456 |
! |
1457 |
||
1458 |
parseMethodSilent:aString |
|
1459 |
"parse a method. |
|
1460 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1461 |
The parser can be queried for selector, receiver, args, locals, |
|
1462 |
used selectors etc. |
|
258 | 1463 |
Like #parseMethod:, but warning/error messages are suppressed." |
141 | 1464 |
|
1465 |
^ self parseMethodSilent:aString in:nil |
|
258 | 1466 |
|
1467 |
"Modified: 24.4.1996 / 13:32:44 / cg" |
|
141 | 1468 |
! |
1469 |
||
1470 |
parseMethodSilent:aString in:aClass |
|
1471 |
"parse a method in a given class. |
|
1472 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1473 |
The parser can be queried for selector, receiver, args, locals, |
|
1474 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1475 |
Like #parseMethod:in:, but warning/error messages are suppressed." |
1476 |
||
1477 |
^ self |
|
1576 | 1478 |
parseMethod:aString |
1479 |
in:aClass |
|
1480 |
ignoreErrors:true |
|
1481 |
ignoreWarnings:true |
|
258 | 1482 |
|
1483 |
"Modified: 24.4.1996 / 13:32:57 / cg" |
|
141 | 1484 |
! |
1485 |
||
1486 |
parseMethodSpecification:aString |
|
1487 |
"parse a methods selector & arg specification; |
|
1488 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1489 |
The parser can be queried for selector, receiver etc." |
|
1490 |
||
1491 |
^ self parseMethodSpecification:aString in:nil |
|
1492 |
||
1493 |
" |
|
1494 |
|p| |
|
1495 |
||
1496 |
p := Parser parseMethodSpecification:'foo:arg1 bar:arg2 baz:arg3'. |
|
1497 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1498 |
'args: ' print. p methodArgs printNL. |
|
1499 |
'sel: ' print. p selector printNL |
|
1500 |
" |
|
1501 |
! |
|
1502 |
||
1503 |
parseMethodSpecification:aString in:aClass |
|
1504 |
"parse a methods selector & arg spec for a given class; |
|
1505 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1506 |
The parser can be queried for selector, receiver etc." |
|
1507 |
||
1508 |
^ self parseMethodSpecification:aString |
|
1576 | 1509 |
in:aClass |
1510 |
ignoreErrors:false |
|
1511 |
ignoreWarnings:false |
|
141 | 1512 |
! |
1513 |
||
1365 | 1514 |
parseMethodSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1515 |
"parse a methods selector & arg spec for a given class; |
1516 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1517 |
The parser can be queried for selector, receiver etc. |
|
1518 |
noErrors and noWarnings specify if error- and warningMessages are |
|
1519 |
to be output onto the Transcript." |
|
1520 |
||
1521 |
|parser tree| |
|
1522 |
||
1523 |
aString isNil ifTrue:[^ nil]. |
|
1524 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1525 |
parser ignoreErrors:ignoreErrors. |
1526 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1527 |
"/ parser nextToken. |
141 | 1528 |
tree := parser parseMethodSpec. |
1529 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1530 |
^ parser |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1531 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1532 |
"Modified: 20.4.1996 / 20:09:48 / cg" |
141 | 1533 |
! |
1534 |
||
1535 |
parseMethodSpecificationSilent:aString |
|
1536 |
"parse a methods selector & arg specification; |
|
1537 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1538 |
The parser can be queried for selector, receiver etc. |
|
1539 |
Like #parseMethodSpecification:, but does not display any error/warning Messages on the transcript." |
|
1540 |
||
1541 |
^ self parseMethodSpecificationSilent:aString in:nil |
|
1542 |
! |
|
1543 |
||
1544 |
parseMethodSpecificationSilent:aString in:aClass |
|
1545 |
"parse a methods selector & arg spec for a given class; |
|
1546 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1547 |
The parser can be queried for selector, receiver etc. |
|
1548 |
Like #parseMethodSpecification:in:, but does not display any error/warning Messages on the transcript." |
|
1549 |
||
1550 |
^ self parseMethodSpecification:aString |
|
1576 | 1551 |
in:aClass |
1552 |
ignoreErrors:true |
|
1553 |
ignoreWarnings:true |
|
141 | 1554 |
|
1555 |
"Created: 31.10.1995 / 14:37:49 / cg" |
|
1556 |
! |
|
0 | 1557 |
|
7 | 1558 |
selectorInExpression:aString |
47 | 1559 |
"parse an expression - return the selector. Even malformed expressions |
1560 |
(such as missing receiver or missing arg are parsed. |
|
1561 |
Used for the SystemBrowsers implementors/senders query-box initial text. |
|
21 | 1562 |
Returns nil if unparsable." |
7 | 1563 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1564 |
|tree parser sel| |
7 | 1565 |
|
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1566 |
(aString size == 0) ifTrue:[^ nil]. |
7 | 1567 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1568 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1569 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1570 |
do:[ |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1571 |
tree := self withSelf:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1572 |
parseExpression:aString |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1573 |
notifying:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1574 |
ignoreErrors:true |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1575 |
ignoreWarnings:true. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1576 |
]. |
21 | 1577 |
|
1578 |
" |
|
1579 |
special: take the expression of the right side, if its an |
|
1580 |
assignment or return |
|
1581 |
" |
|
7 | 1582 |
(tree notNil and:[tree ~~ #Error]) ifTrue:[ |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1583 |
(tree isAssignment |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1584 |
or:[tree isReturnNode]) ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1585 |
tree expression isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1586 |
tree := tree expression |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1587 |
] |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1588 |
]. |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1589 |
tree isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1590 |
^ tree selector |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1591 |
]. |
7 | 1592 |
]. |
1593 |
||
21 | 1594 |
" |
1595 |
mhmh, try expression without receiver |
|
1596 |
" |
|
7 | 1597 |
parser := self for:(ReadStream on:aString). |
1365 | 1598 |
parser ignoreErrors:true. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1599 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1600 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1601 |
do:[ |
1482
d80c83f1167a
catch twoByte string parsing in selectorInExpression
Claus Gittinger <cg@exept.de>
parents:
1471
diff
changeset
|
1602 |
parser nextToken. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1603 |
sel := parser degeneratedKeywordExpressionForSelector |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1604 |
]. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1605 |
^ sel |
7 | 1606 |
|
1607 |
" |
|
20 | 1608 |
Parser selectorInExpression:'foo at:1 put:(5 * bar)' |
1609 |
Parser selectorInExpression:'(foo at:1) at:1' |
|
47 | 1610 |
Parser selectorInExpression:'a + 4' |
1611 |
Parser selectorInExpression:'a negated' |
|
20 | 1612 |
Parser selectorInExpression:'at:1 put:5' |
47 | 1613 |
Parser selectorInExpression:'at:1 put:' |
1614 |
Parser selectorInExpression:'a at:1 put:5' |
|
1615 |
Parser selectorInExpression:'a at:1 put:' |
|
20 | 1616 |
Parser selectorInExpression:'a := foo at:1 put:5' |
7 | 1617 |
" |
451 | 1618 |
|
1619 |
"Modified: 17.12.1996 / 12:12:47 / cg" |
|
7 | 1620 |
! |
1621 |
||
1622 |
withSelf:anObject parseExpression:aString notifying:someOne |
|
1623 |
"parse aString as an expression with self set to anObject; |
|
21 | 1624 |
Return the parseTree (if ok), nil (for an empty string |
1625 |
or comment only ) or #Error (syntactic error). |
|
1626 |
||
1627 |
Errors and warnings are forwarded to someOne (usually some |
|
1628 |
codeView) which can highlight it and show a popup box." |
|
7 | 1629 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1630 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1631 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1632 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1633 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1634 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1635 |
ignoreErrors:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1636 |
ignoreWarnings:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1637 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1638 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1639 |
"Modified: 24.6.1997 / 16:43:37 / cg" |
7 | 1640 |
! |
1641 |
||
1642 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignore |
|
0 | 1643 |
"parse aString as an expression with self set to anObject; |
21 | 1644 |
Return the parseTree (if ok), nil (for an empty string |
1645 |
or comment only ) or #Error (syntactic error). |
|
1646 |
||
1647 |
Errors and warnings are forwarded to someOne (usually some |
|
1648 |
codeView) which can highlight it and show a popup box." |
|
1649 |
||
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1650 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1651 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1652 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1653 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1654 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1655 |
ignoreErrors:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1656 |
ignoreWarnings:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1657 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1658 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1659 |
"Modified: 24.6.1997 / 16:43:26 / cg" |
21 | 1660 |
! |
1661 |
||
1662 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
|
1663 |
"parse aString as an expression with self set to anObject; |
|
1664 |
Return the parseTree (if ok), nil (for an empty string |
|
1665 |
or comment only ) or #Error (syntactic error). |
|
1666 |
||
1667 |
Errors and warnings are forwarded to someOne (usually some |
|
1668 |
codeView) which can highlight it and show a popup box, |
|
1669 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
0 | 1670 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1671 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1672 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1673 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1674 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1675 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1676 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1677 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1678 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1679 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1680 |
"Modified: 24.6.1997 / 16:43:12 / cg" |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1681 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1682 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1683 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1684 |
"parse aString as an expression with self set to anObject; |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1685 |
Return the parseTree (if ok), nil (for an empty string |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1686 |
or comment only ) or #Error (syntactic error). |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1687 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1688 |
Errors and warnings are forwarded to someOne (usually some |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1689 |
codeView) which can highlight it and show a popup box, |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1690 |
iff ignoreErrors/ignoreWarnings is true respectively." |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1691 |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1692 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1693 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1694 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1695 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1696 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1697 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1698 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1699 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1700 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1701 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1702 |
withSelf:anObject parseExpression:aString onError:errorValue notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1703 |
"parse aString as an expression with self set to anObject; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1704 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1705 |
or comment only ) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1706 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1707 |
Errors and warnings are forwarded to someOne (usually some |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1708 |
codeView) which can highlight it and show a popup box, |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1709 |
iff ignoreErrors/ignoreWarnings is true respectively." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1710 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1711 |
|parser tree| |
0 | 1712 |
|
1713 |
aString isNil ifTrue:[^ nil]. |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1714 |
|
0 | 1715 |
parser := self for:(ReadStream on:aString). |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1716 |
tree := parser |
1006 | 1717 |
parseExpressionWithSelf:anObject |
1718 |
notifying:someOne |
|
1719 |
ignoreErrors:ignoreErrors |
|
1720 |
ignoreWarnings:ignoreWarnings |
|
1721 |
inNameSpace:aNameSpaceOrNil. |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1722 |
tree == #Error ifTrue:[ |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1723 |
^ errorValue value |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1724 |
]. |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1725 |
^ tree |
1006 | 1726 |
|
1727 |
"Modified: / 14.12.1999 / 15:12:16 / cg" |
|
0 | 1728 |
! ! |
1729 |
||
1621 | 1730 |
!Parser class methodsFor:'private'! |
1731 |
||
1732 |
makeImmutableArray:anArray |
|
1733 |
|newArray| |
|
1734 |
||
1735 |
newArray := anArray copy. |
|
1736 |
ImmutableArray notNil ifTrue:[ |
|
1737 |
newArray changeClassTo:ImmutableArray. |
|
1738 |
]. |
|
1739 |
newArray beImmutable. |
|
1740 |
^ newArray |
|
1741 |
! |
|
1742 |
||
1743 |
makeImmutableString:aString |
|
1744 |
|newString| |
|
1745 |
||
1746 |
newString := aString copy. |
|
1747 |
ImmutableString notNil ifTrue:[ |
|
1748 |
newString changeClassTo:ImmutableString. |
|
1749 |
]. |
|
1750 |
newString beImmutable. |
|
1751 |
^ newString |
|
1752 |
! ! |
|
1753 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1754 |
!Parser class methodsFor:'unparsing'! |
20 | 1755 |
|
1756 |
methodSpecificationForSelector:aSelector |
|
1757 |
"given a selector such as #foo:bar:, return a string that could |
|
1758 |
serve as a methods specification source code. |
|
1759 |
To be used for code generators" |
|
1760 |
||
807 | 1761 |
|argNames n| |
1762 |
||
1763 |
n := aSelector numArgs. |
|
1764 |
n == 1 ifTrue:[ |
|
1765 |
argNames := #('arg') |
|
1766 |
] ifFalse:[ |
|
1767 |
n <= 15 ifTrue:[ |
|
1768 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' |
|
1769 |
'arg7' 'arg8' 'arg9' 'arg10' 'arg11' 'arg12' |
|
1770 |
'arg13' 'arg14' 'arg15') |
|
1771 |
] ifFalse:[ |
|
1772 |
argNames := (1 to:aSelector numArgs) collect:[:i | 'arg' , i printString]. |
|
1773 |
]. |
|
1774 |
]. |
|
1775 |
^ self methodSpecificationForSelector:aSelector argNames:argNames |
|
1776 |
||
20 | 1777 |
" |
807 | 1778 |
Parser methodSpecificationForSelector:#foo: |
20 | 1779 |
Parser methodSpecificationForSelector:#foo:bar: |
807 | 1780 |
Parser methodSpecificationForSelector:#foo:bar:baz: |
21 | 1781 |
Parser methodSpecificationForSelector:#+ |
20 | 1782 |
Parser methodSpecificationForSelector:#negated |
1783 |
" |
|
807 | 1784 |
|
1785 |
"Modified: / 12.2.1999 / 13:12:44 / cg" |
|
20 | 1786 |
! |
1787 |
||
1788 |
methodSpecificationForSelector:aSelector argNames:argNames |
|
1789 |
"given a selector such as #foo:bar:, return a string that could |
|
1790 |
serve as a methods specification source code. |
|
1791 |
To be used for code generators" |
|
1792 |
||
806 | 1793 |
|s nargs parts part| |
20 | 1794 |
|
1795 |
s := WriteStream on:String new. |
|
44 | 1796 |
nargs := aSelector numArgs. |
20 | 1797 |
nargs == 0 ifTrue:[ |
806 | 1798 |
s nextPutAll:aSelector |
20 | 1799 |
] ifFalse:[ |
806 | 1800 |
parts := aSelector partsIfSelector. |
1801 |
1 to:nargs do:[:i | |
|
1802 |
part := parts at:i. |
|
1803 |
s nextPutAll:part. |
|
1804 |
(part endsWith:$:) ifFalse:[ |
|
1805 |
s space. |
|
1806 |
]. |
|
1807 |
s nextPutAll:(argNames at:i). |
|
1808 |
i ~~ nargs ifTrue:[s space]. |
|
1809 |
] |
|
20 | 1810 |
]. |
1811 |
^ s contents |
|
1812 |
||
1813 |
" |
|
1814 |
Parser methodSpecificationForSelector:#foo:bar: argNames:#('one' 'two' 'three') |
|
1815 |
Parser methodSpecificationForSelector:#+ argNames:#('one') |
|
1816 |
Parser methodSpecificationForSelector:#negated |
|
1817 |
" |
|
806 | 1818 |
|
1819 |
"Modified: / 12.2.1999 / 12:33:50 / cg" |
|
20 | 1820 |
! ! |
1821 |
||
1417 | 1822 |
!Parser methodsFor:'Compatibility-ST80'! |
0 | 1823 |
|
918 | 1824 |
evaluate:aString in:aClassOrContext to:to notifying:aRequestor ifFail:failBlock |
35 | 1825 |
|parseTree value| |
0 | 1826 |
|
1827 |
aString isNil ifTrue:[^ nil]. |
|
1828 |
self initializeFor:(ReadStream on:aString). |
|
918 | 1829 |
|
1830 |
"/ stupid - there seem to be differences among the various |
|
1831 |
"/ ST dialects ... |
|
1832 |
aClassOrContext isBehavior ifTrue:[ |
|
1833 |
self setClassToCompileFor:aClassOrContext. |
|
1834 |
selfValue := nil. |
|
1835 |
] ifFalse:[ |
|
1836 |
self setContext:aClassOrContext. |
|
1837 |
aClassOrContext notNil ifTrue:[ |
|
1838 |
self setSelf:(aClassOrContext receiver) |
|
1839 |
]. |
|
1840 |
]. |
|
0 | 1841 |
requestor := aRequestor. |
1842 |
||
1843 |
self nextToken. |
|
1844 |
parseTree := self parseMethodBody. |
|
1845 |
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1846 |
parseTree notNil ifTrue:[ |
|
918 | 1847 |
self evalExitBlock:[:value | ^ failBlock value]. |
1848 |
value := parseTree evaluate |
|
0 | 1849 |
]. |
35 | 1850 |
self release. |
1851 |
^ value |
|
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1852 |
! |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1853 |
|
624 | 1854 |
parse:methodSource in:aClass notifying:aRequestor |
1855 |
"parse a methods source. |
|
1856 |
Return the methods parseTree" |
|
1857 |
||
1858 |
self initializeFor:methodSource. |
|
1859 |
classToCompileFor := aClass. |
|
1860 |
requestor := aRequestor. |
|
1861 |
self parseMethod. |
|
918 | 1862 |
|
624 | 1863 |
^ MethodNode new |
1864 |
selector:selector |
|
1865 |
arguments:methodArgs |
|
1866 |
locals:methodVars |
|
1207 | 1867 |
statements:tree asCollectionOfStatements |
624 | 1868 |
|
1214 | 1869 |
"Created: / 17.10.1997 / 12:35:01 / cg" |
1870 |
"Modified: / 5.11.2001 / 16:56:43 / cg" |
|
624 | 1871 |
! |
1872 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1873 |
parseSelector:aStringOrStream |
624 | 1874 |
"parse a methods source for the methods selector. |
1875 |
Return the selector" |
|
1876 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1877 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1878 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1879 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1880 |
|
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1881 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1882 |
Parser new |
624 | 1883 |
parseSelector:' |
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1884 |
parseSelector:aStringOrStream |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1885 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1886 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1887 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1888 |
' |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1889 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1890 |
|
624 | 1891 |
"Modified: 17.10.1997 / 12:35:46 / cg" |
0 | 1892 |
! ! |
1893 |
||
44 | 1894 |
!Parser methodsFor:'accessing'! |
1895 |
||
1896 |
correctedSource |
|
1897 |
^ correctedSource |
|
1898 |
! |
|
1899 |
||
1605
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1900 |
doItTemporaries |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1901 |
^ doItTemporaries |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1902 |
! |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1903 |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1904 |
endOfLastToken |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1905 |
^ tokenPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1906 |
! |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1907 |
|
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1908 |
endOfSelectorPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1909 |
"return the sourcePosition of the last character of the methods selector spec" |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1910 |
|
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1911 |
^ endOfSelectorPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1912 |
! |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1913 |
|
141 | 1914 |
errorFlag |
1915 |
"return true if there where any errors (valid after parsing)" |
|
1916 |
||
1917 |
^ errorFlag |
|
1918 |
! |
|
1919 |
||
1920 |
evalExitBlock:aBlock |
|
1921 |
"when evaluating a return expression, this block is evaluated" |
|
1922 |
||
1923 |
evalExitBlock := aBlock |
|
1924 |
! |
|
1925 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1926 |
getNameSpace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1927 |
"retrieve the nameSpace, as found in a Namespace directive" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1928 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1929 |
^ currentNamespace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1930 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1931 |
"Modified: 8.11.1996 / 13:45:35 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1932 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1933 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1934 |
implicitSelfSends |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1935 |
^ parserFlags implicitSelfSends |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1936 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1937 |
|
1571 | 1938 |
implicitSelfSends:aBoolean |
1939 |
"turn on/off implicit self sends" |
|
1940 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1941 |
parserFlags implicitSelfSends:aBoolean |
1571 | 1942 |
! |
1943 |
||
19 | 1944 |
primitiveNumber |
1945 |
"return the ST-80 style primitiveNumber or nil (valid after parsing)" |
|
1946 |
||
1947 |
^ primitiveNr |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1948 |
! |
97 | 1949 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1950 |
primitiveResources |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1951 |
"return the ST-80 style resource info or nil (valid after parsing)." |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1952 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1953 |
^ primitiveResource |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1954 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1955 |
"Created: 29.5.1996 / 17:28:00 / cg" |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1956 |
! |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1957 |
|
35 | 1958 |
release |
664 | 1959 |
methodArgs := methodVars := tree := selfNode := superNode := nilNode := nil. |
35 | 1960 |
super release. |
664 | 1961 |
|
1962 |
"Modified: / 31.3.1998 / 19:45:58 / cg" |
|
90 | 1963 |
! |
1964 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1965 |
setNameSpace:aNameSpaceName |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
1966 |
currentNamespace := NameSpace fullName:aNameSpaceName |
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1967 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1968 |
"Modified: 8.11.1996 / 13:43:14 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1969 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1970 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1971 |
setPackage:aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1972 |
currentPackage := aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1973 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1974 |
|
141 | 1975 |
targetClass |
1976 |
^ classToCompileFor |
|
1977 |
! |
|
1978 |
||
90 | 1979 |
targetClass:aClass |
117 | 1980 |
classToCompileFor := aClass |
1981 |
! |
|
1982 |
||
141 | 1983 |
tree |
1984 |
"return the parsetree" |
|
1985 |
||
1986 |
^tree |
|
1987 |
! |
|
1988 |
||
1989 |
tree:aTree |
|
1990 |
"private: set the tree - for internal use only" |
|
1991 |
||
1992 |
tree := aTree |
|
1363 | 1993 |
! |
1994 |
||
1995 |
warnSTXHereExtensionUsed |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1996 |
^ parserFlags warnSTXHereExtensionUsed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1997 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1998 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1999 |
warnSTXHereExtensionUsed:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2000 |
parserFlags warnSTXHereExtensionUsed:aBoolean |
141 | 2001 |
! ! |
2002 |
||
1418 | 2003 |
!Parser methodsFor:'dummy-syntax detection'! |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2004 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2005 |
markArgumentIdentifierFrom:pos1 to:pos2 |
1525 | 2006 |
"intentionally left empty" |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2007 |
! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2008 |
|
883 | 2009 |
markBadIdentifierFrom:pos1 to:pos2 |
1525 | 2010 |
"intentionally left empty" |
883 | 2011 |
! |
2012 |
||
663 | 2013 |
markBooleanConstantFrom:pos1 to:pos2 |
1525 | 2014 |
"intentionally left empty" |
663 | 2015 |
! |
2016 |
||
673 | 2017 |
markBracketAt:pos |
1525 | 2018 |
"intentionally left empty" |
673 | 2019 |
! |
2020 |
||
663 | 2021 |
markConstantFrom:pos1 to:pos2 |
1525 | 2022 |
"intentionally left empty" |
663 | 2023 |
! |
2024 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2025 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
1525 | 2026 |
"intentionally left empty" |
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2027 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2028 |
|
663 | 2029 |
markGlobalIdentifierFrom:pos1 to:pos2 |
1525 | 2030 |
"intentionally left empty" |
663 | 2031 |
! |
2032 |
||
2033 |
markHereFrom:pos1 to:pos2 |
|
1525 | 2034 |
"intentionally left empty" |
663 | 2035 |
! |
2036 |
||
2037 |
markIdentifierFrom:pos1 to:pos2 |
|
1525 | 2038 |
"intentionally left empty" |
663 | 2039 |
! |
2040 |
||
687 | 2041 |
markInstVarIdentifierFrom:pos1 to:pos2 |
1525 | 2042 |
"intentionally left empty" |
687 | 2043 |
! |
2044 |
||
663 | 2045 |
markLocalIdentifierFrom:pos1 to:pos2 |
1525 | 2046 |
"intentionally left empty" |
663 | 2047 |
! |
2048 |
||
2049 |
markMethodSelectorFrom:pos1 to:pos2 |
|
1525 | 2050 |
"intentionally left empty" |
663 | 2051 |
! |
2052 |
||
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2053 |
markParenthesisAt:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2054 |
"intentionally left empty" |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2055 |
! |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2056 |
|
837 | 2057 |
markReturnAt:pos |
1525 | 2058 |
"intentionally left empty" |
837 | 2059 |
! |
2060 |
||
864 | 2061 |
markSelector:sel from:pos1 to:pos2 receiverNode:aNode |
1525 | 2062 |
"intentionally left empty" |
864 | 2063 |
! |
2064 |
||
663 | 2065 |
markSelfFrom:pos1 to:pos2 |
1525 | 2066 |
"intentionally left empty" |
663 | 2067 |
! |
2068 |
||
2069 |
markSuperFrom:pos1 to:pos2 |
|
1525 | 2070 |
"intentionally left empty" |
664 | 2071 |
! |
2072 |
||
2073 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
1525 | 2074 |
"intentionally left empty" |
687 | 2075 |
! |
2076 |
||
2077 |
markVariable:v |
|
1525 | 2078 |
"intentionally left empty" |
687 | 2079 |
! |
2080 |
||
2081 |
markVariable:v from:pos1 to:pos2 |
|
1525 | 2082 |
"intentionally left empty" |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2083 |
! ! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2084 |
|
141 | 2085 |
!Parser methodsFor:'error correction'! |
2086 |
||
1295 | 2087 |
addDoItTemporary:varName |
2088 |
|holder| |
|
2089 |
||
2090 |
doItTemporaries isNil ifTrue:[ |
|
2091 |
doItTemporaries := IdentityDictionary new. |
|
2092 |
]. |
|
2093 |
doItTemporaries at:varName asSymbol put:(holder := ValueHolder new). |
|
2094 |
^ holder |
|
2095 |
! |
|
2096 |
||
141 | 2097 |
askForCorrection:aString fromList:aList |
2098 |
"launch a selection box, which allows user to enter correction. |
|
2099 |
return newString or nil (for abort)" |
|
2100 |
||
1323 | 2101 |
|box rslt| |
141 | 2102 |
|
2103 |
"in systems without widgets ..." |
|
2104 |
ListSelectionBox isNil ifTrue:[ |
|
1285 | 2105 |
^ self confirm:aString |
141 | 2106 |
]. |
2107 |
box := ListSelectionBox title:aString. |
|
2108 |
box initialText:(aList at:1). |
|
2109 |
box list:aList. |
|
1285 | 2110 |
box okText:'Correct'. |
1323 | 2111 |
box action:[:aString | rslt := aString]. |
141 | 2112 |
box showAtPointer. |
1323 | 2113 |
box destroy. |
2114 |
^ rslt |
|
2115 |
! |
|
2116 |
||
2117 |
askForCorrection:aString fromList:aList for:originalSelector |
|
2118 |
"launch a selection box, which allows user to enter correction. |
|
2119 |
return newString or nil (for abort)" |
|
2120 |
||
2121 |
|box rslt| |
|
2122 |
||
2123 |
"in systems without widgets ..." |
|
2124 |
ListSelectionBox isNil ifTrue:[ |
|
2125 |
^ self confirm:aString |
|
2126 |
]. |
|
2127 |
box := ListSelectionBox title:aString. |
|
2128 |
box initialText:(aList at:1). |
|
2129 |
box list:aList. |
|
2130 |
box okText:'Correct'. |
|
2131 |
box action:[:aString | rslt := aString]. |
|
2132 |
box addButton:(Button label:'Keep Selector' action:[rslt := originalSelector. box hide]) after:(box okButton). |
|
2133 |
box showAtPointer. |
|
2134 |
box destroy. |
|
2135 |
^ rslt |
|
141 | 2136 |
! |
2137 |
||
1295 | 2138 |
askForVariableTypeWhenDeclaringUndefined:varName |
2139 |
|l how varNameIsLowercase choice holder newClass| |
|
2140 |
||
2141 |
l := #(). |
|
2142 |
how := #(). |
|
2143 |
||
2144 |
varNameIsLowercase := (varName at:1) isLowercase. |
|
2145 |
||
2146 |
"/ BlockVar, InstVar and classInstVar not yet implemented |
|
2147 |
varNameIsLowercase ifTrue:[ |
|
2148 |
"/ currentBlock notNil ifTrue:[ |
|
2149 |
"/ l := l , #( 'Block local' ). |
|
2150 |
"/ how := how , #( BlockVariable ). |
|
2151 |
"/ ]. |
|
2152 |
selector notNil ifTrue:[ |
|
2153 |
l := l , #( 'Method Local Variable' ). |
|
2154 |
how := how , #( MethodVariable ). |
|
2155 |
]. |
|
2156 |
(classToCompileFor notNil |
|
2157 |
and:[classToCompileFor isMeta not |
|
2158 |
and:[classToCompileFor isBuiltInClass not |
|
1440 | 2159 |
and:[(self isDoIt not)]]]) ifTrue:[ |
1295 | 2160 |
l := l copyWith:'Instance Variable'. |
2161 |
how := how copyWith: #InstanceVariable. |
|
2162 |
]. |
|
2163 |
] ifFalse:[ |
|
2164 |
l := l , #( 'New Class' 'Global' 'NameSpace' ). |
|
2165 |
how := how , #( NewClass GlobalVariable NameSpace ). |
|
2166 |
||
2167 |
(classToCompileFor notNil |
|
2168 |
and:[classToCompileFor isBuiltInClass not |
|
1440 | 2169 |
and:[self isDoIt not]]) ifTrue:[ |
1295 | 2170 |
classToCompileFor isMeta ifTrue:[ |
2171 |
l := l , #('Class Instance Variable'). |
|
2172 |
how := how , #( ClassInstanceVariable). |
|
2173 |
]. |
|
2174 |
l := l , #('Class Variable' ). |
|
2175 |
how := how , #( ClassVariable). |
|
2176 |
] |
|
2177 |
]. |
|
1440 | 2178 |
self isDoIt ifTrue:[ |
1295 | 2179 |
l size > 0 ifTrue:[ |
2180 |
l := l , #( '-' ). |
|
2181 |
how := how , #( nil ). |
|
2182 |
]. |
|
2183 |
l := l , #( 'Workspace Variable' 'DoIt Temporary'). |
|
2184 |
how := how , #( WorkspaceVariable DoItTemporary ). |
|
2185 |
]. |
|
2186 |
||
2187 |
l size > 0 ifTrue:[ |
|
2188 |
l := (Array with:('Declare ' , varName allBold , ' as:') |
|
2189 |
with:'-' |
|
2190 |
) , l. |
|
2191 |
how := #(nil nil) , how. |
|
2192 |
choice := (PopUpMenu labels:l) startUp. |
|
2193 |
(choice notNil and:[choice > 0]) ifTrue:[ |
|
2194 |
choice := how at:choice. |
|
2195 |
||
2196 |
choice == #WorkspaceVariable ifTrue:[ |
|
2197 |
holder := Workspace addWorkspaceVariable:varName. |
|
2198 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
2199 |
]. |
|
2200 |
choice == #DoItTemporary ifTrue:[ |
|
2201 |
holder := self addDoItTemporary:varName. |
|
2202 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
2203 |
]. |
|
2204 |
||
2205 |
choice == #GlobalVariable ifTrue:[ |
|
2206 |
Smalltalk at:varName asSymbol put:nil. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2207 |
^ VariableNode globalNamed:varName |
1295 | 2208 |
]. |
2209 |
||
2210 |
choice == #NewClass ifTrue:[ |
|
2211 |
newClass := Object subclass:varName asSymbol |
|
2212 |
instanceVariableNames:'' |
|
2213 |
classVariableNames:'' |
|
2214 |
poolDictionaries:'' |
|
2215 |
category:'* As yet uncategorized *'. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2216 |
^ VariableNode globalNamed:newClass name |
1295 | 2217 |
]. |
2218 |
||
2219 |
choice == #NameSpace ifTrue:[ |
|
2220 |
NameSpace name:varName. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2221 |
^ VariableNode globalNamed:varName |
1295 | 2222 |
]. |
2223 |
||
2224 |
choice == #ClassVariable ifTrue:[ |
|
2225 |
classToCompileFor theNonMetaclass addClassVarName:varName. |
|
2226 |
^ VariableNode type:#ClassVariable class:classToCompileFor theNonMetaclass name:varName |
|
2227 |
]. |
|
2228 |
||
2229 |
choice == #InstanceVariable ifTrue:[ |
|
2230 |
classToCompileFor theNonMetaclass addInstVarName:varName. |
|
2231 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2232 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2233 |
RestartCompilationSignal raise. |
|
2234 |
"/ not reached - restarted compile will not arrive here again |
|
2235 |
self error:'restart compile failed'. |
|
2236 |
]. |
|
2237 |
||
2238 |
choice == #ClassInstanceVariable ifTrue:[ |
|
2239 |
classToCompileFor theMetaclass addInstVarName:varName. |
|
2240 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2241 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2242 |
RestartCompilationSignal raise. |
|
2243 |
"/ not reached - restarted compile will not arrive here again |
|
2244 |
self error:'restart compile failed'. |
|
2245 |
]. |
|
2246 |
||
2247 |
choice == #MethodVariable ifTrue:[ |
|
2248 |
|varIndex var endLocalsPos posToInsert ins| |
|
2249 |
||
2250 |
localVarDefPosition size == 2 ifTrue:[ |
|
2251 |
endLocalsPos := posToInsert := localVarDefPosition at:2. |
|
2252 |
ins := ' ' , varName. |
|
2253 |
] ifFalse:[ |
|
2254 |
endOfSelectorPosition notNil ifTrue:[ |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2255 |
posToInsert := beginOfBodyPosition. |
1295 | 2256 |
ins := '|' , varName , '|' , Character cr asString , Character cr asString. |
2257 |
ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1). |
|
2258 |
] |
|
2259 |
]. |
|
2260 |
posToInsert notNil ifTrue:[ |
|
2261 |
requestor |
|
2262 |
insertString:ins |
|
2263 |
atCharacterPosition:posToInsert. |
|
2264 |
||
2265 |
endLocalsPos notNil ifTrue:[ |
|
2266 |
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1). |
|
2267 |
||
2268 |
methodVarNames := methodVarNames copyWith:varName. |
|
2269 |
methodVars := methodVars copyWith:(var := Variable new name:varName). |
|
2270 |
] ifFalse:[ |
|
2271 |
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1. |
|
2272 |
||
2273 |
methodVarNames := Array with:varName. |
|
2274 |
methodVars := Array with:(var := Variable new name:varName). |
|
2275 |
]. |
|
2276 |
correctedSource := requestor currentSourceCode. |
|
2277 |
source := (ReadStream on:correctedSource) |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2278 |
position:(source position1Based + ins size). |
1295 | 2279 |
|
2280 |
varIndex := methodVarNames size. |
|
2281 |
var used:true. |
|
2282 |
^ VariableNode type:#MethodVariable |
|
2283 |
name:varName |
|
2284 |
token:var |
|
2285 |
index:varIndex |
|
2286 |
]. |
|
2287 |
]. |
|
2288 |
self warning:'Sorry - unimplemented (adding ' , choice , ')'. |
|
2289 |
]. |
|
2290 |
^ #Error |
|
2291 |
]. |
|
2292 |
^ nil. |
|
2293 |
! |
|
2294 |
||
1519 | 2295 |
checkBlockArgumentNameConventionsFor:aVariableName |
2296 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2297 |
! |
|
2298 |
||
2299 |
checkBlockVariableNameConventionsFor:aVariableName |
|
2300 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2301 |
! |
|
2302 |
||
2303 |
checkForLowercaseVariableName:aVariableName |
|
2304 |
aVariableName first isUppercase ifTrue:[ |
|
2305 |
self |
|
2306 |
syntaxError:('variable "' , aVariableName , '" should be lowercase (by convention)') |
|
2307 |
position:tokenPosition to:source position1Based - 1. |
|
2308 |
]. |
|
2309 |
! |
|
2310 |
||
2311 |
checkForProperUseOfArticleInVariableName:aVariableName |
|
1632 | 2312 |
|firstCharacterAfterArticle whatShouldItBeNamed| |
1519 | 2313 |
|
1521
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2314 |
aVariableName size > 4 ifTrue:[ |
1519 | 2315 |
(aVariableName startsWith:'an') ifTrue:[ |
1632 | 2316 |
firstCharacterAfterArticle := aVariableName at:3. |
2317 |
firstCharacterAfterArticle isUppercase ifTrue:[ |
|
2318 |
('AEIOX' includes:firstCharacterAfterArticle) ifFalse:[ |
|
1643 | 2319 |
((aVariableName copyFrom:3) startsWith:'Up') ifFalse:[ |
2320 |
whatShouldItBeNamed := 'a' , (aVariableName copyFrom:3). |
|
2321 |
] |
|
1632 | 2322 |
] |
1519 | 2323 |
]. |
1643 | 2324 |
] ifFalse:[ |
2325 |
(aVariableName startsWith:'a') ifTrue:[ |
|
2326 |
firstCharacterAfterArticle := aVariableName at:2. |
|
2327 |
firstCharacterAfterArticle isUppercase ifTrue:[ |
|
2328 |
('AEIOX' includes:firstCharacterAfterArticle) ifTrue:[ |
|
1650 | 2329 |
((aVariableName copyFrom:2) asLowercase startsWith:'one') ifFalse:[ |
2330 |
whatShouldItBeNamed := 'an' , (aVariableName copyFrom:2). |
|
2331 |
] |
|
1643 | 2332 |
]. |
1521
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2333 |
]. |
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2334 |
]. |
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2335 |
]. |
1632 | 2336 |
whatShouldItBeNamed notNil ifTrue:[ |
2337 |
self |
|
2338 |
warnCommonMistake:('variable "',aVariableName,'" should be named "',whatShouldItBeNamed,'" (by english language rules)') |
|
2339 |
position:tokenPosition to:source position1Based - 1. |
|
2340 |
]. |
|
1519 | 2341 |
]. |
2342 |
! |
|
2343 |
||
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2344 |
checkIfAllSubclassesOf:aClass implement:aSelector |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2345 |
(aClass subclasses |
1517 | 2346 |
contains:[:cls | (cls implements:aSelector) not]) ifTrue:[^ false]. |
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2347 |
^ true. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2348 |
! |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2349 |
|
1522
777862196320
checkVariable-conventions: can be (are by default) disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
2350 |
checkLocalVariableNameConventionsFor:aVariableName |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2351 |
parserFlags warnAboutVariableNameConventions == true ifTrue:[ |
1522
777862196320
checkVariable-conventions: can be (are by default) disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
2352 |
self checkForLowercaseVariableName:aVariableName. |
777862196320
checkVariable-conventions: can be (are by default) disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
2353 |
]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2354 |
parserFlags warnAboutWrongVariableNames == true ifTrue:[ |
1521
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2355 |
self checkForProperUseOfArticleInVariableName:aVariableName. |
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2356 |
]. |
1519 | 2357 |
! |
2358 |
||
2359 |
checkMethodArgumentNameConventionsFor:aVariableName |
|
2360 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2361 |
! |
|
2362 |
||
2363 |
checkMethodVariableNameConventionsFor:aVariableName |
|
2364 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2365 |
! |
|
2366 |
||
1507 | 2367 |
checkSelector:selector for:receiver inClass:cls |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2368 |
"check wether a method with selector exists in class cls and |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2369 |
that the method is not obsolete. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2370 |
If cls is nil, check all classes for the selector. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2371 |
Return an error string on error or nil on success" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2372 |
|
1507 | 2373 |
|err mthd implementor implementors allowed| |
1190
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2374 |
|
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2375 |
cls isNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2376 |
SystemBrowser isNil ifTrue:[ |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2377 |
^ nil |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2378 |
]. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2379 |
"beware, this is sort of slow, especially for the SyntaxHighlighter" |
1190
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2380 |
implementors := SystemBrowser |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2381 |
findImplementorsOf:selector |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2382 |
in:(Smalltalk allClasses) |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2383 |
ignoreCase:false. |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2384 |
implementors size == 0 ifTrue:[ |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2385 |
^ 'is nowhere implemented' |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2386 |
]. |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2387 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2388 |
(implementors conform:[:eachMethod| eachMethod isObsolete]) ifTrue:[ |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2389 |
^ 'each implementation of this selector in the system is deprecated' |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2390 |
]. |
1190
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2391 |
^ nil |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2392 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2393 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2394 |
mthd := cls lookupMethodFor:selector. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2395 |
mthd isNil ifTrue:[ |
1327 | 2396 |
cls == Boolean ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2397 |
mthd := True compiledMethodAt:selector. |
1327 | 2398 |
mthd isNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2399 |
mthd := False compiledMethodAt:selector. |
1327 | 2400 |
]. |
2401 |
] |
|
2402 |
]. |
|
2403 |
mthd isNil ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2404 |
"if it implements #doesNotUnderstand somewhere, assume it is ok" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2405 |
implementor := cls whichClassIncludesSelector:#doesNotUnderstand:. |
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
2406 |
"/ (implementor isNil or:[implementor == Object]) ifTrue:[ |
1599 | 2407 |
err := 'is not implemented in ' , cls name allBold |
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
2408 |
"/ ]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2409 |
] ifFalse:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2410 |
(mthd sends:#shouldNotImplement) ifTrue:[ |
1562 | 2411 |
mthd messagesSent size == 1 ifTrue:[ |
2412 |
allowed := (cls == classToCompileFor). "methods in abstract classes may send messages to abstract methods in the same class" |
|
2413 |
allowed ifFalse:[ |
|
2414 |
err := 'is not (should not be) implemented' |
|
2415 |
] |
|
1542 | 2416 |
] |
1517 | 2417 |
] ifFalse:[ |
2418 |
(mthd sends:#subclassResponsibility) ifTrue:[ |
|
2419 |
allowed := (cls == classToCompileFor). "methods in abstract classes may send messages to abstract methods in the same class" |
|
2420 |
allowed ifFalse:[ |
|
2421 |
"methods in abstract classes may send messages to abstract methods in meta class" |
|
2422 |
(cls == classToCompileFor class) ifTrue:[ |
|
2423 |
allowed := receiver isMessage and:[receiver selector = 'class'] |
|
2424 |
]. |
|
1507 | 2425 |
]. |
1517 | 2426 |
allowed ifTrue:[ |
1519 | 2427 |
"/ not from cg to stefan: thats wrong - if not implemented in all subclasses, |
2428 |
"/ its a bug of the subclass not a bug here - that message send here |
|
2429 |
"/ is perfectly correct. (it is very annoying for a framework developped to get |
|
2430 |
"/ error messages for bugs which are not his... |
|
2431 |
"/ (self checkIfAllSubclassesOf:cls implement:selector) ifFalse:[ |
|
2432 |
"/ "if not all subclasses implement the selector - this is a possible bug" |
|
2433 |
"/ allowed := false |
|
2434 |
"/ ]. |
|
1507 | 2435 |
]. |
1517 | 2436 |
allowed ifFalse:[ |
2437 |
err := 'is subclassResponsibility' |
|
2438 |
]. |
|
2439 |
] ifFalse:[mthd isObsolete ifTrue:[ |
|
2440 |
err := 'is deprecated'. |
|
2441 |
]] |
|
2442 |
]. |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2443 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2444 |
^ err. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2445 |
! |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2446 |
|
141 | 2447 |
correctByDeleting |
2448 |
"correct (by deleting token) if user wants to; |
|
2449 |
return #Error if there was no correction; |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2450 |
nil if there was one." |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2451 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2452 |
|selectionSize| |
141 | 2453 |
|
2454 |
(self confirm:'confirm deleting') ifFalse:[^ #Error]. |
|
2455 |
||
2456 |
" |
|
2457 |
tell requestor (i.e. CodeView) about the change |
|
2458 |
this will update what the requestor shows. |
|
2459 |
" |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2460 |
selectionSize := requestor selection size. |
141 | 2461 |
requestor deleteSelection. |
2462 |
||
2463 |
" |
|
2464 |
get the updated source-string |
|
2465 |
which is needed, when we eventually install the new method |
|
2466 |
" |
|
2467 |
correctedSource := requestor currentSourceCode. |
|
1167 | 2468 |
"/ update the current source position |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2469 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2470 |
position:(source position1Based - selectionSize). |
1369
2304dd8c3173
recompilation after correct-by-deleting unused local
Claus Gittinger <cg@exept.de>
parents:
1368
diff
changeset
|
2471 |
|
141 | 2472 |
^ nil |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2473 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2474 |
"Modified: / 22.1.1998 / 16:39:11 / stefan" |
141 | 2475 |
! |
2476 |
||
1439 | 2477 |
correctSelector:aSelectorString message:msg positions:posVector in:aClassOrNil for:receiverNode |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2478 |
"notify error and correct if user wants to; |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2479 |
return #Error if there was no correction |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2480 |
or a ParseNode as returned by variable" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2481 |
|
1439 | 2482 |
|correctIt suggestedNames newSelector className classToGenerateCode pos1 pos2| |
2483 |
||
2484 |
pos1 := posVector first start. |
|
2485 |
pos2 := posVector last stop. |
|
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2486 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2487 |
alreadyWarnedUnimplementedSelectors isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2488 |
alreadyWarnedUnimplementedSelectors := Set new |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2489 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2490 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2491 |
(alreadyWarnedUnimplementedSelectors includes:aSelectorString) ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2492 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2493 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2494 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2495 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2496 |
sorry, but I cannot handle keywords with more than one-part |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2497 |
currently (too much work - maybe Ill do it later when everything else works :-) |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2498 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2499 |
(aSelectorString occurrencesOf:$:) > 1 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2500 |
self warning:msg position:pos1 to:pos2. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2501 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2502 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2503 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2504 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2505 |
correctIt := self correctableSelectorWarning:msg position:pos1 to:pos2. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2506 |
correctIt == #generate ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2507 |
receiverNode isSelf ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2508 |
classToGenerateCode := classToCompileFor |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2509 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2510 |
receiverNode isVariable ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2511 |
receiverNode isGlobal ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2512 |
classToGenerateCode := receiverNode evaluate. |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2513 |
classToGenerateCode isBehavior ifTrue:[ |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2514 |
classToGenerateCode := classToGenerateCode theMetaclass. |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2515 |
] ifFalse:[ |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2516 |
classToGenerateCode := nil |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2517 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2518 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2519 |
] |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2520 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2521 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2522 |
className := Dialog request:'Generate code in class:' initialAnswer:classToCompileFor name. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2523 |
className size == 0 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2524 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2525 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2526 |
classToGenerateCode := Smalltalk at:className asSymbol. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2527 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2528 |
self warn:'No such class.'. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2529 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2530 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2531 |
]. |
1252
666db3206028
#implements: -> #includesSelector:
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2532 |
(classToGenerateCode includesSelector:aSelectorString asSymbol) ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2533 |
"do not overwrite an already existant (deprecated) method" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2534 |
classToGenerateCode |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2535 |
compile:((self class methodSpecificationForSelector:aSelectorString) , '\ self shouldImplement' withCRs) |
1323 | 2536 |
classified:(Compiler defaultMethodCategory). |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2537 |
]. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2538 |
correctIt := false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2539 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2540 |
correctIt ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2541 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2542 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2543 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2544 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2545 |
suggestedNames := self findBestSelectorsFor:aSelectorString in:aClassOrNil. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2546 |
suggestedNames notNil ifTrue:[ |
1323 | 2547 |
newSelector := self askForCorrection:'Correct Selector to: ' fromList:suggestedNames for:aSelectorString. |
2548 |
newSelector isNil ifTrue:[AbortSignal raise "^ aSelectorString"]. |
|
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2549 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2550 |
self information:'no good correction found'. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2551 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2552 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2553 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2554 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2555 |
tell requestor (i.e. CodeView) about the change |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2556 |
this will update what the requestor shows. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2557 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2558 |
requestor replaceSelectionBy:newSelector keepCursor:false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2559 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2560 |
get the updated source-string |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2561 |
which is needed, when we eventually install the new method |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2562 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2563 |
correctedSource := requestor currentSourceCode. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2564 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2565 |
position:(source position1Based + 1 + (newSelector size - aSelectorString size)). |
1361 | 2566 |
"/ Parser murks. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2567 |
^ newSelector |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2568 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2569 |
"Modified: / 22.1.1998 / 16:36:04 / stefan" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2570 |
"Created: / 19.1.2000 / 16:34:01 / cg" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2571 |
"Modified: / 19.1.2000 / 16:34:55 / cg" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2572 |
! |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2573 |
|
1167 | 2574 |
correctSourceByDeletingFrom:start to:stop |
2575 |
"correct (by deleting token) if user wants to; |
|
2576 |
return #Error if there was no correction; |
|
2577 |
nil if there was one." |
|
2578 |
||
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2579 |
|deleteSize localDefsStart localDefsStop newPos| |
1167 | 2580 |
|
2581 |
" |
|
2582 |
tell requestor (i.e. CodeView) about the change |
|
2583 |
this will update what the requestor shows. |
|
2584 |
" |
|
2585 |
deleteSize := stop - start + 1. |
|
2586 |
requestor deleteFromCharacterPosition:start to:stop. |
|
2587 |
||
2588 |
" |
|
2589 |
get the updated source-string |
|
2590 |
which is needed, when we eventually install the new method |
|
2591 |
" |
|
2592 |
correctedSource := requestor currentSourceCode. |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2593 |
|
1167 | 2594 |
"/ update the current source position |
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2595 |
source atEnd ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2596 |
newPos := correctedSource size. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2597 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2598 |
source position1Based >= stop ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2599 |
newPos := source position1Based - deleteSize |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2600 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2601 |
source position1Based < start ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2602 |
newPos := source position1Based |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2603 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2604 |
newPos := start |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2605 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2606 |
] |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2607 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2608 |
source := (ReadStream on:correctedSource) position1Based:newPos. |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2609 |
|
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2610 |
localDefsStart := localVarDefPosition at:1. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2611 |
localDefsStop := localVarDefPosition at:2. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2612 |
|
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2613 |
localDefsStop <= start ifTrue:[^ self]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2614 |
localDefsStart >= stop ifTrue:[^ self]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2615 |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2616 |
(localDefsStart >= start and:[localDefsStop <= stop]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2617 |
localVarDefPosition := nil. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2618 |
^ self |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2619 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2620 |
|
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2621 |
"/ must update |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2622 |
(start > localDefsStart and:[stop < localDefsStop]) ifTrue:[ |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2623 |
localVarDefPosition at:2 put:(localDefsStop - (stop-start+1)). |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2624 |
^ self. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2625 |
]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2626 |
self halt. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2627 |
^ self |
1167 | 2628 |
! |
2629 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2630 |
correctVariable:varName atPosition:pos1 to:pos2 |
141 | 2631 |
"notify error and correct if user wants to; |
2632 |
return #Error if there was no correction |
|
2633 |
or a ParseNode as returned by variable" |
|
2634 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2635 |
|correctIt suggestedNames newName rslt |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2636 |
varNameIsLowercase undeclared boldName| |
141 | 2637 |
|
877 | 2638 |
varNameIsLowercase := (varName at:1) isLowercase. |
2639 |
||
141 | 2640 |
correctIt := self undefError:varName position:pos1 to:pos2. |
887 | 2641 |
(correctIt == false or:[correctIt == #continue]) ifTrue:[ |
877 | 2642 |
"/ no correction wanted. |
2643 |
||
2644 |
"/ lowerCase vars are added to the Undeclared dictionary, |
|
2645 |
"/ allowing easy search for bad-spots later. |
|
1285 | 2646 |
boldName := varName allBold. |
877 | 2647 |
|
2648 |
varNameIsLowercase ifTrue:[ |
|
1205 | 2649 |
undeclared := Smalltalk at:#Undeclared. |
2650 |
((undeclared notNil) |
|
2651 |
and:[(undeclared includes:varName asSymbol)]) ifFalse:[ |
|
1285 | 2652 |
self warning:('Adding ''' , boldName , ''' as Undeclared.\\Remember to fix that later.') withCRs position:pos1 to:pos2. |
725
326f4fe4a880
only warn once for undeclared vars.
Claus Gittinger <cg@exept.de>
parents:
718
diff
changeset
|
2653 |
]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2654 |
^ self defineAsUndeclaredVariable:varName |
877 | 2655 |
]. |
2656 |
||
2657 |
"/ upperCase vars are declared as global |
|
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2658 |
(warnedUndefVars isNil or:[(warnedUndefVars includes:varName) not]) ifTrue:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2659 |
(warnedUnknownNamespaces isNil or:[(warnedUnknownNamespaces includes:varName) not]) ifTrue:[ |
1285 | 2660 |
self warning:('adding ''' , boldName , ''' as Global.') withCRs position:pos1 to:pos2. |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2661 |
]. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2662 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2663 |
^ VariableNode globalNamed:varName |
877 | 2664 |
]. |
2665 |
||
1491 | 2666 |
correctIt == #Error ifTrue:[ |
2667 |
^ #Error |
|
2668 |
]. |
|
2669 |
||
877 | 2670 |
correctIt == #declare ifTrue:[ |
2671 |
"/ declare it |
|
1295 | 2672 |
rslt := self askForVariableTypeWhenDeclaringUndefined:varName. |
2673 |
rslt notNil ifTrue:[ |
|
2674 |
^ rslt |
|
2675 |
]. |
|
141 | 2676 |
]. |
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2677 |
(correctIt isKindOf:ParseNode) ifTrue:[ |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2678 |
^ correctIt |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2679 |
]. |
141 | 2680 |
|
2681 |
suggestedNames := self findBestVariablesFor:varName. |
|
877 | 2682 |
suggestedNames isNil ifTrue:[ |
1285 | 2683 |
self information:'No good correction found'. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2684 |
^ #Error |
141 | 2685 |
]. |
2686 |
||
1285 | 2687 |
newName := self askForCorrection:'Correct Variable to: ' fromList:suggestedNames. |
877 | 2688 |
newName isNil ifTrue:[^ #Error]. |
2689 |
" |
|
2690 |
newName := suggestedNames at:1. |
|
2691 |
(self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error]. |
|
2692 |
" |
|
2693 |
||
141 | 2694 |
" |
2695 |
tell requestor (i.e. CodeView) about the change |
|
2696 |
this will update what the requestor shows. |
|
2697 |
" |
|
2698 |
requestor replaceSelectionBy:newName. |
|
2699 |
" |
|
2700 |
get the updated source-string |
|
2701 |
which is needed, when we eventually install the new method |
|
2702 |
" |
|
2703 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2704 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2705 |
position:(source position1Based + newName size - tokenName size). |
141 | 2706 |
|
2707 |
"redo parse with new value" |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
2708 |
token := tokenName := newName. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2709 |
rslt := self variableOrError:tokenName. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2710 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2711 |
"/ failed again ? |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2712 |
rslt == #Error ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2713 |
"/ install as Undeclared:<name>, remember in #undeclared |
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2714 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2715 |
rslt := self defineAsUndeclaredVariable:varName |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2716 |
]. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2717 |
^ rslt |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2718 |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2719 |
"Modified: / 22.1.1998 / 16:34:01 / stefan" |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
2720 |
"Modified: / 15.11.2001 / 22:56:38 / cg" |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2721 |
! |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2722 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2723 |
defineAsUndeclaredVariable:aName |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2724 |
"define varName as undeclared variable |
629 | 2725 |
(actually, it will be installed as a funny global named 'Undeclared:::<name>'). |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2726 |
You can browse for methods with undeclareds by searching for global accesses |
629 | 2727 |
to 'Undeclared:::*' (or use the search-undeclared item in the launchers menu)." |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2728 |
|
1206 | 2729 |
|varName undeclared| |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2730 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2731 |
varName := aName. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2732 |
|
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2733 |
"/ install as Undeclared:<name>, remember in Undeclared |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2734 |
|
1206 | 2735 |
undeclared := Smalltalk at:#Undeclared. |
2736 |
undeclared isNil ifTrue:[ |
|
2737 |
Smalltalk at:#Undeclared put:(undeclared := IdentitySet new). |
|
2738 |
]. |
|
2739 |
undeclared add:tokenName asSymbol. |
|
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
2740 |
varName := (Smalltalk undeclaredPrefix) , tokenName. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2741 |
varName := varName asSymbol. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2742 |
Smalltalk at:varName put:nil. |
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2743 |
|
762
66cd2b4f6689
Big BUG: remember original name in usedVars - not Undeclared::xxx
tm
parents:
755
diff
changeset
|
2744 |
parseForCode ifFalse:[self rememberGlobalUsed:aName]. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2745 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2746 |
^ VariableNode globalNamed:varName |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
601
diff
changeset
|
2747 |
|
629 | 2748 |
"Modified: / 31.10.1997 / 01:16:03 / cg" |
141 | 2749 |
! |
2750 |
||
1167 | 2751 |
deleteDefinitionOf:varName in:defStartPos to:defEndPos |
1393 | 2752 |
"this removes the definition of varName from the declaration part i.e. |
2753 |
if the source was '... | foo bar baz |...' |
|
2754 |
deleting the var 'bar' changes the source to '... | foo baz |...'. |
|
2755 |
The code below tries to be somewhat smart w.r.t. spaces by |
|
2756 |
trying to remove the whiteSpace around the removed variable also. |
|
2757 |
However, this seems to not always work correctly" |
|
2758 |
||
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2759 |
|source startSearch pos pos2 nextChar varSlot p p2| |
1172 | 2760 |
|
2761 |
varSlot := methodVars detect:[:var | var name = varName]. |
|
2762 |
methodVars removeIdentical:varSlot. |
|
1167 | 2763 |
|
2764 |
source := requestor currentSourceCode. |
|
2765 |
startSearch := defStartPos+1. |
|
2766 |
||
2767 |
[ |
|
1393 | 2768 |
|prevChar isFirstVar didPassEndOfLine| |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2769 |
|
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2770 |
"/ search this name's position in the declaration part ... |
1167 | 2771 |
pos := source indexOfSubCollection:varName startingAt:startSearch ifAbsent:0. |
1326 | 2772 |
(pos == 0 or:[pos >= defEndPos]) ifTrue:[ |
2773 |
self error:'should not happen' mayProceed:true. |
|
1167 | 2774 |
^ self. |
2775 |
]. |
|
2776 |
||
2777 |
pos2 := pos + varName size - 1. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2778 |
pos > 1 ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2779 |
prevChar := source at:pos-1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2780 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2781 |
(prevChar isNil or:[prevChar isLetterOrDigit not]) ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2782 |
nextChar := source at:pos2+1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2783 |
nextChar isLetterOrDigit ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2784 |
"/ halfway intuitive space-removal behavior; |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2785 |
"/ if there was a space after/before the |-char, |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2786 |
"/ leave it; otherwise remove it. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2787 |
isFirstVar := pos == (defStartPos+1). |
1393 | 2788 |
(source at:pos-1) isSeparator ifTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2789 |
pos := pos - 1. |
1393 | 2790 |
[ (source at:pos-1) isSeparator] whileTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2791 |
pos := pos - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2792 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2793 |
(source at:pos-1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2794 |
"/ there was a space before - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2795 |
pos := pos + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2796 |
isFirstVar := true. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2797 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2798 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2799 |
|
1393 | 2800 |
(source at:pos2+1) isSeparator ifTrue:[ |
2801 |
didPassEndOfLine := (source at:pos2+1) == Character cr. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2802 |
pos2 := pos2 + 1. |
1393 | 2803 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
2804 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2805 |
pos2 := pos2 + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2806 |
]. |
1393 | 2807 |
|
2808 |
didPassEndOfLine ifFalse:[ |
|
2809 |
(source at:pos2+1) == $" ifTrue:[ |
|
2810 |
"/ comment follows - assume it belongs to the removed variable |
|
2811 |
pos2 := pos2 + 1. |
|
2812 |
(source at:pos2+1) == $/ ifTrue:[ |
|
2813 |
"/ EOL comment |
|
2814 |
[ (source at:pos2+1) == Character cr ] whileFalse:[ |
|
2815 |
pos2 := pos2 + 1. |
|
2816 |
]. |
|
2817 |
pos2 := pos2 + 1. |
|
2818 |
] ifFalse:[ |
|
2819 |
"/ regular comment |
|
2820 |
[ (source at:pos2+1) == $" ] whileFalse:[ |
|
2821 |
pos2 := pos2 + 1. |
|
2822 |
]. |
|
2823 |
pos2 := pos2 + 1. |
|
2824 |
]. |
|
2825 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
|
2826 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
2827 |
pos2 := pos2 + 1. |
|
2828 |
]. |
|
2829 |
] |
|
2830 |
]. |
|
2831 |
||
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2832 |
(source at:pos2+1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2833 |
"/ there was a space after - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2834 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2835 |
] ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2836 |
isFirstVar ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2837 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2838 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2839 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2840 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2841 |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2842 |
"/ if this was the last, remove empty var-declaration completely |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2843 |
((source at:pos-1) == $| |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2844 |
and:[ (source at:pos2+1) == $| ]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2845 |
pos := pos - 1. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2846 |
pos2 := pos2 + 1. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2847 |
"/ see if that gives us an empty line |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2848 |
p := pos. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2849 |
p2 := pos2. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2850 |
|
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2851 |
[(source at:p-1) == Character space] whileTrue:[ p := p - 1 ]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2852 |
[(source at:p2+1) == Character space] whileTrue:[ p2 := p2 + 1 ]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2853 |
((source at:p-1) == Character cr and:[ (source at:p2+1) == Character cr]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2854 |
pos := p-1. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2855 |
pos2 := p2. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2856 |
(((source at:pos-1) == Character cr) and:[((source at:pos-2) == Character cr)]) |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2857 |
ifTrue:[ pos := pos - 1 ] |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2858 |
ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2859 |
(((source at:pos2+1) == Character cr) and:[((source at:pos2+2) == Character cr)]) ifTrue:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2860 |
pos2 := pos2 + 1 ]]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2861 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2862 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2863 |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2864 |
self correctSourceByDeletingFrom:pos to:pos2. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2865 |
^ self. |
1167 | 2866 |
]. |
2867 |
]. |
|
2868 |
startSearch := pos2 + 1. |
|
2869 |
] loop |
|
2870 |
! |
|
2871 |
||
141 | 2872 |
findBestSelectorsFor:aString |
2873 |
"collect known selectors with their spelling distances to aString; |
|
2874 |
return the 10 best suggestions" |
|
2875 |
||
1187 | 2876 |
^ self class findBestSelectorsFor:aString |
141 | 2877 |
|
2878 |
"Time millisecondsToRun:[Parser new findBestSelectorsFor:'foo']" |
|
2879 |
"Parser new findBestSelectorsFor:'findBestSel'" |
|
2880 |
"Parser new findBestSelectorsFor:'fildBestSelectrFr'" |
|
2881 |
! |
|
2882 |
||
1022 | 2883 |
findBestSelectorsFor:aString in:aClassOrNil |
2884 |
"collect known selectors with their spelling distances to aString; |
|
2885 |
return the 10 best suggestions. If the argument, aClassOrNil is not nil, |
|
2886 |
the message is assumed to be sent to instances of that class (i.e. offer |
|
2887 |
corrections from that hierarchy only)" |
|
2888 |
||
1187 | 2889 |
^ self class findBestSelectorsFor:aString in:aClassOrNil |
1022 | 2890 |
! |
2891 |
||
141 | 2892 |
findBestVariablesFor:aString |
2893 |
"collect known variables with their spelling distances to aString; |
|
2894 |
return the 10 best suggestions" |
|
2895 |
||
1200 | 2896 |
|names dists searchBlock args vars "aClass className baseClass" |
1647 | 2897 |
n instVarNames classVarNames spellAgainstNodeAction spellAgainstAction| |
141 | 2898 |
|
2899 |
names := OrderedCollection new. |
|
2900 |
dists := OrderedCollection new. |
|
2901 |
||
1200 | 2902 |
spellAgainstAction := |
2903 |
[:givenName | |
|
2904 |
|dist| |
|
2905 |
||
2906 |
names add:givenName. |
|
2907 |
dist := aString spellAgainst:givenName. |
|
2908 |
(aString startsWith:givenName) ifTrue:[ |
|
1647 | 2909 |
dist := dist + (givenName size * 10). |
1200 | 2910 |
]. |
2911 |
dists add:dist |
|
2912 |
]. |
|
2913 |
||
1647 | 2914 |
spellAgainstNodeAction := |
2915 |
[:aVarNode | |
|
2916 |
spellAgainstAction value:(aVarNode name). |
|
2917 |
]. |
|
2918 |
||
2919 |
"block arguments" |
|
2920 |
searchBlock := currentBlock. |
|
2921 |
[searchBlock notNil] whileTrue:[ |
|
2922 |
args := searchBlock arguments. |
|
2923 |
args notNil ifTrue:[ |
|
2924 |
args do:spellAgainstNodeAction |
|
2925 |
]. |
|
2926 |
||
2927 |
vars := searchBlock variables. |
|
2928 |
vars notNil ifTrue:[ |
|
2929 |
vars do:spellAgainstNodeAction |
|
2930 |
]. |
|
2931 |
searchBlock := searchBlock home |
|
2932 |
]. |
|
2933 |
||
141 | 2934 |
"method-variables" |
2935 |
methodVars notNil ifTrue:[ |
|
1200 | 2936 |
methodVarNames do:spellAgainstAction |
141 | 2937 |
]. |
2938 |
||
2939 |
"method-arguments" |
|
2940 |
methodArgs notNil ifTrue:[ |
|
1200 | 2941 |
methodArgNames do:spellAgainstAction |
141 | 2942 |
]. |
2943 |
||
2944 |
"instance-variables" |
|
2945 |
classToCompileFor notNil ifTrue:[ |
|
1200 | 2946 |
self classesInstVarNames do:spellAgainstAction |
141 | 2947 |
]. |
2948 |
||
2949 |
"class-variables" |
|
2950 |
classToCompileFor notNil ifTrue:[ |
|
1200 | 2951 |
self classesClassVarNames do:spellAgainstAction. |
141 | 2952 |
|
2953 |
"/ aClass := classToCompileFor. |
|
2954 |
"/ aClass isMeta ifTrue:[ |
|
2955 |
"/ className := aClass name. |
|
2956 |
"/ className := className copyWithoutLast:5. |
|
2957 |
"/ baseClass := Smalltalk at:(className asSymbol). |
|
2958 |
"/ baseClass notNil ifTrue:[ |
|
2959 |
"/ aClass := baseClass |
|
2960 |
"/ ] |
|
2961 |
"/ ]. |
|
2962 |
"/ [aClass notNil] whileTrue:[ |
|
2963 |
"/ (aClass classVarNames) do:[:classVarName | |
|
2964 |
"/ names add:classVarName. |
|
2965 |
"/ dists add:(aString spellAgainst: "levenshteinTo:"classVarName) |
|
2966 |
"/ ]. |
|
2967 |
"/ aClass := aClass superclass |
|
2968 |
"/ ] |
|
2969 |
||
2970 |
]. |
|
2971 |
||
2972 |
"globals" |
|
2973 |
Smalltalk keysDo:[:aKey | |
|
1647 | 2974 |
|globalVarName parts| |
1200 | 2975 |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2976 |
globalVarName := aKey asString. |
1200 | 2977 |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2978 |
"only compare strings where length is about right" |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2979 |
((globalVarName size - aString size) abs < 3) ifTrue:[ |
1200 | 2980 |
spellAgainstAction value:globalVarName. |
1647 | 2981 |
]. |
2982 |
(globalVarName includes:$:) ifTrue:[ |
|
2983 |
parts := globalVarName asCollectionOfSubCollectionsSeparatedByAll:'::'. |
|
2984 |
parts size > 1 ifTrue:[ |
|
2985 |
parts do:[:eachPart | |
|
2986 |
|dist| |
|
2987 |
((eachPart size - aString size) abs < 3) ifTrue:[ |
|
2988 |
names add:globalVarName. |
|
2989 |
dist := aString spellAgainst:eachPart. |
|
2990 |
(aString startsWith:eachPart) ifTrue:[ |
|
2991 |
dist := dist + (eachPart size * 10). |
|
2992 |
]. |
|
2993 |
dists add:dist |
|
2994 |
]. |
|
2995 |
]. |
|
2996 |
]. |
|
2997 |
]. |
|
141 | 2998 |
]. |
2999 |
||
3000 |
"misc" |
|
1200 | 3001 |
#('self' 'super' 'nil' 'thisContext') do:spellAgainstAction. |
141 | 3002 |
|
3003 |
(dists size ~~ 0) ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3004 |
dists sortWith:names. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3005 |
dists := dists reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3006 |
names := names reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3007 |
n := names size min:10. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3008 |
names := names copyTo:n. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3009 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3010 |
"if it starts with a lower case character, add all local & instvar names" |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3011 |
(aString at:1) isLowercase ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3012 |
methodVarNames size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3013 |
names add:'---- method locals ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3014 |
methodVarNames asSortedCollection do:[:methodVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3015 |
names add:methodVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3016 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3017 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3018 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3019 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3020 |
methodArgs size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3021 |
names add:'---- method arguments ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3022 |
methodArgNames asSortedCollection do:[:methodArgName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3023 |
names add:methodArgName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3024 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3025 |
]. |
1078 | 3026 |
classToCompileFor notNil ifTrue:[ |
3027 |
instVarNames := OrderedCollection new. |
|
3028 |
self classesInstVarNames asSortedCollection do:[:instVarName | |
|
3029 |
(instVarNames includes:instVarName) ifFalse:[ |
|
3030 |
instVarNames add:instVarName. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3031 |
] |
1078 | 3032 |
]. |
3033 |
||
3034 |
instVarNames size > 0 ifTrue:[ |
|
3035 |
(classToCompileFor notNil and:[classToCompileFor isMeta]) ifTrue:[ |
|
3036 |
names add:'---- class instance variables ----'. |
|
3037 |
] ifFalse:[ |
|
3038 |
names add:'---- instance variables ----'. |
|
3039 |
]. |
|
3040 |
instVarNames do:[:instVarName | |
|
3041 |
(names includes:instVarName) ifFalse:[ |
|
3042 |
names add:instVarName. |
|
3043 |
] |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3044 |
] |
1078 | 3045 |
]. |
3046 |
||
3047 |
classVarNames := OrderedCollection new. |
|
3048 |
self classesClassVarNames asSortedCollection do:[:classVarName | |
|
3049 |
(classVarNames includes:classVarName) ifFalse:[ |
|
3050 |
classVarNames add:classVarName. |
|
3051 |
] |
|
3052 |
]. |
|
3053 |
||
3054 |
classVarNames size > 0 ifTrue:[ |
|
3055 |
names add:'---- class variables ----'. |
|
3056 |
classVarNames do:[:classVarName | |
|
3057 |
(names includes:classVarName) ifFalse:[ |
|
3058 |
names add:classVarName. |
|
3059 |
] |
|
3060 |
] |
|
3061 |
]. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3062 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3063 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3064 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3065 |
^ names |
141 | 3066 |
]. |
3067 |
^ nil |
|
450 | 3068 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
3069 |
"Modified: 11.1.1997 / 21:28:28 / cg" |
141 | 3070 |
! |
3071 |
||
3072 |
selectorCheck:aSelectorString for:receiver position:pos1 to:pos2 |
|
1439 | 3073 |
^ self selectorCheck:aSelectorString for:receiver positions:(Array with:(pos1 to:pos2)). |
3074 |
! |
|
3075 |
||
3076 |
selectorCheck:aSelectorString for:receiver positions:posVector |
|
141 | 3077 |
"just a quick check: if a selector is totally unknown as a symbol, |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3078 |
has the same name as a variable, cannot be understood or is obsolete. |
141 | 3079 |
Simple, but catches many typos" |
3080 |
||
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3081 |
|isSyntaxHighlighter err selectorSymbol rec names recType selClass newSelector nm nowhereImplemented |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3082 |
pos1 pos2 canDefine| |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3083 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3084 |
isSyntaxHighlighter := self isSyntaxHighlighter. |
141 | 3085 |
|
3086 |
" |
|
3087 |
if compiling lazy, or errors are to be ignored, or there |
|
3088 |
is no requestor, do not check |
|
3089 |
" |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3090 |
isSyntaxHighlighter ifFalse:[ |
1545 | 3091 |
(LazyCompilation == true) ifTrue:[^ aSelectorString]. |
1022 | 3092 |
(ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString]. |
3093 |
(requestor isNil or:[requestor isStream]) ifTrue:[^ aSelectorString]. |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
3094 |
]. |
141 | 3095 |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3096 |
canDefine := false. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3097 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3098 |
pos1 := posVector first start. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3099 |
pos2 := posVector last stop. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3100 |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3101 |
aSelectorString = '#' ifTrue:[ |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3102 |
self warnPossibleIncompatibility:'''#'' might not be a valid selector in other smalltalk systems' position:pos1 to:pos2. |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3103 |
]. |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3104 |
|
141 | 3105 |
" |
3106 |
check if the selector is known at all |
|
3107 |
- if not, it cannot be understood |
|
3108 |
" |
|
1327 | 3109 |
nowhereImplemented := false. |
3110 |
||
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3111 |
selectorSymbol := aSelectorString asSymbolIfInterned. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3112 |
selectorSymbol isNil ifTrue:[ |
1327 | 3113 |
nowhereImplemented := true. |
1518 | 3114 |
] ifFalse:[ |
3115 |
"/ temporarily disabled - too slow. |
|
3116 |
"/ self isSyntaxHighlighter ifTrue:[ |
|
3117 |
"/ nowhereImplemented := (self implementedInAnyClass:selectorSymbol) not. |
|
3118 |
"/ ] |
|
1327 | 3119 |
]. |
3120 |
||
3121 |
nowhereImplemented ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3122 |
err := ' is currently nowhere implemented'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3123 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3124 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3125 |
if the selector has the name of a variable, use another message |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3126 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3127 |
((methodVarNames notNil and:[methodVarNames includes:aSelectorString]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3128 |
or:[(methodArgNames notNil and:[methodArgNames includes:aSelectorString]) |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3129 |
or:[classToCompileFor notNil |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3130 |
and:[((names := self classesInstVarNames) notNil and:[names includes:aSelectorString]) |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3131 |
or:[((names := self classesClassInstVarNames) notNil and:[names includes:aSelectorString]) |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3132 |
or:[(names := self classesClassVarNames) notNil and:[names includes:aSelectorString] |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3133 |
]]]]]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3134 |
err := ' is currently nowhere implemented .. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3135 |
.. but a variable with that name is defined. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3136 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3137 |
Missing ''.'' after the previous expression |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3138 |
or missing keyword/receiver before that word ?'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3139 |
]. |
1327 | 3140 |
] ifFalse:[ |
3141 |
receiver notNil ifTrue:[ |
|
3142 |
selClass := self typeOfNode:receiver. |
|
3143 |
selClass notNil ifTrue:[ |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3144 |
"this could be performed if selClass isNil, but it is too slow" |
1507 | 3145 |
err := self checkSelector:selectorSymbol for:receiver inClass:selClass. |
1327 | 3146 |
]. |
3147 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3148 |
(receiver isConstant or:[receiver isBlock]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3149 |
err notNil ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3150 |
err := err, ' in ' , selClass name , ' or any of its superclasses'. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3151 |
]. |
1327 | 3152 |
] ifFalse:[(((recType := receiver type) == #GlobalVariable) |
3153 |
or:[recType == #PrivateClass]) ifTrue:[ |
|
3154 |
rec := receiver evaluate. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3155 |
"/ dont check autoloaded classes - it may work after loading |
1327 | 3156 |
(rec isNil |
3157 |
or:[rec isBehavior and:[rec isLoaded not]]) ifTrue:[ |
|
3158 |
^ aSelectorString |
|
3159 |
]. |
|
3160 |
||
3161 |
err notNil ifTrue:[ |
|
3162 |
(rec isBehavior |
|
3163 |
and:[rec theNonMetaclass name = receiver name]) ifTrue:[ |
|
3164 |
err := err, ' in ' , rec theNonMetaclass name. |
|
3165 |
] ifFalse:[ |
|
3166 |
err := err, ' in currently assigned value (is currently ' , rec classNameWithArticle , ')'. |
|
3167 |
] |
|
3168 |
]. |
|
3169 |
] ifFalse:[receiver isSuper ifTrue:[ |
|
3170 |
receiver isHere ifFalse:[ |
|
3171 |
err notNil ifTrue:[ |
|
3172 |
err := err, ' in superclass chain'. |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3173 |
]. |
1327 | 3174 |
] ifTrue:[ |
3175 |
err notNil ifTrue:[ |
|
3176 |
err := err, ' in this class or superclass chain'. |
|
1203
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3177 |
]. |
1327 | 3178 |
] |
3179 |
] ifFalse:[receiver isSelf ifTrue:[ |
|
3180 |
err notNil ifTrue:[ |
|
3181 |
|subErr| |
|
3182 |
||
3183 |
"/ understood by all subclasses ? |
|
3184 |
classToCompileFor allSubclassesDo:[:eachSubclass | |
|
3185 |
subErr isNil ifTrue:[ |
|
3186 |
selClass := eachSubclass. |
|
1507 | 3187 |
subErr := self checkSelector:selectorSymbol for:receiver inClass:selClass. |
1327 | 3188 |
]. |
3189 |
]. |
|
3190 |
subErr notNil ifTrue:[ |
|
3191 |
err := subErr, ' in this class, superclass chain or all subclasses' |
|
3192 |
] ifFalse:[ |
|
3193 |
err := err, ' in this class or superclass chain'. |
|
1440 | 3194 |
]. |
3195 |
canDefine := true. |
|
1327 | 3196 |
]. |
3197 |
] ifFalse:[(receiver isUnaryMessage |
|
3198 |
and:[receiver selector == #class |
|
3199 |
and:[receiver receiver isSelf]]) ifTrue:[ |
|
3200 |
"its a message to self class - can check this too ..." |
|
3201 |
err notNil ifTrue:[ |
|
3202 |
classToCompileFor isMeta ifTrue:[ |
|
3203 |
err := err, ' for the classes class'. |
|
1507 | 3204 |
(self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[ |
1327 | 3205 |
err := err, '...\\...but its implemented for the class itself. You probably do not want the #class message here.'. |
3206 |
err := err withCRs. |
|
3207 |
]. |
|
3208 |
] ifFalse:[ |
|
3209 |
err := err, ' for my class'. |
|
1507 | 3210 |
(self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[ |
1327 | 3211 |
err := err, '...\\...but its implemented for instances. You may want to remove the #class message.'. |
3212 |
err := err withCRs. |
|
3213 |
]. |
|
1203
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3214 |
]. |
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3215 |
]. |
1327 | 3216 |
] ifFalse:[(receiver isMethodVariable and:[receiver token type isNil]) ifTrue:[ |
3217 |
"if it is an uninitialized variable ..." |
|
3218 |
((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not]) |
|
1441 | 3219 |
and:[hasPrimitiveCode not |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3220 |
and:[currentBlock isNil |
1327 | 3221 |
and:[alreadyWarnedUninitializedVars isNil |
1442 | 3222 |
or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]]]) |
1327 | 3223 |
ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3224 |
((#(at: at:put: basicAt: basicAt:put:) includes:selectorSymbol) |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3225 |
or:[(nil respondsTo:selectorSymbol) not])ifTrue:[ |
1327 | 3226 |
"/ avoid trouble in miniTalk |
3227 |
"/ during bootstrap |
|
3228 |
nm := receiver name. |
|
3229 |
Text notNil ifTrue:[ |
|
3230 |
nm := nm allItalic |
|
3231 |
]. |
|
3232 |
err := 'sent to possibly uninitialized variable ''' , nm , ''' here (?)'. |
|
3233 |
alreadyWarnedUninitializedVars isNil ifTrue:[ |
|
3234 |
alreadyWarnedUninitializedVars := Set new |
|
3235 |
]. |
|
3236 |
alreadyWarnedUninitializedVars add:receiver name |
|
3237 |
] |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3238 |
] |
1327 | 3239 |
] ifFalse:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3240 |
(err notNil and:[selClass notNil]) ifTrue:[ |
1327 | 3241 |
err := err, ' (message to ' , selClass nameWithArticle , ')'. |
3242 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3243 |
]]]]]]. |
1327 | 3244 |
] |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3245 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3246 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3247 |
err notNil ifTrue:[ |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3248 |
(receiver notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3249 |
and:[((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3250 |
or:[recType == #PrivateClass]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3251 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3252 |
"/ - it may work after loading |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3253 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3254 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3255 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3256 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3257 |
and:[rec isLoaded not]]) ifTrue:[ |
1022 | 3258 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3259 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3260 |
rec class == UndefinedVariable ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3261 |
"/ dont check undefined vars; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3262 |
"/ it may work after loading/defining |
1022 | 3263 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3264 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3265 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3266 |
Text notNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3267 |
err := '"' , aSelectorString allBold, '" ', err |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
3268 |
] ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3269 |
err := aSelectorString , ' ', err |
1052
0a1e613468f5
avoid trouble if Text class is not present (in mini-image)
Claus Gittinger <cg@exept.de>
parents:
1043
diff
changeset
|
3270 |
]. |
1157
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3271 |
"/ if its a recursive invocation of just that selector, do not complain |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3272 |
(selector = aSelectorString and:[ receiver isSelf]) ifTrue:[ |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3273 |
^ aSelectorString |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3274 |
]. |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3275 |
isSyntaxHighlighter ifTrue:[ |
1439 | 3276 |
posVector do:[:p | |
3277 |
self markUnknownIdentifierFrom:(p start) to:(p stop). |
|
3278 |
]. |
|
3279 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3280 |
isSyntaxHighlighter ifFalse:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3281 |
err := err , '\\This is a warning from the compiler - the code has not yet been executed/compiled.'. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3282 |
newSelector := self correctSelector:aSelectorString |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3283 |
message:err withCRs |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3284 |
positions:posVector in:selClass for:receiver. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3285 |
"/ self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3286 |
^ newSelector. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3287 |
]. |
141 | 3288 |
]. |
1022 | 3289 |
^ aSelectorString |
141 | 3290 |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3291 |
"Modified: / 5.9.1995 / 17:02:11 / claus" |
1022 | 3292 |
"Modified: / 19.1.2000 / 16:34:03 / cg" |
1327 | 3293 |
! |
3294 |
||
3295 |
typeOfNode:aNode |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3296 |
|nodeVal nodeType classHint| |
1327 | 3297 |
|
3298 |
aNode isConstant ifTrue:[ |
|
3299 |
" |
|
3300 |
if the receiver is a constant, we can check if it responds |
|
3301 |
to this selector |
|
3302 |
" |
|
3303 |
nodeVal := aNode evaluate. |
|
3304 |
^ nodeVal class. |
|
3305 |
]. |
|
3306 |
||
3307 |
"/ this should help with typos, sending #ifTrue to blocks ... |
|
3308 |
aNode isBlock ifTrue:[ |
|
3309 |
^ Block |
|
3310 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3311 |
aNode isVariable ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3312 |
nodeType := aNode type. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3313 |
(nodeType == #GlobalVariable or:[nodeType == #PrivateClass]) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3314 |
"if the receiver is a global, we check it too ..." |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3315 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3316 |
nodeVal := aNode evaluate. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3317 |
"/ dont check autoloaded classes |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3318 |
"/ - it may work after loading |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3319 |
(nodeVal isNil |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3320 |
or:[nodeVal isBehavior and:[nodeVal isLoaded not]]) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3321 |
^ nil |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3322 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3323 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3324 |
^ nodeVal class. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3325 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3326 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3327 |
(aNode isLocal) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3328 |
classHint := aNode token classHint. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3329 |
classHint notNil ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3330 |
^ Smalltalk classNamed:classHint |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3331 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3332 |
]. |
1327 | 3333 |
]. |
3334 |
||
3335 |
aNode isSuper ifTrue:[ |
|
3336 |
"if its a super- or here-send, we can do more checking" |
|
3337 |
aNode isHere ifFalse:[ |
|
3338 |
^ classToCompileFor superclass ? UndefinedObject. |
|
3339 |
]. |
|
3340 |
^ classToCompileFor. |
|
3341 |
]. |
|
3342 |
aNode isSelf ifTrue:[ |
|
3343 |
^ classToCompileFor. |
|
3344 |
]. |
|
3345 |
||
3346 |
(aNode isUnaryMessage) ifTrue:[ |
|
3347 |
(aNode selector == #class) ifTrue:[ |
|
3348 |
aNode receiver isSelf ifTrue:[ |
|
3349 |
"its a message to self class - can check this too ..." |
|
3350 |
^ classToCompileFor class. |
|
3351 |
]. |
|
3352 |
]. |
|
3353 |
( #(#'isNil' #'notNil') includes:aNode selector) ifTrue:[ |
|
3354 |
^ Boolean. |
|
3355 |
] |
|
3356 |
]. |
|
3357 |
aNode isBinaryMessage ifTrue:[ |
|
3358 |
( #(#'<' #'>' #'>=' #'<=' #'=' #'==' #'~=' #'~~') includes:aNode selector) ifTrue:[ |
|
3359 |
^ Boolean. |
|
3360 |
] |
|
3361 |
]. |
|
3362 |
||
3363 |
^ nil |
|
0 | 3364 |
! ! |
3365 |
||
3366 |
!Parser methodsFor:'error handling'! |
|
3367 |
||
1259 | 3368 |
blockArgRedefined:tokenName from:pos1 to:pos2 |
3369 |
"argname reuse" |
|
3370 |
||
3371 |
self isSyntaxHighlighter ifTrue:[ |
|
3372 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3373 |
] ifFalse:[ |
|
3374 |
self |
|
3375 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3376 |
position:pos1 to:pos2 |
|
3377 |
]. |
|
3378 |
! |
|
3379 |
||
1495 | 3380 |
errorMessageForUndefined:aName |
3381 |
|idx implementors| |
|
3382 |
||
3383 |
classToCompileFor notNil ifTrue:[ |
|
3384 |
"/ is it an instance-variable marked inaccessable ? |
|
3385 |
||
3386 |
idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1. |
|
3387 |
idx ~~ 0 ifTrue:[ |
|
3388 |
^ '''%1'' is a hidden instvar (not accessable from ST-code)'. |
|
3389 |
]. |
|
3390 |
||
3391 |
"/ is it an instance variable, while evaluateing for the class ? |
|
3392 |
classToCompileFor isMeta ifTrue:[ |
|
3393 |
(classToCompileFor soleInstance allInstVarNames includes:aName) ifTrue:[ |
|
3394 |
^ 'Warning: ''%1'' is an instvar\(hint: you are evaluating/compiling in the classes context)'. |
|
3395 |
] |
|
3396 |
] |
|
3397 |
]. |
|
3398 |
self isDoIt ifTrue:[ |
|
1576 | 3399 |
SystemBrowser notNil ifTrue:[ |
1569
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3400 |
implementors := SystemBrowser |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3401 |
findImplementorsOf:aName |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3402 |
in:(Smalltalk allClasses) |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3403 |
ignoreCase:false. |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3404 |
implementors size > 0 ifTrue:[ |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3405 |
^ '''%1'' is undefined but known as a message selector.\(hint: did you forget to select the receiver ?)'. |
1576 | 3406 |
]. |
1495 | 3407 |
]. |
3408 |
]. |
|
3409 |
^ '''%1'' is undefined'. |
|
3410 |
! |
|
3411 |
||
141 | 3412 |
exitWith:something |
3413 |
"this is the longjump out of evaluation via a return expression" |
|
3414 |
||
3415 |
evalExitBlock value:something |
|
3416 |
! |
|
3417 |
||
3418 |
identifierExpectedIn:what |
|
3419 |
|msg| |
|
3420 |
||
3421 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
1260
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3422 |
msg := 'Reserved keyword in ' |
141 | 3423 |
] ifFalse:[ |
1260
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3424 |
msg := 'Identifier expected in ' |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3425 |
]. |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3426 |
self syntaxError:(msg , what , ' (got ''' , tokenType printString, ''')') |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3427 |
position:tokenPosition to:source position1Based - 1. |
141 | 3428 |
^ #Error |
3429 |
! |
|
3430 |
||
1259 | 3431 |
methodArgRedefined:tokenName from:pos1 to:pos2 |
3432 |
"argname reuse" |
|
3433 |
||
3434 |
self isSyntaxHighlighter ifTrue:[ |
|
3435 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3436 |
] ifFalse:[ |
|
3437 |
self |
|
3438 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3439 |
position:pos1 to:pos2 |
|
3440 |
]. |
|
3441 |
! |
|
3442 |
||
0 | 3443 |
showErrorMessage:aMessage position:pos |
19 | 3444 |
"redefined since parser can give more detailed info about |
3445 |
the class & selector where the error occured." |
|
3446 |
||
1534 | 3447 |
|msg| |
71 | 3448 |
|
19 | 3449 |
ignoreErrors ifFalse:[ |
1160 | 3450 |
Smalltalk silentLoading == true ifFalse:[ |
1534 | 3451 |
msg := ''. |
1160 | 3452 |
pos notNil ifTrue:[ |
1534 | 3453 |
msg := msg , (pos printString). |
3454 |
msg := msg , ' '. |
|
1160 | 3455 |
]. |
1534 | 3456 |
msg := msg , aMessage. |
1160 | 3457 |
selector notNil ifTrue:[ |
1534 | 3458 |
msg := msg , ' in '. |
1160 | 3459 |
classToCompileFor notNil ifTrue:[ |
1534 | 3460 |
msg := msg , classToCompileFor name , '>>' |
3461 |
]. |
|
3462 |
msg := msg , selector. |
|
1160 | 3463 |
] ifFalse:[ |
3464 |
classToCompileFor notNil ifTrue:[ |
|
1534 | 3465 |
msg := msg , ' (' , classToCompileFor name , ')' |
1160 | 3466 |
] |
3467 |
]. |
|
1534 | 3468 |
|
3469 |
UserInformation isHandled ifTrue:[ |
|
3470 |
UserInformation raiseErrorString:msg |
|
3471 |
] ifFalse:[ |
|
3472 |
Transcript showCR:msg. |
|
3473 |
] |
|
1160 | 3474 |
] |
0 | 3475 |
] |
273 | 3476 |
|
3477 |
"Modified: 18.5.1996 / 15:44:15 / cg" |
|
0 | 3478 |
! |
3479 |
||
171 | 3480 |
showErrorMessageForClass:aClass |
3481 |
"/ compiler parseError:'syntax error'. |
|
3482 |
Transcript show:' '. |
|
3483 |
aClass notNil ifTrue:[ |
|
1576 | 3484 |
Transcript show:aClass name , '>>' |
171 | 3485 |
]. |
3486 |
selector notNil ifTrue:[ |
|
1576 | 3487 |
Transcript show:(selector) |
171 | 3488 |
]. |
273 | 3489 |
Transcript showCR:' -> Error'. |
171 | 3490 |
|
3491 |
"Created: 13.12.1995 / 20:24:34 / cg" |
|
273 | 3492 |
"Modified: 18.5.1996 / 15:44:17 / cg" |
171 | 3493 |
! |
3494 |
||
0 | 3495 |
undefError:aName position:pos1 to:pos2 |
3 | 3496 |
"report an undefined variable error - return true, if it should be |
86 | 3497 |
corrected. If not corrected, only one warning is made per undefined |
3498 |
variable." |
|
3499 |
||
1495 | 3500 |
|ex doCorrect boldName| |
1400 | 3501 |
|
3502 |
ex := UndefinedVariableNotification newException. |
|
3503 |
ex parser:self. |
|
3504 |
ex parameter:aName. |
|
3505 |
ex suspendedContext:thisContext. |
|
3506 |
doCorrect := ex raiseRequest. |
|
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3507 |
doCorrect notNil ifTrue:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3508 |
^ doCorrect |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3509 |
]. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3510 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3511 |
parserFlags warnUndeclared ifFalse:[^ false]. |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
3512 |
ignoreWarnings ifTrue:[^ false]. |
607 | 3513 |
|
86 | 3514 |
" |
3515 |
alredy warned about this one ? |
|
3516 |
" |
|
3517 |
warnedUndefVars notNil ifTrue:[ |
|
877 | 3518 |
(warnedUndefVars includes:aName) ifTrue:[ |
3519 |
"already warned about this one" |
|
3520 |
^ false |
|
3521 |
]. |
|
86 | 3522 |
]. |
3523 |
||
131 | 3524 |
"/ (classToCompileFor notNil |
3525 |
"/ and:[classToCompileFor superclass notNil |
|
3526 |
"/ and:[classToCompileFor superclass instanceVariableString isNil]]) ifTrue:[ |
|
132
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
3527 |
"/ self showErrorMessage:'Error: no source information (instvar names)' position:pos1. |
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
3528 |
"/ ^ false |
131 | 3529 |
"/ ]. |
3530 |
||
1285 | 3531 |
boldName := aName allBold. |
3532 |
||
131 | 3533 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
877 | 3534 |
aName first isUppercase ifFalse:[ |
1285 | 3535 |
self showErrorMessage:('Error: ''' , boldName , ''' is undefined') position:pos1. |
877 | 3536 |
]. |
3537 |
doCorrect := false. |
|
86 | 3538 |
] ifFalse:[ |
877 | 3539 |
" |
3540 |
ask requestor for correct/continue/abort ... |
|
3541 |
it is supposed to raise abort or return true/false. |
|
3542 |
True return means that correction is wanted. |
|
3543 |
" |
|
1495 | 3544 |
doCorrect := self |
3545 |
correctableError:((self errorMessageForUndefined:aName) bindWith:boldName) withCRs |
|
3546 |
position:pos1 to:pos2 |
|
86 | 3547 |
]. |
3548 |
||
877 | 3549 |
doCorrect == false ifTrue:[ |
3550 |
warnedUndefVars isNil ifTrue:[ |
|
3551 |
warnedUndefVars := Set new. |
|
3552 |
]. |
|
3553 |
warnedUndefVars add:aName. |
|
3 | 3554 |
]. |
0 | 3555 |
|
86 | 3556 |
^ doCorrect |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
3557 |
|
607 | 3558 |
"Modified: 7.9.1997 / 02:14:36 / cg" |
1160 | 3559 |
! |
3560 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3561 |
warnSTXHereExtensionUsedAt:position |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3562 |
ignoreWarnings ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3563 |
didWarnAboutSTXHereExtensionUsed ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3564 |
parserFlags warnSTXHereExtensionUsed ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3565 |
self warning:'here-sends are a nonstandard feature of ST/X' |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3566 |
position:position to:position+3. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3567 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3568 |
only warn once |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3569 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3570 |
didWarnAboutSTXHereExtensionUsed := true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3571 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3572 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3573 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3574 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3575 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3576 |
warnSTXNameSpaceUseAt:position |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3577 |
ignoreWarnings ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3578 |
didWarnAboutSTXNameSpaceUse ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3579 |
parserFlags warnSTXNameSpaceUse ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3580 |
self warning:'nameSpaces are a nonstandard feature of ST/X' |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3581 |
doNotShowAgainAction:[ ParserFlags warnSTXSpecials:false ] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3582 |
position:position to:(source position1Based). |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3583 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3584 |
only warn once |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3585 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3586 |
didWarnAboutSTXNameSpaceUse := false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3587 |
] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3588 |
] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3589 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3590 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3591 |
|
1160 | 3592 |
warnUnused:aNameCollection |
3593 |
"report an unused method variable" |
|
3594 |
||
1638 | 3595 |
|msg answer| |
1160 | 3596 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3597 |
(ignoreErrors not |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3598 |
and:[ignoreWarnings not |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3599 |
and:[parserFlags warnUnusedVars]]) ifTrue:[ |
1638 | 3600 |
msg := 'Unused method variable(s): '. |
1160 | 3601 |
aNameCollection asSortedCollection do:[:name| |
1638 | 3602 |
msg := msg , (' "',name allBold,'"'). |
3603 |
]. |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3604 |
|
1160 | 3605 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3606 |
self showErrorMessage:('Warning: ', msg) position:nil. |
1160 | 3607 |
] ifFalse:[ |
1167 | 3608 |
answer := requestor |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3609 |
unusedVariableWarning:msg |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
3610 |
position:(localVarDefPosition first) to:(localVarDefPosition last) from:self. |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3611 |
|
1167 | 3612 |
answer == true ifTrue:[ |
3613 |
"/ delete the definitions ... |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3614 |
aNameCollection do:[:eachName | |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
3615 |
self deleteDefinitionOf:eachName in:(localVarDefPosition first) to:(localVarDefPosition last). |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3616 |
]. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3617 |
RestartCompilationSignal raise |
1167 | 3618 |
]. |
1160 | 3619 |
]. |
3620 |
]. |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3621 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3622 |
"Modified: / 17.11.2001 / 10:30:47 / cg" |
0 | 3623 |
! ! |
3624 |
||
1363 | 3625 |
!Parser methodsFor:'evaluating expressions'! |
3626 |
||
3627 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
3628 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3629 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3630 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3631 |
is non-nil, it is evaluated if an error occurs. |
|
3632 |
Finally, compile specifies if the string should be compiled down to |
|
3633 |
bytecode or instead be interpreted from the parseTree. |
|
3634 |
The first should be done for doIts etc, where a readable walkback is |
|
3635 |
required. |
|
3636 |
The latter is better done for constants, styleSheet and resource |
|
3637 |
reading and simple sends, where the overhead of compilation is bigger |
|
3638 |
than the interpretation overhead." |
|
3639 |
||
1548 | 3640 |
^ self |
3641 |
evaluate:aStringOrStream |
|
3642 |
in:aContext |
|
3643 |
receiver:anObject |
|
3644 |
notifying:requestor |
|
3645 |
logged:logged |
|
3646 |
ifFail:failBlock |
|
3647 |
compile:compile |
|
3648 |
checkForEndOfInput:true |
|
3649 |
! |
|
3650 |
||
3651 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile checkForEndOfInput:checkForEndOfInput |
|
3652 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3653 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3654 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3655 |
is non-nil, it is evaluated if an error occurs. |
|
3656 |
Finally, compile specifies if the string should be compiled down to |
|
3657 |
bytecode or instead be interpreted from the parseTree. |
|
3658 |
The first should be done for doIts etc, where a readable walkback is |
|
3659 |
required. |
|
3660 |
The latter is better done for constants, styleSheet and resource |
|
3661 |
reading and simple sends, where the overhead of compilation is bigger |
|
3662 |
than the interpretation overhead." |
|
3663 |
||
1363 | 3664 |
|tree mustBackup loggedString chgStream value s sReal spc |
3665 |
nameSpaceQuerySignal compiler| |
|
3666 |
||
3667 |
aStringOrStream isNil ifTrue:[ |
|
3668 |
EmptySourceNotificationSignal raiseRequest. |
|
3669 |
^ nil |
|
3670 |
]. |
|
3671 |
(mustBackup := aStringOrStream isStream) ifTrue:[ |
|
3672 |
s := aStringOrStream. |
|
3673 |
] ifFalse:[ |
|
3674 |
loggedString := aStringOrStream. |
|
3675 |
s := ReadStream on:aStringOrStream. |
|
3676 |
]. |
|
3677 |
||
3678 |
self source:s. |
|
3679 |
||
3680 |
self parseForCode. |
|
3681 |
self foldConstants:nil. |
|
3682 |
self setSelf:anObject. |
|
3683 |
self setContext:aContext. |
|
3684 |
aContext notNil ifTrue:[ |
|
3685 |
self setSelf:(aContext receiver). |
|
3686 |
"/ aContext method notNil ifTrue:[ |
|
3687 |
"/ cls := aContext method mclass |
|
3688 |
"/ ]. |
|
3689 |
"/ self setClassToCompileFor:(cls ? aContext receiver class). |
|
3690 |
self setClassToCompileFor:(aContext receiver class). |
|
3691 |
]. |
|
3692 |
self notifying:requestor. |
|
3693 |
self nextToken. |
|
3694 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3695 |
tree := self parseMethodBodyOrEmpty. |
|
3696 |
||
1548 | 3697 |
checkForEndOfInput ifTrue:[self checkForEndOfInput]. |
1363 | 3698 |
|
3699 |
"if reading from a stream, backup for next expression" |
|
3700 |
mustBackup ifTrue:[ |
|
3701 |
self backupPosition |
|
3702 |
]. |
|
3703 |
||
3704 |
(self errorFlag or:[tree == #Error]) ifTrue:[ |
|
3705 |
failBlock notNil ifTrue:[ |
|
3706 |
^ failBlock value |
|
3707 |
]. |
|
3708 |
^ #Error |
|
3709 |
]. |
|
3710 |
||
3711 |
tree isNil ifTrue:[ |
|
3712 |
EmptySourceNotificationSignal raiseRequest. |
|
3713 |
^ nil |
|
3714 |
]. |
|
3715 |
||
3716 |
(logged |
|
3717 |
and:[loggedString notNil |
|
3718 |
and:[Smalltalk logDoits]]) ifTrue:[ |
|
3719 |
Class updateChangeFileQuerySignal query ifTrue:[ |
|
3720 |
chgStream := Class changesStream. |
|
3721 |
chgStream notNil ifTrue:[ |
|
3722 |
chgStream nextChunkPut:loggedString. |
|
3723 |
chgStream cr. |
|
3724 |
chgStream close |
|
3725 |
] |
|
3726 |
]. |
|
3727 |
Project notNil ifTrue:[ |
|
3728 |
Class updateChangeListQuerySignal query ifTrue:[ |
|
3729 |
Project addDoIt:loggedString |
|
3730 |
] |
|
3731 |
] |
|
3732 |
]. |
|
3733 |
||
3734 |
" |
|
3735 |
during the evaluation, handle nameSpace queries |
|
3736 |
from the value as defined by any namespace directive. |
|
3737 |
This, if its a class definition expression, the class will |
|
3738 |
be installed there. |
|
3739 |
" |
|
3740 |
nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
3741 |
||
3742 |
spc := self getNameSpace. |
|
3743 |
spc isNil ifTrue:[ |
|
3744 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
|
3745 |
spc := requestor currentNameSpace |
|
3746 |
] ifFalse:[ |
|
3747 |
spc := nameSpaceQuerySignal query. |
|
3748 |
] |
|
3749 |
]. |
|
3750 |
||
3751 |
nameSpaceQuerySignal answer:spc |
|
3752 |
do:[ |
|
3753 |
|method| |
|
3754 |
||
3755 |
" |
|
3756 |
if compile is false, or the parse tree is that of a constant, |
|
3757 |
or a variable, quickly return its value. |
|
3758 |
This is used for example, when reading simple objects |
|
3759 |
via #readFrom:. |
|
3760 |
The overhead of compiling a method is avoided in this case. |
|
3761 |
" |
|
3762 |
((SuppressDoItCompilation == true) |
|
3763 |
or:[compile not |
|
3764 |
or:[tree isConstant |
|
3765 |
or:[tree isVariable |
|
3766 |
or:[aStringOrStream isStream |
|
3767 |
or:[aContext notNil]]]]]) ifTrue:[ |
|
3768 |
^ tree evaluate |
|
3769 |
]. |
|
3770 |
||
3771 |
" |
|
3772 |
if I am the ByteCodeCompiler, |
|
3773 |
generate a dummy method, execute it and return the value. |
|
3774 |
otherwise, just evaluate the tree; slower, but not too bad ... |
|
3775 |
||
3776 |
This allows systems to be delivered without the ByteCodeCompiler, |
|
3777 |
and still evaluate expressions |
|
3778 |
(needed to read resource files or to process .rc files). |
|
3779 |
" |
|
3780 |
self == Parser ifTrue:[ |
|
3781 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3782 |
value := tree evaluate. |
|
3783 |
self evalExitBlock:nil. |
|
3784 |
] ifFalse:[ |
|
3785 |
s := self correctedSource. |
|
3786 |
s isNil ifTrue:[ |
|
3787 |
aStringOrStream isStream ifTrue:[ |
|
3788 |
s := self collectedSource. "/ does not work yet ... |
|
3789 |
] ifFalse:[ |
|
3790 |
s := aStringOrStream |
|
3791 |
]. |
|
3792 |
]. |
|
3793 |
||
3794 |
"/ actually, its a block, to allow |
|
3795 |
"/ easy return ... |
|
3796 |
||
1421
dcdc178254f0
preserve lineNumbers in compiled code (evaluate)
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
3797 |
sReal := 'doIt ^[ ' , s , '\] value' withCRs. |
1363 | 3798 |
|
1366
f91f6a0a56d5
when required to compile, use Compiler instead of self class.
Claus Gittinger <cg@exept.de>
parents:
1365
diff
changeset
|
3799 |
compiler := ByteCodeCompiler new. |
1363 | 3800 |
compiler initializeFlagsFrom:self. |
3801 |
method := compiler |
|
3802 |
compile:sReal |
|
3803 |
forClass:anObject class |
|
3804 |
inCategory:'_temporary_' |
|
3805 |
notifying:requestor |
|
3806 |
install:false |
|
3807 |
skipIfSame:false |
|
3808 |
silent:true |
|
3809 |
foldConstants:false. |
|
3810 |
||
3811 |
method notNil ifTrue:[ |
|
3812 |
method ~~ #Error ifTrue:[ |
|
3813 |
" |
|
3814 |
fake: patch the source string, to what the user expects |
|
3815 |
in the browser |
|
3816 |
" |
|
1421
dcdc178254f0
preserve lineNumbers in compiled code (evaluate)
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
3817 |
method source:"' ' , "s string. |
1363 | 3818 |
" |
3819 |
dont do any just-in-time compilation on it. |
|
3820 |
" |
|
3821 |
method checked:true. |
|
3822 |
||
3823 |
value := method |
|
3824 |
valueWithReceiver:anObject |
|
3825 |
arguments:nil "/ (Array with:m) |
|
1440 | 3826 |
selector:(requestor isNil ifTrue:#'doItX' ifFalse:#'doIt') "/ #doIt: |
1363 | 3827 |
search:nil |
3828 |
sender:nil. |
|
3829 |
] ifFalse:[ |
|
3830 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3831 |
value := tree evaluate. |
|
3832 |
self evalExitBlock:nil. |
|
3833 |
] |
|
3834 |
]. |
|
3835 |
] |
|
3836 |
]. |
|
3837 |
self release. |
|
3838 |
^ value |
|
3839 |
||
3840 |
"Created: / 8.2.1997 / 19:34:44 / cg" |
|
3841 |
"Modified: / 18.3.1999 / 18:25:40 / stefan" |
|
3842 |
"Modified: / 6.2.2000 / 15:01:57 / cg" |
|
3843 |
! ! |
|
3844 |
||
0 | 3845 |
!Parser methodsFor:'parsing'! |
3846 |
||
141 | 3847 |
block |
3848 |
"parse a block; return a node-tree, nil or #Error" |
|
3849 |
||
883 | 3850 |
|node args argNames arg pos pos2 lno| |
141 | 3851 |
|
3852 |
lno := tokenLineNr. |
|
3853 |
self nextToken. |
|
3854 |
(tokenType == $: ) ifTrue:[ |
|
663 | 3855 |
[tokenType == $:] whileTrue:[ |
3856 |
pos := tokenPosition. |
|
3857 |
self nextToken. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3858 |
|
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3859 |
(pos == (tokenPosition - 1)) ifFalse:[ |
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3860 |
self warnPossibleIncompatibility:'space(s) between colon and identifier may be non-portable' position:pos to:tokenPosition. |
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3861 |
]. |
883 | 3862 |
(tokenType ~~ #Identifier) ifTrue:[ |
663 | 3863 |
^ self identifierExpectedIn:'block-arg declaration' |
3864 |
]. |
|
883 | 3865 |
|
3866 |
pos2 := tokenPosition + tokenName size - 1. |
|
3867 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 3868 |
self checkBlockArgumentNameConventionsFor:tokenName. |
663 | 3869 |
arg := Variable name:tokenName. |
3870 |
args isNil ifTrue:[ |
|
3871 |
args := Array with:arg. |
|
3872 |
argNames := Array with:tokenName. |
|
3873 |
] ifFalse:[ |
|
3874 |
(argNames includes:tokenName) ifTrue:[ |
|
1259 | 3875 |
self blockArgRedefined:tokenName from:tokenPosition to:pos2 |
663 | 3876 |
]. |
3877 |
args := args copyWith:arg. |
|
3878 |
argNames := argNames copyWith:tokenName. |
|
3879 |
]. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3880 |
self nextToken. |
663 | 3881 |
]. |
3882 |
(tokenType ~~ $| ) ifTrue:[ |
|
3883 |
"ST-80 allows [:arg ]" |
|
3884 |
(tokenType == $] ) ifTrue:[ |
|
3885 |
node := BlockNode arguments:args home:currentBlock variables:nil. |
|
3886 |
node lineNumber:lno. |
|
3887 |
^ node |
|
3888 |
]. |
|
3889 |
self syntaxError:'| expected after block-arg declaration'. |
|
3890 |
^ #Error |
|
3891 |
]. |
|
3892 |
self nextToken |
|
141 | 3893 |
]. |
3894 |
node := self blockBody:args. |
|
3895 |
(node notNil and:[node ~~ #Error]) ifTrue:[ |
|
663 | 3896 |
node lineNumber:lno. |
141 | 3897 |
]. |
3898 |
^ node |
|
663 | 3899 |
|
3900 |
"Modified: / 31.3.1998 / 17:31:34 / cg" |
|
141 | 3901 |
! |
3902 |
||
3903 |
blockBody:args |
|
3904 |
"parse a blocks body; return a node-tree, nil or #Error" |
|
3905 |
||
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3906 |
|stats node var vars lno pos2| |
141 | 3907 |
|
3908 |
lno := tokenLineNr. |
|
3909 |
(tokenType == $| ) ifTrue:[ |
|
668 | 3910 |
self nextToken. |
3911 |
[tokenType == $|] whileFalse:[ |
|
3912 |
(tokenType == #Identifier) ifFalse:[ |
|
3913 |
^ self identifierExpectedIn:'block-var declaration' |
|
3914 |
]. |
|
883 | 3915 |
pos2 := tokenPosition + tokenName size - 1. |
3916 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 3917 |
self checkBlockVariableNameConventionsFor:tokenName. |
668 | 3918 |
var := Variable name:tokenName. |
3919 |
vars isNil ifTrue:[ |
|
3920 |
vars := Array with:var. |
|
3921 |
] ifFalse:[ |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3922 |
(vars contains:[:var | var name = tokenName]) ifTrue:[ |
883 | 3923 |
"/ varname reuse |
3924 |
self isSyntaxHighlighter ifTrue:[ |
|
3925 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3926 |
] ifFalse:[ |
|
3927 |
self |
|
3928 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
3929 |
position:tokenPosition to:pos2. |
|
3930 |
] |
|
668 | 3931 |
] ifFalse:[ |
3932 |
vars := vars copyWith:var. |
|
3933 |
] |
|
3934 |
]. |
|
3935 |
self nextToken. |
|
1471 | 3936 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3937 |
parserFlags allowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
1471 | 3938 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
3939 |
self nextToken. |
|
3940 |
"/ Q: should we allow literals only, or arbitrary expressions ? |
|
3941 |
self halt:'unimplemented feature'. |
|
3942 |
] |
|
3943 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3944 |
parserFlags allowDomainVariables == true ifTrue:[ |
1471 | 3945 |
(tokenType == $() ifTrue:[ |
3946 |
self variableTypeDeclarationFor:var. |
|
3947 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3948 |
]. |
668 | 3949 |
]. |
3950 |
self nextToken |
|
141 | 3951 |
]. |
382 | 3952 |
|
141 | 3953 |
node := BlockNode arguments:args home:currentBlock variables:vars. |
3954 |
node lineNumber:lno. |
|
3955 |
currentBlock := node. |
|
3956 |
stats := self blockStatementList. |
|
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3957 |
(stats == #Error) ifTrue:[^ #Error]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3958 |
|
382 | 3959 |
lineNumberInfo == #full ifTrue:[ |
668 | 3960 |
node endLineNumber:tokenLineNr |
382 | 3961 |
]. |
141 | 3962 |
node statements:stats. |
3963 |
currentBlock := node home. |
|
3964 |
^ node |
|
382 | 3965 |
|
668 | 3966 |
"Modified: / 31.3.1998 / 22:46:09 / cg" |
141 | 3967 |
! |
3968 |
||
3969 |
blockExpression |
|
3970 |
"parse a blockExpression; return a node-tree, nil or #Error. |
|
3971 |
Not used by ST/X's parser, but added for ST-80 compatibility." |
|
3972 |
||
3973 |
tokenType ~~ $[ ifTrue:[ |
|
1576 | 3974 |
self syntaxError:'[ expected'. |
3975 |
^ #Error. |
|
141 | 3976 |
]. |
3977 |
^ self block |
|
3978 |
! |
|
3979 |
||
3980 |
blockStatementList |
|
3981 |
"parse a blocks statementlist; return a node-tree, nil or #Error" |
|
3982 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3983 |
|thisStatement prevStatement firstStatement eMsg| |
141 | 3984 |
|
3985 |
(tokenType == $] ) ifTrue:[^ nil]. |
|
3986 |
thisStatement := self statement. |
|
3987 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3988 |
firstStatement := thisStatement. |
|
3989 |
[tokenType == $] ] whileFalse:[ |
|
673 | 3990 |
(tokenType == $.) ifFalse:[ |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3991 |
(tokenType == #EOF) ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3992 |
self syntaxError:'missing '']'' in block' position:(source position1Based) to:(source position1Based). |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3993 |
^ #Error. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3994 |
]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3995 |
|
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3996 |
(tokenType == $) ) ifTrue:[ |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3997 |
eMsg := 'missing '']'' or bad '')'' in block' |
673 | 3998 |
] ifFalse:[ |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3999 |
eMsg := 'missing ''.'' between statements (i.e. ''' , tokenType printString , '''-token unexpected)' |
673 | 4000 |
]. |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
4001 |
self syntaxError:eMsg position:tokenPosition to:tokenPosition. |
673 | 4002 |
^ #Error |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4003 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4004 |
prevStatement := thisStatement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4005 |
self nextToken. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4006 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4007 |
tokenType == $] ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4008 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4009 |
*** I had a warning here (since it was not defined |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4010 |
*** in the blue-book; but PD-code contains a lot of |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4011 |
*** code with periods at the end so that the warnings |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4012 |
*** became annoying |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4013 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4014 |
self warning:'period after last statement in block'. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4015 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4016 |
self markBracketAt:tokenPosition. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4017 |
^ firstStatement |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4018 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4019 |
thisStatement := self statement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4020 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4021 |
prevStatement nextStatement:thisStatement |
141 | 4022 |
]. |
673 | 4023 |
self markBracketAt:tokenPosition. |
141 | 4024 |
^ firstStatement |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4025 |
|
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4026 |
"Modified: / 16.7.1998 / 20:38:25 / cg" |
141 | 4027 |
! |
4028 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4029 |
checkForEndOfInput |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4030 |
|what| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4031 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4032 |
(tokenType ~~ #EOF) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4033 |
"/ just for the nicer error message |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4034 |
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[ |
1638 | 4035 |
self parseError:'"',tokenName allBold,'" unexpected (missing ''.'' or '':'' before ' , tokenName , ' ?)' |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4036 |
position:tokenPosition to:(tokenPosition + tokenName size - 1) |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4037 |
] ifFalse:[ |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4038 |
tokenType isCharacter ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4039 |
what := '''' , tokenType , ''''. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4040 |
] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4041 |
what := tokenType printString. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4042 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4043 |
self parseError:(what , ' unexpected (missing ''.'', '':'' or selector before it ?)') |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4044 |
position:tokenPosition to:source position1Based-1. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4045 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4046 |
^#Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4047 |
] |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4048 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4049 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4050 |
checkReturnedValues |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4051 |
| returnsSelf returnsBoolean returnsNonBooleanLiteral| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4052 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4053 |
ignoreWarnings ifTrue:[^ self]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4054 |
returnedValues isNil ifTrue:[^ self]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4055 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4056 |
returnsBoolean := returnedValues contains:[:node | node isConstant and:[node value isBoolean]]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4057 |
returnsNonBooleanLiteral := returnedValues contains:[:node | node isConstant and:[node value isBoolean not]]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4058 |
returnsSelf := returnedValues contains:[:node | node isSelf]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4059 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4060 |
returnsBoolean ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4061 |
(returnsNonBooleanLiteral or:[returnsSelf]) ifTrue:[ |
1455 | 4062 |
self |
4063 |
warning:'Possible Error Warning:\\Method returns both boolean and non-boolean values.' withCRs |
|
4064 |
position:1 to:tokenPosition |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4065 |
] |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4066 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4067 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4068 |
"Created: / 17.11.2001 / 10:31:03 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4069 |
"Modified: / 17.11.2001 / 10:34:16 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4070 |
! |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4071 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4072 |
checkUnusedMethodVars |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4073 |
| unused| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4074 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4075 |
ignoreWarnings ifFalse:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4076 |
methodVars notNil ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4077 |
unused := methodVars select:[:var| var used ~~ true] thenCollect:[:var| var name]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4078 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4079 |
unused size > 0 ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4080 |
self warnUnused:unused. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4081 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4082 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4083 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4084 |
"Created: / 17.11.2001 / 10:23:47 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4085 |
! |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4086 |
|
1224
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4087 |
parseExceptionOrContextPragma |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4088 |
|pragmaType| |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4089 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4090 |
"/ < resource: has already been parsed. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4091 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4092 |
pragmaType := tokenName. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4093 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4094 |
self nextToken. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4095 |
(tokenType ~~ #Symbol) ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4096 |
self parseError:'symbol expected'. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4097 |
^ #Error |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4098 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4099 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4100 |
((pragmaType = 'exception:' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4101 |
and:[tokenValue == #'handle' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4102 |
or:[tokenValue == #'raise' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4103 |
or:[tokenValue == #'unwind']]]) |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4104 |
or:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4105 |
pragmaType = 'context:' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4106 |
and:[(tokenValue == #'return')]]) |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4107 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4108 |
ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4109 |
primitiveContextInfo isNil ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4110 |
primitiveContextInfo := Set new. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4111 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4112 |
primitiveContextInfo add:(pragmaType->tokenValue). |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4113 |
] ifFalse:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4114 |
self parseError:'unrecognized exception pragma: ' , tokenValue. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4115 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4116 |
self nextToken. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4117 |
! |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4118 |
|
1006 | 4119 |
parseExpressionWithSelf:anObject notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
4120 |
"parse aString as an expression with self set to anObject; |
|
4121 |
Return the parseTree (if ok), nil (for an empty string |
|
4122 |
or comment only ) or #Error (syntactic error). |
|
4123 |
||
4124 |
Errors and warnings are forwarded to someOne (usually some |
|
4125 |
codeView) which can highlight it and show a popup box, |
|
4126 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
4127 |
||
4128 |
|tree token| |
|
4129 |
||
4130 |
aNameSpaceOrNil notNil ifTrue:[ |
|
4131 |
self currentNameSpace:aNameSpaceOrNil |
|
4132 |
]. |
|
4133 |
self setSelf:anObject. |
|
4134 |
self notifying:someOne. |
|
1365 | 4135 |
self ignoreErrors:ignoreErrors. |
4136 |
self ignoreWarnings:ignoreWarnings. |
|
1006 | 4137 |
token := self nextToken. |
4138 |
(token == $^) ifTrue:[ |
|
4139 |
self nextToken. |
|
4140 |
]. |
|
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4141 |
(token == #EOF) ifTrue:[ |
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4142 |
^ nil |
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4143 |
]. |
1006 | 4144 |
tree := self expression. |
4145 |
(self errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4146 |
"/ tokenType ~~ #EOF ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4147 |
"/ self parseError:'nothing more expected' position:tokenPosition |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4148 |
"/ ]. |
1006 | 4149 |
^ tree |
4150 |
||
4151 |
"Created: / 14.12.1999 / 15:11:37 / cg" |
|
4152 |
! |
|
4153 |
||
1259 | 4154 |
parseExtendedMethodSpec |
4155 |
|pos1 pos2 var| |
|
4156 |
||
4157 |
"/ EXPERIMENTAL |
|
4158 |
false ifTrue:[ |
|
4159 |
(tokenType == #Symbol) ifTrue:[ |
|
4160 |
pos1 := tokenPosition. |
|
4161 |
selector := token asSymbol. |
|
4162 |
self nextToken. |
|
4163 |
self markMethodSelectorFrom:pos1 to:(tokenPosition-1). |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4164 |
beginOfBodyPosition := tokenPosition. |
1259 | 4165 |
|
4166 |
tokenType == $( ifTrue:[ |
|
4167 |
self nextToken. |
|
4168 |
[ tokenType ~~ $) ] whileTrue:[ |
|
4169 |
||
4170 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
|
4171 |
pos2 := tokenPosition+tokenName size-1. |
|
4172 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
4173 |
var := Variable name:tokenName. |
|
4174 |
methodArgs isNil ifTrue:[ |
|
4175 |
methodArgs := Array with:var. |
|
4176 |
methodArgNames := Array with:tokenName |
|
4177 |
] ifFalse:[ |
|
4178 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
4179 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
|
4180 |
]. |
|
4181 |
methodArgs := methodArgs copyWith:var. |
|
4182 |
methodArgNames := methodArgNames copyWith:tokenName |
|
4183 |
]. |
|
4184 |
self nextToken. |
|
4185 |
]. |
|
4186 |
self nextToken. |
|
4187 |
]. |
|
4188 |
||
4189 |
^ self |
|
4190 |
]. |
|
4191 |
]. |
|
4192 |
^ #Error |
|
4193 |
! |
|
4194 |
||
0 | 4195 |
parseMethod |
19 | 4196 |
"parse a method. |
4197 |
Return the parseTree or #Error. |
|
4198 |
||
4199 |
method ::= methodSpec methodBody |
|
4200 |
" |
|
0 | 4201 |
|
4202 |
|parseTree| |
|
4203 |
||
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4204 |
"/ self nextToken. |
0 | 4205 |
(self parseMethodSpec == #Error) ifTrue:[^ #Error]. |
4206 |
parseTree := self parseMethodBody. |
|
4207 |
(parseTree == #Error) ifFalse:[ |
|
1171
0c43ce981f1b
oops - remove unused vars does not work (yet)
Claus Gittinger <cg@exept.de>
parents:
1169
diff
changeset
|
4208 |
self tree:parseTree |
0 | 4209 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4210 |
self checkForEndOfInput. |
0 | 4211 |
^ parseTree |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4212 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4213 |
"Modified: 20.4.1996 / 20:09:26 / cg" |
0 | 4214 |
! |
4215 |
||
19 | 4216 |
parseMethodBody |
4217 |
"parse a methods body (locals & statements). |
|
4218 |
No more tokens may follow. |
|
4219 |
Return a node-tree, or #Error |
|
4220 |
||
4221 |
methodBody ::= '<' st80Primitive '>' #EOF |
|
883 | 4222 |
| '<' st80Primitive '>' methodBodyVarSpec statementList #EOF |
19 | 4223 |
|
4224 |
" |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4225 |
|stats| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4226 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4227 |
stats := self parseMethodBodyOrEmpty. |
19 | 4228 |
(stats == #Error) ifFalse:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4229 |
self checkForEndOfInput. |
19 | 4230 |
]. |
1160 | 4231 |
ignoreWarnings ifFalse:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4232 |
self checkUnusedMethodVars. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4233 |
self checkReturnedValues. |
1160 | 4234 |
]. |
19 | 4235 |
^ stats |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
4236 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4237 |
"Modified: / 17.11.2001 / 10:31:12 / cg" |
19 | 4238 |
! |
4239 |
||
79 | 4240 |
parseMethodBodyOrEmpty |
0 | 4241 |
"parse a methods body (locals & statements); |
19 | 4242 |
return a node-tree, nil or #Error. |
4243 |
empty (or comment only) input is accepted and returns nil. |
|
4244 |
||
4245 |
methodBodyOrNil ::= '<' st80Primitive '>' |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4246 |
| '<' st80Primitive '>' methodBodyVarSpec statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4247 |
| <empty> |
19 | 4248 |
" |
0 | 4249 |
|
265 | 4250 |
|stats| |
0 | 4251 |
|
4252 |
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error]. |
|
4253 |
||
4254 |
(tokenType ~~ #EOF) ifTrue:[ |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4255 |
stats := self statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4256 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4257 |
"/ (tokenType ~~ #EOF) ifTrue:[ |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4258 |
"/ self parseError:'nothing more expected here' position:tokenPosition to:tokenPosition. |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4259 |
"/ ^ #Error |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4260 |
"/ ]. |
1231 | 4261 |
(stats notNil |
4262 |
and:[stats ~~ #Error]) ifTrue:[ |
|
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
4263 |
(self isStatementAnUnconditionalReturn:stats last) ifFalse:[ |
1231 | 4264 |
"/ remember a returned self here. |
1262 | 4265 |
self rememberReturnedValue:(self selfNode) |
1231 | 4266 |
]. |
4267 |
]. |
|
1551 | 4268 |
tree notNil ifTrue:[ |
4269 |
tree last nextStatement:stats. |
|
4270 |
^ tree. |
|
4271 |
]. |
|
0 | 4272 |
^ stats |
265 | 4273 |
|
4274 |
"Modified: 27.4.1996 / 16:57:56 / cg" |
|
0 | 4275 |
! |
4276 |
||
19 | 4277 |
parseMethodBodyVarSpec |
265 | 4278 |
"parse a methods local variable specification, handling |
4279 |
possible primitive or resourceSpecs. |
|
4280 |
. |
|
19 | 4281 |
Leave spec of locals in methodLocals as a side effect. |
4282 |
Return #Error or nil. |
|
0 | 4283 |
|
19 | 4284 |
methodBodyVarSpec ::= '|' { IDENTIFIER } '|' |
663 | 4285 |
| <empty> |
19 | 4286 |
" |
0 | 4287 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4288 |
|var pos pos2 msg classHint| |
0 | 4289 |
|
265 | 4290 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
663 | 4291 |
self parsePrimitiveOrResourceSpecOrEmpty. |
265 | 4292 |
]. |
4293 |
||
0 | 4294 |
(tokenType == $|) ifTrue:[ |
663 | 4295 |
"memorize position for declaration in correction" |
883 | 4296 |
|
1638 | 4297 |
localVarDefPosition := Array with:tokenPosition with:nil. |
663 | 4298 |
self nextToken. |
4299 |
pos := tokenPosition. |
|
4300 |
[tokenType == #Identifier] whileTrue:[ |
|
883 | 4301 |
pos2 := tokenPosition + tokenName size - 1. |
4302 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4303 |
self checkMethodVariableNameConventionsFor:tokenName. |
663 | 4304 |
var := Variable name:tokenName. |
883 | 4305 |
|
663 | 4306 |
methodVars isNil ifTrue:[ |
4307 |
methodVars := OrderedCollection with:var. |
|
4308 |
methodVarNames := OrderedCollection with:tokenName |
|
4309 |
] ifFalse:[ |
|
4310 |
(methodVarNames includes:tokenName) ifTrue:[ |
|
883 | 4311 |
"/ redefinition |
4312 |
self isSyntaxHighlighter ifTrue:[ |
|
4313 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
4314 |
] ifFalse:[ |
|
4315 |
self |
|
1638 | 4316 |
parseError:'redefinition of ''' , tokenName , ''' in local variables.' |
883 | 4317 |
position:tokenPosition to:pos2. |
4318 |
] |
|
663 | 4319 |
] ifFalse:[ |
4320 |
methodVars add:var. |
|
4321 |
methodVarNames add:tokenName |
|
4322 |
] |
|
4323 |
]. |
|
883 | 4324 |
|
1638 | 4325 |
parserFlags warnHiddenVariables ifTrue:[ |
4326 |
methodArgNames notNil ifTrue:[ |
|
4327 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
4328 |
self |
|
4329 |
warning:'local variable "' , tokenName allBold , '" hides method argument.' |
|
4330 |
position:tokenPosition to:pos2 |
|
4331 |
] |
|
4332 |
]. |
|
4333 |
classToCompileFor notNil ifTrue:[ |
|
4334 |
(self classesInstVarNames includes:tokenName) ifTrue:[ |
|
4335 |
self |
|
4336 |
warning:'local variable "' , tokenName allBold , '" hides instance variable.' |
|
4337 |
position:tokenPosition to:pos2 |
|
4338 |
] |
|
4339 |
]. |
|
663 | 4340 |
]. |
1638 | 4341 |
|
663 | 4342 |
self nextToken. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4343 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4344 |
classHint := nil. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4345 |
lastDirective notNil ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4346 |
lastDirective isClassHintDirective ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4347 |
var classHint:lastDirective className. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4348 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4349 |
lastDirective := nil. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4350 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4351 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4352 |
parserFlags allowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
1471 | 4353 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
4354 |
self nextToken. |
|
4355 |
"/ Q: should we allow literals only, or arbitrary expressions ? |
|
4356 |
self halt:'unimplemented feature'. |
|
4357 |
] |
|
4358 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4359 |
parserFlags allowDomainVariables == true ifTrue:[ |
1471 | 4360 |
(tokenType == $() ifTrue:[ |
4361 |
self variableTypeDeclarationFor:var. |
|
4362 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4363 |
]. |
663 | 4364 |
pos := tokenPosition |
4365 |
]. |
|
883 | 4366 |
|
663 | 4367 |
(tokenType ~~ $|) ifTrue:[ |
4368 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
1638 | 4369 |
msg := 'reserved keyword "',tokenName allBold,'" in local var declaration'. |
883 | 4370 |
pos2 := tokenPosition + tokenName size - 1. |
4371 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
663 | 4372 |
] ifFalse:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4373 |
pos2 := source position1Based-1. |
663 | 4374 |
msg := 'Identifier or | expected in local var declaration' |
4375 |
]. |
|
883 | 4376 |
self syntaxError:msg position:tokenPosition to:pos2. |
663 | 4377 |
^ #Error |
4378 |
]. |
|
1638 | 4379 |
localVarDefPosition at:2 put:tokenPosition. |
663 | 4380 |
self nextToken |
0 | 4381 |
]. |
984 | 4382 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4383 |
parserFlags allowSqueakExtensions ifTrue:[ |
984 | 4384 |
"/ allow for primitiveSpec after local-var decl. |
4385 |
||
4386 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
|
4387 |
self parsePrimitiveOrResourceSpecOrEmpty. |
|
4388 |
] |
|
4389 |
]. |
|
4390 |
||
0 | 4391 |
^ nil |
139
65eaf1a009f5
warn if method local hides method arg
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
4392 |
|
663 | 4393 |
"Modified: / 31.3.1998 / 17:30:33 / cg" |
0 | 4394 |
! |
4395 |
||
141 | 4396 |
parseMethodSpec |
4397 |
"parse a methods selector & arg specification; |
|
4398 |
Set selector and methodArgs in the receiver as a side effect. |
|
4399 |
Return the receiver or #Error. |
|
4400 |
||
4401 |
methodSpec ::= { KEYWORD IDENTIFIER } |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4402 |
| binaryOperator IDENTIFIER |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4403 |
| IDENTIFIER |
141 | 4404 |
" |
4405 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4406 |
|arg pos2| |
141 | 4407 |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4408 |
tokenType isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4409 |
self nextToken. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4410 |
]. |
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4411 |
|
141 | 4412 |
(tokenType == #Keyword) ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4413 |
selector := ''. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4414 |
[tokenType == #Keyword] whileTrue:[ |
663 | 4415 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4416 |
selector := selector , tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4417 |
self nextToken. |
883 | 4418 |
|
1259 | 4419 |
(tokenType ~~ #Identifier) ifTrue:[ |
4420 |
"/ ^ #Error]. |
|
4421 |
^ self identifierExpectedIn:'method-arg declaration' |
|
4422 |
]. |
|
4423 |
||
883 | 4424 |
pos2 := tokenPosition+tokenName size-1. |
4425 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4426 |
self checkMethodArgumentNameConventionsFor:tokenName. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4427 |
arg := Variable name:tokenName. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4428 |
methodArgs isNil ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4429 |
methodArgs := Array with:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4430 |
methodArgNames := Array with:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4431 |
] ifFalse:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4432 |
(methodArgNames includes:tokenName) ifTrue:[ |
1259 | 4433 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4434 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4435 |
methodArgs := methodArgs copyWith:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4436 |
methodArgNames := methodArgNames copyWith:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4437 |
]. |
1638 | 4438 |
parserFlags warnHiddenVariables ifTrue:[ |
1642
751a220b67be
ChangesBrowser: compress changes didn't work if there were changes
Stefan Vogel <sv@exept.de>
parents:
1640
diff
changeset
|
4439 |
classToCompileFor isBehavior ifTrue:[ |
1638 | 4440 |
(self classesInstVarNames includes:tokenName) ifTrue:[ |
4441 |
self |
|
4442 |
warning:'argument "' , tokenName allBold , '" hides instance variable.' |
|
4443 |
position:tokenPosition to:pos2 |
|
4444 |
] |
|
4445 |
]. |
|
4446 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4447 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4448 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4449 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4450 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4451 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4452 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4453 |
selector := selector asSymbol. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4454 |
endOfSelectorPosition := pos2. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4455 |
beginOfBodyPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4456 |
^ self |
141 | 4457 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4458 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4459 |
(self isValidUnarySelector:tokenType) ifTrue:[ |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4460 |
pos2 := tokenPosition+tokenName size-1. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4461 |
self markMethodSelectorFrom:tokenPosition to:pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4462 |
selector := tokenName asSymbol. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4463 |
endOfSelectorPosition := pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4464 |
self nextToken. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4465 |
beginOfBodyPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4466 |
^ self |
141 | 4467 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4468 |
|
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4469 |
"/ special handling for |, which is also a lexical token |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4470 |
tokenType == $| ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4471 |
tokenType := #BinaryOperator. |
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4472 |
token := tokenName := '|' |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4473 |
]. |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4474 |
|
141 | 4475 |
(tokenType == #BinaryOperator) ifTrue:[ |
663 | 4476 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4477 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4478 |
self nextToken. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4479 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4480 |
pos2 := tokenPosition+tokenName size-1. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4481 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
1519 | 4482 |
self checkMethodArgumentNameConventionsFor:tokenName. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4483 |
arg := Variable name:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4484 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4485 |
methodArgs := Array with:arg. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4486 |
methodArgNames := Array with:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4487 |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4488 |
endOfSelectorPosition := pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4489 |
self nextToken. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4490 |
beginOfBodyPosition := tokenPosition. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4491 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4492 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4493 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4494 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4495 |
^ self |
141 | 4496 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4497 |
|
1259 | 4498 |
^ self parseExtendedMethodSpec |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4499 |
|
663 | 4500 |
"Modified: / 31.3.1998 / 17:31:59 / cg" |
141 | 4501 |
! |
4502 |
||
713 | 4503 |
statement |
4504 |
"parse a statement; return a node-tree or #Error. |
|
4505 |
||
4506 |
statement ::= '^' expression |
|
4507 |
| PRIMITIVECODE |
|
4508 |
| expression |
|
4509 |
" |
|
4510 |
||
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4511 |
|expr node lnr code| |
713 | 4512 |
|
4513 |
(tokenType == $^) ifTrue:[ |
|
837 | 4514 |
self markReturnAt:tokenPosition. |
713 | 4515 |
lnr := tokenLineNr. |
4516 |
self nextToken. |
|
4517 |
expr := self expression. |
|
4518 |
(expr == #Error) ifTrue:[^ #Error]. |
|
4519 |
node := ReturnNode expression:expr. |
|
4520 |
node home:self blockHome:currentBlock. |
|
4521 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4522 |
|
1231 | 4523 |
self rememberReturnedValue:expr. |
713 | 4524 |
^ node |
4525 |
]. |
|
4526 |
||
4527 |
(tokenType == #Primitive) ifTrue:[ |
|
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4528 |
code := tokenValue. |
713 | 4529 |
self nextToken. |
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4530 |
node := PrimitiveNode code:code. |
713 | 4531 |
node isOptional ifFalse:[ |
4532 |
hasNonOptionalPrimitiveCode := true |
|
4533 |
]. |
|
4534 |
hasPrimitiveCode := true. |
|
4535 |
^ node |
|
4536 |
]. |
|
4537 |
||
4538 |
(tokenType == #EOF) ifTrue:[ |
|
733
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4539 |
currentBlock notNil ifTrue:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4540 |
self syntaxError:'missing '']'' at end of block'. |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4541 |
] ifFalse:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4542 |
self syntaxError:'period after last statement'. |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4543 |
]. |
713 | 4544 |
^ #Error |
4545 |
]. |
|
4546 |
||
984 | 4547 |
(tokenType == $.) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4548 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
984 | 4549 |
"/ allow empty statement |
4550 |
^ StatementNode expression:nil. |
|
4551 |
]. |
|
4552 |
]. |
|
4553 |
||
713 | 4554 |
expr := self expression. |
4555 |
(expr == #Error) ifTrue:[^ #Error]. |
|
4556 |
||
4557 |
"/ classToCompileFor notNil ifTrue:[ |
|
4558 |
"/ currentBlock isNil ifTrue:[ |
|
4559 |
"/ expr isPrimary ifTrue:[ |
|
4560 |
"/ self warning:'useless computation - missing ^ ?' |
|
4561 |
"/ ] |
|
4562 |
"/ ] |
|
4563 |
"/ ]. |
|
4564 |
||
4565 |
node := StatementNode expression:expr. |
|
4566 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
4567 |
^ node |
|
4568 |
||
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4569 |
"Modified: / 17.11.2001 / 10:22:33 / cg" |
713 | 4570 |
! |
4571 |
||
4572 |
statementList |
|
4573 |
"parse a statementlist; return a node-tree, nil or #Error. |
|
4574 |
Statements must be separated by periods. |
|
4575 |
||
4576 |
statementList ::= <statement> |
|
988 | 4577 |
| <statementList> . <statement> |
713 | 4578 |
" |
4579 |
||
4580 |
|thisStatement prevStatement firstStatement correctIt periodPos |
|
4581 |
prevExpr| |
|
4582 |
||
4583 |
thisStatement := self statement. |
|
4584 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4585 |
firstStatement := thisStatement. |
|
4586 |
[tokenType == $.] whileTrue:[ |
|
988 | 4587 |
prevExpr := thisStatement expression. |
4588 |
(prevExpr notNil |
|
4589 |
and:[prevExpr isMessage |
|
4590 |
and:[thisStatement isReturnNode not]]) ifTrue:[ |
|
4591 |
(#(#'=' #'==') includes:prevExpr selector) ifTrue:[ |
|
1487 | 4592 |
self warning:'useless computation - mistyped assignment (i.e. did you mean '':='') ?' position:prevExpr selectorPosition |
988 | 4593 |
]. |
4594 |
]. |
|
4595 |
||
4596 |
periodPos := tokenPosition. |
|
4597 |
self nextToken. |
|
4598 |
(tokenType == $]) ifTrue:[ |
|
4599 |
currentBlock isNil ifTrue:[ |
|
4600 |
self parseError:'block nesting error'. |
|
713 | 4601 |
" |
988 | 4602 |
*** I had a warning here (since it was not defined |
4603 |
*** in the blue-book; but PD-code contains a lot of |
|
4604 |
*** code with periods at the end so that the warnings |
|
4605 |
*** became annoying |
|
4606 |
||
4607 |
] ifFalse:[ |
|
4608 |
self warning:'period after last statement' position:periodPos |
|
713 | 4609 |
" |
988 | 4610 |
]. |
4611 |
^ firstStatement |
|
4612 |
]. |
|
4613 |
(tokenType == #EOF) ifTrue:[ |
|
4614 |
currentBlock notNil ifTrue:[ |
|
4615 |
self parseError:'block nesting error (expected '']'')'. |
|
713 | 4616 |
" |
988 | 4617 |
*** I had a warning here (since it was not defined |
4618 |
*** in the blue-book; but PD-code contains a lot of |
|
4619 |
*** code with periods at the end so that the warnings |
|
4620 |
*** became annoying |
|
4621 |
||
4622 |
] ifFalse:[ |
|
4623 |
self warning:'period after last statement' position:periodPos |
|
713 | 4624 |
" |
988 | 4625 |
]. |
4626 |
^ firstStatement |
|
4627 |
]. |
|
4628 |
||
4629 |
prevStatement := thisStatement. |
|
4630 |
prevStatement isReturnNode ifTrue:[ |
|
4631 |
self warning:'statements after return' position:tokenPosition |
|
4632 |
]. |
|
713 | 4633 |
" |
988 | 4634 |
periodPos := tokenPosition. |
4635 |
self nextToken. |
|
713 | 4636 |
" |
4637 |
||
988 | 4638 |
((tokenType == $]) or:[tokenType == #EOF]) ifTrue:[ |
4639 |
(currentBlock isNil and:[tokenType == $]]) ifTrue:[ |
|
4640 |
self parseError:'block nesting error'. |
|
4641 |
] ifFalse:[ |
|
4642 |
correctIt := self correctableError:'period after last statement in block' |
|
4643 |
position:periodPos to:(periodPos + 1). |
|
4644 |
correctIt ifTrue:[ |
|
4645 |
(self correctByDeleting == #Error) ifTrue:[ |
|
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4646 |
self errorFlag:true |
988 | 4647 |
] |
4648 |
] |
|
4649 |
]. |
|
4650 |
^ firstStatement |
|
4651 |
]. |
|
4652 |
thisStatement := self statement. |
|
4653 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4654 |
prevStatement nextStatement:thisStatement |
|
713 | 4655 |
]. |
4656 |
^ firstStatement |
|
4657 |
||
4658 |
"Modified: 14.4.1997 / 20:46:46 / cg" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4659 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4660 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4661 |
variableTypeDeclarationFor:aVariable |
1471 | 4662 |
"experimental support for Domain variables (constraint programming support): |
4663 |
a variable-declaration of the form |
|
4664 |
|var (domain) ... | |
|
4665 |
declares var as a domainVariable. |
|
4666 |
Valid domains are: |
|
4667 |
min %% max - integer range domain |
|
4668 |
Bool - boolean domain |
|
4669 |
Nat - positive integer domain |
|
4670 |
Int - integer domain |
|
4671 |
#sym1 ... #sym2 - enumerated symbolic domain |
|
4672 |
" |
|
4673 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4674 |
|min max domain enumValues| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4675 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4676 |
(tokenType == $() ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4677 |
self syntaxError:'''('' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4678 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4679 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4680 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4681 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4682 |
(tokenType == #Integer) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4683 |
min := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4684 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4685 |
((tokenType == #BinaryOperator) and:[token = '%%']) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4686 |
self syntaxError:'''%%'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4687 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4688 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4689 |
(tokenType == #Integer) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4690 |
self syntaxError:'Integer (upper bound) expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4691 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4692 |
max := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4693 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4694 |
domain := IntegerDomain min:min max:max. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4695 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4696 |
((tokenType == #Identifier) and:[token first isUppercase]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4697 |
token = 'Bool' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4698 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4699 |
domain := BooleanDomain new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4700 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4701 |
token = 'Nat' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4702 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4703 |
domain := IntegerDomain min:0 max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4704 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4705 |
token = 'Int' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4706 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4707 |
domain := IntegerDomain min:(SmallInteger minVal) max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4708 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4709 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4710 |
((tokenType == #Symbol) or:[(tokenType == #Identifier)]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4711 |
enumValues := OrderedCollection new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4712 |
[((tokenType == #Symbol) or:[(tokenType == #Identifier)])] whileTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4713 |
enumValues add:token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4714 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4715 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4716 |
domain := EnumeratedDomain new values:enumValues. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4717 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4718 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4719 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4720 |
domain isNil ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4721 |
self syntaxError:'invalid domain' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4722 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4723 |
aVariable domain:domain. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4724 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4725 |
(tokenType == $)) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4726 |
self syntaxError:''')'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4727 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4728 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4729 |
self nextToken. |
713 | 4730 |
! ! |
4731 |
||
4732 |
!Parser methodsFor:'parsing-expressions'! |
|
4733 |
||
4734 |
array |
|
4735 |
|arr elements elem pos1| |
|
4736 |
||
4737 |
pos1 := tokenPosition. |
|
4738 |
elements := OrderedCollection new:20. |
|
4739 |
[tokenType ~~ $) ] whileTrue:[ |
|
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4740 |
elem := self arrayConstant. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4741 |
|
1062 | 4742 |
"/ (elem == #Error) ifTrue:[ |
4743 |
"/ (tokenType == #EOF) ifTrue:[ |
|
4744 |
"/ self syntaxError:'unterminated array-constant; '')'' expected' |
|
4745 |
"/ position:pos1 to:tokenPosition |
|
4746 |
"/ ]. |
|
4747 |
"/ ^ #Error |
|
4748 |
"/ ]. |
|
713 | 4749 |
elem isSymbol ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4750 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
713 | 4751 |
]. |
4752 |
elements add:elem. |
|
4753 |
self nextToken |
|
4754 |
]. |
|
4755 |
arr := Array withAll:elements. |
|
4756 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4757 |
parserFlags arraysAreImmutable ifTrue:[ |
1615 | 4758 |
^ self makeImmutableArray:arr |
713 | 4759 |
]. |
4760 |
^ arr |
|
4761 |
||
4762 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
4763 |
! |
|
4764 |
||
4765 |
arrayConstant |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4766 |
|val| |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4767 |
|
713 | 4768 |
(tokenType == #Nil) ifTrue:[ |
4769 |
^ nil |
|
4770 |
]. |
|
4771 |
((tokenType == #Integer) |
|
4772 |
or:[tokenType == #Float]) ifTrue:[ |
|
4773 |
^ tokenValue |
|
4774 |
]. |
|
1615 | 4775 |
(tokenType == #String) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4776 |
parserFlags stringsAreImmutable ifTrue:[^ self makeImmutableString:tokenValue]. |
1615 | 4777 |
^ tokenValue |
4778 |
]. |
|
4779 |
(tokenType == #Character) ifTrue:[ |
|
713 | 4780 |
^ tokenValue |
4781 |
]. |
|
4782 |
(tokenType == #True) ifTrue:[ |
|
4783 |
^ true |
|
4784 |
]. |
|
4785 |
(tokenType == #False) ifTrue:[ |
|
4786 |
^ false |
|
4787 |
]. |
|
4788 |
(tokenType == #Error) ifTrue:[ |
|
1062 | 4789 |
^ ParseErrorSignal raise. |
713 | 4790 |
]. |
4791 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
1604
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4792 |
val := tokenName asSymbol. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4793 |
parseForCode ifFalse:[ |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4794 |
self rememberSymbolUsed:val. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4795 |
]. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4796 |
^ val |
713 | 4797 |
]. |
4798 |
||
4799 |
"/ some more special symbol consts ... |
|
4800 |
(tokenType == $| ) ifTrue:[ |
|
4801 |
^ #| |
|
4802 |
]. |
|
4803 |
(tokenType == #Self ) ifTrue:[ |
|
4804 |
^ #'self' |
|
4805 |
]. |
|
4806 |
(tokenType == #Super ) ifTrue:[ |
|
4807 |
^ #'super' |
|
4808 |
]. |
|
4809 |
(tokenType == #Here ) ifTrue:[ |
|
4810 |
^ #'here' |
|
4811 |
]. |
|
4812 |
(tokenType == #ThisContext ) ifTrue:[ |
|
4813 |
^ #'thisContext' |
|
4814 |
]. |
|
4815 |
||
4816 |
((tokenType == #Keyword) |
|
4817 |
or:[tokenType == #Identifier]) ifTrue:[ |
|
1604
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4818 |
val := tokenName asSymbol. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4819 |
parseForCode ifFalse:[ |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4820 |
self rememberSymbolUsed:val. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4821 |
]. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4822 |
^ val |
713 | 4823 |
]. |
4824 |
((tokenType == $() |
|
4825 |
or:[tokenType == #HashLeftParen]) ifTrue:[ |
|
4826 |
self nextToken. |
|
4827 |
^ self array |
|
4828 |
]. |
|
4829 |
((tokenType == $[) |
|
4830 |
or:[tokenType == #HashLeftBrack]) ifTrue:[ |
|
4831 |
self nextToken. |
|
4832 |
^ self byteArray |
|
4833 |
]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4834 |
(tokenType == #HashLeftBrace) ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4835 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4836 |
val := QualifiedName for:val name. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4837 |
^ val |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4838 |
]. |
713 | 4839 |
(tokenType == #Symbol) ifTrue:[ |
1066
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4840 |
parseForCode ifFalse:[ |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4841 |
self rememberSymbolUsed:tokenValue. |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4842 |
]. |
713 | 4843 |
^ tokenValue |
4844 |
]. |
|
4845 |
(tokenType == #EOF) ifTrue:[ |
|
4846 |
"just for the better error-hilight; let caller handle error" |
|
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4847 |
self syntaxError:'error in array-constant; EOF unexpected'. |
1062 | 4848 |
^ ParseErrorSignal raise. |
713 | 4849 |
]. |
4850 |
self syntaxError:('error in array-constant; ' |
|
4851 |
, tokenType printString |
|
4852 |
, ' unexpected'). |
|
1062 | 4853 |
^ ParseErrorSignal raise. |
713 | 4854 |
|
4855 |
"Modified: / 14.4.1998 / 18:22:54 / cg" |
|
4856 |
! |
|
4857 |
||
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4858 |
arrayIndexingExpression |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4859 |
"parse an array index expression; this is a squeak/stx extension. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4860 |
foo[idx] is syntactic sugar for foo matrixAt:x |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4861 |
and foo[idx] := expr is syntactic sugar for foo matrixAt:x put:expr" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4862 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4863 |
|receiver argList selectorStream valNode| |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4864 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4865 |
receiver := self functionCallExpression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4866 |
tokenType == $[ ifFalse:[^ receiver]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4867 |
parserFlags allowArrayIndexSyntaxExtension == true ifFalse:[^ receiver.]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4868 |
(receiver == #Error) ifTrue:[^ #Error]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4869 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4870 |
selectorStream := WriteStream on: (String new: 32). |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4871 |
argList := OrderedCollection new. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4872 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4873 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4874 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4875 |
|indexNode| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4876 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4877 |
self nextToken. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4878 |
indexNode := self primary. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4879 |
argList isEmpty ifTrue:[selectorStream nextPutAll:'_']. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4880 |
selectorStream nextPutAll:'at:'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4881 |
argList add: indexNode. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4882 |
(tokenType == #BinaryOperator ) and:[ token = ','] |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4883 |
] whileTrue. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4884 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4885 |
tokenType == $] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4886 |
self parseError:''']'' expected'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4887 |
^ #Error |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4888 |
]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4889 |
self nextToken. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4890 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4891 |
tokenType == $[ ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4892 |
receiver := MessageNode |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4893 |
receiver:receiver |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4894 |
selector:(selectorStream contents) |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4895 |
args:argList. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4896 |
selectorStream := WriteStream on: (String new: 32). |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4897 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4898 |
tokenType == $[ |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4899 |
] whileTrue. |
1411 | 4900 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4901 |
tokenType == #':=' ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4902 |
self nextToken. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4903 |
selectorStream nextPutAll:'put:'. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4904 |
valNode := self expression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4905 |
valNode == #Error ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4906 |
^ valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4907 |
]. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4908 |
"/ this was found in squeak - why make it a block ? |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4909 |
"/ (valNode isKindOf: BlockNode) ifFalse:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4910 |
"/ valNode _ BlockNode new |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4911 |
"/ arguments: #() |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4912 |
"/ statements: (OrderedCollection with: valNode) |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4913 |
"/ returns: false |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4914 |
"/ from: encoder. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4915 |
"/ ]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4916 |
argList add: valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4917 |
]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4918 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4919 |
^ MessageNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4920 |
receiver:receiver |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4921 |
selector:selectorStream contents |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4922 |
args:argList. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4923 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4924 |
" |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4925 |
AllowArrayIndexSyntaxExtension := true. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4926 |
AllowArrayIndexSyntaxExtension := false. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4927 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4928 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4929 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4930 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4931 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4932 |
foo := Array new:10 withAll:2. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4933 |
1 + foo[1]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4934 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4935 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4936 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4937 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4938 |
foo := Array new:10. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4939 |
foo[1] := 'hello'. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4940 |
foo[2]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4941 |
foo[1]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4942 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4943 |
! |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4944 |
|
713 | 4945 |
binaryExpression |
4946 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
4947 |
||
1328 | 4948 |
|receiver| |
713 | 4949 |
|
4950 |
receiver := self unaryExpression. |
|
4951 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 4952 |
^ self binaryExpressionFor:receiver |
4953 |
! |
|
4954 |
||
4955 |
binaryExpressionFor:receiverArg |
|
4956 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
4957 |
||
1547 | 4958 |
|receiver expr arg sel pos1 pos2 lno note| |
1328 | 4959 |
|
4960 |
receiver := receiverArg. |
|
4961 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
713 | 4962 |
|
4963 |
"special kludge: since Scanner cannot know if -digit is a binary |
|
4964 |
expression or a negative constant, handle cases here" |
|
4965 |
||
4966 |
[(tokenType == #BinaryOperator) |
|
4967 |
or:[(tokenType == $|) |
|
4968 |
or:[((tokenType == #Integer) or:[tokenType == #Float]) |
|
4969 |
and:[tokenValue < 0]]] |
|
4970 |
] whileTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4971 |
"/ kludge alarm: in a function-call argList, #, is not a binarySelector |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4972 |
inFunctionCallArgument == true ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4973 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4974 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4975 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4976 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4977 |
|
1547 | 4978 |
pos1 := tokenPosition. |
713 | 4979 |
lno := tokenLineNr. |
4980 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4981 |
"/ kludge alarm: bar and minus are not scanned as binop |
713 | 4982 |
(tokenType == $|) ifTrue:[ |
4983 |
sel := '|'. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4984 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:tokenPosition. |
713 | 4985 |
self nextToken |
4986 |
] ifFalse:[ |
|
4987 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4988 |
sel := tokenName. |
1022 | 4989 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:(tokenPosition + tokenName size - 1). |
713 | 4990 |
self nextToken |
4991 |
] ifFalse:[ |
|
4992 |
sel := '-'. |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4993 |
token := tokenValue := tokenValue negated |
713 | 4994 |
] |
4995 |
]. |
|
1547 | 4996 |
|
4997 |
pos2 := pos1 + sel size - 1. |
|
4998 |
self markSelector:sel from:pos1 to:pos2 receiverNode:receiver. |
|
713 | 4999 |
|
5000 |
arg := self unaryExpression. |
|
5001 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5002 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5003 |
expr := BinaryNode receiver:receiver selector:sel arg:arg fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5004 |
expr isErrorNode ifTrue:[ |
1547 | 5005 |
self parseError:(expr errorString) position:pos1 to:tokenPosition. |
713 | 5006 |
errorFlag := false. "ok, user wants it - so he'll get it" |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5007 |
expr := BinaryNode receiver:receiver selector:sel arg:arg fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5008 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5009 |
note := self plausibilityCheck:expr. |
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
5010 |
note notNil ifTrue:[ |
1547 | 5011 |
self warning:note position:pos1 to:pos2 |
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
5012 |
]. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5013 |
expr lineNumber:lno. |
1547 | 5014 |
expr selectorPosition:pos1. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5015 |
parseForCode ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5016 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5017 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5018 |
receiver := expr. "/ for next message |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5019 |
|
713 | 5020 |
]. |
5021 |
^ receiver |
|
5022 |
||
5023 |
"Modified: / 9.1.1998 / 19:05:18 / stefan" |
|
1022 | 5024 |
"Modified: / 19.1.2000 / 16:22:04 / cg" |
713 | 5025 |
! |
5026 |
||
5027 |
byteArray |
|
5028 |
"started with ST-80 R4 - allow byteArray constants as #[ ... ]" |
|
5029 |
||
5030 |
|bytes index limit newArray elem pos1 pos2| |
|
5031 |
||
5032 |
pos1 := tokenPosition. |
|
5033 |
bytes := ByteArray uninitializedNew:5000. |
|
5034 |
index := 0. limit := 5000. |
|
5035 |
[tokenType ~~ $] ] whileTrue:[ |
|
1576 | 5036 |
pos2 := tokenPosition. |
5037 |
" |
|
5038 |
this is not good programming style, but speeds up |
|
5039 |
reading of huge byte arrays (i.e. stored Images ...) |
|
5040 |
" |
|
5041 |
(tokenType == #Integer) ifTrue:[ |
|
5042 |
elem := tokenValue |
|
5043 |
] ifFalse:[ |
|
5044 |
elem := self arrayConstant. |
|
5045 |
(elem == #Error) ifTrue:[ |
|
5046 |
(tokenType == #EOF) ifTrue:[ |
|
5047 |
self syntaxError:'unterminated bytearray-constant; '']'' expected' |
|
5048 |
position:pos1 to:tokenPosition |
|
5049 |
]. |
|
5050 |
^ #Error |
|
5051 |
]. |
|
5052 |
]. |
|
5053 |
((elem isMemberOf:SmallInteger) and:[elem between:0 and:255]) ifTrue:[ |
|
5054 |
index := index + 1. |
|
5055 |
bytes at:index put:elem. |
|
5056 |
index == limit ifTrue:[ |
|
5057 |
newArray := ByteArray uninitializedNew:(limit * 2). |
|
5058 |
newArray replaceFrom:1 to:limit with:bytes startingAt:1. |
|
5059 |
limit := limit * 2. |
|
5060 |
bytes := newArray |
|
5061 |
]. |
|
5062 |
] ifFalse:[ |
|
5063 |
self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1 |
|
5064 |
]. |
|
5065 |
self nextToken. |
|
713 | 5066 |
]. |
5067 |
newArray := ByteArray uninitializedNew:index. |
|
5068 |
newArray replaceFrom:1 to:index with:bytes startingAt:1. |
|
5069 |
^ newArray |
|
5070 |
! |
|
5071 |
||
5072 |
degeneratedKeywordExpressionForSelector |
|
1406 | 5073 |
"parse a keyword-expression without receiver - for the selector only. |
5074 |
Return the selector or nil (if it cannot be determined). |
|
5075 |
This is not used in normal parsing, but instead to extract the selector from a code fragment. |
|
5076 |
(for example, the system browsers 'implementors'-function uses this to extract a selector from |
|
5077 |
the selection)" |
|
713 | 5078 |
|
5079 |
|sel arg rec| |
|
5080 |
||
5081 |
(tokenType == #Keyword) ifTrue:[ |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5082 |
sel := tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5083 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5084 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5085 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5086 |
[tokenType == #Keyword] whileTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5087 |
sel := sel , tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5088 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5089 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5090 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5091 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5092 |
^ sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5093 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5094 |
|
1406 | 5095 |
(rec := self arrayIndexingExpression) == #Error ifTrue:[ ^ nil]. |
5096 |
sel := self degeneratedKeywordExpressionForSelector. |
|
5097 |
sel notNil ifTrue:[ ^ sel]. |
|
5098 |
||
1407 | 5099 |
rec isAssignment ifTrue:[ |
5100 |
rec := rec expression |
|
5101 |
]. |
|
1406 | 5102 |
rec isMessage ifTrue:[ |
5103 |
^ rec selector |
|
5104 |
]. |
|
5105 |
^ nil |
|
1524 | 5106 |
|
5107 |
" |
|
5108 |
(self new source:'hello:world:') nextToken; degeneratedKeywordExpressionForSelector |
|
5109 |
(self new source:'hello:world') nextToken; degeneratedKeywordExpressionForSelector |
|
5110 |
(self new source:'hello:') nextToken; degeneratedKeywordExpressionForSelector |
|
5111 |
" |
|
713 | 5112 |
! |
5113 |
||
5114 |
expression |
|
5115 |
"parse a cascade-expression; return a node-tree, nil or #Error. |
|
5116 |
||
5117 |
expression ::= keywordExpression |
|
5118 |
| keywordExpression cascade |
|
5119 |
||
5120 |
cascade ::= ';' expressionSendPart |
|
5121 |
| cascade ';' expressionSendPart |
|
5122 |
||
5123 |
expressionSendPart ::= { KEYWORD binaryExpression } |
|
5124 |
| BINARYOPERATOR unaryExpression |
|
5125 |
| IDENTIFIER |
|
5126 |
" |
|
5127 |
||
864 | 5128 |
|receiver arg sel args pos pos2 lno tokenEnd realReceiver positions| |
713 | 5129 |
|
5130 |
pos := tokenPosition. |
|
5131 |
receiver := self keywordExpression. |
|
5132 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
5133 |
(tokenType == $;) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5134 |
receiver isMessage ifFalse:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5135 |
self syntaxError:'left side of cascade must be a message expression' |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5136 |
position:pos to:tokenPosition. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5137 |
realReceiver := receiver. "/ only to allow continuing. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5138 |
] ifTrue:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5139 |
realReceiver := receiver receiver. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5140 |
]. |
713 | 5141 |
[tokenType == $;] whileTrue:[ |
5142 |
self nextToken. |
|
5143 |
(tokenType == #Identifier) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5144 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5145 |
self markSelector:tokenName from:tokenPosition to:tokenEnd receiverNode:realReceiver. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5146 |
sel := tokenName. |
1022 | 5147 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 5148 |
receiver := CascadeNode receiver:receiver selector:sel. |
5149 |
receiver lineNumber:tokenLineNr. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5150 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5151 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5152 |
]. |
713 | 5153 |
self nextToken. |
5154 |
] ifFalse:[ |
|
5155 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5156 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5157 |
self markSelector:tokenName from:tokenPosition to:tokenEnd receiverNode:realReceiver. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
5158 |
sel := tokenName. |
1022 | 5159 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 5160 |
lno := tokenLineNr. |
5161 |
self nextToken. |
|
5162 |
arg := self unaryExpression. |
|
5163 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5164 |
receiver := CascadeNode receiver:receiver selector:sel arg:arg. |
|
5165 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5166 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5167 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5168 |
]. |
713 | 5169 |
] ifFalse:[ |
5170 |
(tokenType == #Keyword) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5171 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5172 |
positions := OrderedCollection with:(tokenPosition to:tokenEnd). |
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5173 |
pos := tokenPosition. |
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5174 |
pos2 := tokenEnd. |
713 | 5175 |
lno := tokenLineNr. |
5176 |
sel := tokenName. |
|
5177 |
self nextToken. |
|
5178 |
arg := self binaryExpression. |
|
5179 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5180 |
args := Array with:arg. |
|
5181 |
[tokenType == #Keyword] whileTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5182 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5183 |
positions add:(tokenPosition to:tokenEnd). |
713 | 5184 |
sel := sel , tokenName. |
5185 |
self nextToken. |
|
5186 |
arg := self binaryExpression. |
|
5187 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5188 |
args := args copyWith:arg. |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5189 |
pos2 := tokenEnd |
713 | 5190 |
]. |
864 | 5191 |
positions do:[:p | |
5192 |
self markSelector:sel from:p start to:p stop receiverNode:realReceiver. |
|
5193 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5194 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5195 |
sel := self selectorCheck:sel for:realReceiver position:pos to:pos2. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5196 |
|
713 | 5197 |
receiver := CascadeNode receiver:receiver selector:sel args:args. |
5198 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5199 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5200 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5201 |
]. |
713 | 5202 |
] ifFalse:[ |
5203 |
(tokenType == #Error) ifTrue:[^ #Error]. |
|
5204 |
self syntaxError:('invalid cascade; ' , tokenType printString , ' unexpected') |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5205 |
position:tokenPosition to:source position1Based - 1. |
713 | 5206 |
^ #Error |
5207 |
] |
|
5208 |
] |
|
5209 |
] |
|
5210 |
]. |
|
5211 |
||
5212 |
"obscure (unspecified ?) if selector follows; Question: |
|
5213 |
||
5214 |
is |
|
5215 |
'expr sel1; sel2 sel3' |
|
5216 |
||
5217 |
to be parsed as: |
|
5218 |
(t := expr. |
|
5219 |
t sel1. |
|
5220 |
t sel2) sel3 |
|
5221 |
||
5222 |
or: |
|
5223 |
(t := expr. |
|
5224 |
t sel1. |
|
5225 |
t sel2 sel3) |
|
5226 |
" |
|
5227 |
((tokenType == #Identifier) |
|
5228 |
or:[(tokenType == #BinaryOperator) |
|
5229 |
or:[tokenType == #Keyword]]) ifTrue:[ |
|
1328 | 5230 |
self syntaxError:'ambigous cascade - please group using (...)' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5231 |
position:tokenPosition to:source position1Based - 1. |
713 | 5232 |
^ #Error |
1328 | 5233 |
"/ self warning: "syntaxError:" 'possibly ambigous cascade - please group using (...)' |
5234 |
"/ position:tokenPosition to:source position - 1. |
|
5235 |
"/ tokenType == #Identifier ifTrue:[ |
|
5236 |
"/ ^ self unaryExpressionFor:receiver |
|
5237 |
"/ ]. |
|
5238 |
"/ tokenType == #BinaryOperator ifTrue:[ |
|
5239 |
"/ ^ self binaryExpressionFor:receiver |
|
5240 |
"/ ]. |
|
5241 |
"/ ^ self keywordExpressionFor:receiver |
|
713 | 5242 |
] |
5243 |
]. |
|
5244 |
^ receiver |
|
5245 |
||
1022 | 5246 |
"Modified: / 19.1.2000 / 16:22:16 / cg" |
713 | 5247 |
! |
5248 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5249 |
functionCallArgList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5250 |
|argList arg prevInFunctionCallArgument| |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5251 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5252 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5253 |
tokenType == $) ifTrue:[ self nextToken. ^ #() ]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5254 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5255 |
argList := OrderedCollection new. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5256 |
[ true ] whileTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5257 |
prevInFunctionCallArgument := inFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5258 |
inFunctionCallArgument := true. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5259 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5260 |
arg := self expression. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5261 |
argList add:arg. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5262 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5263 |
inFunctionCallArgument := prevInFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5264 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5265 |
tokenType == $) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5266 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5267 |
^ argList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5268 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5269 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5270 |
self parseError:'"," or ")" expected'. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5271 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5272 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5273 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5274 |
! |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5275 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5276 |
functionCallExpression |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5277 |
"parse a functionCall; |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5278 |
this is an st/x extension. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5279 |
foo(x) |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5280 |
is syntactic sugar for |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5281 |
foo value:x |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5282 |
" |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5283 |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5284 |
|receiver numArgs argList evalSelectors evalSelector| |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5285 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5286 |
receiver := self primary. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5287 |
tokenType == $( ifFalse:[^ receiver]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5288 |
parserFlags allowFunctionCallSyntaxForBlockEvaluation ifFalse:[^ receiver.]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5289 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5290 |
(receiver == #Error) ifTrue:[^ #Error]. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5291 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5292 |
receiver isVariable ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5293 |
((receiver isMessage or:[receiver isAssignment]) and:[receiver parenthized]) ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5294 |
receiver isBlock ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5295 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5296 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5297 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5298 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5299 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5300 |
argList := self functionCallArgList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5301 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5302 |
"/ make it a block evaluation |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5303 |
numArgs := argList size. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5304 |
numArgs == 0 ifTrue:[ |
1341 | 5305 |
^ UnaryNode receiver:receiver selector:#value |
5306 |
]. |
|
1579 | 5307 |
evalSelectors := #(#'value:' |
1341 | 5308 |
#'value:value:' |
5309 |
#'value:value:value:' |
|
5310 |
#'value:value:value:value:' |
|
5311 |
#'value:value:value:value:value:' |
|
5312 |
#'value:value:value:value:value:value:' |
|
5313 |
#'value:value:value:value:value:value:value:' |
|
5314 |
#'value:value:value:value:value:value:value:value:' |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5315 |
). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5316 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5317 |
numArgs <= evalSelectors size ifTrue:[ |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5318 |
evalSelector := evalSelectors at:numArgs. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5319 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5320 |
receiver:receiver |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5321 |
selector:evalSelector |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5322 |
args:argList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5323 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5324 |
"/ gen argument vector |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5325 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5326 |
receiver:receiver |
1341 | 5327 |
selector:#valueWithArguments: |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5328 |
args:(self genMakeArrayWith:argList). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5329 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5330 |
" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5331 |
Parser allowFunctionCallSyntaxForBlockEvaluation:true. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5332 |
" |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5333 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5334 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5335 |
|foo| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5336 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5337 |
foo := [:x | x + 1]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5338 |
1 + foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5339 |
foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5340 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5341 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5342 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5343 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5344 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5345 |
add1 := addN(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5346 |
add1(10). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5347 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5348 |
"AllowFunctionCallSyntaxForBlockEvaluation := false." |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5349 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5350 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5351 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5352 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5353 |
add1 := addN value:1. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5354 |
add1 value:10 |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5355 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5356 |
! |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5357 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5358 |
genMakeArrayWith:elementExpressions |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5359 |
"return a node to generate an array at runtime. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5360 |
Will generate: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5361 |
Array with:el1 ... with:elN (if N <= 5) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5362 |
or: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5363 |
(Array new at:1 put:el1; ... at:N put:elN; yourself) (otherwise) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5364 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5365 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5366 |
|numEl arrRec sel expr| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5367 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5368 |
arrRec := VariableNode globalNamed:#Array. |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5369 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5370 |
numEl := elementExpressions size. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5371 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5372 |
(numEl between:1 and:8) ifTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5373 |
sel := #( |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5374 |
#'with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5375 |
#'with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5376 |
#'with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5377 |
#'with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5378 |
#'with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5379 |
#'with:with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5380 |
#'with:with:with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5381 |
#'with:with:with:with:with:with:with:with:' |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5382 |
) at:numEl. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5383 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5384 |
^ MessageNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5385 |
receiver:arrRec |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5386 |
selector:sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5387 |
args:elementExpressions. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5388 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5389 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5390 |
"/ array creation expression ... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5391 |
expr := MessageNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5392 |
receiver:arrRec |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5393 |
selector:#new: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5394 |
arg:(ConstantNode type:#Integer value:numEl). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5395 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5396 |
numEl == 0 ifTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5397 |
^ expr. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5398 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5399 |
"/ followed by a bunch of #at:put: messages... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5400 |
elementExpressions keysAndValuesDo:[:idx :e | |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5401 |
expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5402 |
receiver:expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5403 |
selector:#at:put: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5404 |
arg1:(ConstantNode type:#Integer value:idx) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5405 |
arg2:e |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5406 |
fold:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5407 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5408 |
"/ followed by a #yourself: message... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5409 |
expr := CascadeNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5410 |
receiver:expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5411 |
selector:#yourself. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5412 |
^ expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5413 |
! |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5414 |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5415 |
isValidUnarySelector:tokenType |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5416 |
tokenType == #Identifier ifTrue:[^true]. |
1373 | 5417 |
tokenType == #Here ifTrue:[^true]. |
5418 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5419 |
parserFlags allowReservedWordsAsSelectors == true ifTrue:[ |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5420 |
tokenType == #Self ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5421 |
tokenType == #Nil ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5422 |
tokenType == #True ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5423 |
tokenType == #False ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5424 |
tokenType == #Super ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5425 |
tokenType == #ThisContext ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5426 |
]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5427 |
^ false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5428 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5429 |
" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5430 |
ParserFlags allowReservedWordsAsSelectors:true. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5431 |
1234 self. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5432 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5433 |
ParserFlags allowReservedWordsAsSelectors:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5434 |
1234 self. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5435 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5436 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5437 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5438 |
1234 self |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5439 |
1234 nil |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5440 |
1234 true |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5441 |
1234 false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5442 |
1234 here |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5443 |
1234 super |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5444 |
1234 thisContext |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5445 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5446 |
! |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5447 |
|
713 | 5448 |
keywordExpression |
5449 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5450 |
||
5451 |
keywordExpression ::= binaryexpression |
|
5452 |
| { KEYWORD-PART binaryExpression } |
|
5453 |
" |
|
5454 |
||
1328 | 5455 |
|receiver| |
5456 |
||
713 | 5457 |
receiver := self binaryExpression. |
5458 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 5459 |
^ self keywordExpressionFor:receiver |
5460 |
! |
|
5461 |
||
5462 |
keywordExpressionFor:receiverArg |
|
5463 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5464 |
||
5465 |
keywordExpression ::= binaryexpression |
|
5466 |
| { KEYWORD-PART binaryExpression } |
|
5467 |
" |
|
5468 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5469 |
|expr receiver sel arg args posR1 posR2 pos1 pos2 lno note positions| |
1328 | 5470 |
|
5471 |
receiver := receiverArg. |
|
5472 |
posR1 := tokenPosition. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5473 |
(tokenType == #Keyword) ifFalse:[^ receiver]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5474 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5475 |
pos1 := posR2 := tokenPosition. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5476 |
pos2 := tokenPosition + tokenName size - 1. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5477 |
positions := OrderedCollection with:(pos1 to:pos2). |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5478 |
sel := tokenName. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5479 |
lno := tokenLineNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5480 |
self nextToken. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5481 |
arg := self binaryExpression. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5482 |
(arg == #Error) ifTrue:[^ #Error]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5483 |
args := Array with:arg. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5484 |
[tokenType == #Keyword] whileTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5485 |
sel := sel , tokenName. |
713 | 5486 |
pos2 := tokenPosition + tokenName size - 1. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5487 |
positions add:(tokenPosition to:pos2). |
713 | 5488 |
self nextToken. |
5489 |
arg := self binaryExpression. |
|
5490 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5491 |
args := args copyWith:arg. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5492 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5493 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5494 |
positions do:[:p | |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5495 |
self markSelector:sel from:p start to:p stop receiverNode:receiver. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5496 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5497 |
sel := self selectorCheck:sel for:receiver positions:positions. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5498 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5499 |
ignoreErrors ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5500 |
(Class definitionSelectors includes:sel) ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5501 |
receiver isVariable ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5502 |
receiver isUndeclared ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5503 |
self parseError:('undefined superclass: ' , receiver name) position:pos1 to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5504 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5505 |
] |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5506 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5507 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5508 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5509 |
expr := MessageNode receiver:receiver selector:sel args:args fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5510 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5511 |
self parseError:(expr errorString) position:pos1 to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5512 |
errorFlag := false. "ok, user wants it - so he'll get it" |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5513 |
expr := MessageNode receiver:receiver selector:sel args:args fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5514 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5515 |
expr lineNumber:lno. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5516 |
note := self plausibilityCheck:expr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5517 |
note notNil ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5518 |
self warning:note position:pos1 to:pos2 |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5519 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5520 |
parseForCode ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5521 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5522 |
]. |
713 | 5523 |
|
1193 | 5524 |
"/ (contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
5525 |
"/ receiver isSuper ifTrue:[ |
|
5526 |
"/ sel ~= selector ifTrue:[ |
|
5527 |
"/ self warnCommonMistake:'possible bad super message (selector should be same as in current method) ?' |
|
5528 |
"/ position:posR1 to:posR2-1 |
|
5529 |
"/ ]. |
|
5530 |
"/ ]. |
|
5531 |
"/ ]. |
|
5532 |
"/ |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5533 |
(sel = #and: or:[sel = #or:]) ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5534 |
expr arg1 isBlock ifFalse:[ |
1575 | 5535 |
(expr arg1 isVariable |
5536 |
and:[ (expr arg1 name asLowercase includesString:'block')]) ifFalse:[ |
|
5537 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5538 |
position:pos2+1 to:tokenPosition-1 |
1575 | 5539 |
] |
5540 |
]. |
|
5541 |
^ expr. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5542 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5543 |
(sel = #whileTrue: or:[sel = #whileFalse:]) ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5544 |
expr receiver isBlock ifFalse:[ |
1575 | 5545 |
(expr receiver isVariable |
5546 |
and:[ (expr receiver name asLowercase includesString:'block')]) ifFalse:[ |
|
5547 |
self warnCommonMistake:'(possible common mistake) missing block brackets ?' |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5548 |
position:posR1 to:posR2-1 |
1575 | 5549 |
] |
5550 |
]. |
|
5551 |
^ expr. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5552 |
]. |
1576 | 5553 |
(sel = #ifTrue: or:[sel = #ifFalse:]) ifTrue:[ |
5554 |
expr receiver isMessage ifTrue:[ |
|
5555 |
(expr receiver selector = #whileTrue or:[expr receiver selector = #whileFalse]) ifTrue:[ |
|
5556 |
self warnCommonMistake:'strange receiver expression' |
|
5557 |
position:posR1 to:posR2-1 |
|
5558 |
]. |
|
5559 |
] |
|
5560 |
]. |
|
5561 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5562 |
^ expr. |
713 | 5563 |
|
1022 | 5564 |
"Modified: / 19.1.2000 / 16:22:22 / cg" |
713 | 5565 |
! |
5566 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5567 |
nodeForMethodArg:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5568 |
|varIndex var| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5569 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5570 |
methodArgNames isNil ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5571 |
varIndex := methodArgNames indexOf:varName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5572 |
varIndex == 0 ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5573 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5574 |
var := methodArgs at:varIndex. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5575 |
"/ var used:true. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5576 |
^ VariableNode type:#MethodArg |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5577 |
name:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5578 |
token:var |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5579 |
index:varIndex |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5580 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5581 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5582 |
nodeForMethodVariable:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5583 |
|varIndex var| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5584 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5585 |
methodVarNames isNil ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5586 |
varIndex := methodVarNames indexOf:varName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5587 |
varIndex == 0 ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5588 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5589 |
var := methodVars at:varIndex. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5590 |
var used:true. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5591 |
parseForCode ifFalse:[self rememberLocalUsed:varName]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5592 |
^ VariableNode type:#MethodVariable |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5593 |
name:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5594 |
token:var |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5595 |
index:varIndex |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5596 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5597 |
|
0 | 5598 |
primary |
1028 | 5599 |
"parse a primary-expression; return a node-tree, nil or #Error. |
5600 |
This also cares for namespace-access-pathes." |
|
0 | 5601 |
|
1227 | 5602 |
|val pos node eMsg| |
924 | 5603 |
|
44 | 5604 |
(tokenType == #Self) ifTrue:[ |
1227 | 5605 |
^ self primary_self. |
5606 |
]. |
|
5607 |
||
5608 |
pos := tokenPosition. |
|
0 | 5609 |
(tokenType == #Identifier) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5610 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5611 |
must check for variable first, to be backward compatible |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5612 |
with other smalltalks. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5613 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5614 |
tokenName = 'here' ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5615 |
(self variableOrError:tokenName) == #Error ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5616 |
self warnSTXHereExtensionUsedAt:pos. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5617 |
tokenType := #Here. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5618 |
^ self primary_here. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5619 |
] |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5620 |
]. |
1227 | 5621 |
^ self primary_identifier |
0 | 5622 |
]. |
49 | 5623 |
|
44 | 5624 |
((tokenType == #Integer) |
120 | 5625 |
or:[(tokenType == #String) |
44 | 5626 |
or:[(tokenType == #Character) |
5627 |
or:[(tokenType == #Float) |
|
5628 |
or:[(tokenType == #Symbol)]]]]) ifTrue:[ |
|
1227 | 5629 |
^ self primary_simpleLiteral. |
0 | 5630 |
]. |
924 | 5631 |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5632 |
(tokenType == #FixedPoint) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5633 |
parserFlags allowFixedPointLiterals == true ifFalse:[ |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5634 |
self parseError:'non-Standard literal: FixedPoint. Please enable in settings.' position:pos to:tokenPosition. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5635 |
^ #Error |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5636 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5637 |
^ self primary_simpleLiteral. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5638 |
]. |
0 | 5639 |
(tokenType == #Nil) ifTrue:[ |
1227 | 5640 |
^ self primary_nil. |
5641 |
]. |
|
0 | 5642 |
(tokenType == #True) ifTrue:[ |
1227 | 5643 |
^ self primary_true |
0 | 5644 |
]. |
5645 |
(tokenType == #False) ifTrue:[ |
|
1227 | 5646 |
^ self primary_false |
5647 |
]. |
|
0 | 5648 |
(tokenType == #Super) ifTrue:[ |
1227 | 5649 |
^ self primary_super. |
5650 |
]. |
|
924 | 5651 |
|
0 | 5652 |
(tokenType == #ThisContext) ifTrue:[ |
1262 | 5653 |
^ self primary_thisContext |
0 | 5654 |
]. |
924 | 5655 |
|
0 | 5656 |
(tokenType == #HashLeftParen) ifTrue:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5657 |
self nextToken. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5658 |
self inArrayLiteral:true. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5659 |
ParseErrorSignal handle:[:ex | |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5660 |
self inArrayLiteral:false. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5661 |
^ #Error |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5662 |
] do:[ |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5663 |
val := self array. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5664 |
]. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5665 |
self inArrayLiteral:false. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5666 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5667 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5668 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5669 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5670 |
^ ConstantNode type:#Array value:val |
0 | 5671 |
]. |
924 | 5672 |
|
5673 |
(tokenType == #HashLeftBrace) ifTrue:[ |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5674 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5675 |
self nextToken. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5676 |
^ val. |
924 | 5677 |
]. |
5678 |
||
0 | 5679 |
(tokenType == #HashLeftBrack) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5680 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5681 |
val := self byteArray. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5682 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5683 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5684 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5685 |
]. |
924 | 5686 |
^ ConstantNode type:#ByteArray value:val |
0 | 5687 |
]. |
432 | 5688 |
|
0 | 5689 |
(tokenType == $() ifTrue:[ |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5690 |
parenthesisLevel := parenthesisLevel + 1. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5691 |
self markParenthesisAt:tokenPosition. |
1227 | 5692 |
^ self primary_expression. |
0 | 5693 |
]. |
924 | 5694 |
|
0 | 5695 |
(tokenType == $[ ) ifTrue:[ |
673 | 5696 |
self markBracketAt:tokenPosition. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5697 |
val := self block. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5698 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5699 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5700 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5701 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5702 |
^ val |
0 | 5703 |
]. |
19 | 5704 |
|
1262 | 5705 |
"/ EXPERIMENTAL - may be in next release |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5706 |
parserFlags allowVariableReferences == true ifTrue:[ |
1295 | 5707 |
((tokenType == #BinaryOperator) and:[token = '&']) ifTrue:[ |
5708 |
self nextToken. |
|
5709 |
node := self primary_identifier. |
|
5710 |
"/ generate a Reference |
|
5711 |
^ self makeReferenceFor:node |
|
5712 |
]. |
|
5713 |
]. |
|
5714 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5715 |
(tokenType == ${ ) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5716 |
parserFlags allowSqueakExtensions == true ifFalse:[ |
1335 | 5717 |
self parseError:'non-Standard Squeak extension: Brace Computed Array. Enable in settings.' position:pos to:tokenPosition. |
1453
205e70e12abe
squeak-brace extension error is now proceedable
Claus Gittinger <cg@exept.de>
parents:
1446
diff
changeset
|
5718 |
errorFlag := false. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5719 |
]. |
1227 | 5720 |
^ self primary_squeakComputedArray. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5721 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5722 |
|
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5723 |
(tokenType == #Primitive) ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5724 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5725 |
node := PrimitiveNode code:tokenValue. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5726 |
hasNonOptionalPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5727 |
hasPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5728 |
^ node |
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5729 |
]. |
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5730 |
|
1227 | 5731 |
tokenType == #HashHashLeftParen ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5732 |
self halt. |
1295 | 5733 |
self nextToken. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5734 |
parserFlags allowDolphinExtensions == true ifFalse:[ |
1335 | 5735 |
self parseError:'non-Standard Dolphin extension: ##(..). Enable in settings.' position:pos to:tokenPosition. |
1227 | 5736 |
^ #Error |
5737 |
]. |
|
5738 |
^ self primary_dolphinComputedLiteral. |
|
5739 |
]. |
|
1299 | 5740 |
tokenType == #ExclaLeftBrack ifTrue:[ |
1295 | 5741 |
self nextToken. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5742 |
parserFlags allowLazyValueExtension == true ifFalse:[ |
1335 | 5743 |
self parseError:'non-Standard LazyValue extension. Enable in classVariable.' position:pos to:tokenPosition. |
1295 | 5744 |
^ #Error |
5745 |
]. |
|
5746 |
^ self primary_lazyValue. |
|
5747 |
]. |
|
5748 |
tokenType == #HashHash ifTrue:[ |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
5749 |
self warnPossibleIncompatibility:'''##'' might be interpreted differently in other smalltalk systems' position:pos to:tokenPosition. |
1295 | 5750 |
tokenType := #Symbol. |
5751 |
token := tokenValue := tokenName := '#'. |
|
5752 |
^ self primary_simpleLiteral. |
|
5753 |
]. |
|
1227 | 5754 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5755 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5756 |
((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5757 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5758 |
(tokenType == $( ) ifFalse:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5759 |
self parseError:'''('' expected after #.' position:pos to:tokenPosition. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5760 |
^ self. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5761 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5762 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5763 |
self inArrayLiteral:true. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5764 |
ParseErrorSignal handle:[:ex | |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5765 |
self inArrayLiteral:false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5766 |
^ #Error |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5767 |
] do:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5768 |
val := self array. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5769 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5770 |
self inArrayLiteral:false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5771 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5772 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5773 |
^ #Error |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5774 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5775 |
^ ConstantNode type:#Array value:val |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5776 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5777 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5778 |
|
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5779 |
((tokenType == #BinaryOperator) and:[token = '-']) ifTrue:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5780 |
self nextToken. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5781 |
((tokenType == #Integer) |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5782 |
or:[(tokenType == #Float)]) ifFalse:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5783 |
self parseError:'number expected after sign.' position:pos to:tokenPosition. |
1539 | 5784 |
^ #Error. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5785 |
]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5786 |
parserFlags allowSqueakExtensions == true ifFalse:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5787 |
self parseError:'non-Standard Squeak extension: space between sign and number. Enable in settings.' position:pos to:tokenPosition. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5788 |
errorFlag := false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5789 |
]. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5790 |
|
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5791 |
node := self primary_simpleLiteral. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5792 |
node isConstant ifFalse:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5793 |
self parseError:'number expected after sign.' position:pos to:tokenPosition. |
1539 | 5794 |
^ #Error. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5795 |
]. |
1557
311e94185248
oops - parser clobbered Const1Node (negated)
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
5796 |
^ ConstantNode type:(node type) value:(node value negated). |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5797 |
]. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5798 |
|
0 | 5799 |
(tokenType == #Error) ifTrue:[^ #Error]. |
44 | 5800 |
tokenType isCharacter ifTrue:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5801 |
self syntaxError:('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5802 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5803 |
' unexpected') position:tokenPosition to:tokenPosition |
0 | 5804 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5805 |
(#(BinaryOperator Keyword) includes:tokenType) ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5806 |
eMsg := ('error in primary; ' |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5807 |
, tokenType printString , '(' , tokenName , ') ' , |
805 | 5808 |
' unexpected (missing receiver ?)') |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5809 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5810 |
eMsg := ('error in primary; ' |
1295 | 5811 |
, (token ? '') , ' (', tokenType printString , |
5812 |
') unexpected') |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5813 |
]. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5814 |
self syntaxError:eMsg position:tokenPosition to:source position1Based - 1 |
0 | 5815 |
]. |
5816 |
^ #Error |
|
120 | 5817 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5818 |
"Created: / 13.9.1995 / 12:50:50 / claus" |
1068 | 5819 |
"Modified: / 18.8.2000 / 20:51:22 / cg" |
0 | 5820 |
! |
5821 |
||
1227 | 5822 |
primary_dolphinComputedLiteral |
1273
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5823 |
"parse a dolphin computed literal; return a node-tree, or raise an Error. |
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5824 |
In dolphin, these are written as: ##( expression ) |
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5825 |
and create a literal constant for the expressions value. |
1274 | 5826 |
Right now, only a subset is supported - Strings, ByteArrays and Characters. |
5827 |
WARNING: this is only supported to allow filing in dolphin code. |
|
5828 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
5829 |
if you ever plan to stc-compile it into a shared library" |
|
1227 | 5830 |
|
5831 |
|pos expr val| |
|
5832 |
||
5833 |
pos := tokenPosition. |
|
5834 |
||
5835 |
expr := self expression. |
|
5836 |
||
5837 |
tokenType ~~ $) ifTrue:[ |
|
5838 |
self parseError:''')'' expected' position:tokenPosition. |
|
5839 |
^ #Error |
|
5840 |
]. |
|
5841 |
self nextToken. |
|
5842 |
||
5843 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5844 |
^ #Error |
|
5845 |
]. |
|
5846 |
||
5847 |
val := expr evaluate. |
|
5848 |
||
5849 |
val isLiteral ifTrue:[ |
|
1272
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5850 |
val isString ifTrue:[ |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5851 |
^ ConstantNode type:#String value:val |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5852 |
]. |
1227 | 5853 |
val isByteArray ifTrue:[ |
5854 |
^ ConstantNode type:#ByteArray value:val |
|
5855 |
]. |
|
1234 | 5856 |
val isCharacter ifTrue:[ |
5857 |
^ ConstantNode type:#Character value:val |
|
5858 |
]. |
|
1295 | 5859 |
val isInteger ifTrue:[ |
5860 |
^ ConstantNode type:#Integer value:val |
|
5861 |
]. |
|
1328 | 5862 |
val isLimitedPrecisionReal ifTrue:[ |
5863 |
^ ConstantNode type:#Float value:val |
|
5864 |
]. |
|
1295 | 5865 |
val isArray ifTrue:[ |
5866 |
^ ConstantNode type:#Array value:val |
|
5867 |
]. |
|
1227 | 5868 |
] ifFalse:[ |
5869 |
self parseError:'must be representable as a literal (for now)' position:pos. |
|
5870 |
^ #Error |
|
5871 |
]. |
|
1326 | 5872 |
self halt:'unimplemented'. |
1227 | 5873 |
"/ "/ make it an array creation expression ... |
5874 |
"/ expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5875 |
"/ receiver:(VariableNode globalNamed:#Array) |
1227 | 5876 |
"/ selector:#new: |
5877 |
"/ arg:(ConstantNode type:#Integer value:(exprList size)). |
|
5878 |
"/ |
|
5879 |
"/ exprList size == 0 ifTrue:[ |
|
5880 |
"/ ^ expr. |
|
5881 |
"/ ]. |
|
5882 |
"/ exprList keysAndValuesDo:[:idx :e | |
|
5883 |
"/ expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
|
5884 |
"/ receiver:expr |
|
5885 |
"/ selector:#at:put: |
|
5886 |
"/ arg1:(ConstantNode type:#Integer value:idx) |
|
5887 |
"/ arg2:e |
|
5888 |
"/ fold:false. |
|
5889 |
"/ ]. |
|
5890 |
"/ expr := CascadeNode |
|
5891 |
"/ receiver:expr |
|
5892 |
"/ selector:#yourself. |
|
5893 |
"/ ^ expr |
|
5894 |
! |
|
5895 |
||
5896 |
primary_expression |
|
5897 |
"parse a parentized expression primary; return a node-tree, or raise an Error." |
|
5898 |
||
5899 |
|pos val eMsg| |
|
5900 |
||
5901 |
pos := tokenPosition. |
|
5902 |
||
5903 |
self nextToken. |
|
5904 |
val := self expression. |
|
5905 |
(val == #Error) ifTrue:[^ #Error]. |
|
5906 |
(tokenType ~~ $) ) ifTrue:[ |
|
5907 |
tokenType isCharacter ifTrue:[ |
|
5908 |
eMsg := 'missing '')'' (i.e. ''' , tokenType asString , ''' unexpected)'. |
|
5909 |
] ifFalse:[ |
|
5910 |
eMsg := 'missing '')'''. |
|
5911 |
]. |
|
5912 |
self syntaxError:eMsg withCRs position:pos to:tokenPosition. |
|
5913 |
^ #Error |
|
5914 |
]. |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5915 |
self markParenthesisAt:tokenPosition. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5916 |
parenthesisLevel := parenthesisLevel - 1. |
1227 | 5917 |
self nextToken. |
5918 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5919 |
^ #Error |
|
5920 |
]. |
|
5921 |
val parenthized:true. |
|
5922 |
^ val |
|
5923 |
! |
|
5924 |
||
5925 |
primary_false |
|
5926 |
"parse a false primary; return a node-tree, or raise an Error." |
|
5927 |
||
5928 |
|pos| |
|
5929 |
||
5930 |
pos := tokenPosition. |
|
5931 |
||
5932 |
self nextToken. |
|
5933 |
(self noAssignmentAllowed:'assignment to ''false''' at:pos) ifFalse:[ |
|
5934 |
^ #Error |
|
5935 |
]. |
|
5936 |
self markBooleanConstantFrom:pos to:pos+4. |
|
5937 |
^ ConstantNode type:#False value:false |
|
5938 |
! |
|
5939 |
||
5940 |
primary_here |
|
5941 |
"parse a here primary; return a node-tree, nil or #Error." |
|
5942 |
||
5943 |
|pos| |
|
5944 |
||
5945 |
pos := tokenPosition. |
|
5946 |
||
5947 |
self nextToken. |
|
5948 |
(self noAssignmentAllowed:'assignment to pseudo variable ''here''' at:pos) ifFalse:[ |
|
5949 |
^ #Error |
|
5950 |
]. |
|
5951 |
classToCompileFor isNil ifTrue:[ |
|
5952 |
self warning:'in which class are you ?' position:pos to:(pos + 3). |
|
5953 |
]. |
|
5954 |
self markSelfFrom:pos to:pos+3. |
|
5955 |
^ SuperNode value:selfValue inClass:classToCompileFor here:true |
|
5956 |
! |
|
5957 |
||
5958 |
primary_identifier |
|
1638 | 5959 |
"parse a primary; return a node-tree, or raise an Error." |
1227 | 5960 |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5961 |
|pos1 pos2 expr varName rawName var globlName nameSpace nameSpaceGlobal |
1551 | 5962 |
t cls lnr node holder autoHow assignmentAllowed| |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5963 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5964 |
pos1 := tokenPosition. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5965 |
pos2 := tokenPosition + tokenName size - 1. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5966 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5967 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5968 |
|
1440 | 5969 |
(self isDoIt |
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5970 |
and:[currentBlock isNil |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5971 |
and:[(requestor askFor:#isWorkspace) |
1359 | 5972 |
and:[(autoHow := requestor autoDefineVariables) notNil]]]) ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5973 |
var := self variableOrError:varName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5974 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5975 |
(var == #Error) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5976 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
1359 | 5977 |
autoHow == #workspace ifTrue:[ |
5978 |
holder := Workspace addWorkspaceVariable:varName. |
|
5979 |
var := VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
5980 |
] ifFalse:[ |
|
5981 |
holder := self addDoItTemporary:varName. |
|
5982 |
var := VariableNode type:#DoItTemporary holder:holder name:varName |
|
5983 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5984 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5985 |
var := self correctVariable:varName atPosition:pos1 to:pos2. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5986 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5987 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5988 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5989 |
var := self variable. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5990 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5991 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5992 |
|
1227 | 5993 |
"/ errorFlag == true ifTrue:[self halt]. |
5994 |
(var == #Error) ifTrue:[ |
|
5995 |
errorFlag := true |
|
5996 |
]. |
|
5997 |
||
5998 |
(tokenType == #'::') ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5999 |
globlName := rawName := varName. |
1227 | 6000 |
|
6001 |
"is it in a namespace ?" |
|
6002 |
nameSpace := self findNameSpaceWith:globlName. |
|
6003 |
nameSpace notNil ifTrue:[ |
|
6004 |
globlName := nameSpace name , '::' , globlName |
|
6005 |
]. |
|
6006 |
||
6007 |
[tokenType == #'::'] whileTrue:[ |
|
6008 |
nameSpace := globlName. |
|
6009 |
||
6010 |
self nextToken. |
|
6011 |
(tokenType == #Identifier) ifTrue:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6012 |
self warnSTXNameSpaceUseAt:pos1. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6013 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6014 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6015 |
globlName := (nameSpace , '::' , varName). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6016 |
rawName := (rawName , '::' , varName). |
1227 | 6017 |
|
6018 |
nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil. |
|
6019 |
nameSpaceGlobal isNil ifTrue:[ |
|
6020 |
warnedUnknownNamespaces isNil ifTrue:[ |
|
6021 |
warnedUnknownNamespaces := Set new. |
|
6022 |
]. |
|
6023 |
(warnedUnknownNamespaces includes:nameSpace) ifFalse:[ |
|
6024 |
self warning:('unknown nameSpace: ', nameSpace) |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6025 |
position:pos1 to:tokenPosition-1. |
1227 | 6026 |
"/ self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1. |
6027 |
warnedUnknownNamespaces add:nameSpace. |
|
6028 |
] |
|
6029 |
] ifFalse:[ |
|
6030 |
nameSpaceGlobal isNameSpace ifTrue:[ |
|
6031 |
"/ for now: only Smalltalk is allowed |
|
6032 |
nameSpaceGlobal ~~ Smalltalk ifTrue:[ |
|
6033 |
"/ self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1. |
|
6034 |
] ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6035 |
globlName := varName |
1227 | 6036 |
]. |
6037 |
] ifFalse:[ |
|
6038 |
nameSpaceGlobal isBehavior ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6039 |
self parseError:('invalid nameSpace: ' , nameSpace) position:pos1 to:tokenPosition-1. |
1227 | 6040 |
] ifTrue:[ |
1391 | 6041 |
nameSpaceGlobal isLoaded ifTrue:[ |
6042 |
(nameSpaceGlobal privateClassesAt:varName asSymbol) isNil ifTrue:[ |
|
1570 | 6043 |
(Smalltalk at:rawName asSymbol) notNil ifTrue:[ |
6044 |
self warning:('Possible name clash (global: ' , rawName , ' vs. private: ' , (nameSpace , '::', varName) , ') - assume globl.') |
|
6045 |
position:pos1 to:tokenPosition-1. |
|
6046 |
globlName := rawName asSymbol. |
|
6047 |
] ifFalse:[ |
|
6048 |
self warning:('no private class: ' , varName , ' in class: ' , nameSpace) |
|
6049 |
position:pos1 to:tokenPosition-1. |
|
1391 | 6050 |
"/ self parseError:('no private class: ' , name , ' in class: ' , nameSpace) position:pos to:tokenPosition-1. |
1570 | 6051 |
] |
1391 | 6052 |
] |
1227 | 6053 |
] |
6054 |
] |
|
6055 |
]. |
|
6056 |
]. |
|
6057 |
self nextToken. |
|
6058 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6059 |
var := VariableNode globalNamed:globlName. |
1227 | 6060 |
parseForCode ifFalse:[self rememberGlobalUsed:globlName]. |
6061 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6062 |
self markVariable:var from:pos1 to:pos1 + rawName size - 1. |
1227 | 6063 |
]. |
6064 |
||
6065 |
var == #Error ifTrue:[ |
|
6066 |
^ #Error |
|
6067 |
]. |
|
6068 |
||
6069 |
errorFlag ~~ true ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6070 |
self markVariable:var from:pos1 to:pos1 + varName size - 1. |
1227 | 6071 |
]. |
6072 |
(ignoreErrors or:[ignoreWarnings or:[parseForCode not]]) ifTrue:[ |
|
6073 |
errorFlag := false. |
|
6074 |
]. |
|
6075 |
||
6076 |
((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[ |
|
6077 |
parseForCode ifFalse:[ |
|
6078 |
var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name]. |
|
6079 |
var isClassVariable ifTrue:[ self rememberClassVarRead:var name]. |
|
6080 |
]. |
|
6081 |
^ var |
|
6082 |
]. |
|
6083 |
||
1551 | 6084 |
"/ assignment... |
6085 |
||
1227 | 6086 |
"/ careful: it could already be an implicit self send |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6087 |
parserFlags implicitSelfSends ifTrue:[ |
1227 | 6088 |
var isMessage ifTrue:[ |
6089 |
self nextToken. |
|
6090 |
expr := self expression. |
|
6091 |
self isSyntaxHighlighter ifFalse:[ |
|
6092 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
6093 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6094 |
^ MessageNode receiver:(self selfNode) selector:('__' , varName , ':') asSymbol arg:expr. |
1227 | 6095 |
]. |
6096 |
]. |
|
6097 |
||
1551 | 6098 |
assignmentAllowed := true. |
6099 |
||
1227 | 6100 |
(var ~~ #Error) ifTrue:[ |
6101 |
t := var type. |
|
6102 |
t == #MethodVariable ifTrue:[ |
|
6103 |
modifiedLocalVars isNil ifTrue:[ |
|
6104 |
modifiedLocalVars := Set new. |
|
6105 |
]. |
|
6106 |
modifiedLocalVars add:var name. |
|
1551 | 6107 |
] ifFalse:[ (t == #InstanceVariable) ifTrue:[ |
6108 |
varName := self classesInstVarNames at:(var index). |
|
6109 |
||
6110 |
"/ ca once did this to "name" and wondered what happened to his class ... |
|
6111 |
"/ (not really a beginners bug, but may happen as a typo or missing local variable; |
|
6112 |
"/ and is hard to track down later) |
|
6113 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6114 |
parserFlags warnCommonMistakes ifTrue:[ |
1551 | 6115 |
classToCompileFor isMeta ifTrue:[ |
6116 |
(classToCompileFor isSubclassOf:Class) ifTrue:[ |
|
6117 |
(Class allInstVarNames includes:(var name)) ifTrue:[ |
|
6118 |
self warning:'assignment to a classInstanceVariable\(see hierarchy of "Class")' withCRs position:pos1 to:pos2. |
|
6119 |
] |
|
6120 |
] |
|
6121 |
] |
|
6122 |
]. |
|
6123 |
parseForCode ifFalse:[ |
|
6124 |
modifiedInstVars isNil ifTrue:[ |
|
6125 |
modifiedInstVars := Set new |
|
6126 |
]. |
|
6127 |
modifiedInstVars add:varName |
|
6128 |
] |
|
6129 |
] ifFalse:[ (t == #ClassVariable) ifTrue:[ |
|
6130 |
varName := var name. |
|
6131 |
varName := varName copyFrom:((varName indexOf:$:) + 1). |
|
6132 |
parseForCode ifFalse:[ |
|
6133 |
modifiedClassVars isNil ifTrue:[ |
|
6134 |
modifiedClassVars := Set new |
|
6135 |
]. |
|
6136 |
modifiedClassVars add:varName |
|
6137 |
] |
|
6138 |
] ifFalse:[ (t == #GlobalVariable) ifTrue:[ |
|
6139 |
(cls := Smalltalk classNamed:var name) notNil ifTrue:[ |
|
6140 |
cls name = var name ifTrue:[ |
|
6141 |
self warning:'assignment to global which refers to a class' position:pos1 to:pos2. |
|
6142 |
] |
|
6143 |
]. |
|
6144 |
parseForCode ifFalse:[ |
|
6145 |
modifiedGlobals isNil ifTrue:[ |
|
6146 |
modifiedGlobals := Set new |
|
6147 |
]. |
|
6148 |
modifiedGlobals add:var name |
|
6149 |
] |
|
6150 |
] ifFalse:[ |
|
6151 |
(t == #PrivateClass) ifTrue:[ |
|
6152 |
assignmentAllowed := false. |
|
6153 |
self parseError:'assignment to private class' position:pos1 to:pos2. |
|
6154 |
] ifFalse:[ (t == #MethodArg) ifTrue:[ |
|
6155 |
assignmentAllowed := false. |
|
6156 |
self parseError:'assignment to method argument' position:pos1 to:pos2. |
|
6157 |
] ifFalse:[ (t == #BlockArg) ifTrue:[ |
|
6158 |
assignmentAllowed := false. |
|
6159 |
self parseError:'assignment to block argument' position:pos1 to:pos2. |
|
6160 |
] ifFalse:[ (t == #PoolVariable) ifTrue:[ |
|
6161 |
self isDoIt ifTrue:[ |
|
6162 |
self warning:'assignment to pool variable' position:pos1 to:pos2. |
|
6163 |
assignmentAllowed := true. |
|
6164 |
] ifFalse:[ |
|
6165 |
self parseError:'assignment to pool variable' position:pos1 to:pos2. |
|
6166 |
] |
|
6167 |
]]]]]]] |
|
1227 | 6168 |
]. |
6169 |
]. |
|
6170 |
||
6171 |
lnr := tokenLineNr. |
|
6172 |
||
6173 |
self nextToken. |
|
6174 |
pos2 := tokenPosition. |
|
6175 |
expr := self expression. |
|
6176 |
||
6177 |
"/ a typical beginner error: |
|
6178 |
"/ expr ifTrue:[ |
|
6179 |
"/ var := super |
|
6180 |
"/ ] ifFalse:[ |
|
6181 |
"/ var := something-else |
|
6182 |
"/ ]. |
|
6183 |
"/ var messageSend |
|
6184 |
"/ |
|
6185 |
"/ does not what a beginner might think. |
|
6186 |
||
6187 |
self isSyntaxHighlighter ifTrue:[ |
|
6188 |
(expr == #Error) ifTrue:[^ #Error]. |
|
6189 |
] ifFalse:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6190 |
parserFlags warnCommonMistakes ifTrue:[ |
1227 | 6191 |
(expr ~~ #Error and:[expr isSuper]) ifTrue:[ |
1551 | 6192 |
self warning:'followup messageSends to "' , var name , '" will have normal send semantics\(i.e. NO super- or here-sends). Use self to avoid confusion.' withCRs position:pos1 to:pos2. |
1227 | 6193 |
]. |
6194 |
]. |
|
6195 |
||
6196 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
6197 |
expr isVariable ifTrue:[ |
|
6198 |
expr name = var name ifTrue:[ |
|
1551 | 6199 |
self warning:('useless assignment to "' , var name, '"' ) position:pos1 to:pos2-1. |
1227 | 6200 |
]. |
6201 |
]. |
|
6202 |
]. |
|
1551 | 6203 |
assignmentAllowed ifTrue:[ |
6204 |
node := AssignmentNode variable:var expression:expr. |
|
6205 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
6206 |
] ifFalse:[ |
|
6207 |
self parseError:('assignment to "' , var name, '" suppressed' ) position:pos1 to:pos2-1. |
|
6208 |
node := expr. |
|
6209 |
]. |
|
1227 | 6210 |
^ node |
6211 |
! |
|
6212 |
||
1295 | 6213 |
primary_lazyValue |
6214 |
|pos block expr| |
|
6215 |
||
6216 |
pos := tokenPosition. |
|
6217 |
||
6218 |
(tokenType == $: ) ifTrue:[ |
|
6219 |
self parseError:'lazyValues have no arguments' position:tokenPosition. |
|
6220 |
^ #Error |
|
6221 |
]. |
|
6222 |
||
6223 |
block := self blockBody:#(). |
|
6224 |
self nextToken. |
|
6225 |
||
6226 |
expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6227 |
receiver:(VariableNode globalNamed:#LazyValue) |
1295 | 6228 |
selector:#'block:' |
6229 |
arg:block. |
|
6230 |
^ expr |
|
6231 |
! |
|
6232 |
||
1227 | 6233 |
primary_nil |
6234 |
"parse a nil primary; return a node-tree, nil or #Error." |
|
6235 |
||
6236 |
|pos| |
|
6237 |
||
6238 |
pos := tokenPosition. |
|
6239 |
||
6240 |
self nextToken. |
|
6241 |
(self noAssignmentAllowed:'assignment to ''nil''' at:pos) ifFalse:[ |
|
6242 |
^ #Error |
|
6243 |
]. |
|
6244 |
"/ self markConstantFrom:pos to:pos+2. |
|
6245 |
nilNode isNil ifTrue:[ |
|
6246 |
nilNode := ConstantNode type:#Nil value:nil |
|
6247 |
]. |
|
6248 |
^ nilNode |
|
6249 |
! |
|
6250 |
||
6251 |
primary_self |
|
6252 |
"parse a self primary; return a node-tree, nil or #Error." |
|
6253 |
||
6254 |
|pos| |
|
6255 |
||
6256 |
pos := tokenPosition. |
|
6257 |
||
6258 |
self nextToken. |
|
6259 |
(self noAssignmentAllowed:'assignment to pseudo variable ''self''' at:pos) ifFalse:[ |
|
6260 |
^ ParseError raise |
|
6261 |
]. |
|
6262 |
self markSelfFrom:pos to:pos+3. |
|
1262 | 6263 |
^ self selfNode |
1227 | 6264 |
! |
6265 |
||
6266 |
primary_simpleLiteral |
|
6267 |
"parse a simple literal primary; return a node-tree, or raise an Error." |
|
6268 |
||
6269 |
|pos val| |
|
6270 |
||
6271 |
pos := tokenPosition. |
|
6272 |
||
6273 |
"/ |
|
6274 |
"/ ImmutableStrings are experimental |
|
6275 |
"/ |
|
6276 |
((tokenType == #String) |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6277 |
and:[(parserFlags stringsAreImmutable)]) ifTrue:[ |
1615 | 6278 |
token := tokenValue := self makeImmutableString:tokenValue. |
1227 | 6279 |
]. |
6280 |
(tokenType == #Symbol) ifTrue:[ |
|
6281 |
parseForCode ifFalse:[ |
|
6282 |
self rememberSymbolUsed:tokenValue |
|
6283 |
]. |
|
6284 |
]. |
|
6285 |
val := ConstantNode type:tokenType value:tokenValue. |
|
6286 |
||
6287 |
tokenValue isSymbol ifTrue:[ |
|
6288 |
self markSymbolFrom:tokenPosition to:tokenPosition+tokenValue size-1. |
|
6289 |
]. |
|
6290 |
||
6291 |
self nextToken. |
|
6292 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
|
6293 |
^ #Error |
|
6294 |
]. |
|
6295 |
^ val |
|
6296 |
! |
|
6297 |
||
6298 |
primary_squeakComputedArray |
|
1274 | 6299 |
"parse a squeak computed array literal; return a node-tree, or raise an Error. |
6300 |
In squeak, these are written as: { expr1 . expr2 . ... exprN ) |
|
6301 |
and create a literalArray containing the exprI values. |
|
6302 |
WARNING: this is only supported to allow filing in squeak code. |
|
6303 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
6304 |
if you ever plan to stc-compile it into a shared library" |
|
6305 |
||
1227 | 6306 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6307 |
|pos exprList| |
1227 | 6308 |
|
6309 |
pos := tokenPosition. |
|
6310 |
||
6311 |
self nextToken. |
|
6312 |
exprList := self squeakComputedArray. |
|
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6313 |
(exprList == #Error) ifTrue:[ ^ #Error ]. |
1227 | 6314 |
|
6315 |
tokenType ~~ $} ifTrue:[ |
|
6316 |
self parseError:'''}'' expected' position:tokenPosition. |
|
6317 |
^ #Error |
|
6318 |
]. |
|
6319 |
self nextToken. |
|
6320 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
6321 |
^ #Error |
|
6322 |
]. |
|
6323 |
||
6324 |
"/ make it an array creation expression ... |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6325 |
^ self genMakeArrayWith:exprList |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6326 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6327 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6328 |
Compiler allowSqueakExtensions:true. |
1299 | 6329 |
" |
6330 |
||
6331 |
" |
|
6332 |
{ 1@2. 10 factorial. Date today }. |
|
6333 |
" |
|
6334 |
||
6335 |
" |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6336 |
Compiler allowSqueakExtensions:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6337 |
" |
1227 | 6338 |
! |
6339 |
||
6340 |
primary_super |
|
6341 |
"parse a super primary; return a node-tree, nil or #Error." |
|
6342 |
||
6343 |
|pos| |
|
6344 |
||
6345 |
pos := tokenPosition. |
|
6346 |
||
6347 |
usesSuper := true. |
|
6348 |
self nextToken. |
|
6349 |
(self noAssignmentAllowed:'assignment to pseudo variable ''super''' at:pos) ifFalse:[ |
|
6350 |
^ #Error |
|
6351 |
]. |
|
6352 |
(classToCompileFor isNil or:[classToCompileFor superclass isNil]) ifTrue:[ |
|
6353 |
self warning:'superclass is (currently ?) nil' position:pos to:(pos + 4). |
|
6354 |
]. |
|
6355 |
superNode isNil ifTrue:[ |
|
6356 |
superNode := SuperNode value:selfValue inClass:classToCompileFor |
|
6357 |
]. |
|
6358 |
self markSelfFrom:pos to:pos+4. |
|
6359 |
^ superNode |
|
6360 |
! |
|
6361 |
||
1262 | 6362 |
primary_thisContext |
6363 |
"parse a thisContext primary; return a node-tree, or raise an Error." |
|
6364 |
||
6365 |
|pos| |
|
6366 |
||
6367 |
pos := tokenPosition. |
|
6368 |
||
6369 |
self nextToken. |
|
6370 |
(self noAssignmentAllowed:'assignment to pseudo variable ''thisContext''' at:pos) ifFalse:[ |
|
6371 |
^ #Error |
|
6372 |
]. |
|
6373 |
self markIdentifierFrom:pos to:pos+10. |
|
6374 |
^ VariableNode type:#ThisContext context:contextToEvaluateIn. "/ often nil |
|
6375 |
! |
|
6376 |
||
1227 | 6377 |
primary_true |
6378 |
"parse a true primary; return a node-tree, or raise an Error." |
|
6379 |
||
6380 |
|pos| |
|
6381 |
||
6382 |
pos := tokenPosition. |
|
6383 |
||
6384 |
self nextToken. |
|
6385 |
(self noAssignmentAllowed:'assignment to ''true''' at:pos) ifFalse:[ |
|
6386 |
^ #Error |
|
6387 |
]. |
|
6388 |
self markBooleanConstantFrom:pos to:pos+3. |
|
6389 |
^ ConstantNode type:#True value:true |
|
6390 |
! |
|
6391 |
||
924 | 6392 |
qualifiedName |
6393 |
"a vw3.x (and later) feature: QualifiedName is #{ id ... id } |
|
6394 |
and mapped to a global variable here. |
|
6395 |
The initial #{ is supposed to be not yet skipped." |
|
6396 |
||
1436 | 6397 |
|elements elem pos1 nm| |
924 | 6398 |
|
6399 |
pos1 := tokenPosition. |
|
6400 |
self nextToken. |
|
6401 |
elements := OrderedCollection new. |
|
1436 | 6402 |
[ tokenType ~~ $} ] whileTrue:[ |
6403 |
(tokenType == #Identifier) ifFalse:[ |
|
6404 |
self syntaxError:'bad qualifiedName; Identifier expected' |
|
924 | 6405 |
position:pos1 to:tokenPosition |
6406 |
]. |
|
1436 | 6407 |
elem := tokenName. |
924 | 6408 |
elements add:elem. |
1028 | 6409 |
|
6410 |
self nextToken. |
|
1436 | 6411 |
tokenType = $} ifTrue:[ |
1028 | 6412 |
] ifFalse:[ |
1436 | 6413 |
tokenType == #'::' ifTrue:[ |
6414 |
"/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
6415 |
"/(which is a kludge) |
|
6416 |
self nextToken. |
|
6417 |
] ifFalse:[ |
|
1028 | 6418 |
self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
6419 |
position:pos1 to:tokenPosition. |
|
6420 |
]. |
|
6421 |
]. |
|
1436 | 6422 |
|
6423 |
"/ elem := self variable. |
|
6424 |
"/ (elem == #Error) ifTrue:[ |
|
6425 |
"/ (tokenType == #EOF) ifTrue:[ |
|
6426 |
"/ self syntaxError:'unterminated qualifiedName; ''}'' expected' |
|
6427 |
"/ position:pos1 to:tokenPosition |
|
6428 |
"/ ]. |
|
6429 |
"/ ^ #Error |
|
6430 |
"/ ]. |
|
6431 |
"/ errorFlag := false. |
|
6432 |
"/ (elem isVariable and:[elem isGlobal]) ifFalse:[ |
|
6433 |
"/ self warning:'elements of a qualifiedName should be globalIdentifiers' |
|
6434 |
"/ position:pos1 to:tokenPosition |
|
6435 |
"/ ]. |
|
6436 |
"/ elements add:elem. |
|
6437 |
"/ |
|
6438 |
"/ self nextToken. |
|
6439 |
"/ tokenType == #'::' ifTrue:[ |
|
6440 |
"/ "/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
6441 |
"/ "/(which is a kludge) |
|
6442 |
"/ self nextToken. |
|
6443 |
"/ ] ifFalse:[ |
|
6444 |
"/ tokenType ~~ $} ifTrue:[ |
|
6445 |
"/ self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
|
6446 |
"/ position:pos1 to:tokenPosition. |
|
6447 |
"/ ^ #Error |
|
6448 |
"/ ]. |
|
6449 |
"/ ]. |
|
6450 |
]. |
|
1437 | 6451 |
nm := (elements asStringWith:'::') asSymbol. |
1436 | 6452 |
^ ConstantNode type:#Symbol value:nm |
6453 |
||
6454 |
"/ elements size > 1 ifTrue:[ |
|
6455 |
"/ self syntaxError:'Sorry: qualified names are not yet implemented.'. |
|
6456 |
"/ ]. |
|
6457 |
"/ ^ elements first. |
|
924 | 6458 |
|
6459 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
6460 |
! |
|
6461 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6462 |
squeakComputedArray |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6463 |
|expressions elem pos1| |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6464 |
|
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6465 |
tokenType == $} ifTrue:[ |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6466 |
^ #() |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6467 |
]. |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6468 |
|
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6469 |
pos1 := tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6470 |
expressions := OrderedCollection new:20. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6471 |
[true] whileTrue:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6472 |
elem := self expression. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6473 |
(elem == #Error) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6474 |
(tokenType == #EOF) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6475 |
self syntaxError:'unterminated computed-array-element; ''}'' expected' |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6476 |
position:pos1 to:tokenPosition |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6477 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6478 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6479 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6480 |
expressions add:elem. |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6481 |
tokenType == $. ifFalse:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6482 |
^ expressions |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6483 |
]. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6484 |
self nextToken. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6485 |
tokenType == $} ifTrue:[ |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6486 |
^ expressions |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6487 |
]. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6488 |
]. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6489 |
"/ not reached |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6490 |
! |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6491 |
|
141 | 6492 |
unaryExpression |
6493 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6494 |
||
1328 | 6495 |
|receiver| |
141 | 6496 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
6497 |
receiver := self arrayIndexingExpression. |
141 | 6498 |
(receiver == #Error) ifTrue:[^ #Error]. |
1328 | 6499 |
^ self unaryExpressionFor:receiver |
6500 |
! |
|
6501 |
||
6502 |
unaryExpressionFor:receiverArg |
|
6503 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6504 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6505 |
|receiver expr sel pos pos2 note lNr arguments| |
1328 | 6506 |
|
6507 |
receiver := receiverArg. |
|
6508 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
6509 |
[ self isValidUnarySelector:tokenType ] whileTrue:[ |
663 | 6510 |
pos := tokenPosition. |
6511 |
pos2 := pos + tokenName size - 1. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6512 |
lNr := tokenLineNr. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
6513 |
sel := tokenName. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6514 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6515 |
self markSelector:sel from:pos to:pos2 receiverNode:receiver. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6516 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6517 |
self nextToken. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6518 |
tokenType == $( ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6519 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6520 |
"/ croquet/squeak extension - c/java-style arguments |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6521 |
arguments := self functionCallArgList. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6522 |
"/ synthetic selector: foo[:[with:[with:[...]]]] |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6523 |
arguments notEmpty ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6524 |
sel := sel , ':'. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6525 |
arguments size - 1 timesRepeat:[ sel := sel , 'with:' ]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6526 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6527 |
sel := self selectorCheck:sel for:receiver position:pos to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6528 |
expr := MessageNode receiver:receiver selector:sel args:arguments fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6529 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6530 |
self parseError:(expr errorString) position:pos to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6531 |
errorFlag := false. "ok, user wants it - so he'll get it" |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6532 |
expr := MessageNode receiver:receiver selector:sel args:arguments fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6533 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6534 |
expr lineNumber:lNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6535 |
note := self plausibilityCheck:receiver. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6536 |
note notNil ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6537 |
self warning:note position:pos to:pos2 |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6538 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6539 |
parseForCode ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6540 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6541 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6542 |
^ expr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6543 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6544 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6545 |
|
1022 | 6546 |
sel := self selectorCheck:sel for:receiver position:pos to:pos2. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6547 |
expr := UnaryNode receiver:receiver selector:sel fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6548 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6549 |
self parseError:(expr errorString) position:pos to:pos2. |
663 | 6550 |
errorFlag := false. "ok, user wants it - so he'll get it" |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6551 |
expr := UnaryNode receiver:receiver selector:sel fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6552 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6553 |
expr lineNumber:lNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6554 |
|
1193 | 6555 |
note := self plausibilityCheck:receiver. |
6556 |
note notNil ifTrue:[ |
|
6557 |
self warning:note position:pos to:pos2 |
|
6558 |
]. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
6559 |
parseForCode ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6560 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6561 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6562 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6563 |
receiver := expr. "/ for next message |
141 | 6564 |
]. |
6565 |
^ receiver |
|
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
6566 |
|
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
6567 |
"Modified: / 6.2.2000 / 14:54:20 / cg" |
141 | 6568 |
! |
6569 |
||
6570 |
variable |
|
1028 | 6571 |
"parse a simple (i.e. non-namespace-access path) variable; |
6572 |
return a node-tree, nil or #Error. |
|
6573 |
Does not advance to next token. |
|
6574 |
If undefined, notify error and correct if user wants to" |
|
141 | 6575 |
|
864 | 6576 |
|v pos1 pos2| |
687 | 6577 |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6578 |
v := self variableOrError:tokenName. |
664 | 6579 |
(v ~~ #Error) ifTrue:[ |
663 | 6580 |
(v isMemberOf:VariableNode) ifTrue:[ |
687 | 6581 |
self markVariable:v. |
663 | 6582 |
]. |
6583 |
^ v |
|
6584 |
]. |
|
865 | 6585 |
|
687 | 6586 |
pos1 := tokenPosition. |
864 | 6587 |
pos2 := pos1+tokenName size-1. |
6588 |
self markUnknownIdentifierFrom:pos1 to:pos2. |
|
664 | 6589 |
|
1089 | 6590 |
parseForCode == true ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6591 |
v := self correctVariable:tokenName atPosition:pos1 to:pos2. |
1089 | 6592 |
(v ~~ #Error) ifTrue:[^ v]. |
6593 |
]. |
|
6594 |
||
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
6595 |
self errorFlag:true. |
664 | 6596 |
|
141 | 6597 |
parseForCode ifFalse:[ |
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
6598 |
self rememberGlobalUsed:(Smalltalk undeclaredPrefix) , tokenName. |
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
6599 |
self rememberGlobalUsed:tokenName. |
141 | 6600 |
] ifTrue:[ |
663 | 6601 |
tokenName first isLowercase ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6602 |
parserFlags implicitSelfSends ifTrue:[ |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6603 |
^ UnaryNode receiver:(self selfNode) selector:('__' , tokenName) asSymbol. |
663 | 6604 |
]. |
6605 |
^ #Error |
|
6606 |
] |
|
141 | 6607 |
]. |
865 | 6608 |
|
869 | 6609 |
"/ self markGlobalIdentifierFrom:pos1 to:pos2. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6610 |
^ VariableNode globalNamed:tokenName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6611 |
|
687 | 6612 |
"Modified: / 16.4.1998 / 18:46:45 / cg" |
141 | 6613 |
! |
6614 |
||
0 | 6615 |
variableOrError |
1028 | 6616 |
"parse a simple (i.e. non-namespace-access path) variable; |
6617 |
return a node-tree, nil or #Error. |
|
6618 |
Does not advance to next token." |
|
0 | 6619 |
|
21 | 6620 |
^ self variableOrError:tokenName |
6621 |
! |
|
6622 |
||
6623 |
variableOrError:varName |
|
1028 | 6624 |
"parse a simple (i.e. non-namespace-access path) variable; |
6625 |
return a node-tree, nil or #Error. |
|
6626 |
Does not advance to next token." |
|
21 | 6627 |
|
1551 | 6628 |
|varIndex aClass searchBlock args vars sharedPools |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6629 |
tokenSymbol space classVarIndex holder node| |
0 | 6630 |
|
6631 |
"is it a block-arg or block-var ?" |
|
6632 |
searchBlock := currentBlock. |
|
6633 |
[searchBlock notNil] whileTrue:[ |
|
628 | 6634 |
vars := searchBlock variables. |
6635 |
vars notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6636 |
varIndex := vars findFirst:[:aBlockVar | aBlockVar name = varName]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6637 |
varIndex ~~ 0 ifTrue:[ |
628 | 6638 |
^ VariableNode type:#BlockVariable |
6639 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6640 |
token:(vars at:varIndex) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6641 |
index:varIndex |
628 | 6642 |
block:searchBlock |
6643 |
from:currentBlock |
|
6644 |
]. |
|
6645 |
]. |
|
6646 |
||
6647 |
args := searchBlock arguments. |
|
6648 |
args notNil ifTrue:[ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6649 |
varIndex := args findFirst:[:aBlockArg | aBlockArg name = varName]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6650 |
varIndex ~~ 0 ifTrue:[ |
628 | 6651 |
^ VariableNode type:#BlockArg |
6652 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6653 |
token:(args at:varIndex) |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6654 |
index:varIndex |
628 | 6655 |
block:searchBlock |
6656 |
from:currentBlock |
|
6657 |
]. |
|
6658 |
||
6659 |
]. |
|
6660 |
||
6661 |
searchBlock := searchBlock home |
|
0 | 6662 |
]. |
6663 |
||
6664 |
"is it a method-variable ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6665 |
(node := self nodeForMethodVariable:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6666 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6667 |
^ node |
0 | 6668 |
]. |
6669 |
||
6670 |
"is it a method-argument ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6671 |
(node := self nodeForMethodArg:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6672 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6673 |
^ node |
0 | 6674 |
]. |
6675 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6676 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6677 |
|con varNames| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6678 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6679 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6680 |
"/ search names of the context. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6681 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6682 |
con := contextToEvaluateIn. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6683 |
[con notNil] whileTrue:[ |
1446
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
6684 |
varNames := con argAndVarNames. |
690 | 6685 |
varNames size > 0 ifTrue:[ |
6686 |
varIndex := varNames lastIndexOf:varName. |
|
6687 |
varIndex ~~ 0 ifTrue:[ |
|
6688 |
^ VariableNode type:#ContextVariable |
|
6689 |
name:varName |
|
6690 |
context:con |
|
6691 |
index:varIndex |
|
6692 |
]. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6693 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6694 |
con := con home. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6695 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6696 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6697 |
|
0 | 6698 |
classToCompileFor notNil ifTrue:[ |
628 | 6699 |
"is it an instance-variable ?" |
6700 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6701 |
varIndex := (self classesInstVarNames) lastIndexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6702 |
varIndex ~~ 0 ifTrue:[ |
628 | 6703 |
classToCompileFor isMeta ifTrue:[ |
6704 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
6705 |
classVarIndex ~~ 0 ifTrue:[ |
|
6706 |
"/ give a warning - that maybe a common error |
|
825 | 6707 |
alreadyWarnedClassInstVarRefs isNil ifTrue:[ |
6708 |
alreadyWarnedClassInstVarRefs := Set new |
|
6709 |
]. |
|
6710 |
(alreadyWarnedClassInstVarRefs includes:varName) ifFalse:[ |
|
6711 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class-instance variable here.') withCRs. |
|
6712 |
alreadyWarnedClassInstVarRefs add:varName. |
|
6713 |
]. |
|
628 | 6714 |
]. |
6715 |
]. |
|
6716 |
parseForCode ifFalse:[self rememberInstVarUsed:varName]. |
|
6717 |
^ VariableNode type:#InstanceVariable |
|
6718 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6719 |
index:varIndex |
628 | 6720 |
selfValue:selfValue |
6721 |
]. |
|
6722 |
||
6723 |
"/ see if there is a corresponding classVar (for the warning) |
|
6724 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
6725 |
||
6726 |
"/ "is it a class-instance-variable ?" |
|
6727 |
"/ |
|
6728 |
"/ Notice: |
|
6729 |
"/ it is no longer allowed to fetch class-instance variables |
|
6730 |
"/ from instance methods ... |
|
6731 |
"/ (used to be in previous ST/X versions) |
|
6732 |
"/ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6733 |
varIndex := (self classesClassInstVarNames) lastIndexOf:varName. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6734 |
varIndex ~~ 0 ifTrue:[ |
628 | 6735 |
aClass := self inWhichClassIsClassInstVar:varName. |
6736 |
aClass notNil ifTrue:[ |
|
6737 |
classToCompileFor isMeta ifFalse:[ |
|
6738 |
classVarIndex == 0 ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6739 |
"/ there is no corresponding classVar; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6740 |
"/ wants to access classInstVar ? |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6741 |
contextToEvaluateIn notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6742 |
"/ allow it in a doIt ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6743 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6744 |
^ VariableNode type:#ClassInstanceVariable |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6745 |
name:varName |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6746 |
index:varIndex |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6747 |
selfClass:aClass |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6748 |
]. |
628 | 6749 |
self parseError:'access to class-inst-var from inst method is not allowed'. |
6750 |
^ #Error. |
|
6751 |
] ifFalse:[ |
|
6752 |
"/ give a warning - that maybe a common error |
|
738 | 6753 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class variable here (instMethods dont see classInstVars).') withCRs. |
628 | 6754 |
] |
6755 |
]. |
|
6756 |
||
6757 |
"/ OLD CODE: |
|
6758 |
"/ self warning:'access to class-inst-var from inst method will soon be no longer supported'. |
|
443
e7d0bad68d60
oops - previous versions allowed access to class-instance variables
Claus Gittinger <cg@exept.de>
parents:
432
diff
changeset
|
6759 |
"/ |
628 | 6760 |
"/ parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
6761 |
"/ ^ VariableNode type:#ClassInstanceVariable |
|
6762 |
"/ name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6763 |
"/ index:varIndex |
628 | 6764 |
"/ selfClass:aClass |
6765 |
"/ ]. |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6766 |
] ifFalse:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6767 |
"/ self halt:'oops - should not happen'. |
628 | 6768 |
] |
6769 |
]. |
|
6770 |
||
6771 |
"is it a class-variable ?" |
|
6772 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6773 |
varIndex := classVarIndex. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6774 |
varIndex ~~ 0 ifTrue:[ |
628 | 6775 |
aClass := self inWhichClassIsClassVar:varName. |
6776 |
aClass notNil ifTrue:[ |
|
6777 |
parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
|
6778 |
^ VariableNode type:#ClassVariable class:aClass name:varName |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6779 |
]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6780 |
"/ self halt:'oops - should not happen'. |
628 | 6781 |
]. |
6782 |
||
6783 |
"is it a private-class ?" |
|
6784 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6785 |
aClass := self classToLookForClassVars. |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6786 |
aClass := aClass theNonMetaclass. |
628 | 6787 |
(aClass privateClassesAt:varName) notNil ifTrue:[ |
6788 |
parseForCode ifFalse:[self rememberGlobalUsed:(aClass name , '::' , varName)]. |
|
6789 |
^ VariableNode type:#PrivateClass class:aClass name:varName |
|
6790 |
]. |
|
1551 | 6791 |
|
6792 |
" is it a pool-variable ?" |
|
6793 |
sharedPools := classToCompileFor theNonMetaclass sharedPools. |
|
6794 |
sharedPools notNil ifTrue:[ |
|
6795 |
sharedPools do:[:eachPoolName | |
|
6796 |
|sharedPool| |
|
6797 |
||
6798 |
sharedPool := Smalltalk classNamed:eachPoolName. |
|
1556 | 6799 |
sharedPool isNil ifTrue:[ |
6800 |
self warning:('No such pool: ' , eachPoolName). |
|
6801 |
] ifFalse:[ |
|
6802 |
(sharedPool includesKey:varName) ifTrue:[ |
|
6803 |
parseForCode ifFalse:[self rememberGlobalUsed:(sharedPool name , ':' , varName)]. |
|
6804 |
^ VariableNode type:#PoolVariable class:sharedPool name:varName |
|
6805 |
]. |
|
1551 | 6806 |
]. |
6807 |
]. |
|
6808 |
]. |
|
418 | 6809 |
]. |
6810 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6811 |
"is it in a namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6812 |
space := self findNameSpaceWith:varName. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6813 |
space notNil ifTrue:[ |
628 | 6814 |
space ~~ Smalltalk ifTrue:[ |
6815 |
parseForCode ifFalse:[self rememberGlobalUsed:(space name , '::' , varName)]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6816 |
space isNameSpace ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6817 |
^ VariableNode globalNamed:(space name , '::' , varName) |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6818 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6819 |
^ VariableNode type:#PrivateClass class:space name:varName |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6820 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6821 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6822 |
^ VariableNode globalNamed:varName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6823 |
]. |
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6824 |
|
0 | 6825 |
"is it a global-variable ?" |
63 | 6826 |
tokenSymbol := varName asSymbolIfInterned. |
6827 |
tokenSymbol notNil ifTrue:[ |
|
628 | 6828 |
(Smalltalk includesKey:tokenSymbol) ifTrue:[ |
6829 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6830 |
^ VariableNode globalNamed:tokenSymbol |
628 | 6831 |
] |
0 | 6832 |
]. |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6833 |
|
877 | 6834 |
"is it a workspace variable ?" |
6835 |
(requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
6836 |
"/ when parsing doits, this is done twice; |
|
6837 |
"/ first, for the parse, then as a block-code |
|
6838 |
"/ for the code. |
|
6839 |
"/ We only care for WorkspaceVars in doIts |
|
1440 | 6840 |
(self isDoIt) ifTrue:[ |
1295 | 6841 |
(Workspace notNil |
6842 |
and:[(holder := Workspace workspaceVariableAt:varName) notNil]) |
|
6843 |
ifTrue:[ |
|
6844 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
877 | 6845 |
] |
6846 |
] |
|
6847 |
]. |
|
1295 | 6848 |
"is it a doIt variable ?" |
6849 |
||
6850 |
"/ (requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
6851 |
"/ when parsing doits, this is done twice; |
|
6852 |
"/ first, for the parse, then as a block-code |
|
6853 |
"/ for the code. |
|
6854 |
"/ We only care for WorkspaceVars in doIts |
|
6855 |
||
1440 | 6856 |
(self isDoIt) ifTrue:[ |
1295 | 6857 |
(doItTemporaries notNil |
6858 |
and:[(holder := doItTemporaries at:varName asSymbol ifAbsent:nil) notNil]) |
|
6859 |
ifTrue:[ |
|
6860 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
6861 |
] |
|
6862 |
]. |
|
6863 |
"/ ]. |
|
0 | 6864 |
^ #Error |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6865 |
"Modified: / 5.11.2001 / 16:45:35 / cg" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6866 |
! ! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6867 |
|
1410 | 6868 |
!Parser methodsFor:'parsing-primitives & pragmas'! |
6869 |
||
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6870 |
checkForClosingAngle |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6871 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6872 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6873 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6874 |
self parseError:'bad primitive definition (''>'' expected)'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6875 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6876 |
! |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6877 |
|
1551 | 6878 |
parseExternalFunctionCallDeclaration |
6879 |
|callType cString cStream cParser returnType |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6880 |
functionName argTypes moduleName fn node args sel| |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6881 |
|
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6882 |
"callType is one of C: / cdecl: / api: / apicall:" |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6883 |
callType := tokenName asSymbol. |
1410 | 6884 |
|
6885 |
cString := source upTo:$>. |
|
6886 |
self nextToken. |
|
6887 |
cStream := cString readStream. |
|
6888 |
||
1551 | 6889 |
CParser isNil ifTrue:[ |
6890 |
self parseError:'no parser for cdecl'. |
|
1410 | 6891 |
^ -1 |
6892 |
]. |
|
1551 | 6893 |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6894 |
callType = #'cdecl:' ifTrue:[ |
1551 | 6895 |
cParser := CParser new. |
6896 |
cParser source:cStream scannerClass:CDeclScanner. |
|
6897 |
cParser nextToken. |
|
6898 |
returnType := cParser type. |
|
6899 |
||
6900 |
cParser tokenType ~~ #String ifTrue:[ |
|
6901 |
self parseError:'invalid cdecl - functionName expected'. |
|
6902 |
^ -1 |
|
6903 |
]. |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6904 |
functionName := cParser token asSymbol. |
1551 | 6905 |
cParser nextToken. |
6906 |
argTypes := cParser parseFunctionArgumentSpec. |
|
6907 |
||
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6908 |
(cParser tokenType == #Identifier and:[cParser token = #module]) ifTrue:[ |
1551 | 6909 |
cParser nextToken. |
6910 |
cParser tokenType ~~ $: ifTrue:[ |
|
6911 |
self parseError:'colon expected'. |
|
6912 |
^ -1 |
|
6913 |
]. |
|
6914 |
cParser nextToken. |
|
6915 |
cParser tokenType ~~ #String ifTrue:[ |
|
6916 |
self parseError:'invalid cdecl - moduleName expected'. |
|
6917 |
^ -1 |
|
6918 |
]. |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6919 |
moduleName := cParser token asSymbol. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6920 |
]. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6921 |
(argTypes size == 1 and:[argTypes first isCVoid]) ifTrue:[ |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6922 |
argTypes := #() |
1551 | 6923 |
]. |
6924 |
argTypes size ~~ methodArgNames size ifTrue:[ |
|
6925 |
self parseError:'number of method args does not match function arg list'. |
|
6926 |
]. |
|
6927 |
fn := ExternalLibraryFunction |
|
6928 |
name:functionName |
|
6929 |
module:moduleName |
|
6930 |
callType:callType |
|
6931 |
returnType:returnType |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6932 |
argumentTypes:argTypes asArray. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6933 |
|
1551 | 6934 |
args := (methodArgNames ? #()) collect:[:eachArgName | node := self nodeForMethodArg:eachArgName]. |
6935 |
sel := #( |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6936 |
invoke |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6937 |
invokeWith: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6938 |
invokeWith:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6939 |
invokeWith:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6940 |
invokeWith:with:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6941 |
invokeWith:with:with:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6942 |
invokeWith:with:with:with:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6943 |
invokeWith:with:with:with:with:with:with: |
1551 | 6944 |
) at:args size+1 ifAbsent:nil. |
6945 |
sel isNil ifTrue:[ |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6946 |
sel := #invokeWithArguments:. |
1551 | 6947 |
self halt. |
6948 |
||
6949 |
]. |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6950 |
node := MessageNode receiver:(ConstantNode type:nil value:fn) selector:sel args:args fold:false. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6951 |
tree := ReturnNode new expression:node. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6952 |
"/ self isSyntaxHighlighter ifFalse:[ self halt ]. |
1551 | 6953 |
^ -1 |
6954 |
]. |
|
6955 |
||
6956 |
self parseError:'unsupported external function call type: ' , callType. |
|
1410 | 6957 |
^ -1 |
1551 | 6958 |
|
6959 |
" |
|
6960 |
(Parser for:'foo <cdecl: void ''glFlush'' (void) module: ''GL''>') |
|
6961 |
nextToken; |
|
6962 |
parseMethod |
|
6963 |
" |
|
1410 | 6964 |
! |
6965 |
||
6966 |
parsePrimitive |
|
6967 |
"parse an ST-80 type primitive as '< primitive: nr >'; |
|
6968 |
return primitive number or #Error. |
|
6969 |
or a Squeak-style primitive, as '< primitive: string >'; |
|
6970 |
return primitive name or #Error. |
|
6971 |
||
6972 |
Also, ST-80 style resource specs are parsed; the result is |
|
6973 |
left (as side effect) in primitiveResource. |
|
6974 |
(maybe someone else knows what to do with it ...) |
|
6975 |
Well, as we now have this mechanism, I'll use it to mark methods which |
|
6976 |
do keyboard processing ... <resource: keyboard ( keys )> |
|
6977 |
For faster finding of used keyboard accelerators, |
|
6978 |
and to mark resource methods (image, menu or canvas resources). |
|
6979 |
||
6980 |
prim ::= st80Primitive | st80Pragma | stxPragma |
|
6981 |
squeakPrimitive | newSTXPrimitive | resourceDecl |
|
6982 |
||
6983 |
st80Primitive ::= 'primitive:' INTEGER |
|
6984 |
st80Pragma ::= 'exception:' ( 'handle | 'raise' | 'unwind' ) |
|
6985 |
stxPragma ::= 'context:' 'return' |
|
6986 |
||
6987 |
squeakPrimitive ::= 'primitive:' STRING |
|
6988 |
||
6989 |
newSTXPrimitive ::= 'primitive' |
|
6990 |
||
6991 |
resourceDecl ::= 'resource:' SYMBOL - leave SYMBOL in primitiveResource |
|
6992 |
| 'resource:' SYMBOL (...) - leave (SYMBOL (...)) in primitiveResource |
|
6993 |
" |
|
6994 |
||
6995 |
(tokenType == #Keyword or:[tokenType == #Identifier]) ifFalse:[ |
|
6996 |
self parseError:'bad primitive definition (keyword expected)'. |
|
6997 |
^ #Error |
|
6998 |
]. |
|
6999 |
||
7000 |
(tokenName = 'primitive:') ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7001 |
^ self parseTraditionalPrimitive. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7002 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7003 |
(tokenName = 'primitive') ifTrue:[ |
1410 | 7004 |
self nextToken. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7005 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7006 |
^ 0. "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7007 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7008 |
(tokenName = 'resource:') ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7009 |
self parseResourcePragma. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7010 |
^ nil. "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7011 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7012 |
(tokenName = 'exception:' |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7013 |
or:[tokenName = 'context:']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7014 |
self parseExceptionOrContextPragma. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7015 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7016 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7017 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7018 |
(tokenName = 'C:') ifTrue:[ |
1551 | 7019 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7020 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7021 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7022 |
(tokenName = 'api:') ifTrue:[ |
1551 | 7023 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7024 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7025 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7026 |
(tokenName = 'apicall:') ifTrue:[ |
1551 | 7027 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7028 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7029 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7030 |
(tokenName = 'cdecl:') ifTrue:[ |
1551 | 7031 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7032 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7033 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7034 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7035 |
self parseError:'unrecognized pragma: ' , tokenName. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7036 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7037 |
"/ skip |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7038 |
[tokenType ~~ #EOF] whileTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7039 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7040 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7041 |
^ nil "/ no primitive number |
1410 | 7042 |
]. |
7043 |
self nextToken. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7044 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7045 |
^ nil "/ no primitive number |
1410 | 7046 |
! |
7047 |
||
7048 |
parsePrimitiveOrResourceSpecOrEmpty |
|
7049 |
"parse a methods primitive or resource spec" |
|
7050 |
||
7051 |
|pos wmsg primNr primNrOrString| |
|
7052 |
||
7053 |
[(tokenType == #BinaryOperator) and:[tokenName = '<']] whileTrue:[ |
|
7054 |
pos := tokenPosition. |
|
7055 |
self nextToken. |
|
7056 |
primNrOrString := self parsePrimitive. |
|
7057 |
||
7058 |
(primNrOrString == #Error) ifTrue:[^ #Error]. |
|
7059 |
wmsg := nil. |
|
7060 |
||
7061 |
primNrOrString isString ifTrue:[ |
|
7062 |
primNr := self primitiveNumberFromName:primNrOrString |
|
7063 |
] ifFalse:[ |
|
7064 |
primNr := primNrOrString |
|
7065 |
]. |
|
7066 |
||
7067 |
primNr notNil ifTrue:[ |
|
7068 |
primNr < 0 ifTrue:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7069 |
parserFlags warnST80Directives == true ifTrue:[ |
1410 | 7070 |
wmsg := 'ST-80/Squeak directive ignored'. |
7071 |
]. |
|
7072 |
] ifFalse:[ |
|
7073 |
primNr > 0 ifTrue:[ |
|
7074 |
primitiveNr := primNr. |
|
7075 |
wmsg := 'ST-80 primitive may not work' |
|
7076 |
] ifFalse:[ |
|
7077 |
primitiveNr := primNr. |
|
7078 |
wmsg := 'ST/X primitives only work in rel5 and newer' |
|
7079 |
] |
|
7080 |
]. |
|
1551 | 7081 |
wmsg notNil ifTrue:[self warning:wmsg position:pos] |
7082 |
]. |
|
1410 | 7083 |
]. |
7084 |
||
7085 |
"Created: 27.4.1996 / 16:55:55 / cg" |
|
7086 |
"Modified: 29.5.1996 / 17:25:52 / cg" |
|
7087 |
! |
|
7088 |
||
7089 |
parseResourcePragma |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7090 |
" '< resource:' has already been parsed." |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7091 |
|
1410 | 7092 |
|keys resource resourceValue| |
7093 |
||
7094 |
self nextToken. |
|
7095 |
(tokenType ~~ #Symbol) ifTrue:[ |
|
7096 |
self parseError:'symbol expected'. |
|
7097 |
^ #Error |
|
7098 |
]. |
|
7099 |
||
7100 |
resource := tokenValue. |
|
7101 |
resourceValue := true. |
|
7102 |
||
7103 |
self nextToken. |
|
7104 |
||
7105 |
tokenType == $( ifTrue:[ |
|
7106 |
self nextToken. |
|
7107 |
keys := OrderedCollection new. |
|
7108 |
[(tokenType == $)) or:[tokenType == #EOF] ] whileFalse:[ |
|
7109 |
keys add:tokenValue. |
|
7110 |
self nextToken. |
|
7111 |
]. |
|
7112 |
resourceValue := keys. |
|
7113 |
(tokenType == $)) ifFalse:[ |
|
7114 |
self parseError:'unterminated primitive/spec (missing '')'')'. |
|
7115 |
]. |
|
7116 |
self nextToken. |
|
7117 |
]. |
|
7118 |
||
7119 |
primitiveResource isNil ifTrue:[ |
|
7120 |
primitiveResource := IdentityDictionary new. |
|
7121 |
]. |
|
7122 |
primitiveResource at:(resource asSymbol) put:resourceValue. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7123 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7124 |
! |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7125 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7126 |
parseTraditionalPrimitive |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7127 |
"parse everything after the initial '<primitive:'" |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7128 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7129 |
|primNumber| |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7130 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7131 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7132 |
(tokenType == #Integer) ifFalse:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7133 |
parserFlags allowSqueakExtensions ifTrue:[ |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7134 |
(tokenType == #String) ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7135 |
self parseError:'primitive number or name expected'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7136 |
^ #Error |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7137 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7138 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7139 |
self parseError:'primitive number expected'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7140 |
^ #Error |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7141 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7142 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7143 |
primitiveNr notNil ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7144 |
self parseError:'only one primitive spec allowed'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7145 |
primNumber := -1. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7146 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7147 |
primNumber := tokenValue. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7148 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7149 |
self nextToken. |
1556 | 7150 |
|
7151 |
(tokenType == #Keyword) ifTrue:[ |
|
7152 |
(tokenName = 'errorCode:') ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7153 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7154 |
(tokenType == #Identifier) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7155 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7156 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7157 |
self error:'not yet implemented'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7158 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7159 |
]. |
1556 | 7160 |
(tokenName = 'module:') ifTrue:[ |
7161 |
self nextToken. |
|
7162 |
(tokenType == #String) ifTrue:[ |
|
7163 |
self nextToken. |
|
7164 |
] ifFalse:[ |
|
7165 |
self error:'not yet implemented'. |
|
7166 |
] |
|
7167 |
]. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7168 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7169 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7170 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7171 |
^ primNumber |
1410 | 7172 |
! |
7173 |
||
7174 |
primitiveNumberFromName:aPrimitiveName |
|
7175 |
"for future compatibility with Squeak ..." |
|
7176 |
||
7177 |
^ nil |
|
7178 |
! ! |
|
7179 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7180 |
!Parser methodsFor:'private'! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7181 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7182 |
currentNameSpace |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7183 |
|spc| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7184 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7185 |
spc := currentNamespace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7186 |
spc isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7187 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7188 |
spc := requestor currentNameSpace |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7189 |
] ifFalse:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7190 |
spc := Class nameSpaceQuerySignal query. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7191 |
]. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7192 |
currentNamespace := spc. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7193 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7194 |
^ spc |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7195 |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7196 |
"Created: / 19.12.1996 / 23:47:58 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7197 |
"Modified: / 14.10.1997 / 20:56:06 / cg" |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7198 |
"Modified: / 18.3.1999 / 18:25:50 / stefan" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7199 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7200 |
|
492
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7201 |
currentNameSpace:aNameSpace |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7202 |
currentNamespace := aNameSpace. |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7203 |
|
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7204 |
"Created: 8.2.1997 / 19:37:03 / cg" |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7205 |
! |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7206 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7207 |
currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7208 |
|pkg| |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7209 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7210 |
pkg := currentPackage. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7211 |
pkg isNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7212 |
(requestor respondsTo:#currentPackage) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7213 |
pkg := requestor currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7214 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7215 |
pkg := Class packageQuerySignal query. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7216 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7217 |
currentPackage := pkg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7218 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7219 |
^ pkg |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7220 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7221 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7222 |
currentPackage:aPackageName |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7223 |
currentPackage := aPackageName. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7224 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7225 |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7226 |
currentUsedNameSpaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7227 |
|spaces| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7228 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7229 |
spaces := currentUsedNamespaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7230 |
spaces isNil ifTrue:[ |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7231 |
(requestor respondsTo:#usedNameSpaces) ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7232 |
spaces := requestor usedNameSpaces |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7233 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7234 |
spaces := Class usedNameSpaceQuerySignal query. |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7235 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7236 |
spaces isNil ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7237 |
spaces := #() |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7238 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7239 |
currentUsedNamespaces := spaces. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7240 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7241 |
^ spaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7242 |
|
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7243 |
"Created: / 19.12.1996 / 23:49:10 / cg" |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7244 |
"Modified: / 7.4.1998 / 08:59:28 / cg" |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7245 |
"Modified: / 18.3.1999 / 18:25:57 / stefan" |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7246 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7247 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7248 |
findNameSpaceWith:aVariableName |
692 | 7249 |
|ns currentSpace usedSpaces| |
486
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
7250 |
|
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
7251 |
"/ private names have already been searched for. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7252 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7253 |
classToCompileFor notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7254 |
"/ Q: |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7255 |
"/ consider private classes of superclasses. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7256 |
"/ or search in the top owing classes namespace only ? |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7257 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7258 |
"/ for now, ignore other private classes - they are only |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7259 |
"/ known to the corresponding ownerClass. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7260 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7261 |
"is it in the classes namespace ?" |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7262 |
|
1315 | 7263 |
ns := classToCompileFor topNameSpace. |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7264 |
(ns notNil |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7265 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
1142 | 7266 |
ns isNameSpace ifTrue:[ |
7267 |
(ns at:aVariableName) notNil ifTrue:[ |
|
7268 |
^ ns |
|
7269 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7270 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7271 |
]. |
494
bb3e71c90dfd
currentClasses nameSpace is first to look for globals.
Claus Gittinger <cg@exept.de>
parents:
493
diff
changeset
|
7272 |
|
495 | 7273 |
"/ ns := classToCompileFor nameSpace. |
7274 |
"/ ns notNil ifTrue:[ |
|
7275 |
"/ "is it in the current classes namespace ?" |
|
7276 |
"/ (ns at:aVariableName asSymbol) notNil ifTrue:[ |
|
7277 |
"/ ^ ns |
|
7278 |
"/ ] |
|
7279 |
"/ ]. |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7280 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7281 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7282 |
"is it in the current namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7283 |
currentSpace := self currentNameSpace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7284 |
(currentSpace notNil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7285 |
and:[currentSpace ~~ Smalltalk]) ifTrue:[ |
1043 | 7286 |
currentSpace isNameSpace ifTrue:[ |
7287 |
(currentSpace at:aVariableName) notNil ifTrue:[ |
|
7288 |
^ currentSpace |
|
7289 |
] |
|
7290 |
] ifFalse:[ |
|
7291 |
(currentSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
|
7292 |
^ currentSpace |
|
7293 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7294 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7295 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7296 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7297 |
"is it in one of the used namespaces ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7298 |
usedSpaces := self currentUsedNameSpaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7299 |
usedSpaces notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7300 |
usedSpaces do:[:aNameSpace | |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7301 |
(aNameSpace at:aVariableName) notNil ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7302 |
^ aNameSpace |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7303 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7304 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7305 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7306 |
^ nil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7307 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7308 |
"Created: 19.12.1996 / 23:51:02 / cg" |
619 | 7309 |
"Modified: 14.10.1997 / 20:56:35 / cg" |
713 | 7310 |
! |
7311 |
||
1327 | 7312 |
implementedInAnyClass:selector |
7313 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
1518 | 7314 |
(cls includesSelector:selector) ifTrue:[^ true]. |
1327 | 7315 |
]. |
7316 |
^ false |
|
7317 |
! |
|
7318 |
||
713 | 7319 |
inWhichClassIsClassInstVar:aString |
7320 |
"search class-chain for the class-instance variable named aString |
|
7321 |
- return the class or nil if not found" |
|
7322 |
||
7323 |
|aClass| |
|
7324 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7325 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7326 |
|
713 | 7327 |
[aClass notNil] whileTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7328 |
(aClass class instVarNames includes:aString) ifTrue:[ ^ aClass]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7329 |
aClass := aClass superclass |
713 | 7330 |
]. |
7331 |
^ nil |
|
7332 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7333 |
"Modified: / 18.6.1998 / 15:45:34 / cg" |
713 | 7334 |
! |
7335 |
||
7336 |
inWhichClassIsClassVar:aString |
|
7337 |
"search class-chain for the classvariable named aString |
|
7338 |
- return the class or nil if not found" |
|
7339 |
||
7340 |
|aClass className baseClass| |
|
7341 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7342 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7343 |
|
713 | 7344 |
aClass isMeta ifTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7345 |
className := aClass name copyWithoutLast:6. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7346 |
baseClass := Smalltalk at:(className asSymbol). |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7347 |
baseClass notNil ifTrue:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7348 |
aClass := baseClass |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7349 |
] |
713 | 7350 |
]. |
7351 |
^ aClass whichClassDefinesClassVar:aString |
|
7352 |
||
7353 |
"/ [aClass notNil] whileTrue:[ |
|
7354 |
"/ (aClass classVarNames includes:aString) ifTrue:[ ^ aClass]. |
|
7355 |
"/ aClass := aClass superclass |
|
7356 |
"/ ]. |
|
7357 |
"/ ^ nil |
|
7358 |
||
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7359 |
"Modified: / 17.6.1996 / 17:18:41 / stefan" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7360 |
"Modified: / 18.6.1998 / 15:45:29 / cg" |
787 | 7361 |
! |
7362 |
||
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7363 |
isStatementAnUnconditionalReturn:aStatementNode |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7364 |
|expr selector block1 block2 stats1 stats2| |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7365 |
|
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7366 |
aStatementNode isReturnNode ifTrue:[^ true ]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7367 |
((expr := aStatementNode expression) notNil |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7368 |
and:[expr isMessage]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7369 |
selector := expr selector. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7370 |
(selector == #'ifTrue:ifFalse:' or:[selector == #'ifFalse:ifTrue:']) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7371 |
block1 := expr arg1. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7372 |
block2 := expr arguments at:2. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7373 |
(block1 isBlockNode and:[ block2 isBlockNode]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7374 |
stats1 := block1 statements. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7375 |
stats2 := block2 statements. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7376 |
(stats1 notEmptyOrNil and:[ stats2 notEmptyOrNil]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7377 |
^ (self isStatementAnUnconditionalReturn:stats1 last) |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7378 |
and:[self isStatementAnUnconditionalReturn:stats2 last] |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7379 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7380 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7381 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7382 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7383 |
^ false. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7384 |
! |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7385 |
|
1615 | 7386 |
makeImmutableArray:anArray |
1621 | 7387 |
^ self class makeImmutableArray:anArray |
1615 | 7388 |
! |
7389 |
||
7390 |
makeImmutableString:aString |
|
1621 | 7391 |
^ self class makeImmutableString:aString |
1615 | 7392 |
! |
7393 |
||
1262 | 7394 |
makeReferenceFor:aNode |
7395 |
|rec sel indexNode contextNode arg1 arg2| |
|
7396 |
||
7397 |
contextNode := VariableNode type:#ThisContext context:contextToEvaluateIn. |
|
7398 |
indexNode := ConstantNode type:#Integer value:aNode index. |
|
7399 |
||
7400 |
aNode isArgument ifTrue:[ |
|
7401 |
sel := #forArgument:in:. |
|
7402 |
arg1 := indexNode. |
|
7403 |
arg2 := contextNode. |
|
7404 |
] ifFalse:[ |
|
7405 |
aNode isLocal ifTrue:[ |
|
7406 |
sel := #forLocal:in:. |
|
7407 |
arg1 := indexNode. |
|
7408 |
arg2 := contextNode. |
|
7409 |
] ifFalse:[ |
|
7410 |
self parseError:'unsupported variable reference (must be local or argument)'. |
|
7411 |
^ aNode |
|
7412 |
] |
|
7413 |
]. |
|
7414 |
||
7415 |
parseForCode ifFalse:[self rememberGlobalUsed:'Reference']. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7416 |
rec := VariableNode globalNamed:'Reference'. |
1262 | 7417 |
|
7418 |
^ MessageNode receiver:rec selector:sel arg1:arg1 arg2:arg2. |
|
7419 |
! |
|
7420 |
||
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7421 |
noAssignmentAllowed:eMsg at:pos |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7422 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7423 |
self parseError:eMsg position:pos to:tokenPosition + tokenType size - 1. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7424 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7425 |
^ false |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7426 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7427 |
self nextToken. "/ eat the assign when doing highlighting only |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7428 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7429 |
^ true |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7430 |
! |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7431 |
|
787 | 7432 |
plausibilityCheck:aNode |
1193 | 7433 |
|note| |
7434 |
||
7435 |
note := aNode plausibilityCheck. |
|
7436 |
note isNil ifTrue:[ |
|
7437 |
aNode isMessage ifTrue:[ |
|
7438 |
(contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
|
7439 |
aNode receiver isSuper ifTrue:[ |
|
1535 | 7440 |
aNode receiver isHere ifFalse:[ |
7441 |
aNode selector ~= selector ifTrue:[ |
|
7442 |
^ 'possible bad super message (selector should be same as in current method) ?' |
|
7443 |
] |
|
1193 | 7444 |
]. |
7445 |
]. |
|
7446 |
]. |
|
7447 |
]. |
|
7448 |
]. |
|
7449 |
^ note |
|
1262 | 7450 |
! |
7451 |
||
7452 |
selfNode |
|
7453 |
selfNode isNil ifTrue:[ |
|
7454 |
selfNode := SelfNode value:selfValue |
|
7455 |
]. |
|
7456 |
^ selfNode |
|
141 | 7457 |
! ! |
7458 |
||
7459 |
!Parser methodsFor:'queries'! |
|
7460 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7461 |
classToLookForClassVars |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7462 |
"helper - return the class to look for classVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7463 |
If there is a context in which we evaluate, the |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7464 |
methods implementing class is used instead of the |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7465 |
class of the receiver." |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7466 |
|
1160 | 7467 |
|m who| |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7468 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7469 |
contextToEvaluateIn notNil ifTrue:[ |
748 | 7470 |
m := contextToEvaluateIn method. |
7471 |
m notNil ifTrue:[ |
|
7472 |
who := contextToEvaluateIn method who. |
|
7473 |
who notNil ifTrue:[ |
|
7474 |
^ who methodClass. |
|
7475 |
] |
|
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7476 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7477 |
"/ mhmh - might be a doIt ... |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7478 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7479 |
^ classToCompileFor |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7480 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7481 |
"Created: / 18.6.1998 / 15:43:42 / cg" |
748 | 7482 |
"Modified: / 21.7.1998 / 18:19:52 / cg" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7483 |
! |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7484 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7485 |
classesClassInstVarNames |
141 | 7486 |
"caching allInstVarNames for next compilation saves time ..." |
7487 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7488 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7489 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7490 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7491 |
|cls| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7492 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7493 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7494 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7495 |
(PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7496 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7497 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7498 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7499 |
PrevClass := cls. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7500 |
|
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7501 |
PrevClassInstVarNames := cls class allInstVarNames. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7502 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7503 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7504 |
names := PrevClassInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7505 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7506 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7507 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7508 |
"Created: / 14.10.1996 / 18:03:35 / cg" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7509 |
"Modified: / 18.6.1998 / 15:44:41 / cg" |
0 | 7510 |
! |
7511 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7512 |
classesClassVarNames |
141 | 7513 |
"caching allClassVarNames for next compilation saves time ..." |
7514 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7515 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7516 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7517 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7518 |
|cls aClass| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7519 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7520 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7521 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7522 |
(PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7523 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7524 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7525 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7526 |
aClass := PrevClass := cls. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7527 |
aClass isMeta ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7528 |
aClass := aClass soleInstance. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7529 |
aClass isNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7530 |
aClass := classToCompileFor |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7531 |
] |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7532 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7533 |
PrevClassVarNames := aClass allClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7534 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7535 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7536 |
names := PrevClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7537 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7538 |
^ names |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
285
diff
changeset
|
7539 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7540 |
"Modified: / 17.6.1996 / 17:15:53 / stefan" |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7541 |
"Created: / 14.10.1996 / 18:02:41 / cg" |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7542 |
"Modified: / 18.6.1998 / 15:44:30 / cg" |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7543 |
! |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7544 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7545 |
classesInstVarNames |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7546 |
"caching allInstVarNames for next compilation saves time ..." |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7547 |
|
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7548 |
|names| |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7549 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7550 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7551 |
(PrevInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7552 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7553 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7554 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7555 |
PrevClass := classToCompileFor. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7556 |
PrevInstVarNames := classToCompileFor allInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7557 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7558 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7559 |
PrevClass addDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7560 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7561 |
names := PrevInstVarNames |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7562 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7563 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7564 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7565 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7566 |
"Created: 14.10.1996 / 18:00:26 / cg" |
0 | 7567 |
! |
7568 |
||
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7569 |
contextMustBeReturnable |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7570 |
^ primitiveContextInfo notNil |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7571 |
and:[ ^ primitiveContextInfo includes:('context:' -> #return) ] |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7572 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7573 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7574 |
! |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7575 |
|
141 | 7576 |
hasNonOptionalPrimitiveCode |
7577 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
7578 |
||
7579 |
^ hasNonOptionalPrimitiveCode |
|
0 | 7580 |
! |
7581 |
||
141 | 7582 |
hasPrimitiveCode |
7583 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
7584 |
||
7585 |
^ hasPrimitiveCode |
|
98 | 7586 |
! |
7587 |
||
1440 | 7588 |
isDoIt |
7589 |
^ (selector isNil or:[selector == #'doIt' or:[selector == #'doIt:']]) |
|
7590 |
! |
|
7591 |
||
883 | 7592 |
isSyntaxHighlighter |
7593 |
^ false |
|
7594 |
! |
|
7595 |
||
385 | 7596 |
lineNumberInfo |
7597 |
^ lineNumberInfo |
|
7598 |
||
7599 |
"Created: 21.10.1996 / 17:06:16 / cg" |
|
7600 |
! |
|
7601 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7602 |
lineNumberInfo:how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7603 |
lineNumberInfo := how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7604 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7605 |
"Created: 23.10.1996 / 15:39:43 / cg" |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7606 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7607 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7608 |
messagesSent |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7609 |
"return a collection with sent message selectors (valid after parsing). |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7610 |
Includes all sent messages (i.e. also sent super messages)" |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7611 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7612 |
^ (messagesSent ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7613 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7614 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7615 |
messagesSentToSelf |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7616 |
"return a collection with message selectors sent to self only (valid after parsing)" |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7617 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7618 |
^ (messagesSentToSelf ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7619 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7620 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7621 |
messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7622 |
"return a collection with message selectors sent to super only (valid after parsing)" |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7623 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7624 |
^ (messagesSentToSuper ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7625 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7626 |
|
141 | 7627 |
methodArgs |
7628 |
"return an array with methodarg names (valid after parsing spec)" |
|
7629 |
||
7630 |
^ methodArgNames |
|
7631 |
! |
|
7632 |
||
7633 |
methodVars |
|
7634 |
"return a collection with method variablenames (valid after parsing)" |
|
7635 |
||
7636 |
^ methodVarNames |
|
23 | 7637 |
! |
7638 |
||
141 | 7639 |
modifiedClassVars |
7640 |
"return a collection with classvariablenames modified by method (valid after parsing)" |
|
7641 |
||
541 | 7642 |
^ modifiedClassVars ? #() |
7643 |
||
7644 |
"Modified: 19.6.1997 / 17:54:48 / cg" |
|
141 | 7645 |
! |
7646 |
||
7647 |
modifiedGlobals |
|
7648 |
"return a collection with globalnames modified by method (valid after parsing)" |
|
7649 |
||
541 | 7650 |
^ modifiedGlobals ? #() |
7651 |
||
7652 |
"Modified: 19.6.1997 / 17:54:51 / cg" |
|
141 | 7653 |
! |
7654 |
||
7655 |
modifiedInstVars |
|
7656 |
"return a collection with instvariablenames modified by method (valid after parsing)" |
|
7657 |
||
541 | 7658 |
^ modifiedInstVars ? #() |
7659 |
||
7660 |
"Modified: 19.6.1997 / 17:54:27 / cg" |
|
0 | 7661 |
! |
7662 |
||
141 | 7663 |
numberOfMethodArgs |
7664 |
"return the number of methodargs (valid after parsing spec)" |
|
7665 |
||
7666 |
^ methodArgs size |
|
7667 |
! |
|
7668 |
||
7669 |
numberOfMethodVars |
|
7670 |
"return the number of method variables (valid after parsing)" |
|
7671 |
||
7672 |
^ methodVars size |
|
7673 |
! |
|
7674 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7675 |
readClassVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7676 |
"return a collection with classvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7677 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7678 |
^ readClassVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7679 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7680 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7681 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7682 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7683 |
readInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7684 |
"return a collection with instvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7685 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7686 |
^ readInstVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7687 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7688 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7689 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7690 |
|
141 | 7691 |
selector |
7692 |
"return the selector (valid after parsing spec)" |
|
7693 |
||
7694 |
^ selector |
|
0 | 7695 |
! |
7696 |
||
141 | 7697 |
usedClassVars |
7698 |
"return a collection with classvariablenames refd by method (valid after parsing)" |
|
7699 |
||
541 | 7700 |
^ usedClassVars ? #() |
7701 |
||
7702 |
"Modified: 19.6.1997 / 17:54:56 / cg" |
|
141 | 7703 |
! |
7704 |
||
7705 |
usedGlobals |
|
7706 |
"return a collection with globalnames refd by method (valid after parsing)" |
|
7707 |
||
541 | 7708 |
^ usedGlobals ? #() |
7709 |
||
7710 |
"Modified: 19.6.1997 / 17:55:00 / cg" |
|
141 | 7711 |
! |
7712 |
||
7713 |
usedInstVars |
|
7714 |
"return a collection with instvariablenames refd by method (valid after parsing)" |
|
7715 |
||
541 | 7716 |
^ usedInstVars ? #() |
7717 |
||
7718 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
141 | 7719 |
! |
7720 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7721 |
usedSymbols |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7722 |
"return a collection with used symbols (except for sent messages) (valid after parsing)" |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7723 |
|
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7724 |
^ (usedSymbols ? #()) |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7725 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7726 |
|
141 | 7727 |
usedVars |
7728 |
"return a collection with variablenames refd by method (valid after parsing)" |
|
7729 |
||
541 | 7730 |
^ usedVars ? #() |
7731 |
||
7732 |
"Modified: 19.6.1997 / 17:55:04 / cg" |
|
0 | 7733 |
! |
7734 |
||
141 | 7735 |
usesSuper |
7736 |
"return true if the parsed method uses super (valid after parsing)" |
|
7737 |
||
7738 |
^ usesSuper |
|
7739 |
! ! |
|
7740 |
||
7741 |
!Parser methodsFor:'setup'! |
|
7742 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7743 |
arraysAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7744 |
^ parserFlags arraysAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7745 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7746 |
|
1615 | 7747 |
arraysAreImmutable:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7748 |
parserFlags arraysAreImmutable:aBoolean. |
1615 | 7749 |
! |
7750 |
||
1220
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7751 |
classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7752 |
^ classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7753 |
|
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7754 |
"Created: / 15.11.2001 / 17:21:10 / cg" |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7755 |
! |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7756 |
|
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7757 |
foldConstants:aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7758 |
"change the constant folding level. See the classMethod for a description." |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7759 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7760 |
foldConstants := aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7761 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7762 |
"Created: 21.3.1996 / 16:03:22 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7763 |
"Modified: 21.3.1996 / 16:05:04 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7764 |
! |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7765 |
|
141 | 7766 |
initialize |
7767 |
super initialize. |
|
7768 |
||
7769 |
hasPrimitiveCode := hasNonOptionalPrimitiveCode := false. |
|
7770 |
usesSuper := false. |
|
7771 |
parseForCode := false. |
|
377 | 7772 |
foldConstants := FoldConstants. |
7773 |
lineNumberInfo := LineNumberInfo. |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
7774 |
parenthesisLevel := 0. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7775 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7776 |
didWarnAboutSTXNameSpaceUse := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7777 |
didWarnAboutSTXHereExtensionUsed := false. |
607 | 7778 |
|
7779 |
"Modified: 7.9.1997 / 02:04:34 / cg" |
|
141 | 7780 |
! |
7781 |
||
7782 |
parseForCode |
|
7783 |
"turns off certain statistics (keeping referenced variables, modified vars etc.) |
|
7784 |
Use this when parsing for compilation or evaluation" |
|
7785 |
||
7786 |
parseForCode := true |
|
0 | 7787 |
! |
7788 |
||
141 | 7789 |
setClassToCompileFor:aClass |
7790 |
"set the class to be used for parsing/evaluating" |
|
7791 |
||
7792 |
classToCompileFor := aClass. |
|
7793 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
1576 | 7794 |
PrevClass notNil ifTrue:[ |
7795 |
Parser update:PrevClass |
|
7796 |
] |
|
141 | 7797 |
] |
7798 |
! |
|
7799 |
||
7800 |
setContext:aContext |
|
7801 |
"set the context used while evaluating" |
|
7802 |
||
7803 |
contextToEvaluateIn := aContext |
|
7804 |
! |
|
7805 |
||
7806 |
setSelf:anObject |
|
7807 |
"set the value to be used for self while evaluating" |
|
7808 |
||
7809 |
selfValue := anObject. |
|
7810 |
classToCompileFor := anObject class. |
|
7811 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
1576 | 7812 |
PrevClass notNil ifTrue:[ |
7813 |
Parser update:PrevClass |
|
7814 |
] |
|
141 | 7815 |
] |
607 | 7816 |
! |
7817 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7818 |
stringsAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7819 |
^ parserFlags stringsAreImmutable. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7820 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7821 |
|
1615 | 7822 |
stringsAreImmutable:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7823 |
parserFlags stringsAreImmutable:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7824 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7825 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7826 |
warnUndeclared |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7827 |
^ parserFlags warnUndeclared |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7828 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7829 |
"Created: 7.9.1997 / 02:05:00 / cg" |
1615 | 7830 |
! |
7831 |
||
607 | 7832 |
warnUndeclared:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7833 |
parserFlags warnUndeclared:aBoolean. |
607 | 7834 |
|
7835 |
"Created: 7.9.1997 / 02:05:00 / cg" |
|
1160 | 7836 |
! |
7837 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7838 |
warnUnusedVars |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7839 |
^ parserFlags warnUnusedVars |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7840 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7841 |
|
1160 | 7842 |
warnUnusedVars:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7843 |
parserFlags warnUnusedVars:aBoolean. |
0 | 7844 |
! ! |
7845 |
||
84 | 7846 |
!Parser methodsFor:'statistic'! |
7847 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7848 |
rememberClassVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7849 |
readClassVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7850 |
readClassVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7851 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7852 |
readClassVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7853 |
self rememberClassVarUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7854 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7855 |
|
141 | 7856 |
rememberClassVarUsed:name |
7857 |
usedClassVars isNil ifTrue:[ |
|
1576 | 7858 |
usedClassVars := Set new |
141 | 7859 |
]. |
7860 |
usedClassVars add:name. |
|
7861 |
self rememberVariableUsed:name |
|
7862 |
! |
|
7863 |
||
7864 |
rememberGlobalUsed:name |
|
7865 |
usedGlobals isNil ifTrue:[ |
|
1576 | 7866 |
usedGlobals := Set new |
141 | 7867 |
]. |
7868 |
usedGlobals add:name. |
|
7869 |
self rememberVariableUsed:name |
|
7870 |
! |
|
7871 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7872 |
rememberInstVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7873 |
readInstVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7874 |
readInstVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7875 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7876 |
readInstVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7877 |
self rememberVariableUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7878 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7879 |
|
141 | 7880 |
rememberInstVarUsed:name |
7881 |
usedInstVars isNil ifTrue:[ |
|
1576 | 7882 |
usedInstVars := Set new |
141 | 7883 |
]. |
7884 |
usedInstVars add:name. |
|
7885 |
self rememberVariableUsed:name |
|
7886 |
! |
|
7887 |
||
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7888 |
rememberLocalUsed:name |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7889 |
usedLocalVars isNil ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7890 |
usedLocalVars := Set new |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7891 |
]. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7892 |
usedLocalVars add:name. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7893 |
|
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7894 |
! |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7895 |
|
1231 | 7896 |
rememberReturnedValue:anExpressionNode |
7897 |
|expr| |
|
7898 |
||
7899 |
returnedValues isNil ifTrue:[returnedValues := Set new]. |
|
7900 |
||
7901 |
expr := anExpressionNode. |
|
7902 |
expr isAssignment ifTrue:[ |
|
7903 |
expr := expr expression. |
|
7904 |
]. |
|
7905 |
(expr isConstant or:[expr isSelf]) ifTrue:[ |
|
7906 |
returnedValues add:expr |
|
7907 |
]. |
|
7908 |
! |
|
7909 |
||
84 | 7910 |
rememberSelectorUsed:sel |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7911 |
messagesSent isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7912 |
messagesSent := IdentitySet new. |
84 | 7913 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7914 |
messagesSent add:sel |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7915 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7916 |
|
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7917 |
rememberSelectorUsed:sel receiver:receiverNode |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7918 |
self rememberSelectorUsed:sel. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7919 |
receiverNode isSuper ifTrue:[ |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7920 |
self rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7921 |
] ifFalse:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7922 |
receiverNode isSelf ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7923 |
self rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7924 |
]. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7925 |
]. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7926 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7927 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7928 |
rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7929 |
messagesSentToSelf isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7930 |
messagesSentToSelf := IdentitySet new. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7931 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7932 |
messagesSentToSelf add:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7933 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7934 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7935 |
rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7936 |
messagesSentToSuper isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7937 |
messagesSentToSuper := IdentitySet new. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7938 |
]. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7939 |
messagesSentToSuper add:sel |
84 | 7940 |
! |
7941 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7942 |
rememberSymbolUsed:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7943 |
usedSymbols isNil ifTrue:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7944 |
usedSymbols := IdentitySet new. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7945 |
]. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7946 |
usedSymbols add:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7947 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7948 |
|
84 | 7949 |
rememberVariableUsed:name |
7950 |
usedVars isNil ifTrue:[ |
|
1576 | 7951 |
usedVars := Set new |
84 | 7952 |
]. |
7953 |
usedVars add:name |
|
7954 |
! ! |
|
7955 |
||
1340 | 7956 |
!Parser::ParseError methodsFor:'accessing'! |
7957 |
||
1386 | 7958 |
description |
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7959 |
|s| |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7960 |
|
1461 | 7961 |
s := super description. |
7962 |
s last isSeparator ifFalse:[ |
|
7963 |
errorMessage size > 0 ifTrue:[ |
|
7964 |
s := s , ' ' |
|
7965 |
] |
|
7966 |
]. |
|
7967 |
s := s , (errorMessage ? ''). |
|
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7968 |
lineNumber notNil ifTrue:[ |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7969 |
s := s , ' [' , lineNumber asString , ']' |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7970 |
]. |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7971 |
^ s |
1386 | 7972 |
! |
7973 |
||
1340 | 7974 |
endPosition |
7975 |
^ endPosition |
|
7976 |
! |
|
7977 |
||
7978 |
errorMessage |
|
7979 |
^ errorMessage |
|
7980 |
! |
|
7981 |
||
1460 | 7982 |
errorMessage:errorMessageArg startPosition:startPositionArg |
7983 |
errorMessage := errorMessageArg. |
|
7984 |
startPosition := startPositionArg. |
|
7985 |
! |
|
7986 |
||
1340 | 7987 |
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg |
7988 |
errorMessage := errorMessageArg. |
|
7989 |
startPosition := startPositionArg. |
|
7990 |
endPosition := endPositionArg. |
|
7991 |
! |
|
7992 |
||
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7993 |
lineNumber:something |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7994 |
lineNumber := something. |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7995 |
! |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7996 |
|
1340 | 7997 |
parser |
7998 |
^ originator |
|
7999 |
! |
|
8000 |
||
8001 |
startPosition |
|
8002 |
^ startPosition |
|
8003 |
! ! |
|
8004 |
||
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8005 |
!Parser::UndefinedVariableNotification methodsFor:'accessing'! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8006 |
|
1514 | 8007 |
description |
1516 | 8008 |
^ 'undefined variable: ' , self variableName |
1514 | 8009 |
! |
8010 |
||
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8011 |
parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8012 |
"return the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8013 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8014 |
^ parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8015 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8016 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8017 |
parser:something |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8018 |
"set the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8019 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8020 |
parser := something. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8021 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8022 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8023 |
variableName |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8024 |
^ parameter |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8025 |
! ! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8026 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8027 |
!Parser class methodsFor:'documentation'! |
148 | 8028 |
|
8029 |
version |
|
1650 | 8030 |
^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.474 2006-01-11 15:35:29 cg Exp $' |
148 | 8031 |
! ! |
1322
da25e31f423c
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
8032 |
|
141 | 8033 |
Parser initialize! |