author | Claus Gittinger <cg@exept.de> |
Fri, 02 Dec 2005 12:28:55 +0100 | |
changeset 1643 | b52ed0b4a317 |
parent 1642 | 751a220b67be |
child 1647 | 89f03e0bc836 |
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 |
||
49 |
Parser::ParseError subclass:#UndefinedSuperclassError |
|
1579 | 50 |
instanceVariableNames:'' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:Parser |
|
971 | 54 |
! |
55 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
56 |
Notification subclass:#UndefinedVariableNotification |
1579 | 57 |
instanceVariableNames:'parser' |
58 |
classVariableNames:'' |
|
59 |
poolDictionaries:'' |
|
60 |
privateIn:Parser |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
61 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
62 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
63 |
!Parser class methodsFor:'documentation'! |
19 | 64 |
|
20 | 65 |
copyright |
66 |
" |
|
67 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1576 | 68 |
All Rights Reserved |
20 | 69 |
|
70 |
This software is furnished under a license and may be used |
|
71 |
only in accordance with the terms of that license and with the |
|
72 |
inclusion of the above copyright notice. This software may not |
|
73 |
be provided or otherwise made available to, or used by, any |
|
74 |
other person. No title to or ownership of the software is |
|
75 |
hereby transferred. |
|
76 |
" |
|
77 |
! |
|
78 |
||
19 | 79 |
documentation |
80 |
" |
|
81 |
Parser is used for both parsing and evaluating smalltalk expressions; |
|
82 |
it first builds a parseTree which is then interpreted (evaluate) or |
|
83 |
compiled. Compilation is done in the subclass ByteCodeCompiler and/or |
|
84 |
the (planned) MachineCodeCompiler. |
|
85 |
||
173
247ae4b8af76
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
171
diff
changeset
|
86 |
methods of main interest are: |
755 | 87 |
Parser evaluateExpression:... |
19 | 88 |
|
89 |
and: |
|
755 | 90 |
Parser parseExpression:... |
91 |
Parser parseMethod:... |
|
19 | 92 |
|
93 |
there is protocol to parse complete methods, selector specs, body only etc. |
|
94 |
||
95 |
Parser is also used to find the referenced/modified inst/classvars of |
|
96 |
a method - this is done by sending parseXXX message to a parser and asking |
|
97 |
the parser for referencedXVars or modifiedXVars (see SystemBrowser). |
|
98 |
||
99 |
You can also use parsers for all kinds of other things (ChangesBrowser for |
|
100 |
example analyzes the expressions in the changelist ...) by looking at the |
|
101 |
parsers tree. (Although this is somewhat dangerous, since it exports the |
|
755 | 102 |
compilers internals ... better style is to add specialized query methods here) |
19 | 103 |
|
104 |
One instance of Parser is created to parse one method or expression - i.e. |
|
105 |
its not suggested to reuse parsers. |
|
106 |
||
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
107 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
108 |
Constant folding: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
109 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
110 |
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
|
111 |
expressions involving integers and floats are constant folded |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
112 |
(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
|
113 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
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
|
118 |
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
|
119 |
Therefore, this mode is a bit dangerous and disabled by default. |
755 | 120 |
The current implementation, base upon a global constant-folding setting is somewhat stupid |
121 |
and intermediate - a better solution would be to allow the optimization to be controlled |
|
122 |
by a method-pragma, since it may make sense to disable optimization on a method level, |
|
123 |
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
|
124 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
125 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
126 |
Immutable arrays: |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
127 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
128 |
Immutable arrays are experimental and being evaluated. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
return the modified array. These are hard to find bugs. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
133 |
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
|
134 |
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
|
135 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
136 |
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
|
137 |
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
|
138 |
of st/x. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
139 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
140 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
141 |
|
260 | 142 |
[Instance variables:] |
143 |
||
755 | 144 |
classToCompileFor <Class> the class (or nil) we are compiling for |
145 |
||
146 |
selfValue <any> value to use as self when interpreting |
|
147 |
||
148 |
contextToEvaluateIn <Context> the context (or nil) when interpreting |
|
149 |
||
150 |
selector <Symbol> the selector of the parsed method |
|
151 |
(valid after parseMethodSpecification) |
|
152 |
methodArgs internal |
|
153 |
||
154 |
methodArgNames <Collection> the names of the arguments |
|
155 |
(valid after parseMethodSpecification) |
|
156 |
||
157 |
methodVars internal |
|
158 |
||
159 |
methodVarNames <Collection> the names of the method locals |
|
160 |
(valid after parseMethodBodyVarSpec) |
|
161 |
||
162 |
tree <ParseTree> the parse tree - valid after parsing |
|
163 |
||
164 |
currentBlock if currently parsing for a block |
|
165 |
||
166 |
usedInstVars set of all accessed instances variables |
|
167 |
(valid after parsing) |
|
168 |
||
169 |
usedClassVars same for classVars |
|
170 |
||
171 |
usedVars all used variables (inst, class & globals) |
|
172 |
||
173 |
modifiedInstVars set of all modified instance variables |
|
174 |
||
175 |
modifiedClassVars same for clasVars |
|
176 |
||
177 |
localVarDefPosition <Integer> the character offset of the local variable |
|
178 |
def. (i.e. the first '|' if any) |
|
179 |
Not yet used - prepared for automatic add of |
|
180 |
undefined variables |
|
181 |
||
182 |
evalExitBlock internal for interpretation |
|
183 |
||
184 |
selfNode <Node> cached one-and-only 'self' node |
|
185 |
superNode <Node> cached one-and-only 'super' node |
|
186 |
||
187 |
hasPrimitiveCode <Boolean> true, if it contains ST/X style primitive code |
|
188 |
hasNonOptionalPrimitiveCode |
|
189 |
<Boolean> true, if it contains ST/X style primitive code |
|
190 |
which is NOT flagged by the OPTIONAL directive. |
|
191 |
||
192 |
primitiveNr <Integer> the parsed ST-80 type primitive number (or nil) |
|
193 |
||
194 |
logged |
|
195 |
||
196 |
warnedUndefVars <Set> set of all variables which the parser has |
|
197 |
already output a warning (to avoid multiple |
|
198 |
warnings about the same variable) |
|
260 | 199 |
|
200 |
[Class variables:] |
|
201 |
||
755 | 202 |
PrevClass <Class> class, of which properties are |
203 |
cached in: |
|
204 |
||
205 |
PrevInstVarNames <Collection> instance variablenames of cached class |
|
206 |
PrevClassVarNames <Collection> class variablenames of cached class |
|
207 |
PrevClassInstVarNames <Collection> class instance variablenames of cached class |
|
208 |
||
209 |
LazyCompilation <Boolean> EXPERIMENTAL: lazy compilation |
|
210 |
||
211 |
ArraysAreImmutable <Boolean> if true, create array literals |
|
212 |
as instances of ImmutableArray, |
|
213 |
which cannot be stored into. |
|
214 |
Default is false, for compatibility. |
|
215 |
Can be turned on while developping |
|
216 |
new code to make certain that side |
|
217 |
effects are avoided. |
|
218 |
||
1615 | 219 |
StringsAreImmutable <Boolean> same as above for string literals |
220 |
||
755 | 221 |
WarnST80Directives <Boolean> if true, give warnings about |
222 |
ST-80 directives (resource defs) |
|
223 |
which are ignored in st/x. |
|
224 |
defaults to false. |
|
225 |
||
226 |
FoldConstants <Symbol> controls how constant folding should be |
|
227 |
done. |
|
228 |
Can be one of: |
|
229 |
nil - no constant folding |
|
230 |
#level1 - numeric optimizations only |
|
231 |
#level2 - secure optimizations only |
|
232 |
#full - full folding |
|
233 |
||
234 |
level1: arithmetic on constant numbers |
|
235 |
||
236 |
level2: above PLUS array conversions with #asFloatArray, |
|
237 |
#asDoubleArray, string concatenation |
|
238 |
||
239 |
full: constant points. |
|
260 | 240 |
|
241 |
[see also:] |
|
755 | 242 |
ByteCodeCompiler Scanner ObjectFileLoader |
243 |
Workspace |
|
244 |
SystemBrowser |
|
263 | 245 |
|
246 |
[author:] |
|
755 | 247 |
Claus Gittinger |
19 | 248 |
" |
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
249 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
250 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
251 |
examples |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
252 |
" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
253 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
254 |
Parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
255 |
evaluate:'1+2*3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
256 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
257 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
258 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
259 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
260 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
261 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
262 |
[exBegin] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
263 |
Parser undefinedVariableNotification handle:[:ex | |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
264 |
|badName| |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
265 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
266 |
badName := ex variableName. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
267 |
ex proceedWith:(ConstantNode value:5). |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
268 |
] do:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
269 |
^ self compilerClass |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
270 |
evaluate:'foo * 3' |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
271 |
in:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
272 |
receiver:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
273 |
notifying:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
274 |
logged:false |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
275 |
ifFail:nil |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
276 |
] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
277 |
[exEnd] |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
278 |
" |
141 | 279 |
! ! |
280 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
281 |
!Parser class methodsFor:'instance creation'! |
141 | 282 |
|
283 |
for:aStringOrStream in:aClass |
|
284 |
"return a new parser, reading code for aClass from aStringOrStream" |
|
285 |
||
286 |
|parser| |
|
287 |
||
288 |
parser := self for:aStringOrStream. |
|
289 |
parser setClassToCompileFor:aClass. |
|
290 |
^ parser |
|
291 |
! ! |
|
292 |
||
1419 | 293 |
!Parser class methodsFor:'Compatibility-ST80'! |
540 | 294 |
|
295 |
parse:aString class:aClass |
|
296 |
"same as #parseMethod:in: for ST80 compatibility." |
|
297 |
||
298 |
|parser| |
|
299 |
||
300 |
parser := self parseMethod:aString in:aClass. |
|
301 |
parser notNil ifTrue:[^ parser tree]. |
|
302 |
^ nil |
|
303 |
||
304 |
"Modified: 19.6.1997 / 16:34:57 / cg" |
|
305 |
! ! |
|
306 |
||
1419 | 307 |
!Parser class methodsFor:'Compatibility-Squeak'! |
920 | 308 |
|
309 |
evaluate:someString for:aReceiver logged:logged |
|
310 |
^ self evaluate:someString receiver:aReceiver logged:logged |
|
311 |
||
312 |
||
313 |
||
314 |
! ! |
|
315 |
||
1062 | 316 |
!Parser class methodsFor:'Signal constants'! |
317 |
||
318 |
parseErrorSignal |
|
319 |
^ ParseErrorSignal |
|
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
320 |
! |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
321 |
|
1468 | 322 |
restartCompilationSignal |
323 |
^ RestartCompilationSignal |
|
324 |
||
325 |
"Created: / 15.11.2001 / 22:57:05 / cg" |
|
326 |
! |
|
327 |
||
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
328 |
undefinedVariableNotification |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
329 |
^ UndefinedVariableNotification |
1062 | 330 |
! ! |
331 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
332 |
!Parser class methodsFor:'changes'! |
141 | 333 |
|
334 |
flushNameCache |
|
335 |
"unconditional flush name caches" |
|
336 |
||
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
337 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
338 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
339 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
340 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
341 |
PrevClass := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
342 |
PrevInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
343 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
344 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
345 |
] valueUninterruptably |
141 | 346 |
|
347 |
"Parser flushNameCache" |
|
348 |
! |
|
349 |
||
350 |
update:something with:someArgument from:changedObject |
|
351 |
"aClass has changed its definition - flush name caches if we have to" |
|
352 |
||
353 |
(changedObject == PrevClass) ifTrue:[ |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
354 |
something == #definition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
355 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
356 |
] |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
357 |
]. |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
358 |
(changedObject == Smalltalk) ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
359 |
something == #classDefinition ifTrue:[ |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
360 |
self flushNameCache |
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
361 |
] |
141 | 362 |
] |
363 |
! ! |
|
364 |
||
717 | 365 |
!Parser class methodsFor:'class initialization'! |
366 |
||
367 |
initialize |
|
368 |
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
|
369 |
|
717 | 370 |
FoldConstants := #level1. |
371 |
LineNumberInfo := false. |
|
372 |
||
1062 | 373 |
ParseErrorSignal isNil ifTrue:[ |
1380 | 374 |
ParseErrorSignal := ParseError. |
1062 | 375 |
ParseErrorSignal notifierString:'parse error'. |
1380 | 376 |
|
377 |
"/ ParseErrorSignal := Error newSignalMayProceed:true. |
|
378 |
"/ ParseErrorSignal notifierString:'parse error'. |
|
379 |
"/ ParseErrorSignal nameClass:self message:#parseErrorSignal. |
|
1062 | 380 |
]. |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
381 |
RestartCompilationSignal := Signal new. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
382 |
|
1090
7f49c607a315
catch change-notifications from Smalltalk (to flush PrevClass cache)
Claus Gittinger <cg@exept.de>
parents:
1089
diff
changeset
|
383 |
Smalltalk addDependent:self. |
1062 | 384 |
|
717 | 385 |
" |
386 |
self initialize |
|
387 |
" |
|
388 |
||
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
389 |
"Modified: / 15.11.2001 / 22:54:09 / cg" |
717 | 390 |
! ! |
391 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
392 |
!Parser class methodsFor:'controlling compilation'! |
141 | 393 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
394 |
allowArrayIndexSyntaxExtension |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
395 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
396 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
397 |
^ ParserFlags allowArrayIndexSyntaxExtension |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
398 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
399 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
400 |
allowArrayIndexSyntaxExtension:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
401 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
402 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
403 |
ParserFlags allowArrayIndexSyntaxExtension:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
404 |
|
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 |
self allowArrayIndexSyntaxExtension:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
407 |
self allowArrayIndexSyntaxExtension:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
408 |
" |
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 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
411 |
allowFunctionCallSyntaxForBlockEvaluation |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
412 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
413 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
414 |
^ ParserFlags allowFunctionCallSyntaxForBlockEvaluation |
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 |
allowFunctionCallSyntaxForBlockEvaluation:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
418 |
"experimental" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
419 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
420 |
ParserFlags allowFunctionCallSyntaxForBlockEvaluation:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
421 |
|
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 |
self allowFunctionCallSyntaxForBlockEvaluation:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
424 |
self allowFunctionCallSyntaxForBlockEvaluation:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
425 |
" |
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 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
428 |
allowReservedWordsAsSelectors |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
429 |
"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
|
430 |
as unary message selectors." |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
431 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
432 |
^ ParserFlags allowReservedWordsAsSelectors |
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:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
436 |
"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
|
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:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
440 |
self setupActions |
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 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
443 |
self allowReservedWordsAsSelectors:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
444 |
self allowReservedWordsAsSelectors:false |
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 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
447 |
|
141 | 448 |
arraysAreImmutable |
449 |
"return true if arrays are immutable literals" |
|
450 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
451 |
^ ParserFlags arraysAreImmutable |
141 | 452 |
! |
453 |
||
454 |
arraysAreImmutable:aBoolean |
|
455 |
"turn on/off immutable array literals - default is false for ST-80 compatibilty." |
|
456 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
457 |
ParserFlags arraysAreImmutable:aBoolean. |
141 | 458 |
|
459 |
" |
|
460 |
can be added to your private.rc file: |
|
461 |
||
462 |
Compiler arraysAreImmutable:true |
|
463 |
Compiler arraysAreImmutable:false |
|
464 |
" |
|
465 |
! |
|
466 |
||
467 |
compileLazy |
|
468 |
"return true if compiling lazy" |
|
469 |
||
470 |
^ LazyCompilation. |
|
471 |
! |
|
472 |
||
473 |
compileLazy:aBoolean |
|
474 |
"turn on/off lazy compilation - return previous setting. |
|
475 |
Actually this flag belongs into the ByteCodeCompiler subclass, |
|
476 |
but it also controls the reporting of some errors here; therefore |
|
477 |
its located here" |
|
478 |
||
479 |
|oldLazy| |
|
480 |
||
481 |
oldLazy := LazyCompilation. |
|
482 |
LazyCompilation := aBoolean. |
|
483 |
^ oldLazy |
|
484 |
||
485 |
" |
|
486 |
Compiler compileLazy:false |
|
487 |
Compiler compileLazy:true |
|
488 |
" |
|
489 |
! |
|
490 |
||
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
491 |
foldConstants |
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
492 |
"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
|
493 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
494 |
^ FoldConstants |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
495 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
496 |
"Created: 9.2.1996 / 17:40:13 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
497 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
498 |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
499 |
foldConstants:aSymbol |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
500 |
"set the symbol describing how constants are to be folded. |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
501 |
It can be: |
1576 | 502 |
nil - no constant folding |
503 |
#level1 - numeric constants only |
|
504 |
#level2 - level1 PLUS array conversions PLUS string concatenation |
|
505 |
#full - level2 PLUS constant points, constant rectangles (dangerous)" |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
506 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
210
diff
changeset
|
507 |
FoldConstants := aSymbol |
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
508 |
|
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
509 |
"Created: 9.2.1996 / 17:40:34 / cg" |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
510 |
! |
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
511 |
|
141 | 512 |
implicitSelfSends |
513 |
"return true if undefined variables with |
|
514 |
lowercase first character are to be turned |
|
515 |
into implicit self sends" |
|
516 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
517 |
^ ParserFlags implicitSelfSends |
141 | 518 |
! |
519 |
||
520 |
implicitSelfSends:aBoolean |
|
521 |
"turn on/off implicit self sends" |
|
522 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
523 |
ParserFlags implicitSelfSends:aBoolean |
141 | 524 |
|
525 |
" |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
526 |
ParserFlags implicitSelfSends:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
527 |
ParserFlags implicitSelfSends:false |
141 | 528 |
" |
377 | 529 |
! |
530 |
||
531 |
lineNumberInfo |
|
532 |
^ LineNumberInfo |
|
533 |
! |
|
534 |
||
535 |
lineNumberInfo:aBoolean |
|
536 |
LineNumberInfo := aBoolean |
|
752 | 537 |
! |
538 |
||
539 |
stringsAreImmutable |
|
540 |
"return true if strings are immutable literals" |
|
541 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
542 |
^ ParserFlags stringsAreImmutable |
752 | 543 |
|
544 |
"Created: / 3.8.1998 / 14:53:25 / cg" |
|
545 |
! |
|
546 |
||
547 |
stringsAreImmutable:aBoolean |
|
548 |
"turn on/off immutable string literals - default is false for ST-80 compatibilty." |
|
549 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
550 |
ParserFlags stringsAreImmutable:aBoolean. |
752 | 551 |
|
552 |
" |
|
553 |
can be added to your private.rc file: |
|
554 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
555 |
ParserFlags stringsAreImmutable:true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
556 |
ParserFlags stringsAreImmutable:false |
752 | 557 |
" |
558 |
||
559 |
"Created: / 3.8.1998 / 14:53:28 / cg" |
|
1160 | 560 |
! |
561 |
||
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
562 |
warnAboutVariableNameConventions |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
563 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
564 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
565 |
^ ParserFlags warnAboutVariableNameConventions |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
566 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
567 |
|
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
568 |
warnAboutVariableNameConventions:aBoolean |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
569 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
570 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
571 |
ParserFlags warnAboutVariableNameConventions:aBoolean |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
572 |
! |
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 |
warnAboutWrongVariableNames |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
575 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
576 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
577 |
^ ParserFlags warnAboutWrongVariableNames |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
578 |
! |
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 |
warnAboutWrongVariableNames:aBoolean |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
581 |
"controls generation of warning messages about wrong variable names" |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
582 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
583 |
ParserFlags warnAboutWrongVariableNames:aBoolean |
1523
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
584 |
! |
7846be9771d6
checkVariable-conventions accessors
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
585 |
|
1160 | 586 |
warnUnusedVars |
587 |
"controls generation of warning messages about unued method variables" |
|
588 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
589 |
^ ParserFlags warnUnusedVars |
1160 | 590 |
! |
591 |
||
592 |
warnUnusedVars:aBoolean |
|
593 |
"controls generation of warning messages about unued method variables" |
|
594 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
595 |
ParserFlags warnUnusedVars:aBoolean |
19 | 596 |
! ! |
0 | 597 |
|
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
598 |
!Parser class methodsFor:'defaults'! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
599 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
600 |
maxLineNumber |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
601 |
"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
|
602 |
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
|
603 |
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
|
604 |
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
|
605 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
606 |
^ 255 |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
607 |
|
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
608 |
"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
|
609 |
! ! |
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
610 |
|
1187 | 611 |
!Parser class methodsFor:'error correction'! |
612 |
||
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
613 |
findBest:nMax selectorsFor:aString in:aClassOrNil |
1187 | 614 |
"collect known selectors with their spelling distances to aString; |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
615 |
return the nMax best suggestions. If the argument, aClassOrNil is not nil, |
1187 | 616 |
the message is assumed to be sent to instances of that class (i.e. offer |
617 |
corrections from that hierarchy only)" |
|
618 |
||
1286 | 619 |
|info block lcSelector| |
1187 | 620 |
|
621 |
info := SortedCollection new. |
|
622 |
info sortBlock:[:a :b | a value > b value]. |
|
623 |
||
624 |
lcSelector := aString asLowercase. |
|
625 |
||
626 |
block := [:sym :mthd| |
|
1215 | 627 |
|dist lcSym keepThis| |
1187 | 628 |
|
629 |
lcSym := sym asLowercase. |
|
630 |
(info contains:[:i | i key == sym]) ifFalse:[ |
|
631 |
dist := lcSelector spellAgainst:lcSym. |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
632 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
633 |
(lcSym startsWith:lcSelector) ifTrue:[ |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
634 |
dist := dist + (aString size * 10). |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
635 |
]. |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
636 |
|
1215 | 637 |
(dist > 20) ifTrue:[ |
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
638 |
(info contains:[:entry | entry key = sym]) ifFalse:[ |
1215 | 639 |
keepThis := true. |
640 |
info size >= nMax ifTrue:[ |
|
641 |
"will remove last entry anyway - so check if this one will remain ..." |
|
642 |
dist < info last value ifTrue:[ |
|
643 |
keepThis := false. |
|
644 |
] |
|
645 |
]. |
|
646 |
keepThis ifTrue:[ |
|
647 |
"expensive - therefore do this check at last" |
|
648 |
mthd isObsolete ifFalse:[ |
|
649 |
info add:(sym -> dist). |
|
650 |
info size > nMax ifTrue:[ |
|
651 |
info removeLast. |
|
652 |
] |
|
653 |
] |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
654 |
] |
1187 | 655 |
] |
656 |
] |
|
657 |
] |
|
658 |
]. |
|
659 |
||
660 |
aClassOrNil isNil ifTrue:[ |
|
661 |
Smalltalk allClassesDo:[:cls | |
|
662 |
cls methodDictionary keysAndValuesDo:block. |
|
663 |
cls class methodDictionary keysAndValuesDo:block. |
|
664 |
] |
|
665 |
] ifFalse:[ |
|
666 |
aClassOrNil withAllSuperclassesDo:[:cls | |
|
667 |
cls methodDictionary keysAndValuesDo:block. |
|
1323 | 668 |
"/ cls class methodDictionary keysAndValuesDo:block. |
1187 | 669 |
] |
670 |
]. |
|
671 |
||
672 |
^ info asOrderedCollection collect:[:a | a key] |
|
673 |
||
674 |
"Modified: / 19.1.2000 / 16:43:37 / cg" |
|
1199
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
675 |
! |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
676 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
677 |
findBestSelectorsFor:aString |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
678 |
"collect known selectors with their spelling distances to aString; |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
679 |
return the 10 best suggestions" |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
680 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
681 |
^ self findBestSelectorsFor:aString in:nil |
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 |
Parser findBestSelectorsFor:'at' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
685 |
Parser findBestSelectorsFor:'at:pu' |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
686 |
" |
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 |
|
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
689 |
findBestSelectorsFor:aString in:aClassOrNil |
3ffc14d393a7
best selector matching improved
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
690 |
"collect known selectors with their spelling distances to aString; |
1323 | 691 |
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
|
692 |
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
|
693 |
corrections from that hierarchy only)" |
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 |
^ self |
1323 | 696 |
findBest:15 selectorsFor:aString in:aClassOrNil |
1187 | 697 |
! ! |
698 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
699 |
!Parser class methodsFor:'evaluating expressions'! |
0 | 700 |
|
19 | 701 |
evaluate:aStringOrStream |
71 | 702 |
"return the result of evaluating an expression in aStringOrStream. |
703 |
No doit-entry is added to the changeLog." |
|
0 | 704 |
|
19 | 705 |
^ self |
1576 | 706 |
evaluate:aStringOrStream |
707 |
in:nil |
|
708 |
receiver:nil |
|
709 |
notifying:nil |
|
710 |
logged:false |
|
711 |
ifFail:nil |
|
712 |
compile:true |
|
19 | 713 |
|
714 |
" |
|
715 |
Compiler evaluate:'1 + 2' |
|
716 |
Compiler evaluate:'''hello world'' asSortedCollection displayString printNL' |
|
717 |
Compiler evaluate:'''hello world'' asSortedCollection printNL' |
|
718 |
" |
|
0 | 719 |
! |
720 |
||
71 | 721 |
evaluate:aStringOrStream compile:compile |
722 |
"return the result of evaluating aString, |
|
723 |
The compile argument specifies if the string should be compiled down to |
|
724 |
bytecode or instead be interpreted from the parseTree. |
|
725 |
The first should be done for doIts etc, where a readable walkback is |
|
726 |
required. |
|
727 |
The latter is better done for constants, styleSheet and resource |
|
728 |
reading and simple sends, where the overhead of compilation is bigger |
|
729 |
than the interpretation overhead." |
|
730 |
||
731 |
^ self |
|
1576 | 732 |
evaluate:aStringOrStream |
733 |
in:nil |
|
734 |
receiver:nil |
|
735 |
notifying:nil |
|
736 |
logged:false |
|
737 |
ifFail:nil |
|
738 |
compile:compile |
|
71 | 739 |
! |
740 |
||
20 | 741 |
evaluate:aStringOrStream ifFail:failBlock |
742 |
"return the result of evaluating an expression in aStringOrStream. |
|
71 | 743 |
In case of any syntax errors, return the value of failBlock. |
744 |
No doit-entry is added to the changeLog." |
|
20 | 745 |
|
746 |
^ self |
|
1576 | 747 |
evaluate:aStringOrStream |
748 |
in:nil |
|
749 |
receiver:nil |
|
750 |
notifying:nil |
|
751 |
logged:false |
|
752 |
ifFail:failBlock |
|
753 |
compile:true |
|
20 | 754 |
" |
755 |
Compiler evaluate:'1 +' ifFail:['oops'] |
|
756 |
" |
|
757 |
! |
|
758 |
||
71 | 759 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor ifFail:failBlock |
760 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
761 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
762 |
No doIt entry is added to the change-file. |
|
763 |
If the failBlock argument is non-nil, it is evaluated if an error occurs." |
|
764 |
||
765 |
^ self |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
766 |
evaluate:aStringOrStream |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
767 |
in:aContext |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
768 |
receiver:anObject |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
769 |
notifying:requestor |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
770 |
logged:false |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
771 |
ifFail:nil |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
772 |
compile:true |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
773 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
774 |
"Modified: / 17.1.1998 / 02:54:07 / cg" |
20 | 775 |
! |
776 |
||
777 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock |
|
778 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
779 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
780 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
781 |
is non-nil, it is evaluated if an error occurs." |
|
782 |
||
71 | 783 |
^ self |
1576 | 784 |
evaluate:aStringOrStream |
785 |
in:aContext |
|
786 |
receiver:anObject |
|
787 |
notifying:requestor |
|
788 |
logged:logged |
|
789 |
ifFail:failBlock |
|
790 |
compile:true |
|
71 | 791 |
! |
792 |
||
793 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
794 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
795 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
796 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
797 |
is non-nil, it is evaluated if an error occurs. |
|
798 |
Finally, compile specifies if the string should be compiled down to |
|
799 |
bytecode or instead be interpreted from the parseTree. |
|
800 |
The first should be done for doIts etc, where a readable walkback is |
|
801 |
required. |
|
802 |
The latter is better done for constants, styleSheet and resource |
|
803 |
reading and simple sends, where the overhead of compilation is bigger |
|
804 |
than the interpretation overhead." |
|
805 |
||
1363 | 806 |
^ self new |
1548 | 807 |
evaluate:aStringOrStream |
808 |
in:aContext |
|
809 |
receiver:anObject |
|
810 |
notifying:requestor |
|
811 |
logged:logged |
|
812 |
ifFail:failBlock |
|
813 |
compile:compile |
|
1561
175735dcd732
do not check for endOfInput if parsing from a Stream
Claus Gittinger <cg@exept.de>
parents:
1557
diff
changeset
|
814 |
checkForEndOfInput:(aStringOrStream isStream not) |
141 | 815 |
! |
816 |
||
817 |
evaluate:aStringOrStream logged:logged |
|
818 |
"return the result of evaluating an expression in aStringOrStream. |
|
819 |
The argument log controls if an entry is added to the changeLog." |
|
820 |
||
821 |
^ self |
|
1576 | 822 |
evaluate:aStringOrStream |
823 |
in:nil |
|
824 |
receiver:nil |
|
825 |
notifying:nil |
|
826 |
logged:logged |
|
827 |
ifFail:nil |
|
828 |
compile:true |
|
141 | 829 |
" |
830 |
Compiler evaluate:'''some string''' logged:false |
|
831 |
Compiler evaluate:'''some string''' logged:true |
|
832 |
" |
|
833 |
! |
|
834 |
||
835 |
evaluate:aStringOrStream notifying:requestor |
|
836 |
"return the result of evaluating aString, |
|
837 |
errors are reported to requestor" |
|
838 |
||
839 |
^ self |
|
1576 | 840 |
evaluate:aStringOrStream |
841 |
in:nil |
|
842 |
receiver:nil |
|
843 |
notifying:requestor |
|
844 |
logged:false |
|
845 |
ifFail:nil |
|
846 |
compile:true |
|
141 | 847 |
! |
848 |
||
849 |
evaluate:aStringOrStream notifying:requestor compile:compile |
|
850 |
"return the result of evaluating aString, |
|
851 |
errors are reported to requestor. |
|
852 |
The compile argument specifies if the string should be compiled down to |
|
853 |
bytecode or instead be interpreted from the parseTree. |
|
854 |
The first should be done for doIts etc, where a readable walkback is |
|
855 |
required. |
|
856 |
The latter is better done for constants, styleSheet and resource |
|
857 |
reading and simple sends, where the overhead of compilation is bigger |
|
858 |
than the interpretation overhead." |
|
859 |
||
860 |
^ self |
|
1576 | 861 |
evaluate:aStringOrStream |
862 |
in:nil |
|
863 |
receiver:nil |
|
864 |
notifying:requestor |
|
865 |
logged:false |
|
866 |
ifFail:nil |
|
867 |
compile:compile |
|
141 | 868 |
! |
869 |
||
1025
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
870 |
evaluate:aStringOrStream notifying:requestor logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
871 |
"return the result of evaluating aString, |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
872 |
errors are reported to requestor" |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
873 |
|
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
874 |
^ self |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
875 |
evaluate:aStringOrStream |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
876 |
in:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
877 |
receiver:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
878 |
notifying:requestor |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
879 |
logged:logged |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
880 |
ifFail:nil |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
881 |
compile:true |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
882 |
! |
5b3022ecb269
added #evaluate:notifying:logged: (for RB)
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
883 |
|
572 | 884 |
evaluate:aStringOrStream receiver:anObject |
885 |
"return the result of evaluating aString, |
|
886 |
errors are reported to requestor. Allow access to |
|
887 |
anObject as self and to its instVars " |
|
888 |
||
889 |
^ self |
|
1576 | 890 |
evaluate:aStringOrStream |
891 |
in:nil |
|
892 |
receiver:anObject |
|
893 |
notifying:nil |
|
894 |
logged:false |
|
895 |
ifFail:nil |
|
896 |
compile:true |
|
572 | 897 |
|
898 |
" |
|
899 |
Compiler evaluate:'self x' receiver:(1 @ 2) |
|
900 |
" |
|
901 |
||
902 |
"Created: 1.7.1997 / 19:02:24 / cg" |
|
903 |
"Modified: 1.7.1997 / 19:02:33 / cg" |
|
904 |
! |
|
905 |
||
919 | 906 |
evaluate:aStringOrStream receiver:someOne logged:logged |
907 |
"return the result of evaluating an expression in aStringOrStream. |
|
908 |
The argument log controls if an entry is added to the changeLog." |
|
909 |
||
910 |
^ self |
|
911 |
evaluate:aStringOrStream |
|
912 |
in:nil |
|
913 |
receiver:someOne |
|
914 |
notifying:nil |
|
915 |
logged:logged |
|
916 |
ifFail:nil |
|
917 |
compile:true |
|
918 |
" |
|
919 |
Compiler evaluate:'''some string''' logged:false |
|
920 |
Compiler evaluate:'''some string''' logged:true |
|
921 |
Compiler evaluate:'self class' receiver:nil logged:false |
|
922 |
Compiler evaluate:'self class' receiver:1 logged:false |
|
923 |
" |
|
924 |
! |
|
925 |
||
141 | 926 |
evaluate:aStringOrStream receiver:anObject notifying:requestor |
927 |
"return the result of evaluating aString, |
|
928 |
errors are reported to requestor. Allow access to |
|
929 |
anObject as self and to its instVars (used in the inspector)" |
|
930 |
||
931 |
^ self |
|
1576 | 932 |
evaluate:aStringOrStream |
933 |
in:nil |
|
934 |
receiver:anObject |
|
935 |
notifying:requestor |
|
936 |
logged:false |
|
937 |
ifFail:nil |
|
938 |
compile:true |
|
141 | 939 |
|
940 |
" |
|
941 |
Compiler evaluate:'self x' receiver:(1 @ 2) notifying:nil |
|
942 |
" |
|
943 |
! |
|
944 |
||
945 |
evaluate:aStringOrStream receiver:anObject notifying:requestor compile:compile |
|
946 |
"return the result of evaluating aString, |
|
947 |
errors are reported to requestor. Allow access to |
|
948 |
anObject as self and to its instVars (used in the inspector). |
|
949 |
The compile argument specifies if the string should be compiled down to |
|
950 |
bytecode or instead be interpreted from the parseTree. |
|
951 |
The first should be done for doIts etc, where a readable walkback is |
|
952 |
required. |
|
953 |
The latter is better done for constants, styleSheet and resource |
|
954 |
reading and simple sends, where the overhead of compilation is bigger |
|
955 |
than the interpretation overhead." |
|
956 |
||
957 |
^ self |
|
1576 | 958 |
evaluate:aStringOrStream |
959 |
in:nil |
|
960 |
receiver:anObject |
|
961 |
notifying:requestor |
|
962 |
logged:false |
|
963 |
ifFail:nil |
|
964 |
compile:compile |
|
1548 | 965 |
! |
966 |
||
967 |
evaluateFrom:aStringOrStream ifFail:failBlock |
|
968 |
"return the result of evaluating an expression from aStringOrStream. |
|
969 |
In case of any syntax errors, return the value of failBlock. |
|
970 |
No doit-entry is added to the changeLog." |
|
971 |
||
972 |
^ self |
|
973 |
evaluateFrom:aStringOrStream |
|
974 |
in:nil |
|
975 |
receiver:nil |
|
976 |
notifying:nil |
|
977 |
logged:false |
|
978 |
ifFail:failBlock |
|
979 |
compile:true |
|
980 |
" |
|
981 |
Compiler evaluate:'1 + 2' ifFail:['oops'] |
|
982 |
" |
|
983 |
! |
|
984 |
||
985 |
evaluateFrom:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
986 |
"return the result of evaluating the next expression from aStringOrStream, errors are reported to requestor. |
|
987 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
988 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
989 |
is non-nil, it is evaluated if an error occurs. |
|
990 |
Finally, compile specifies if the string should be compiled down to |
|
991 |
bytecode or instead be interpreted from the parseTree. |
|
992 |
The first should be done for doIts etc, where a readable walkback is |
|
993 |
required. |
|
994 |
The latter is better done for constants, styleSheet and resource |
|
995 |
reading and simple sends, where the overhead of compilation is bigger |
|
996 |
than the interpretation overhead." |
|
997 |
||
998 |
^ self new |
|
999 |
evaluate:aStringOrStream |
|
1000 |
in:aContext |
|
1001 |
receiver:anObject |
|
1002 |
notifying:requestor |
|
1003 |
logged:logged |
|
1004 |
ifFail:failBlock |
|
1005 |
compile:compile |
|
1006 |
checkForEndOfInput:false |
|
0 | 1007 |
! ! |
1008 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1009 |
!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
|
1010 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1011 |
argAndVarNamesForContext:aContext |
1546 | 1012 |
<resource:#obsolete> |
1446
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
1013 |
self obsoleteMethodWarning. |
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
1014 |
^ aContext argAndVarNames. |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1015 |
! ! |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
1016 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1017 |
!Parser class methodsFor:'parsing'! |
141 | 1018 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1019 |
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
|
1020 |
"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
|
1021 |
return the containing BlockNode or nil. |
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1022 |
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
|
1023 |
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
|
1024 |
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
|
1025 |
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
|
1026 |
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
|
1027 |
|
429 | 1028 |
|compiler tree mSource who mClass blocks |
397 | 1029 |
maxSoFar innerBlock m| |
1030 |
||
481
187a88a9695d
care for maxLineNo when looking for a block-by-lineNo
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
1031 |
(line isNil or:[line == self maxLineNumber]) ifTrue:[ |
815 | 1032 |
^ nil |
457
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1033 |
]. |
ad25339043ef
care for nil-lineNumber when looking for a block
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
1034 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1035 |
aMethod notNil ifTrue:[ |
815 | 1036 |
m := aMethod. |
1037 |
who := m who. |
|
1038 |
who isNil ifTrue:[ |
|
1039 |
m isWrapped ifTrue:[ |
|
1040 |
m := m wrapper. |
|
1041 |
m notNil ifTrue:[ |
|
1042 |
who := m who. |
|
1043 |
] |
|
1044 |
] |
|
1045 |
]. |
|
1046 |
who notNil ifTrue:[ |
|
1047 |
mClass := who methodClass. |
|
1048 |
mClass isNil ifTrue:[ ^ nil]. |
|
1049 |
]. |
|
1050 |
||
1051 |
mSource := m source. |
|
1052 |
mSource isNil ifTrue:[^ nil]. |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1053 |
] ifFalse:[ |
815 | 1054 |
aString notNil ifTrue:[ |
1055 |
mSource := aString. |
|
1056 |
mClass := UndefinedObject |
|
1057 |
] ifFalse:[ |
|
1058 |
^ nil |
|
1059 |
] |
|
397 | 1060 |
]. |
1061 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1062 |
"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
|
1063 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1064 |
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
|
1065 |
compiler parseForCode. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1066 |
compiler notifying:nil. |
1365 | 1067 |
compiler ignoreWarnings:true. |
1068 |
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
|
1069 |
compiler lineNumberInfo:#full. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1070 |
|
1515
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1071 |
Notification |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1072 |
handle: |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1073 |
[:ex | |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1074 |
ex proceed |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1075 |
] |
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1076 |
do:[ |
1514 | 1077 |
aMethod notNil ifTrue:[ |
1078 |
(compiler parseMethodSpec == #Error) ifTrue:[ |
|
1079 |
^ nil. |
|
1080 |
]. |
|
1081 |
||
1082 |
who notNil ifTrue:[ |
|
1083 |
compiler selector ~~ (who methodSelector) ifTrue:[ |
|
1084 |
^ nil |
|
1085 |
] |
|
1086 |
]. |
|
1087 |
] ifFalse:[ |
|
1088 |
compiler nextToken. |
|
1089 |
]. |
|
1090 |
||
1091 |
tree := compiler parseMethodBody. |
|
1515
8ffe6db5e53f
suppress notifications while searching for blockAtLine.
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
1092 |
]. |
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1093 |
|
815 | 1094 |
(compiler errorFlag |
1095 |
or:[tree == #Error |
|
1096 |
or:[tree isNil]]) ifTrue:[ |
|
1097 |
^ nil |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1098 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1099 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1100 |
blocks := OrderedCollection new. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1101 |
tree collectBlocksInto:blocks. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1102 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1103 |
blocks := blocks select:[:aBlock | |
815 | 1104 |
line between: aBlock lineNumber and:aBlock endLineNumber |
1105 |
||
1106 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1107 |
blocks size == 1 ifTrue:[ |
815 | 1108 |
^ 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
|
1109 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1110 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1111 |
nA notNil ifTrue:[ |
815 | 1112 |
blocks := blocks select:[:aBlock | |
1113 |
aBlock numArgs == nA |
|
1114 |
]. |
|
1115 |
blocks size == 1 ifTrue:[ |
|
1116 |
^ blocks at:1 |
|
1117 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1118 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1119 |
nV notNil ifTrue:[ |
815 | 1120 |
blocks := blocks select:[:aBlock | |
1121 |
aBlock numVars == nV |
|
1122 |
]. |
|
1123 |
blocks size == 1 ifTrue:[ |
|
1124 |
^ blocks at:1 |
|
1125 |
]. |
|
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1126 |
]. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1127 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1128 |
"/ 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
|
1129 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1130 |
maxSoFar := 0. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1131 |
blocks do:[:aBlock | |
815 | 1132 |
aBlock lineNumber > maxSoFar ifTrue:[ |
1133 |
innerBlock := aBlock. |
|
1134 |
maxSoFar := aBlock lineNumber |
|
1135 |
] |
|
391
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 |
^ innerBlock. |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1138 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1139 |
"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
|
1140 |
"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
|
1141 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
1142 |
|
1365 | 1143 |
checkMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
629 | 1144 |
"parse a method in a given class. |
1145 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1146 |
The parser can be queried for selector, receiver, args, locals, |
|
1147 |
used selectors, modified instvars, referenced classvars etc. |
|
1148 |
The noErrors and noWarnings arguments specify if error and warning |
|
1149 |
messages should be sent to the Transcript or suppressed." |
|
1150 |
||
1151 |
|parser tree| |
|
1152 |
||
1153 |
aString isNil ifTrue:[^ nil]. |
|
1154 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1155 |
parser ignoreErrors:ignoreErrors. |
1156 |
parser ignoreWarnings:ignoreWarnings. |
|
629 | 1157 |
tree := parser parseMethod. |
1158 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1159 |
||
1160 |
ReadBeforeWrittenTester searchForReadBeforeWrittenIn:tree |
|
1161 |
||
1162 |
" |
|
1163 |
self |
|
1164 |
checkMethod:'foo |
|
1165 |
|local1 local2 local3| |
|
1166 |
||
1167 |
local1 := local2. |
|
1168 |
^ local3 |
|
1169 |
' |
|
1170 |
in:UndefinedObject |
|
1171 |
ignoreErrors:true |
|
1172 |
ignoreWarnings:true |
|
1173 |
" |
|
1174 |
||
1175 |
"Modified: / 30.10.1997 / 16:38:31 / cg" |
|
1176 |
! |
|
1177 |
||
141 | 1178 |
parseExpression:aString |
1179 |
"parse aString as an expression; |
|
1180 |
Return the parseTree (if ok), nil (for an empty string |
|
258 | 1181 |
or comment only) or #Error (syntactic error). |
1182 |
Error and warning messages are suppressed." |
|
141 | 1183 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1184 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1185 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1186 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1187 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1188 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1189 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1190 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1191 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1192 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1193 |
" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1194 |
Parser parseExpression:'self foo' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1195 |
Parser parseExpression:'self:123' |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1196 |
Parser parseExpression:'self:123' onError:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1197 |
" |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1198 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1199 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1200 |
parseExpression:aString inNameSpace:aNameSpaceOrNil |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1201 |
"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
|
1202 |
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
|
1203 |
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
|
1204 |
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
|
1205 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1206 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1207 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1208 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1209 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1210 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1211 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1212 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1213 |
inNameSpace:aNameSpaceOrNil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1214 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1215 |
"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
|
1216 |
"Created: 24.6.1997 / 16:44:26 / cg" |
141 | 1217 |
! |
1218 |
||
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1219 |
parseExpression:aString inNameSpace:aNameSpaceOrNil onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1220 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1221 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1222 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1223 |
Error and warning messages are suppressed." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1224 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1225 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1226 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1227 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1228 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1229 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1230 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1231 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1232 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1233 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1234 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1235 |
"Created: 24.6.1997 / 16:44:26 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1236 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1237 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1238 |
parseExpression:aString onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1239 |
"parse aString as an expression; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1240 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1241 |
or comment only) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1242 |
Error and warning messages are suppressed." |
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 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1245 |
withSelf:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1246 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1247 |
onError:errorValue |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1248 |
notifying:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1249 |
ignoreErrors:true "silence on Transcript" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1250 |
ignoreWarnings:true |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1251 |
inNameSpace:nil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1252 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1253 |
"Modified: 24.6.1997 / 16:44:00 / cg" |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1254 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1255 |
|
141 | 1256 |
parseMethod:aString |
1257 |
"parse a method. |
|
1258 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1259 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1260 |
used selectors etc. |
1261 |
Error and warning messages are sent to the Transcript." |
|
141 | 1262 |
|
1263 |
^ self parseMethod:aString in:nil |
|
1264 |
||
1265 |
" |
|
1266 |
|p| |
|
1267 |
||
1268 |
p := Parser |
|
1576 | 1269 |
parseMethod:' |
1270 |
foo:arg1 bar:arg2 baz:arg3 |
|
1271 |
|l1 l2| |
|
1272 |
l1 := 0. |
|
1273 |
l2 := arg1. |
|
1274 |
^ self'. |
|
141 | 1275 |
|
1276 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1277 |
'args: ' print. p methodArgs printNL. |
|
1278 |
'sel: ' print. p selector printNL. |
|
1279 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1280 |
'locals: ' print. p methodVars printNL. |
|
1281 |
'tree: ' printNL. p tree printAllOn:Stdout. Stdout cr. |
|
1282 |
" |
|
258 | 1283 |
|
1284 |
"Modified: 24.4.1996 / 13:18:02 / cg" |
|
141 | 1285 |
! |
1286 |
||
1287 |
parseMethod:aString in:aClass |
|
1288 |
"parse a method in a given class. |
|
1289 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1290 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1291 |
used selectors, modified instvars, referenced classvars etc. |
1292 |
Error and warning messages are sent to the Transcript." |
|
141 | 1293 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1294 |
^ self |
1576 | 1295 |
parseMethod:aString |
1296 |
in:aClass |
|
1297 |
ignoreErrors:false |
|
1298 |
ignoreWarnings:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1299 |
|
258 | 1300 |
"Modified: 24.4.1996 / 13:18:34 / cg" |
141 | 1301 |
! |
1302 |
||
1365 | 1303 |
parseMethod:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1304 |
"parse a method in a given class. |
1305 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1306 |
The parser can be queried for selector, receiver, args, locals, |
|
258 | 1307 |
used selectors, modified instvars, referenced classvars etc. |
1308 |
The noErrors and noWarnings arguments specify if error and warning |
|
1309 |
messages should be sent to the Transcript or suppressed." |
|
141 | 1310 |
|
1311 |
|parser tree| |
|
1312 |
||
1313 |
aString isNil ifTrue:[^ nil]. |
|
1314 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1315 |
parser ignoreErrors:ignoreErrors. |
1316 |
parser ignoreWarnings:ignoreWarnings. |
|
141 | 1317 |
tree := parser parseMethod. |
1318 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ nil]. |
|
1319 |
^ parser |
|
258 | 1320 |
|
1321 |
"Modified: 24.4.1996 / 13:19:23 / cg" |
|
141 | 1322 |
! |
1323 |
||
1324 |
parseMethod:aString in:aClass warnings:warnBoolean |
|
1325 |
"parse a method in a given class. |
|
1326 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1327 |
The parser can be queried for selector, receiver, args, locals, |
|
1328 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1329 |
The warnBoolean arguments specifies if warning |
1330 |
messages should be sent to the Transcript or suppressed. |
|
1331 |
||
1332 |
This method is OBSOLETE, and left in for backward compatibility." |
|
1333 |
||
1334 |
self obsoleteMethodWarning. |
|
141 | 1335 |
^ self |
1576 | 1336 |
parseMethod:aString |
1337 |
in:aClass |
|
1338 |
ignoreErrors:false |
|
1339 |
ignoreWarnings:warnBoolean not |
|
258 | 1340 |
|
1341 |
"Modified: 24.4.1996 / 13:28:05 / cg" |
|
141 | 1342 |
! |
1343 |
||
1344 |
parseMethodArgAndVarSpecification:aString |
|
1345 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1346 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1347 |
The parser can be queried for selector, receiver etc. |
1348 |
Error and warning messages are sent to the Transcript. |
|
1349 |
This method is OBSOLETE." |
|
1350 |
||
1351 |
self obsoleteMethodWarning. |
|
141 | 1352 |
^ self parseMethodArgAndVarSpecification:aString in:nil |
1353 |
||
1354 |
" |
|
1355 |
|p| |
|
1356 |
||
1357 |
p := Parser |
|
1576 | 1358 |
parseMethodArgAndVarSpecification:' |
1359 |
foo:arg1 bar:arg2 baz:arg3 |
|
1360 |
|l1 l2|'. |
|
141 | 1361 |
|
1362 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1363 |
'args: ' print. p methodArgs printNL. |
|
1364 |
'sel: ' print. p selector printNL. |
|
1365 |
'nLocal: ' print. p numberOfMethodVars printNL. |
|
1366 |
'locals: ' print. p methodVars printNL. |
|
1367 |
" |
|
258 | 1368 |
|
1369 |
"Modified: 24.4.1996 / 13:29:43 / cg" |
|
141 | 1370 |
! |
1371 |
||
1372 |
parseMethodArgAndVarSpecification:aString in:aClass |
|
1373 |
"parse a methods selector, arg and var spec in a given class; |
|
1374 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
258 | 1375 |
The parser can be queried for selector, receiver, args and locals. |
1376 |
Error and warning messages are sent to the Transcript. |
|
1377 |
This method is OBSOLETE." |
|
1378 |
||
1379 |
self obsoleteMethodWarning. |
|
141 | 1380 |
^ self parseMethodArgAndVarSpecification:aString |
1576 | 1381 |
in:aClass |
1382 |
ignoreErrors:false |
|
1383 |
ignoreWarnings:false |
|
1384 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1385 |
|
258 | 1386 |
"Modified: 24.4.1996 / 13:30:03 / cg" |
141 | 1387 |
! |
1388 |
||
1365 | 1389 |
parseMethodArgAndVarSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings parseBody:body |
141 | 1390 |
"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
|
1391 |
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
|
1392 |
(for primitives & resourceSpecs). |
258 | 1393 |
The noErrors and noWarnings arguments specify if error and warning |
1394 |
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
|
1395 |
|
141 | 1396 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
1397 |
The parser can be queried for selector, receiver, args and locals" |
|
19 | 1398 |
|
0 | 1399 |
|parser| |
1400 |
||
141 | 1401 |
aString isNil ifTrue:[^ nil]. |
1402 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1403 |
parser ignoreErrors:ignoreErrors. |
1404 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1405 |
"/ parser nextToken. |
141 | 1406 |
(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
|
1407 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1408 |
"/ used to be #parseMethodBodyVarSpec |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1409 |
"/ - 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
|
1410 |
"/ |
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1411 |
body ifTrue:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1412 |
parser parseMethodBodyOrEmpty |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1413 |
] ifFalse:[ |
878
f9c8d2544909
added declare-as (local, global or workspace-war)
Claus Gittinger <cg@exept.de>
parents:
877
diff
changeset
|
1414 |
parser parseMethodBodyVarSpec |
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1415 |
]. |
141 | 1416 |
parser errorFlag ifTrue:[^ nil]. |
0 | 1417 |
^ parser |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1418 |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1419 |
"Created: 24.4.1996 / 13:13:06 / cg" |
265 | 1420 |
"Modified: 27.4.1996 / 16:58:02 / cg" |
141 | 1421 |
! |
1422 |
||
1423 |
parseMethodArgAndVarSpecificationSilent:aString |
|
1424 |
"parse a methods selector, arg and var spec (i.e. locals); |
|
1425 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1426 |
The parser can be queried for selector, receiver etc. |
|
258 | 1427 |
Like #parseMethodArgAndVarSpecification:, but does NOT |
141 | 1428 |
display error/warning messages on the transcript." |
1429 |
||
1430 |
^ self parseMethodArgAndVarSpecificationSilent:aString in:nil |
|
258 | 1431 |
|
1432 |
"Modified: 24.4.1996 / 13:30:54 / cg" |
|
141 | 1433 |
! |
1434 |
||
1435 |
parseMethodArgAndVarSpecificationSilent:aString in:aClass |
|
1436 |
"parse a methods selector, arg and var spec in a given class; |
|
1437 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1438 |
The parser can be queried for selector, receiver, args and locals. |
|
1439 |
Like #parseMethodArgAndVarSpecification:in:, but does not |
|
1440 |
display error/warning messages on the transcript." |
|
1441 |
||
1442 |
^ self parseMethodArgAndVarSpecification:aString |
|
1576 | 1443 |
in:aClass |
1444 |
ignoreErrors:true |
|
1445 |
ignoreWarnings:true |
|
1446 |
parseBody:false |
|
257
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1447 |
|
435dcaed969f
dont parse body (when interrested in args & locals only)
Claus Gittinger <cg@exept.de>
parents:
255
diff
changeset
|
1448 |
"Modified: 24.4.1996 / 13:14:27 / cg" |
141 | 1449 |
! |
1450 |
||
1451 |
parseMethodSilent:aString |
|
1452 |
"parse a method. |
|
1453 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1454 |
The parser can be queried for selector, receiver, args, locals, |
|
1455 |
used selectors etc. |
|
258 | 1456 |
Like #parseMethod:, but warning/error messages are suppressed." |
141 | 1457 |
|
1458 |
^ self parseMethodSilent:aString in:nil |
|
258 | 1459 |
|
1460 |
"Modified: 24.4.1996 / 13:32:44 / cg" |
|
141 | 1461 |
! |
1462 |
||
1463 |
parseMethodSilent:aString in:aClass |
|
1464 |
"parse a method in a given class. |
|
1465 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1466 |
The parser can be queried for selector, receiver, args, locals, |
|
1467 |
used selectors, modified instvars, referenced classvars etc. |
|
258 | 1468 |
Like #parseMethod:in:, but warning/error messages are suppressed." |
1469 |
||
1470 |
^ self |
|
1576 | 1471 |
parseMethod:aString |
1472 |
in:aClass |
|
1473 |
ignoreErrors:true |
|
1474 |
ignoreWarnings:true |
|
258 | 1475 |
|
1476 |
"Modified: 24.4.1996 / 13:32:57 / cg" |
|
141 | 1477 |
! |
1478 |
||
1479 |
parseMethodSpecification:aString |
|
1480 |
"parse a methods selector & arg specification; |
|
1481 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1482 |
The parser can be queried for selector, receiver etc." |
|
1483 |
||
1484 |
^ self parseMethodSpecification:aString in:nil |
|
1485 |
||
1486 |
" |
|
1487 |
|p| |
|
1488 |
||
1489 |
p := Parser parseMethodSpecification:'foo:arg1 bar:arg2 baz:arg3'. |
|
1490 |
'nArgs: ' print. p numberOfMethodArgs printNL. |
|
1491 |
'args: ' print. p methodArgs printNL. |
|
1492 |
'sel: ' print. p selector printNL |
|
1493 |
" |
|
1494 |
! |
|
1495 |
||
1496 |
parseMethodSpecification:aString in:aClass |
|
1497 |
"parse a methods selector & arg spec for a given class; |
|
1498 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1499 |
The parser can be queried for selector, receiver etc." |
|
1500 |
||
1501 |
^ self parseMethodSpecification:aString |
|
1576 | 1502 |
in:aClass |
1503 |
ignoreErrors:false |
|
1504 |
ignoreWarnings:false |
|
141 | 1505 |
! |
1506 |
||
1365 | 1507 |
parseMethodSpecification:aString in:aClass ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
141 | 1508 |
"parse a methods selector & arg spec for a given class; |
1509 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1510 |
The parser can be queried for selector, receiver etc. |
|
1511 |
noErrors and noWarnings specify if error- and warningMessages are |
|
1512 |
to be output onto the Transcript." |
|
1513 |
||
1514 |
|parser tree| |
|
1515 |
||
1516 |
aString isNil ifTrue:[^ nil]. |
|
1517 |
parser := self for:(ReadStream on:aString) in:aClass. |
|
1365 | 1518 |
parser ignoreErrors:ignoreErrors. |
1519 |
parser ignoreWarnings:ignoreWarnings. |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1520 |
"/ parser nextToken. |
141 | 1521 |
tree := parser parseMethodSpec. |
1522 |
(parser errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1523 |
^ parser |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1524 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
1525 |
"Modified: 20.4.1996 / 20:09:48 / cg" |
141 | 1526 |
! |
1527 |
||
1528 |
parseMethodSpecificationSilent:aString |
|
1529 |
"parse a methods selector & arg specification; |
|
1530 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1531 |
The parser can be queried for selector, receiver etc. |
|
1532 |
Like #parseMethodSpecification:, but does not display any error/warning Messages on the transcript." |
|
1533 |
||
1534 |
^ self parseMethodSpecificationSilent:aString in:nil |
|
1535 |
! |
|
1536 |
||
1537 |
parseMethodSpecificationSilent:aString in:aClass |
|
1538 |
"parse a methods selector & arg spec for a given class; |
|
1539 |
Return a parser (if ok), nil (empty) or #Error (syntax). |
|
1540 |
The parser can be queried for selector, receiver etc. |
|
1541 |
Like #parseMethodSpecification:in:, but does not display any error/warning Messages on the transcript." |
|
1542 |
||
1543 |
^ self parseMethodSpecification:aString |
|
1576 | 1544 |
in:aClass |
1545 |
ignoreErrors:true |
|
1546 |
ignoreWarnings:true |
|
141 | 1547 |
|
1548 |
"Created: 31.10.1995 / 14:37:49 / cg" |
|
1549 |
! |
|
0 | 1550 |
|
7 | 1551 |
selectorInExpression:aString |
47 | 1552 |
"parse an expression - return the selector. Even malformed expressions |
1553 |
(such as missing receiver or missing arg are parsed. |
|
1554 |
Used for the SystemBrowsers implementors/senders query-box initial text. |
|
21 | 1555 |
Returns nil if unparsable." |
7 | 1556 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1557 |
|tree parser sel| |
7 | 1558 |
|
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1559 |
(aString size == 0) ifTrue:[^ nil]. |
7 | 1560 |
|
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1561 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1562 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1563 |
do:[ |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1564 |
tree := self withSelf:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1565 |
parseExpression:aString |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1566 |
notifying:nil |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1567 |
ignoreErrors:true |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1568 |
ignoreWarnings:true. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1569 |
]. |
21 | 1570 |
|
1571 |
" |
|
1572 |
special: take the expression of the right side, if its an |
|
1573 |
assignment or return |
|
1574 |
" |
|
7 | 1575 |
(tree notNil and:[tree ~~ #Error]) ifTrue:[ |
813
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1576 |
(tree isAssignment |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1577 |
or:[tree isReturnNode]) ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1578 |
tree expression isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1579 |
tree := tree expression |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1580 |
] |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1581 |
]. |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1582 |
tree isMessage ifTrue:[ |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1583 |
^ tree selector |
4d3ec8ff238c
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
807
diff
changeset
|
1584 |
]. |
7 | 1585 |
]. |
1586 |
||
21 | 1587 |
" |
1588 |
mhmh, try expression without receiver |
|
1589 |
" |
|
7 | 1590 |
parser := self for:(ReadStream on:aString). |
1365 | 1591 |
parser ignoreErrors:true. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1592 |
Error |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1593 |
handle:[:ex | ] |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1594 |
do:[ |
1482
d80c83f1167a
catch twoByte string parsing in selectorInExpression
Claus Gittinger <cg@exept.de>
parents:
1471
diff
changeset
|
1595 |
parser nextToken. |
1297
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1596 |
sel := parser degeneratedKeywordExpressionForSelector |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1597 |
]. |
67332caafef7
catch errors when extracting a message selector
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1598 |
^ sel |
7 | 1599 |
|
1600 |
" |
|
20 | 1601 |
Parser selectorInExpression:'foo at:1 put:(5 * bar)' |
1602 |
Parser selectorInExpression:'(foo at:1) at:1' |
|
47 | 1603 |
Parser selectorInExpression:'a + 4' |
1604 |
Parser selectorInExpression:'a negated' |
|
20 | 1605 |
Parser selectorInExpression:'at:1 put:5' |
47 | 1606 |
Parser selectorInExpression:'at:1 put:' |
1607 |
Parser selectorInExpression:'a at:1 put:5' |
|
1608 |
Parser selectorInExpression:'a at:1 put:' |
|
20 | 1609 |
Parser selectorInExpression:'a := foo at:1 put:5' |
7 | 1610 |
" |
451 | 1611 |
|
1612 |
"Modified: 17.12.1996 / 12:12:47 / cg" |
|
7 | 1613 |
! |
1614 |
||
1615 |
withSelf:anObject parseExpression:aString notifying:someOne |
|
1616 |
"parse aString as an expression with self set to anObject; |
|
21 | 1617 |
Return the parseTree (if ok), nil (for an empty string |
1618 |
or comment only ) or #Error (syntactic error). |
|
1619 |
||
1620 |
Errors and warnings are forwarded to someOne (usually some |
|
1621 |
codeView) which can highlight it and show a popup box." |
|
7 | 1622 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1623 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1624 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1625 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1626 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1627 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1628 |
ignoreErrors:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1629 |
ignoreWarnings:false |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1630 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1631 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1632 |
"Modified: 24.6.1997 / 16:43:37 / cg" |
7 | 1633 |
! |
1634 |
||
1635 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignore |
|
0 | 1636 |
"parse aString as an expression with self set to anObject; |
21 | 1637 |
Return the parseTree (if ok), nil (for an empty string |
1638 |
or comment only ) or #Error (syntactic error). |
|
1639 |
||
1640 |
Errors and warnings are forwarded to someOne (usually some |
|
1641 |
codeView) which can highlight it and show a popup box." |
|
1642 |
||
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1643 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1644 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1645 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1646 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1647 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1648 |
ignoreErrors:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1649 |
ignoreWarnings:ignore |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1650 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1651 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1652 |
"Modified: 24.6.1997 / 16:43:26 / cg" |
21 | 1653 |
! |
1654 |
||
1655 |
withSelf:anObject parseExpression:aString notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings |
|
1656 |
"parse aString as an expression with self set to anObject; |
|
1657 |
Return the parseTree (if ok), nil (for an empty string |
|
1658 |
or comment only ) or #Error (syntactic error). |
|
1659 |
||
1660 |
Errors and warnings are forwarded to someOne (usually some |
|
1661 |
codeView) which can highlight it and show a popup box, |
|
1662 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
0 | 1663 |
|
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1664 |
^ self |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1665 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1666 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1667 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1668 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1669 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1670 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1671 |
inNameSpace:nil |
548
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1672 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1673 |
"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
|
1674 |
! |
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1675 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1676 |
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
|
1677 |
"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
|
1678 |
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
|
1679 |
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
|
1680 |
|
79948fed91a7
added entry to parse an expression in a specific nameSpace
Claus Gittinger <cg@exept.de>
parents:
547
diff
changeset
|
1681 |
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
|
1682 |
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
|
1683 |
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
|
1684 |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1685 |
^ self |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1686 |
withSelf:anObject |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1687 |
parseExpression:aString |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1688 |
onError:#Error |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1689 |
notifying:someOne |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1690 |
ignoreErrors:ignoreErrors |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1691 |
ignoreWarnings:ignoreWarnings |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1692 |
inNameSpace:aNameSpaceOrNil |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1693 |
! |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1694 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1695 |
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
|
1696 |
"parse aString as an expression with self set to anObject; |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1697 |
Return the parseTree (if ok), nil (for an empty string |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1698 |
or comment only ) or errorValue (syntactic error). |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1699 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1700 |
Errors and warnings are forwarded to someOne (usually some |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1701 |
codeView) which can highlight it and show a popup box, |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1702 |
iff ignoreErrors/ignoreWarnings is true respectively." |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1703 |
|
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1704 |
|parser tree| |
0 | 1705 |
|
1706 |
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
|
1707 |
|
0 | 1708 |
parser := self for:(ReadStream on:aString). |
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1709 |
tree := parser |
1006 | 1710 |
parseExpressionWithSelf:anObject |
1711 |
notifying:someOne |
|
1712 |
ignoreErrors:ignoreErrors |
|
1713 |
ignoreWarnings:ignoreWarnings |
|
1714 |
inNameSpace:aNameSpaceOrNil. |
|
1096
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1715 |
tree == #Error ifTrue:[ |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1716 |
^ errorValue value |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1717 |
]. |
d1d897aba4d5
added #parseExpression:onError: protocol.
Claus Gittinger <cg@exept.de>
parents:
1091
diff
changeset
|
1718 |
^ tree |
1006 | 1719 |
|
1720 |
"Modified: / 14.12.1999 / 15:12:16 / cg" |
|
0 | 1721 |
! ! |
1722 |
||
1621 | 1723 |
!Parser class methodsFor:'private'! |
1724 |
||
1725 |
makeImmutableArray:anArray |
|
1726 |
|newArray| |
|
1727 |
||
1728 |
newArray := anArray copy. |
|
1729 |
ImmutableArray notNil ifTrue:[ |
|
1730 |
newArray changeClassTo:ImmutableArray. |
|
1731 |
]. |
|
1732 |
newArray beImmutable. |
|
1733 |
^ newArray |
|
1734 |
! |
|
1735 |
||
1736 |
makeImmutableString:aString |
|
1737 |
|newString| |
|
1738 |
||
1739 |
newString := aString copy. |
|
1740 |
ImmutableString notNil ifTrue:[ |
|
1741 |
newString changeClassTo:ImmutableString. |
|
1742 |
]. |
|
1743 |
newString beImmutable. |
|
1744 |
^ newString |
|
1745 |
! ! |
|
1746 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
1747 |
!Parser class methodsFor:'unparsing'! |
20 | 1748 |
|
1749 |
methodSpecificationForSelector:aSelector |
|
1750 |
"given a selector such as #foo:bar:, return a string that could |
|
1751 |
serve as a methods specification source code. |
|
1752 |
To be used for code generators" |
|
1753 |
||
807 | 1754 |
|argNames n| |
1755 |
||
1756 |
n := aSelector numArgs. |
|
1757 |
n == 1 ifTrue:[ |
|
1758 |
argNames := #('arg') |
|
1759 |
] ifFalse:[ |
|
1760 |
n <= 15 ifTrue:[ |
|
1761 |
argNames := #('arg1' 'arg2' 'arg3' 'arg4' 'arg5' 'arg6' |
|
1762 |
'arg7' 'arg8' 'arg9' 'arg10' 'arg11' 'arg12' |
|
1763 |
'arg13' 'arg14' 'arg15') |
|
1764 |
] ifFalse:[ |
|
1765 |
argNames := (1 to:aSelector numArgs) collect:[:i | 'arg' , i printString]. |
|
1766 |
]. |
|
1767 |
]. |
|
1768 |
^ self methodSpecificationForSelector:aSelector argNames:argNames |
|
1769 |
||
20 | 1770 |
" |
807 | 1771 |
Parser methodSpecificationForSelector:#foo: |
20 | 1772 |
Parser methodSpecificationForSelector:#foo:bar: |
807 | 1773 |
Parser methodSpecificationForSelector:#foo:bar:baz: |
21 | 1774 |
Parser methodSpecificationForSelector:#+ |
20 | 1775 |
Parser methodSpecificationForSelector:#negated |
1776 |
" |
|
807 | 1777 |
|
1778 |
"Modified: / 12.2.1999 / 13:12:44 / cg" |
|
20 | 1779 |
! |
1780 |
||
1781 |
methodSpecificationForSelector:aSelector argNames:argNames |
|
1782 |
"given a selector such as #foo:bar:, return a string that could |
|
1783 |
serve as a methods specification source code. |
|
1784 |
To be used for code generators" |
|
1785 |
||
806 | 1786 |
|s nargs parts part| |
20 | 1787 |
|
1788 |
s := WriteStream on:String new. |
|
44 | 1789 |
nargs := aSelector numArgs. |
20 | 1790 |
nargs == 0 ifTrue:[ |
806 | 1791 |
s nextPutAll:aSelector |
20 | 1792 |
] ifFalse:[ |
806 | 1793 |
parts := aSelector partsIfSelector. |
1794 |
1 to:nargs do:[:i | |
|
1795 |
part := parts at:i. |
|
1796 |
s nextPutAll:part. |
|
1797 |
(part endsWith:$:) ifFalse:[ |
|
1798 |
s space. |
|
1799 |
]. |
|
1800 |
s nextPutAll:(argNames at:i). |
|
1801 |
i ~~ nargs ifTrue:[s space]. |
|
1802 |
] |
|
20 | 1803 |
]. |
1804 |
^ s contents |
|
1805 |
||
1806 |
" |
|
1807 |
Parser methodSpecificationForSelector:#foo:bar: argNames:#('one' 'two' 'three') |
|
1808 |
Parser methodSpecificationForSelector:#+ argNames:#('one') |
|
1809 |
Parser methodSpecificationForSelector:#negated |
|
1810 |
" |
|
806 | 1811 |
|
1812 |
"Modified: / 12.2.1999 / 12:33:50 / cg" |
|
20 | 1813 |
! ! |
1814 |
||
1417 | 1815 |
!Parser methodsFor:'Compatibility-ST80'! |
0 | 1816 |
|
918 | 1817 |
evaluate:aString in:aClassOrContext to:to notifying:aRequestor ifFail:failBlock |
35 | 1818 |
|parseTree value| |
0 | 1819 |
|
1820 |
aString isNil ifTrue:[^ nil]. |
|
1821 |
self initializeFor:(ReadStream on:aString). |
|
918 | 1822 |
|
1823 |
"/ stupid - there seem to be differences among the various |
|
1824 |
"/ ST dialects ... |
|
1825 |
aClassOrContext isBehavior ifTrue:[ |
|
1826 |
self setClassToCompileFor:aClassOrContext. |
|
1827 |
selfValue := nil. |
|
1828 |
] ifFalse:[ |
|
1829 |
self setContext:aClassOrContext. |
|
1830 |
aClassOrContext notNil ifTrue:[ |
|
1831 |
self setSelf:(aClassOrContext receiver) |
|
1832 |
]. |
|
1833 |
]. |
|
0 | 1834 |
requestor := aRequestor. |
1835 |
||
1836 |
self nextToken. |
|
1837 |
parseTree := self parseMethodBody. |
|
1838 |
(errorFlag or:[tree == #Error]) ifTrue:[^ #Error]. |
|
1839 |
parseTree notNil ifTrue:[ |
|
918 | 1840 |
self evalExitBlock:[:value | ^ failBlock value]. |
1841 |
value := parseTree evaluate |
|
0 | 1842 |
]. |
35 | 1843 |
self release. |
1844 |
^ value |
|
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1845 |
! |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1846 |
|
624 | 1847 |
parse:methodSource in:aClass notifying:aRequestor |
1848 |
"parse a methods source. |
|
1849 |
Return the methods parseTree" |
|
1850 |
||
1851 |
self initializeFor:methodSource. |
|
1852 |
classToCompileFor := aClass. |
|
1853 |
requestor := aRequestor. |
|
1854 |
self parseMethod. |
|
918 | 1855 |
|
624 | 1856 |
^ MethodNode new |
1857 |
selector:selector |
|
1858 |
arguments:methodArgs |
|
1859 |
locals:methodVars |
|
1207 | 1860 |
statements:tree asCollectionOfStatements |
624 | 1861 |
|
1214 | 1862 |
"Created: / 17.10.1997 / 12:35:01 / cg" |
1863 |
"Modified: / 5.11.2001 / 16:56:43 / cg" |
|
624 | 1864 |
! |
1865 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1866 |
parseSelector:aStringOrStream |
624 | 1867 |
"parse a methods source for the methods selector. |
1868 |
Return the selector" |
|
1869 |
||
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1870 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1871 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1872 |
^ selector. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1873 |
|
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1874 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1875 |
Parser new |
624 | 1876 |
parseSelector:' |
547
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1877 |
parseSelector:aStringOrStream |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1878 |
self initializeFor:aStringOrStream. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1879 |
self parseMethodSpec. |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1880 |
^ selector. |
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 |
" |
5a51414daf36
added #parseSelector for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
541
diff
changeset
|
1883 |
|
624 | 1884 |
"Modified: 17.10.1997 / 12:35:46 / cg" |
0 | 1885 |
! ! |
1886 |
||
44 | 1887 |
!Parser methodsFor:'accessing'! |
1888 |
||
1889 |
correctedSource |
|
1890 |
^ correctedSource |
|
1891 |
! |
|
1892 |
||
1605
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1893 |
doItTemporaries |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1894 |
^ doItTemporaries |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1895 |
! |
9c50ef665ee9
changes to allow for kludge-environments
Claus Gittinger <cg@exept.de>
parents:
1604
diff
changeset
|
1896 |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1897 |
endOfLastToken |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1898 |
^ tokenPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1899 |
! |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1900 |
|
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1901 |
endOfSelectorPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1902 |
"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
|
1903 |
|
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1904 |
^ endOfSelectorPosition |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1905 |
! |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
1906 |
|
141 | 1907 |
errorFlag |
1908 |
"return true if there where any errors (valid after parsing)" |
|
1909 |
||
1910 |
^ errorFlag |
|
1911 |
! |
|
1912 |
||
1913 |
evalExitBlock:aBlock |
|
1914 |
"when evaluating a return expression, this block is evaluated" |
|
1915 |
||
1916 |
evalExitBlock := aBlock |
|
1917 |
! |
|
1918 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1919 |
getNameSpace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1920 |
"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
|
1921 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1922 |
^ currentNamespace |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1923 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1924 |
"Modified: 8.11.1996 / 13:45:35 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1925 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1926 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1927 |
implicitSelfSends |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1928 |
^ parserFlags implicitSelfSends |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1929 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1930 |
|
1571 | 1931 |
implicitSelfSends:aBoolean |
1932 |
"turn on/off implicit self sends" |
|
1933 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1934 |
parserFlags implicitSelfSends:aBoolean |
1571 | 1935 |
! |
1936 |
||
19 | 1937 |
primitiveNumber |
1938 |
"return the ST-80 style primitiveNumber or nil (valid after parsing)" |
|
1939 |
||
1940 |
^ primitiveNr |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
1941 |
! |
97 | 1942 |
|
285
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1943 |
primitiveResources |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1944 |
"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
|
1945 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1946 |
^ primitiveResource |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1947 |
|
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1948 |
"Created: 29.5.1996 / 17:28:00 / cg" |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1949 |
! |
19e8d6d22278
allow multiple resource definitions
Claus Gittinger <cg@exept.de>
parents:
273
diff
changeset
|
1950 |
|
35 | 1951 |
release |
664 | 1952 |
methodArgs := methodVars := tree := selfNode := superNode := nilNode := nil. |
35 | 1953 |
super release. |
664 | 1954 |
|
1955 |
"Modified: / 31.3.1998 / 19:45:58 / cg" |
|
90 | 1956 |
! |
1957 |
||
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1958 |
setNameSpace:aNameSpaceName |
1041
98fa50f8353f
renamed Namespace to NameSpace
Claus Gittinger <cg@exept.de>
parents:
1040
diff
changeset
|
1959 |
currentNamespace := NameSpace fullName:aNameSpaceName |
427
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1960 |
|
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1961 |
"Modified: 8.11.1996 / 13:43:14 / cg" |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1962 |
! |
3d6a4d002824
pass remembered nameSpace back from upQueries
Claus Gittinger <cg@exept.de>
parents:
424
diff
changeset
|
1963 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1964 |
setPackage:aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1965 |
currentPackage := aPackageID |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1966 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
1967 |
|
141 | 1968 |
targetClass |
1969 |
^ classToCompileFor |
|
1970 |
! |
|
1971 |
||
90 | 1972 |
targetClass:aClass |
117 | 1973 |
classToCompileFor := aClass |
1974 |
! |
|
1975 |
||
141 | 1976 |
tree |
1977 |
"return the parsetree" |
|
1978 |
||
1979 |
^tree |
|
1980 |
! |
|
1981 |
||
1982 |
tree:aTree |
|
1983 |
"private: set the tree - for internal use only" |
|
1984 |
||
1985 |
tree := aTree |
|
1363 | 1986 |
! |
1987 |
||
1988 |
warnSTXHereExtensionUsed |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1989 |
^ parserFlags warnSTXHereExtensionUsed |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1990 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1991 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1992 |
warnSTXHereExtensionUsed:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
1993 |
parserFlags warnSTXHereExtensionUsed:aBoolean |
141 | 1994 |
! ! |
1995 |
||
1418 | 1996 |
!Parser methodsFor:'dummy-syntax detection'! |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1997 |
|
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
1998 |
markArgumentIdentifierFrom:pos1 to:pos2 |
1525 | 1999 |
"intentionally left empty" |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2000 |
! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2001 |
|
883 | 2002 |
markBadIdentifierFrom:pos1 to:pos2 |
1525 | 2003 |
"intentionally left empty" |
883 | 2004 |
! |
2005 |
||
663 | 2006 |
markBooleanConstantFrom:pos1 to:pos2 |
1525 | 2007 |
"intentionally left empty" |
663 | 2008 |
! |
2009 |
||
673 | 2010 |
markBracketAt:pos |
1525 | 2011 |
"intentionally left empty" |
673 | 2012 |
! |
2013 |
||
663 | 2014 |
markConstantFrom:pos1 to:pos2 |
1525 | 2015 |
"intentionally left empty" |
663 | 2016 |
! |
2017 |
||
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2018 |
markGlobalClassIdentifierFrom:pos1 to:pos2 |
1525 | 2019 |
"intentionally left empty" |
822
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2020 |
! |
a773bb72cbd6
added extra globalClassIdentifierColor & emphasis
Claus Gittinger <cg@exept.de>
parents:
815
diff
changeset
|
2021 |
|
663 | 2022 |
markGlobalIdentifierFrom:pos1 to:pos2 |
1525 | 2023 |
"intentionally left empty" |
663 | 2024 |
! |
2025 |
||
2026 |
markHereFrom:pos1 to:pos2 |
|
1525 | 2027 |
"intentionally left empty" |
663 | 2028 |
! |
2029 |
||
2030 |
markIdentifierFrom:pos1 to:pos2 |
|
1525 | 2031 |
"intentionally left empty" |
663 | 2032 |
! |
2033 |
||
687 | 2034 |
markInstVarIdentifierFrom:pos1 to:pos2 |
1525 | 2035 |
"intentionally left empty" |
687 | 2036 |
! |
2037 |
||
663 | 2038 |
markLocalIdentifierFrom:pos1 to:pos2 |
1525 | 2039 |
"intentionally left empty" |
663 | 2040 |
! |
2041 |
||
2042 |
markMethodSelectorFrom:pos1 to:pos2 |
|
1525 | 2043 |
"intentionally left empty" |
663 | 2044 |
! |
2045 |
||
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2046 |
markParenthesisAt:pos |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2047 |
"intentionally left empty" |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2048 |
! |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
2049 |
|
837 | 2050 |
markReturnAt:pos |
1525 | 2051 |
"intentionally left empty" |
837 | 2052 |
! |
2053 |
||
864 | 2054 |
markSelector:sel from:pos1 to:pos2 receiverNode:aNode |
1525 | 2055 |
"intentionally left empty" |
864 | 2056 |
! |
2057 |
||
663 | 2058 |
markSelfFrom:pos1 to:pos2 |
1525 | 2059 |
"intentionally left empty" |
663 | 2060 |
! |
2061 |
||
2062 |
markSuperFrom:pos1 to:pos2 |
|
1525 | 2063 |
"intentionally left empty" |
664 | 2064 |
! |
2065 |
||
2066 |
markUnknownIdentifierFrom:pos1 to:pos2 |
|
1525 | 2067 |
"intentionally left empty" |
687 | 2068 |
! |
2069 |
||
2070 |
markVariable:v |
|
1525 | 2071 |
"intentionally left empty" |
687 | 2072 |
! |
2073 |
||
2074 |
markVariable:v from:pos1 to:pos2 |
|
1525 | 2075 |
"intentionally left empty" |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2076 |
! ! |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
2077 |
|
141 | 2078 |
!Parser methodsFor:'error correction'! |
2079 |
||
1295 | 2080 |
addDoItTemporary:varName |
2081 |
|holder| |
|
2082 |
||
2083 |
doItTemporaries isNil ifTrue:[ |
|
2084 |
doItTemporaries := IdentityDictionary new. |
|
2085 |
]. |
|
2086 |
doItTemporaries at:varName asSymbol put:(holder := ValueHolder new). |
|
2087 |
^ holder |
|
2088 |
! |
|
2089 |
||
141 | 2090 |
askForCorrection:aString fromList:aList |
2091 |
"launch a selection box, which allows user to enter correction. |
|
2092 |
return newString or nil (for abort)" |
|
2093 |
||
1323 | 2094 |
|box rslt| |
141 | 2095 |
|
2096 |
"in systems without widgets ..." |
|
2097 |
ListSelectionBox isNil ifTrue:[ |
|
1285 | 2098 |
^ self confirm:aString |
141 | 2099 |
]. |
2100 |
box := ListSelectionBox title:aString. |
|
2101 |
box initialText:(aList at:1). |
|
2102 |
box list:aList. |
|
1285 | 2103 |
box okText:'Correct'. |
1323 | 2104 |
box action:[:aString | rslt := aString]. |
141 | 2105 |
box showAtPointer. |
1323 | 2106 |
box destroy. |
2107 |
^ rslt |
|
2108 |
! |
|
2109 |
||
2110 |
askForCorrection:aString fromList:aList for:originalSelector |
|
2111 |
"launch a selection box, which allows user to enter correction. |
|
2112 |
return newString or nil (for abort)" |
|
2113 |
||
2114 |
|box rslt| |
|
2115 |
||
2116 |
"in systems without widgets ..." |
|
2117 |
ListSelectionBox isNil ifTrue:[ |
|
2118 |
^ self confirm:aString |
|
2119 |
]. |
|
2120 |
box := ListSelectionBox title:aString. |
|
2121 |
box initialText:(aList at:1). |
|
2122 |
box list:aList. |
|
2123 |
box okText:'Correct'. |
|
2124 |
box action:[:aString | rslt := aString]. |
|
2125 |
box addButton:(Button label:'Keep Selector' action:[rslt := originalSelector. box hide]) after:(box okButton). |
|
2126 |
box showAtPointer. |
|
2127 |
box destroy. |
|
2128 |
^ rslt |
|
141 | 2129 |
! |
2130 |
||
1295 | 2131 |
askForVariableTypeWhenDeclaringUndefined:varName |
2132 |
|l how varNameIsLowercase choice holder newClass| |
|
2133 |
||
2134 |
l := #(). |
|
2135 |
how := #(). |
|
2136 |
||
2137 |
varNameIsLowercase := (varName at:1) isLowercase. |
|
2138 |
||
2139 |
"/ BlockVar, InstVar and classInstVar not yet implemented |
|
2140 |
varNameIsLowercase ifTrue:[ |
|
2141 |
"/ currentBlock notNil ifTrue:[ |
|
2142 |
"/ l := l , #( 'Block local' ). |
|
2143 |
"/ how := how , #( BlockVariable ). |
|
2144 |
"/ ]. |
|
2145 |
selector notNil ifTrue:[ |
|
2146 |
l := l , #( 'Method Local Variable' ). |
|
2147 |
how := how , #( MethodVariable ). |
|
2148 |
]. |
|
2149 |
(classToCompileFor notNil |
|
2150 |
and:[classToCompileFor isMeta not |
|
2151 |
and:[classToCompileFor isBuiltInClass not |
|
1440 | 2152 |
and:[(self isDoIt not)]]]) ifTrue:[ |
1295 | 2153 |
l := l copyWith:'Instance Variable'. |
2154 |
how := how copyWith: #InstanceVariable. |
|
2155 |
]. |
|
2156 |
] ifFalse:[ |
|
2157 |
l := l , #( 'New Class' 'Global' 'NameSpace' ). |
|
2158 |
how := how , #( NewClass GlobalVariable NameSpace ). |
|
2159 |
||
2160 |
(classToCompileFor notNil |
|
2161 |
and:[classToCompileFor isBuiltInClass not |
|
1440 | 2162 |
and:[self isDoIt not]]) ifTrue:[ |
1295 | 2163 |
classToCompileFor isMeta ifTrue:[ |
2164 |
l := l , #('Class Instance Variable'). |
|
2165 |
how := how , #( ClassInstanceVariable). |
|
2166 |
]. |
|
2167 |
l := l , #('Class Variable' ). |
|
2168 |
how := how , #( ClassVariable). |
|
2169 |
] |
|
2170 |
]. |
|
1440 | 2171 |
self isDoIt ifTrue:[ |
1295 | 2172 |
l size > 0 ifTrue:[ |
2173 |
l := l , #( '-' ). |
|
2174 |
how := how , #( nil ). |
|
2175 |
]. |
|
2176 |
l := l , #( 'Workspace Variable' 'DoIt Temporary'). |
|
2177 |
how := how , #( WorkspaceVariable DoItTemporary ). |
|
2178 |
]. |
|
2179 |
||
2180 |
l size > 0 ifTrue:[ |
|
2181 |
l := (Array with:('Declare ' , varName allBold , ' as:') |
|
2182 |
with:'-' |
|
2183 |
) , l. |
|
2184 |
how := #(nil nil) , how. |
|
2185 |
choice := (PopUpMenu labels:l) startUp. |
|
2186 |
(choice notNil and:[choice > 0]) ifTrue:[ |
|
2187 |
choice := how at:choice. |
|
2188 |
||
2189 |
choice == #WorkspaceVariable ifTrue:[ |
|
2190 |
holder := Workspace addWorkspaceVariable:varName. |
|
2191 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
2192 |
]. |
|
2193 |
choice == #DoItTemporary ifTrue:[ |
|
2194 |
holder := self addDoItTemporary:varName. |
|
2195 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
2196 |
]. |
|
2197 |
||
2198 |
choice == #GlobalVariable ifTrue:[ |
|
2199 |
Smalltalk at:varName asSymbol put:nil. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2200 |
^ VariableNode globalNamed:varName |
1295 | 2201 |
]. |
2202 |
||
2203 |
choice == #NewClass ifTrue:[ |
|
2204 |
newClass := Object subclass:varName asSymbol |
|
2205 |
instanceVariableNames:'' |
|
2206 |
classVariableNames:'' |
|
2207 |
poolDictionaries:'' |
|
2208 |
category:'* As yet uncategorized *'. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2209 |
^ VariableNode globalNamed:newClass name |
1295 | 2210 |
]. |
2211 |
||
2212 |
choice == #NameSpace ifTrue:[ |
|
2213 |
NameSpace name:varName. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2214 |
^ VariableNode globalNamed:varName |
1295 | 2215 |
]. |
2216 |
||
2217 |
choice == #ClassVariable ifTrue:[ |
|
2218 |
classToCompileFor theNonMetaclass addClassVarName:varName. |
|
2219 |
^ VariableNode type:#ClassVariable class:classToCompileFor theNonMetaclass name:varName |
|
2220 |
]. |
|
2221 |
||
2222 |
choice == #InstanceVariable ifTrue:[ |
|
2223 |
classToCompileFor theNonMetaclass addInstVarName:varName. |
|
2224 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2225 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2226 |
RestartCompilationSignal raise. |
|
2227 |
"/ not reached - restarted compile will not arrive here again |
|
2228 |
self error:'restart compile failed'. |
|
2229 |
]. |
|
2230 |
||
2231 |
choice == #ClassInstanceVariable ifTrue:[ |
|
2232 |
classToCompileFor theMetaclass addInstVarName:varName. |
|
2233 |
"/ ST/X special - classToCompileFor is obsoleted |
|
2234 |
classToCompileFor := Smalltalk classNamed:(classToCompileFor name). |
|
2235 |
RestartCompilationSignal raise. |
|
2236 |
"/ not reached - restarted compile will not arrive here again |
|
2237 |
self error:'restart compile failed'. |
|
2238 |
]. |
|
2239 |
||
2240 |
choice == #MethodVariable ifTrue:[ |
|
2241 |
|varIndex var endLocalsPos posToInsert ins| |
|
2242 |
||
2243 |
localVarDefPosition size == 2 ifTrue:[ |
|
2244 |
endLocalsPos := posToInsert := localVarDefPosition at:2. |
|
2245 |
ins := ' ' , varName. |
|
2246 |
] ifFalse:[ |
|
2247 |
endOfSelectorPosition notNil ifTrue:[ |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2248 |
posToInsert := beginOfBodyPosition. |
1295 | 2249 |
ins := '|' , varName , '|' , Character cr asString , Character cr asString. |
2250 |
ins := ins , (String new:(requestor colOfCharacterPosition:posToInsert)-1). |
|
2251 |
] |
|
2252 |
]. |
|
2253 |
posToInsert notNil ifTrue:[ |
|
2254 |
requestor |
|
2255 |
insertString:ins |
|
2256 |
atCharacterPosition:posToInsert. |
|
2257 |
||
2258 |
endLocalsPos notNil ifTrue:[ |
|
2259 |
localVarDefPosition at:2 put:(endLocalsPos + varName size + 1). |
|
2260 |
||
2261 |
methodVarNames := methodVarNames copyWith:varName. |
|
2262 |
methodVars := methodVars copyWith:(var := Variable new name:varName). |
|
2263 |
] ifFalse:[ |
|
2264 |
localVarDefPosition := Array with:posToInsert with:posToInsert+varName size+1. |
|
2265 |
||
2266 |
methodVarNames := Array with:varName. |
|
2267 |
methodVars := Array with:(var := Variable new name:varName). |
|
2268 |
]. |
|
2269 |
correctedSource := requestor currentSourceCode. |
|
2270 |
source := (ReadStream on:correctedSource) |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2271 |
position:(source position1Based + ins size). |
1295 | 2272 |
|
2273 |
varIndex := methodVarNames size. |
|
2274 |
var used:true. |
|
2275 |
^ VariableNode type:#MethodVariable |
|
2276 |
name:varName |
|
2277 |
token:var |
|
2278 |
index:varIndex |
|
2279 |
]. |
|
2280 |
]. |
|
2281 |
self warning:'Sorry - unimplemented (adding ' , choice , ')'. |
|
2282 |
]. |
|
2283 |
^ #Error |
|
2284 |
]. |
|
2285 |
^ nil. |
|
2286 |
! |
|
2287 |
||
1519 | 2288 |
checkBlockArgumentNameConventionsFor:aVariableName |
2289 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2290 |
! |
|
2291 |
||
2292 |
checkBlockVariableNameConventionsFor:aVariableName |
|
2293 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2294 |
! |
|
2295 |
||
2296 |
checkForLowercaseVariableName:aVariableName |
|
2297 |
aVariableName first isUppercase ifTrue:[ |
|
2298 |
self |
|
2299 |
syntaxError:('variable "' , aVariableName , '" should be lowercase (by convention)') |
|
2300 |
position:tokenPosition to:source position1Based - 1. |
|
2301 |
]. |
|
2302 |
! |
|
2303 |
||
2304 |
checkForProperUseOfArticleInVariableName:aVariableName |
|
1632 | 2305 |
|firstCharacterAfterArticle whatShouldItBeNamed| |
1519 | 2306 |
|
1521
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2307 |
aVariableName size > 4 ifTrue:[ |
1519 | 2308 |
(aVariableName startsWith:'an') ifTrue:[ |
1632 | 2309 |
firstCharacterAfterArticle := aVariableName at:3. |
2310 |
firstCharacterAfterArticle isUppercase ifTrue:[ |
|
2311 |
('AEIOX' includes:firstCharacterAfterArticle) ifFalse:[ |
|
1643 | 2312 |
((aVariableName copyFrom:3) startsWith:'Up') ifFalse:[ |
2313 |
whatShouldItBeNamed := 'a' , (aVariableName copyFrom:3). |
|
2314 |
] |
|
1632 | 2315 |
] |
1519 | 2316 |
]. |
1643 | 2317 |
] ifFalse:[ |
2318 |
(aVariableName startsWith:'a') ifTrue:[ |
|
2319 |
firstCharacterAfterArticle := aVariableName at:2. |
|
2320 |
firstCharacterAfterArticle isUppercase ifTrue:[ |
|
2321 |
('AEIOX' includes:firstCharacterAfterArticle) ifTrue:[ |
|
2322 |
whatShouldItBeNamed := 'an' , (aVariableName copyFrom:2). |
|
2323 |
]. |
|
1521
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2324 |
]. |
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2325 |
]. |
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2326 |
]. |
1632 | 2327 |
whatShouldItBeNamed notNil ifTrue:[ |
2328 |
self |
|
2329 |
warnCommonMistake:('variable "',aVariableName,'" should be named "',whatShouldItBeNamed,'" (by english language rules)') |
|
2330 |
position:tokenPosition to:source position1Based - 1. |
|
2331 |
]. |
|
1519 | 2332 |
]. |
2333 |
! |
|
2334 |
||
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2335 |
checkIfAllSubclassesOf:aClass implement:aSelector |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2336 |
(aClass subclasses |
1517 | 2337 |
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
|
2338 |
^ true. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2339 |
! |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
2340 |
|
1522
777862196320
checkVariable-conventions: can be (are by default) disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
2341 |
checkLocalVariableNameConventionsFor:aVariableName |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2342 |
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
|
2343 |
self checkForLowercaseVariableName:aVariableName. |
777862196320
checkVariable-conventions: can be (are by default) disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
2344 |
]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
2345 |
parserFlags warnAboutWrongVariableNames == true ifTrue:[ |
1521
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2346 |
self checkForProperUseOfArticleInVariableName:aVariableName. |
3488542e7a83
checkVariable-conventions: can be disabled via classVar.
Claus Gittinger <cg@exept.de>
parents:
1520
diff
changeset
|
2347 |
]. |
1519 | 2348 |
! |
2349 |
||
2350 |
checkMethodArgumentNameConventionsFor:aVariableName |
|
2351 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2352 |
! |
|
2353 |
||
2354 |
checkMethodVariableNameConventionsFor:aVariableName |
|
2355 |
self checkLocalVariableNameConventionsFor:aVariableName. |
|
2356 |
! |
|
2357 |
||
1507 | 2358 |
checkSelector:selector for:receiver inClass:cls |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2359 |
"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
|
2360 |
that the method is not obsolete. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2361 |
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
|
2362 |
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
|
2363 |
|
1507 | 2364 |
|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
|
2365 |
|
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2366 |
cls isNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2367 |
SystemBrowser isNil ifTrue:[ |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2368 |
^ nil |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2369 |
]. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2370 |
"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
|
2371 |
implementors := SystemBrowser |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2372 |
findImplementorsOf:selector |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2373 |
in:(Smalltalk allClasses) |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2374 |
ignoreCase:false. |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2375 |
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
|
2376 |
^ 'is nowhere implemented' |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2377 |
]. |
1499
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 |
(implementors conform:[:eachMethod| eachMethod isObsolete]) ifTrue:[ |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2380 |
^ '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
|
2381 |
]. |
1190
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2382 |
^ nil |
8600334a549e
oops - avoid cought error if method is parsed in no class.
Claus Gittinger <cg@exept.de>
parents:
1189
diff
changeset
|
2383 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2384 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2385 |
mthd := cls lookupMethodFor:selector. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2386 |
mthd isNil ifTrue:[ |
1327 | 2387 |
cls == Boolean ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2388 |
mthd := True compiledMethodAt:selector. |
1327 | 2389 |
mthd isNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2390 |
mthd := False compiledMethodAt:selector. |
1327 | 2391 |
]. |
2392 |
] |
|
2393 |
]. |
|
2394 |
mthd isNil ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2395 |
"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
|
2396 |
implementor := cls whichClassIncludesSelector:#doesNotUnderstand:. |
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
2397 |
"/ (implementor isNil or:[implementor == Object]) ifTrue:[ |
1599 | 2398 |
err := 'is not implemented in ' , cls name allBold |
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
2399 |
"/ ]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2400 |
] ifFalse:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
2401 |
(mthd sends:#shouldNotImplement) ifTrue:[ |
1562 | 2402 |
mthd messagesSent size == 1 ifTrue:[ |
2403 |
allowed := (cls == classToCompileFor). "methods in abstract classes may send messages to abstract methods in the same class" |
|
2404 |
allowed ifFalse:[ |
|
2405 |
err := 'is not (should not be) implemented' |
|
2406 |
] |
|
1542 | 2407 |
] |
1517 | 2408 |
] ifFalse:[ |
2409 |
(mthd sends:#subclassResponsibility) ifTrue:[ |
|
2410 |
allowed := (cls == classToCompileFor). "methods in abstract classes may send messages to abstract methods in the same class" |
|
2411 |
allowed ifFalse:[ |
|
2412 |
"methods in abstract classes may send messages to abstract methods in meta class" |
|
2413 |
(cls == classToCompileFor class) ifTrue:[ |
|
2414 |
allowed := receiver isMessage and:[receiver selector = 'class'] |
|
2415 |
]. |
|
1507 | 2416 |
]. |
1517 | 2417 |
allowed ifTrue:[ |
1519 | 2418 |
"/ not from cg to stefan: thats wrong - if not implemented in all subclasses, |
2419 |
"/ its a bug of the subclass not a bug here - that message send here |
|
2420 |
"/ is perfectly correct. (it is very annoying for a framework developped to get |
|
2421 |
"/ error messages for bugs which are not his... |
|
2422 |
"/ (self checkIfAllSubclassesOf:cls implement:selector) ifFalse:[ |
|
2423 |
"/ "if not all subclasses implement the selector - this is a possible bug" |
|
2424 |
"/ allowed := false |
|
2425 |
"/ ]. |
|
1507 | 2426 |
]. |
1517 | 2427 |
allowed ifFalse:[ |
2428 |
err := 'is subclassResponsibility' |
|
2429 |
]. |
|
2430 |
] ifFalse:[mthd isObsolete ifTrue:[ |
|
2431 |
err := 'is deprecated'. |
|
2432 |
]] |
|
2433 |
]. |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2434 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2435 |
^ err. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2436 |
! |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2437 |
|
141 | 2438 |
correctByDeleting |
2439 |
"correct (by deleting token) if user wants to; |
|
2440 |
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
|
2441 |
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
|
2442 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2443 |
|selectionSize| |
141 | 2444 |
|
2445 |
(self confirm:'confirm deleting') ifFalse:[^ #Error]. |
|
2446 |
||
2447 |
" |
|
2448 |
tell requestor (i.e. CodeView) about the change |
|
2449 |
this will update what the requestor shows. |
|
2450 |
" |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2451 |
selectionSize := requestor selection size. |
141 | 2452 |
requestor deleteSelection. |
2453 |
||
2454 |
" |
|
2455 |
get the updated source-string |
|
2456 |
which is needed, when we eventually install the new method |
|
2457 |
" |
|
2458 |
correctedSource := requestor currentSourceCode. |
|
1167 | 2459 |
"/ 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
|
2460 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2461 |
position:(source position1Based - selectionSize). |
1369
2304dd8c3173
recompilation after correct-by-deleting unused local
Claus Gittinger <cg@exept.de>
parents:
1368
diff
changeset
|
2462 |
|
141 | 2463 |
^ nil |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2464 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2465 |
"Modified: / 22.1.1998 / 16:39:11 / stefan" |
141 | 2466 |
! |
2467 |
||
1439 | 2468 |
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
|
2469 |
"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
|
2470 |
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
|
2471 |
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
|
2472 |
|
1439 | 2473 |
|correctIt suggestedNames newSelector className classToGenerateCode pos1 pos2| |
2474 |
||
2475 |
pos1 := posVector first start. |
|
2476 |
pos2 := posVector last stop. |
|
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2477 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2478 |
alreadyWarnedUnimplementedSelectors isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2479 |
alreadyWarnedUnimplementedSelectors := Set new |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2480 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2481 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2482 |
(alreadyWarnedUnimplementedSelectors includes:aSelectorString) ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2483 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2484 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2485 |
|
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 |
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
|
2488 |
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
|
2489 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2490 |
(aSelectorString occurrencesOf:$:) > 1 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2491 |
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
|
2492 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2493 |
^ aSelectorString |
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 |
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
|
2497 |
correctIt == #generate ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2498 |
receiverNode isSelf ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2499 |
classToGenerateCode := classToCompileFor |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2500 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2501 |
receiverNode isVariable ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2502 |
receiverNode isGlobal ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2503 |
classToGenerateCode := receiverNode evaluate. |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2504 |
classToGenerateCode isBehavior ifTrue:[ |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2505 |
classToGenerateCode := classToGenerateCode theMetaclass. |
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2506 |
] ifFalse:[ |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2507 |
classToGenerateCode := nil |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2508 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2509 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2510 |
] |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2511 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2512 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2513 |
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
|
2514 |
className size == 0 ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2515 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2516 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2517 |
classToGenerateCode := Smalltalk at:className asSymbol. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2518 |
classToGenerateCode isNil ifTrue:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2519 |
self warn:'No such class.'. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2520 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2521 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2522 |
]. |
1252
666db3206028
#implements: -> #includesSelector:
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2523 |
(classToGenerateCode includesSelector:aSelectorString asSymbol) ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2524 |
"do not overwrite an already existant (deprecated) method" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2525 |
classToGenerateCode |
1336
67ea8b161346
Generate class methods in class.
Stefan Vogel <sv@exept.de>
parents:
1335
diff
changeset
|
2526 |
compile:((self class methodSpecificationForSelector:aSelectorString) , '\ self shouldImplement' withCRs) |
1323 | 2527 |
classified:(Compiler defaultMethodCategory). |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
2528 |
]. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2529 |
correctIt := false. |
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 |
correctIt ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2532 |
alreadyWarnedUnimplementedSelectors add:aSelectorString. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2533 |
^ aSelectorString |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2534 |
]. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2535 |
|
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2536 |
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
|
2537 |
suggestedNames notNil ifTrue:[ |
1323 | 2538 |
newSelector := self askForCorrection:'Correct Selector to: ' fromList:suggestedNames for:aSelectorString. |
2539 |
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
|
2540 |
] ifFalse:[ |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2541 |
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
|
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 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2546 |
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
|
2547 |
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
|
2548 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2549 |
requestor replaceSelectionBy:newSelector keepCursor:false. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2550 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2551 |
get the updated source-string |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2552 |
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
|
2553 |
" |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2554 |
correctedSource := requestor currentSourceCode. |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2555 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2556 |
position:(source position1Based + 1 + (newSelector size - aSelectorString size)). |
1361 | 2557 |
"/ Parser murks. |
1156
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2558 |
^ newSelector |
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 |
"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
|
2561 |
"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
|
2562 |
"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
|
2563 |
! |
b491528ad92b
fixed 'generate' option (in selector will not be understood)
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
2564 |
|
1167 | 2565 |
correctSourceByDeletingFrom:start to:stop |
2566 |
"correct (by deleting token) if user wants to; |
|
2567 |
return #Error if there was no correction; |
|
2568 |
nil if there was one." |
|
2569 |
||
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2570 |
|deleteSize localDefsStart localDefsStop newPos| |
1167 | 2571 |
|
2572 |
" |
|
2573 |
tell requestor (i.e. CodeView) about the change |
|
2574 |
this will update what the requestor shows. |
|
2575 |
" |
|
2576 |
deleteSize := stop - start + 1. |
|
2577 |
requestor deleteFromCharacterPosition:start to:stop. |
|
2578 |
||
2579 |
" |
|
2580 |
get the updated source-string |
|
2581 |
which is needed, when we eventually install the new method |
|
2582 |
" |
|
2583 |
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
|
2584 |
|
1167 | 2585 |
"/ 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
|
2586 |
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
|
2587 |
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
|
2588 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2589 |
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
|
2590 |
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
|
2591 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2592 |
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
|
2593 |
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
|
2594 |
] ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2595 |
newPos := start |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2596 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2597 |
] |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2598 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2599 |
source := (ReadStream on:correctedSource) position1Based:newPos. |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2600 |
|
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2601 |
localDefsStart := localVarDefPosition at:1. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2602 |
localDefsStop := localVarDefPosition at:2. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2603 |
|
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2604 |
localDefsStop <= start ifTrue:[^ self]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2605 |
localDefsStart >= stop ifTrue:[^ self]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2606 |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2607 |
(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
|
2608 |
localVarDefPosition := nil. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2609 |
^ self |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2610 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2611 |
|
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2612 |
"/ must update |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2613 |
(start > localDefsStart and:[stop < localDefsStop]) ifTrue:[ |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2614 |
localVarDefPosition at:2 put:(localDefsStop - (stop-start+1)). |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2615 |
^ self. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2616 |
]. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2617 |
self halt. |
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
2618 |
^ self |
1167 | 2619 |
! |
2620 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2621 |
correctVariable:varName atPosition:pos1 to:pos2 |
141 | 2622 |
"notify error and correct if user wants to; |
2623 |
return #Error if there was no correction |
|
2624 |
or a ParseNode as returned by variable" |
|
2625 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2626 |
|correctIt suggestedNames newName rslt |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
2627 |
varNameIsLowercase undeclared boldName| |
141 | 2628 |
|
877 | 2629 |
varNameIsLowercase := (varName at:1) isLowercase. |
2630 |
||
141 | 2631 |
correctIt := self undefError:varName position:pos1 to:pos2. |
887 | 2632 |
(correctIt == false or:[correctIt == #continue]) ifTrue:[ |
877 | 2633 |
"/ no correction wanted. |
2634 |
||
2635 |
"/ lowerCase vars are added to the Undeclared dictionary, |
|
2636 |
"/ allowing easy search for bad-spots later. |
|
1285 | 2637 |
boldName := varName allBold. |
877 | 2638 |
|
2639 |
varNameIsLowercase ifTrue:[ |
|
1205 | 2640 |
undeclared := Smalltalk at:#Undeclared. |
2641 |
((undeclared notNil) |
|
2642 |
and:[(undeclared includes:varName asSymbol)]) ifFalse:[ |
|
1285 | 2643 |
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
|
2644 |
]. |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2645 |
^ self defineAsUndeclaredVariable:varName |
877 | 2646 |
]. |
2647 |
||
2648 |
"/ upperCase vars are declared as global |
|
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2649 |
(warnedUndefVars isNil or:[(warnedUndefVars includes:varName) not]) ifTrue:[ |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2650 |
(warnedUnknownNamespaces isNil or:[(warnedUnknownNamespaces includes:varName) not]) ifTrue:[ |
1285 | 2651 |
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
|
2652 |
]. |
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
2653 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2654 |
^ VariableNode globalNamed:varName |
877 | 2655 |
]. |
2656 |
||
1491 | 2657 |
correctIt == #Error ifTrue:[ |
2658 |
^ #Error |
|
2659 |
]. |
|
2660 |
||
877 | 2661 |
correctIt == #declare ifTrue:[ |
2662 |
"/ declare it |
|
1295 | 2663 |
rslt := self askForVariableTypeWhenDeclaringUndefined:varName. |
2664 |
rslt notNil ifTrue:[ |
|
2665 |
^ rslt |
|
2666 |
]. |
|
141 | 2667 |
]. |
1398
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2668 |
(correctIt isKindOf:ParseNode) ifTrue:[ |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2669 |
^ correctIt |
eaef898b063e
added undefinedVariableNotification
Claus Gittinger <cg@exept.de>
parents:
1394
diff
changeset
|
2670 |
]. |
141 | 2671 |
|
2672 |
suggestedNames := self findBestVariablesFor:varName. |
|
877 | 2673 |
suggestedNames isNil ifTrue:[ |
1285 | 2674 |
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
|
2675 |
^ #Error |
141 | 2676 |
]. |
2677 |
||
1285 | 2678 |
newName := self askForCorrection:'Correct Variable to: ' fromList:suggestedNames. |
877 | 2679 |
newName isNil ifTrue:[^ #Error]. |
2680 |
" |
|
2681 |
newName := suggestedNames at:1. |
|
2682 |
(self confirm:('confirm correction to: ' , newName)) ifFalse:[^ #Error]. |
|
2683 |
" |
|
2684 |
||
141 | 2685 |
" |
2686 |
tell requestor (i.e. CodeView) about the change |
|
2687 |
this will update what the requestor shows. |
|
2688 |
" |
|
2689 |
requestor replaceSelectionBy:newName. |
|
2690 |
" |
|
2691 |
get the updated source-string |
|
2692 |
which is needed, when we eventually install the new method |
|
2693 |
" |
|
2694 |
correctedSource := requestor currentSourceCode. |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2695 |
source := (ReadStream on:correctedSource) |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
2696 |
position:(source position1Based + newName size - tokenName size). |
141 | 2697 |
|
2698 |
"redo parse with new value" |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
2699 |
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
|
2700 |
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
|
2701 |
|
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
|
2702 |
"/ 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
|
2703 |
rslt == #Error ifTrue:[ |
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2704 |
"/ 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
|
2705 |
|
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2706 |
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
|
2707 |
]. |
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
|
2708 |
^ 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
|
2709 |
|
644
834399365be9
Highlighting of undefined variables didn't work after first correction
Stefan Vogel <sv@exept.de>
parents:
640
diff
changeset
|
2710 |
"Modified: / 22.1.1998 / 16:34:01 / stefan" |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
2711 |
"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
|
2712 |
! |
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
|
2713 |
|
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
|
2714 |
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
|
2715 |
"define varName as undeclared variable |
629 | 2716 |
(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
|
2717 |
You can browse for methods with undeclareds by searching for global accesses |
629 | 2718 |
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
|
2719 |
|
1206 | 2720 |
|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
|
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 |
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
|
2723 |
|
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 |
"/ 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
|
2725 |
|
1206 | 2726 |
undeclared := Smalltalk at:#Undeclared. |
2727 |
undeclared isNil ifTrue:[ |
|
2728 |
Smalltalk at:#Undeclared put:(undeclared := IdentitySet new). |
|
2729 |
]. |
|
2730 |
undeclared add:tokenName asSymbol. |
|
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
2731 |
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
|
2732 |
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
|
2733 |
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
|
2734 |
|
762
66cd2b4f6689
Big BUG: remember original name in usedVars - not Undeclared::xxx
tm
parents:
755
diff
changeset
|
2735 |
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
|
2736 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
2737 |
^ 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
|
2738 |
|
629 | 2739 |
"Modified: / 31.10.1997 / 01:16:03 / cg" |
141 | 2740 |
! |
2741 |
||
1167 | 2742 |
deleteDefinitionOf:varName in:defStartPos to:defEndPos |
1393 | 2743 |
"this removes the definition of varName from the declaration part i.e. |
2744 |
if the source was '... | foo bar baz |...' |
|
2745 |
deleting the var 'bar' changes the source to '... | foo baz |...'. |
|
2746 |
The code below tries to be somewhat smart w.r.t. spaces by |
|
2747 |
trying to remove the whiteSpace around the removed variable also. |
|
2748 |
However, this seems to not always work correctly" |
|
2749 |
||
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2750 |
|source startSearch pos pos2 nextChar varSlot p p2| |
1172 | 2751 |
|
2752 |
varSlot := methodVars detect:[:var | var name = varName]. |
|
2753 |
methodVars removeIdentical:varSlot. |
|
1167 | 2754 |
|
2755 |
source := requestor currentSourceCode. |
|
2756 |
startSearch := defStartPos+1. |
|
2757 |
||
2758 |
[ |
|
1393 | 2759 |
|prevChar isFirstVar didPassEndOfLine| |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2760 |
|
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2761 |
"/ search this name's position in the declaration part ... |
1167 | 2762 |
pos := source indexOfSubCollection:varName startingAt:startSearch ifAbsent:0. |
1326 | 2763 |
(pos == 0 or:[pos >= defEndPos]) ifTrue:[ |
2764 |
self error:'should not happen' mayProceed:true. |
|
1167 | 2765 |
^ self. |
2766 |
]. |
|
2767 |
||
2768 |
pos2 := pos + varName size - 1. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2769 |
pos > 1 ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2770 |
prevChar := source at:pos-1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2771 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2772 |
(prevChar isNil or:[prevChar isLetterOrDigit not]) ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2773 |
nextChar := source at:pos2+1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2774 |
nextChar isLetterOrDigit ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2775 |
"/ halfway intuitive space-removal behavior; |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2776 |
"/ if there was a space after/before the |-char, |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2777 |
"/ leave it; otherwise remove it. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2778 |
isFirstVar := pos == (defStartPos+1). |
1393 | 2779 |
(source at:pos-1) isSeparator ifTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2780 |
pos := pos - 1. |
1393 | 2781 |
[ (source at:pos-1) isSeparator] whileTrue:[ |
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2782 |
pos := pos - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2783 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2784 |
(source at:pos-1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2785 |
"/ there was a space before - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2786 |
pos := pos + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2787 |
isFirstVar := true. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2788 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2789 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2790 |
|
1393 | 2791 |
(source at:pos2+1) isSeparator ifTrue:[ |
2792 |
didPassEndOfLine := (source at:pos2+1) == Character cr. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2793 |
pos2 := pos2 + 1. |
1393 | 2794 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
2795 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2796 |
pos2 := pos2 + 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2797 |
]. |
1393 | 2798 |
|
2799 |
didPassEndOfLine ifFalse:[ |
|
2800 |
(source at:pos2+1) == $" ifTrue:[ |
|
2801 |
"/ comment follows - assume it belongs to the removed variable |
|
2802 |
pos2 := pos2 + 1. |
|
2803 |
(source at:pos2+1) == $/ ifTrue:[ |
|
2804 |
"/ EOL comment |
|
2805 |
[ (source at:pos2+1) == Character cr ] whileFalse:[ |
|
2806 |
pos2 := pos2 + 1. |
|
2807 |
]. |
|
2808 |
pos2 := pos2 + 1. |
|
2809 |
] ifFalse:[ |
|
2810 |
"/ regular comment |
|
2811 |
[ (source at:pos2+1) == $" ] whileFalse:[ |
|
2812 |
pos2 := pos2 + 1. |
|
2813 |
]. |
|
2814 |
pos2 := pos2 + 1. |
|
2815 |
]. |
|
2816 |
[ (source at:pos2+1) isSeparator] whileTrue:[ |
|
2817 |
(source at:pos2+1) == Character cr ifTrue:[ didPassEndOfLine := true ]. |
|
2818 |
pos2 := pos2 + 1. |
|
2819 |
]. |
|
2820 |
] |
|
2821 |
]. |
|
2822 |
||
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2823 |
(source at:pos2+1) == $| ifTrue:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2824 |
"/ there was a space after - leave it |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2825 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2826 |
] ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2827 |
isFirstVar ifFalse:[ |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2828 |
pos2 := pos2 - 1. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2829 |
] |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2830 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2831 |
]. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2832 |
|
1445
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2833 |
"/ 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
|
2834 |
((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
|
2835 |
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
|
2836 |
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
|
2837 |
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
|
2838 |
"/ 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
|
2839 |
p := pos. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2840 |
p2 := pos2. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2841 |
|
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2842 |
[(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
|
2843 |
[(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
|
2844 |
((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
|
2845 |
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
|
2846 |
pos2 := p2. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2847 |
(((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
|
2848 |
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
|
2849 |
ifFalse:[ |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2850 |
(((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
|
2851 |
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
|
2852 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2853 |
]. |
2bd299cdc753
delete unused variable-decl: when decl is empty, remove it as well
Claus Gittinger <cg@exept.de>
parents:
1442
diff
changeset
|
2854 |
|
1392
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2855 |
self correctSourceByDeletingFrom:pos to:pos2. |
2c06fa7b9bbe
remove unused variable fixed
Claus Gittinger <cg@exept.de>
parents:
1391
diff
changeset
|
2856 |
^ self. |
1167 | 2857 |
]. |
2858 |
]. |
|
2859 |
startSearch := pos2 + 1. |
|
2860 |
] loop |
|
2861 |
! |
|
2862 |
||
141 | 2863 |
findBestSelectorsFor:aString |
2864 |
"collect known selectors with their spelling distances to aString; |
|
2865 |
return the 10 best suggestions" |
|
2866 |
||
1187 | 2867 |
^ self class findBestSelectorsFor:aString |
141 | 2868 |
|
2869 |
"Time millisecondsToRun:[Parser new findBestSelectorsFor:'foo']" |
|
2870 |
"Parser new findBestSelectorsFor:'findBestSel'" |
|
2871 |
"Parser new findBestSelectorsFor:'fildBestSelectrFr'" |
|
2872 |
! |
|
2873 |
||
1022 | 2874 |
findBestSelectorsFor:aString in:aClassOrNil |
2875 |
"collect known selectors with their spelling distances to aString; |
|
2876 |
return the 10 best suggestions. If the argument, aClassOrNil is not nil, |
|
2877 |
the message is assumed to be sent to instances of that class (i.e. offer |
|
2878 |
corrections from that hierarchy only)" |
|
2879 |
||
1187 | 2880 |
^ self class findBestSelectorsFor:aString in:aClassOrNil |
1022 | 2881 |
! |
2882 |
||
141 | 2883 |
findBestVariablesFor:aString |
2884 |
"collect known variables with their spelling distances to aString; |
|
2885 |
return the 10 best suggestions" |
|
2886 |
||
1200 | 2887 |
|names dists searchBlock args vars "aClass className baseClass" |
2888 |
n instVarNames classVarNames spellAgainstAction| |
|
141 | 2889 |
|
2890 |
names := OrderedCollection new. |
|
2891 |
dists := OrderedCollection new. |
|
2892 |
||
1200 | 2893 |
spellAgainstAction := |
2894 |
[:aVarNode | |
|
2895 |
|varName dist| |
|
2896 |
||
2897 |
varName := aVarNode name. |
|
2898 |
names add:varName. |
|
2899 |
||
2900 |
dist := aString spellAgainst:varName. |
|
2901 |
(aString startsWith:varName) ifTrue:[ |
|
2902 |
dist := dist + (aString size * 10). |
|
2903 |
]. |
|
2904 |
dists add:dist |
|
2905 |
]. |
|
2906 |
||
141 | 2907 |
"block arguments" |
2908 |
searchBlock := currentBlock. |
|
2909 |
[searchBlock notNil] whileTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2910 |
args := searchBlock arguments. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2911 |
args notNil ifTrue:[ |
1200 | 2912 |
args do:spellAgainstAction |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2913 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2914 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2915 |
vars := searchBlock variables. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2916 |
vars notNil ifTrue:[ |
1200 | 2917 |
vars do:spellAgainstAction |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2918 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2919 |
searchBlock := searchBlock home |
141 | 2920 |
]. |
2921 |
||
1200 | 2922 |
spellAgainstAction := |
2923 |
[:givenName | |
|
2924 |
|dist| |
|
2925 |
||
2926 |
names add:givenName. |
|
2927 |
dist := aString spellAgainst:givenName. |
|
2928 |
(aString startsWith:givenName) ifTrue:[ |
|
2929 |
dist := dist + (aString size * 10). |
|
2930 |
]. |
|
2931 |
dists add:dist |
|
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 | |
|
1200 | 2974 |
|globalVarName| |
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. |
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2981 |
] |
141 | 2982 |
]. |
2983 |
||
2984 |
"misc" |
|
1200 | 2985 |
#('self' 'super' 'nil' 'thisContext') do:spellAgainstAction. |
141 | 2986 |
|
2987 |
(dists size ~~ 0) ifTrue:[ |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2988 |
dists sortWith:names. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2989 |
dists := dists reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2990 |
names := names reverse. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2991 |
n := names size min:10. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2992 |
names := names copyTo:n. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2993 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2994 |
"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
|
2995 |
(aString at:1) isLowercase ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2996 |
methodVarNames size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2997 |
names add:'---- method locals ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2998 |
methodVarNames asSortedCollection do:[:methodVarName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
2999 |
names add:methodVarName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3000 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3001 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3002 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3003 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3004 |
methodArgs size > 0 ifTrue:[ |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3005 |
names add:'---- method arguments ----'. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3006 |
methodArgNames asSortedCollection do:[:methodArgName | |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3007 |
names add:methodArgName. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3008 |
] |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3009 |
]. |
1078 | 3010 |
classToCompileFor notNil ifTrue:[ |
3011 |
instVarNames := OrderedCollection new. |
|
3012 |
self classesInstVarNames asSortedCollection do:[:instVarName | |
|
3013 |
(instVarNames includes:instVarName) ifFalse:[ |
|
3014 |
instVarNames add:instVarName. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3015 |
] |
1078 | 3016 |
]. |
3017 |
||
3018 |
instVarNames size > 0 ifTrue:[ |
|
3019 |
(classToCompileFor notNil and:[classToCompileFor isMeta]) ifTrue:[ |
|
3020 |
names add:'---- class instance variables ----'. |
|
3021 |
] ifFalse:[ |
|
3022 |
names add:'---- instance variables ----'. |
|
3023 |
]. |
|
3024 |
instVarNames do:[:instVarName | |
|
3025 |
(names includes:instVarName) ifFalse:[ |
|
3026 |
names add:instVarName. |
|
3027 |
] |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3028 |
] |
1078 | 3029 |
]. |
3030 |
||
3031 |
classVarNames := OrderedCollection new. |
|
3032 |
self classesClassVarNames asSortedCollection do:[:classVarName | |
|
3033 |
(classVarNames includes:classVarName) ifFalse:[ |
|
3034 |
classVarNames add:classVarName. |
|
3035 |
] |
|
3036 |
]. |
|
3037 |
||
3038 |
classVarNames size > 0 ifTrue:[ |
|
3039 |
names add:'---- class variables ----'. |
|
3040 |
classVarNames do:[:classVarName | |
|
3041 |
(names includes:classVarName) ifFalse:[ |
|
3042 |
names add:classVarName. |
|
3043 |
] |
|
3044 |
] |
|
3045 |
]. |
|
989
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3046 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3047 |
]. |
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3048 |
|
6e535d9d87d8
better undef-variable message;
Claus Gittinger <cg@exept.de>
parents:
988
diff
changeset
|
3049 |
^ names |
141 | 3050 |
]. |
3051 |
^ nil |
|
450 | 3052 |
|
480
e4ac7e62ca9a
better block-var name detection in debugger
Claus Gittinger <cg@exept.de>
parents:
473
diff
changeset
|
3053 |
"Modified: 11.1.1997 / 21:28:28 / cg" |
141 | 3054 |
! |
3055 |
||
3056 |
selectorCheck:aSelectorString for:receiver position:pos1 to:pos2 |
|
1439 | 3057 |
^ self selectorCheck:aSelectorString for:receiver positions:(Array with:(pos1 to:pos2)). |
3058 |
! |
|
3059 |
||
3060 |
selectorCheck:aSelectorString for:receiver positions:posVector |
|
141 | 3061 |
"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
|
3062 |
has the same name as a variable, cannot be understood or is obsolete. |
141 | 3063 |
Simple, but catches many typos" |
3064 |
||
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3065 |
|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
|
3066 |
pos1 pos2 canDefine| |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3067 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3068 |
isSyntaxHighlighter := self isSyntaxHighlighter. |
141 | 3069 |
|
3070 |
" |
|
3071 |
if compiling lazy, or errors are to be ignored, or there |
|
3072 |
is no requestor, do not check |
|
3073 |
" |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3074 |
isSyntaxHighlighter ifFalse:[ |
1545 | 3075 |
(LazyCompilation == true) ifTrue:[^ aSelectorString]. |
1022 | 3076 |
(ignoreErrors or:[ignoreWarnings]) ifTrue:[^ aSelectorString]. |
3077 |
(requestor isNil or:[requestor isStream]) ifTrue:[^ aSelectorString]. |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
3078 |
]. |
141 | 3079 |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3080 |
canDefine := false. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3081 |
|
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3082 |
pos1 := posVector first start. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3083 |
pos2 := posVector last stop. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3084 |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3085 |
aSelectorString = '#' ifTrue:[ |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3086 |
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
|
3087 |
]. |
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
3088 |
|
141 | 3089 |
" |
3090 |
check if the selector is known at all |
|
3091 |
- if not, it cannot be understood |
|
3092 |
" |
|
1327 | 3093 |
nowhereImplemented := false. |
3094 |
||
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3095 |
selectorSymbol := aSelectorString asSymbolIfInterned. |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3096 |
selectorSymbol isNil ifTrue:[ |
1327 | 3097 |
nowhereImplemented := true. |
1518 | 3098 |
] ifFalse:[ |
3099 |
"/ temporarily disabled - too slow. |
|
3100 |
"/ self isSyntaxHighlighter ifTrue:[ |
|
3101 |
"/ nowhereImplemented := (self implementedInAnyClass:selectorSymbol) not. |
|
3102 |
"/ ] |
|
1327 | 3103 |
]. |
3104 |
||
3105 |
nowhereImplemented ifTrue:[ |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3106 |
err := ' is currently nowhere implemented'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3107 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3108 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3109 |
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
|
3110 |
" |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3111 |
((methodVarNames notNil and:[methodVarNames includes:aSelectorString]) |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3112 |
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
|
3113 |
or:[classToCompileFor notNil |
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3114 |
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
|
3115 |
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
|
3116 |
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
|
3117 |
]]]]]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3118 |
err := ' is currently nowhere implemented .. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3119 |
.. but a variable with that name is defined. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3120 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3121 |
Missing ''.'' after the previous expression |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3122 |
or missing keyword/receiver before that word ?'. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3123 |
]. |
1327 | 3124 |
] ifFalse:[ |
3125 |
receiver notNil ifTrue:[ |
|
3126 |
selClass := self typeOfNode:receiver. |
|
3127 |
selClass notNil ifTrue:[ |
|
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3128 |
"this could be performed if selClass isNil, but it is too slow" |
1507 | 3129 |
err := self checkSelector:selectorSymbol for:receiver inClass:selClass. |
1327 | 3130 |
]. |
3131 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3132 |
(receiver isConstant or:[receiver isBlock]) ifTrue:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3133 |
err notNil ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3134 |
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
|
3135 |
]. |
1327 | 3136 |
] ifFalse:[(((recType := receiver type) == #GlobalVariable) |
3137 |
or:[recType == #PrivateClass]) ifTrue:[ |
|
3138 |
rec := receiver evaluate. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3139 |
"/ dont check autoloaded classes - it may work after loading |
1327 | 3140 |
(rec isNil |
3141 |
or:[rec isBehavior and:[rec isLoaded not]]) ifTrue:[ |
|
3142 |
^ aSelectorString |
|
3143 |
]. |
|
3144 |
||
3145 |
err notNil ifTrue:[ |
|
3146 |
(rec isBehavior |
|
3147 |
and:[rec theNonMetaclass name = receiver name]) ifTrue:[ |
|
3148 |
err := err, ' in ' , rec theNonMetaclass name. |
|
3149 |
] ifFalse:[ |
|
3150 |
err := err, ' in currently assigned value (is currently ' , rec classNameWithArticle , ')'. |
|
3151 |
] |
|
3152 |
]. |
|
3153 |
] ifFalse:[receiver isSuper ifTrue:[ |
|
3154 |
receiver isHere ifFalse:[ |
|
3155 |
err notNil ifTrue:[ |
|
3156 |
err := err, ' in superclass chain'. |
|
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3157 |
]. |
1327 | 3158 |
] ifTrue:[ |
3159 |
err notNil ifTrue:[ |
|
3160 |
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
|
3161 |
]. |
1327 | 3162 |
] |
3163 |
] ifFalse:[receiver isSelf ifTrue:[ |
|
3164 |
err notNil ifTrue:[ |
|
3165 |
|subErr| |
|
3166 |
||
3167 |
"/ understood by all subclasses ? |
|
3168 |
classToCompileFor allSubclassesDo:[:eachSubclass | |
|
3169 |
subErr isNil ifTrue:[ |
|
3170 |
selClass := eachSubclass. |
|
1507 | 3171 |
subErr := self checkSelector:selectorSymbol for:receiver inClass:selClass. |
1327 | 3172 |
]. |
3173 |
]. |
|
3174 |
subErr notNil ifTrue:[ |
|
3175 |
err := subErr, ' in this class, superclass chain or all subclasses' |
|
3176 |
] ifFalse:[ |
|
3177 |
err := err, ' in this class or superclass chain'. |
|
1440 | 3178 |
]. |
3179 |
canDefine := true. |
|
1327 | 3180 |
]. |
3181 |
] ifFalse:[(receiver isUnaryMessage |
|
3182 |
and:[receiver selector == #class |
|
3183 |
and:[receiver receiver isSelf]]) ifTrue:[ |
|
3184 |
"its a message to self class - can check this too ..." |
|
3185 |
err notNil ifTrue:[ |
|
3186 |
classToCompileFor isMeta ifTrue:[ |
|
3187 |
err := err, ' for the classes class'. |
|
1507 | 3188 |
(self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[ |
1327 | 3189 |
err := err, '...\\...but its implemented for the class itself. You probably do not want the #class message here.'. |
3190 |
err := err withCRs. |
|
3191 |
]. |
|
3192 |
] ifFalse:[ |
|
3193 |
err := err, ' for my class'. |
|
1507 | 3194 |
(self checkSelector:selectorSymbol for:receiver inClass:classToCompileFor) isNil ifTrue:[ |
1327 | 3195 |
err := err, '...\\...but its implemented for instances. You may want to remove the #class message.'. |
3196 |
err := err withCRs. |
|
3197 |
]. |
|
1203
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3198 |
]. |
2bd6633eced0
better error message for 'class foo', where foo is implemented in the instance.
Claus Gittinger <cg@exept.de>
parents:
1202
diff
changeset
|
3199 |
]. |
1327 | 3200 |
] ifFalse:[(receiver isMethodVariable and:[receiver token type isNil]) ifTrue:[ |
3201 |
"if it is an uninitialized variable ..." |
|
3202 |
((modifiedLocalVars isNil or:[(modifiedLocalVars includes:receiver name) not]) |
|
1441 | 3203 |
and:[hasPrimitiveCode not |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3204 |
and:[currentBlock isNil |
1327 | 3205 |
and:[alreadyWarnedUninitializedVars isNil |
1442 | 3206 |
or:[(alreadyWarnedUninitializedVars includes:receiver name) not]]]]) |
1327 | 3207 |
ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3208 |
((#(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
|
3209 |
or:[(nil respondsTo:selectorSymbol) not])ifTrue:[ |
1327 | 3210 |
"/ avoid trouble in miniTalk |
3211 |
"/ during bootstrap |
|
3212 |
nm := receiver name. |
|
3213 |
Text notNil ifTrue:[ |
|
3214 |
nm := nm allItalic |
|
3215 |
]. |
|
3216 |
err := 'sent to possibly uninitialized variable ''' , nm , ''' here (?)'. |
|
3217 |
alreadyWarnedUninitializedVars isNil ifTrue:[ |
|
3218 |
alreadyWarnedUninitializedVars := Set new |
|
3219 |
]. |
|
3220 |
alreadyWarnedUninitializedVars add:receiver name |
|
3221 |
] |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3222 |
] |
1327 | 3223 |
] ifFalse:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3224 |
(err notNil and:[selClass notNil]) ifTrue:[ |
1327 | 3225 |
err := err, ' (message to ' , selClass nameWithArticle , ')'. |
3226 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
3227 |
]]]]]]. |
1327 | 3228 |
] |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3229 |
]. |
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3230 |
|
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3231 |
err notNil ifTrue:[ |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3232 |
(receiver notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3233 |
and:[((recType := receiver type) == #GlobalVariable) |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3234 |
or:[recType == #PrivateClass]]) ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3235 |
"/ dont check autoloaded classes |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3236 |
"/ - it may work after loading |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3237 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3238 |
rec := receiver evaluate. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3239 |
(rec notNil |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3240 |
and:[rec isBehavior |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3241 |
and:[rec isLoaded not]]) ifTrue:[ |
1022 | 3242 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3243 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3244 |
rec class == UndefinedVariable ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3245 |
"/ dont check undefined vars; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3246 |
"/ it may work after loading/defining |
1022 | 3247 |
^ aSelectorString |
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3248 |
]. |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3249 |
]. |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3250 |
Text notNil ifTrue:[ |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3251 |
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
|
3252 |
] ifFalse:[ |
1158
f2cbdb21e0b0
Check for obsolete methods, if possible.
Stefan Vogel <sv@exept.de>
parents:
1157
diff
changeset
|
3253 |
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
|
3254 |
]. |
1157
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3255 |
"/ 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
|
3256 |
(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
|
3257 |
^ aSelectorString |
122be9201878
selectorCheck (do not complain for new selector being recursively invoked)
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
3258 |
]. |
1499
69439abfdb93
Warn when using subclassResponsibility or shouldNotImplememt methods
Stefan Vogel <sv@exept.de>
parents:
1495
diff
changeset
|
3259 |
isSyntaxHighlighter ifTrue:[ |
1439 | 3260 |
posVector do:[:p | |
3261 |
self markUnknownIdentifierFrom:(p start) to:(p stop). |
|
3262 |
]. |
|
3263 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3264 |
isSyntaxHighlighter ifFalse:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3265 |
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
|
3266 |
newSelector := self correctSelector:aSelectorString |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3267 |
message:err withCRs |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3268 |
positions:posVector in:selClass for:receiver. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3269 |
"/ self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3270 |
^ newSelector. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3271 |
]. |
141 | 3272 |
]. |
1022 | 3273 |
^ aSelectorString |
141 | 3274 |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
3275 |
"Modified: / 5.9.1995 / 17:02:11 / claus" |
1022 | 3276 |
"Modified: / 19.1.2000 / 16:34:03 / cg" |
1327 | 3277 |
! |
3278 |
||
3279 |
typeOfNode:aNode |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3280 |
|nodeVal nodeType classHint| |
1327 | 3281 |
|
3282 |
aNode isConstant ifTrue:[ |
|
3283 |
" |
|
3284 |
if the receiver is a constant, we can check if it responds |
|
3285 |
to this selector |
|
3286 |
" |
|
3287 |
nodeVal := aNode evaluate. |
|
3288 |
^ nodeVal class. |
|
3289 |
]. |
|
3290 |
||
3291 |
"/ this should help with typos, sending #ifTrue to blocks ... |
|
3292 |
aNode isBlock ifTrue:[ |
|
3293 |
^ Block |
|
3294 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3295 |
aNode isVariable ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3296 |
nodeType := aNode type. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3297 |
(nodeType == #GlobalVariable or:[nodeType == #PrivateClass]) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3298 |
"if the receiver is a global, we check it too ..." |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3299 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3300 |
nodeVal := aNode evaluate. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3301 |
"/ dont check autoloaded classes |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3302 |
"/ - it may work after loading |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3303 |
(nodeVal isNil |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3304 |
or:[nodeVal isBehavior and:[nodeVal isLoaded not]]) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3305 |
^ nil |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3306 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3307 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3308 |
^ nodeVal class. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3309 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3310 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3311 |
(aNode isLocal) ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3312 |
classHint := aNode token classHint. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3313 |
classHint notNil ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
3314 |
^ Smalltalk classNamed:classHint |
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 |
]. |
1327 | 3317 |
]. |
3318 |
||
3319 |
aNode isSuper ifTrue:[ |
|
3320 |
"if its a super- or here-send, we can do more checking" |
|
3321 |
aNode isHere ifFalse:[ |
|
3322 |
^ classToCompileFor superclass ? UndefinedObject. |
|
3323 |
]. |
|
3324 |
^ classToCompileFor. |
|
3325 |
]. |
|
3326 |
aNode isSelf ifTrue:[ |
|
3327 |
^ classToCompileFor. |
|
3328 |
]. |
|
3329 |
||
3330 |
(aNode isUnaryMessage) ifTrue:[ |
|
3331 |
(aNode selector == #class) ifTrue:[ |
|
3332 |
aNode receiver isSelf ifTrue:[ |
|
3333 |
"its a message to self class - can check this too ..." |
|
3334 |
^ classToCompileFor class. |
|
3335 |
]. |
|
3336 |
]. |
|
3337 |
( #(#'isNil' #'notNil') includes:aNode selector) ifTrue:[ |
|
3338 |
^ Boolean. |
|
3339 |
] |
|
3340 |
]. |
|
3341 |
aNode isBinaryMessage ifTrue:[ |
|
3342 |
( #(#'<' #'>' #'>=' #'<=' #'=' #'==' #'~=' #'~~') includes:aNode selector) ifTrue:[ |
|
3343 |
^ Boolean. |
|
3344 |
] |
|
3345 |
]. |
|
3346 |
||
3347 |
^ nil |
|
0 | 3348 |
! ! |
3349 |
||
3350 |
!Parser methodsFor:'error handling'! |
|
3351 |
||
1259 | 3352 |
blockArgRedefined:tokenName from:pos1 to:pos2 |
3353 |
"argname reuse" |
|
3354 |
||
3355 |
self isSyntaxHighlighter ifTrue:[ |
|
3356 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3357 |
] ifFalse:[ |
|
3358 |
self |
|
3359 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3360 |
position:pos1 to:pos2 |
|
3361 |
]. |
|
3362 |
! |
|
3363 |
||
1495 | 3364 |
errorMessageForUndefined:aName |
3365 |
|idx implementors| |
|
3366 |
||
3367 |
classToCompileFor notNil ifTrue:[ |
|
3368 |
"/ is it an instance-variable marked inaccessable ? |
|
3369 |
||
3370 |
idx := (self classesInstVarNames) indexOf:(aName , '*') startingAt:1. |
|
3371 |
idx ~~ 0 ifTrue:[ |
|
3372 |
^ '''%1'' is a hidden instvar (not accessable from ST-code)'. |
|
3373 |
]. |
|
3374 |
||
3375 |
"/ is it an instance variable, while evaluateing for the class ? |
|
3376 |
classToCompileFor isMeta ifTrue:[ |
|
3377 |
(classToCompileFor soleInstance allInstVarNames includes:aName) ifTrue:[ |
|
3378 |
^ 'Warning: ''%1'' is an instvar\(hint: you are evaluating/compiling in the classes context)'. |
|
3379 |
] |
|
3380 |
] |
|
3381 |
]. |
|
3382 |
self isDoIt ifTrue:[ |
|
1576 | 3383 |
SystemBrowser notNil ifTrue:[ |
1569
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3384 |
implementors := SystemBrowser |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3385 |
findImplementorsOf:aName |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3386 |
in:(Smalltalk allClasses) |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3387 |
ignoreCase:false. |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3388 |
implementors size > 0 ifTrue:[ |
b20e45617214
do not depend on SystemBrowser beeing present
Claus Gittinger <cg@exept.de>
parents:
1564
diff
changeset
|
3389 |
^ '''%1'' is undefined but known as a message selector.\(hint: did you forget to select the receiver ?)'. |
1576 | 3390 |
]. |
1495 | 3391 |
]. |
3392 |
]. |
|
3393 |
^ '''%1'' is undefined'. |
|
3394 |
! |
|
3395 |
||
141 | 3396 |
exitWith:something |
3397 |
"this is the longjump out of evaluation via a return expression" |
|
3398 |
||
3399 |
evalExitBlock value:something |
|
3400 |
! |
|
3401 |
||
3402 |
identifierExpectedIn:what |
|
3403 |
|msg| |
|
3404 |
||
3405 |
(#(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
|
3406 |
msg := 'Reserved keyword in ' |
141 | 3407 |
] ifFalse:[ |
1260
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3408 |
msg := 'Identifier expected in ' |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3409 |
]. |
50e4668049aa
identifier expected - better error message
Claus Gittinger <cg@exept.de>
parents:
1259
diff
changeset
|
3410 |
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
|
3411 |
position:tokenPosition to:source position1Based - 1. |
141 | 3412 |
^ #Error |
3413 |
! |
|
3414 |
||
1259 | 3415 |
methodArgRedefined:tokenName from:pos1 to:pos2 |
3416 |
"argname reuse" |
|
3417 |
||
3418 |
self isSyntaxHighlighter ifTrue:[ |
|
3419 |
self markBadIdentifierFrom:pos1 to:pos2. |
|
3420 |
] ifFalse:[ |
|
3421 |
self |
|
3422 |
syntaxError:'redefinition of ''' , tokenName , ''' in argument list.' |
|
3423 |
position:pos1 to:pos2 |
|
3424 |
]. |
|
3425 |
! |
|
3426 |
||
0 | 3427 |
showErrorMessage:aMessage position:pos |
19 | 3428 |
"redefined since parser can give more detailed info about |
3429 |
the class & selector where the error occured." |
|
3430 |
||
1534 | 3431 |
|msg| |
71 | 3432 |
|
19 | 3433 |
ignoreErrors ifFalse:[ |
1160 | 3434 |
Smalltalk silentLoading == true ifFalse:[ |
1534 | 3435 |
msg := ''. |
1160 | 3436 |
pos notNil ifTrue:[ |
1534 | 3437 |
msg := msg , (pos printString). |
3438 |
msg := msg , ' '. |
|
1160 | 3439 |
]. |
1534 | 3440 |
msg := msg , aMessage. |
1160 | 3441 |
selector notNil ifTrue:[ |
1534 | 3442 |
msg := msg , ' in '. |
1160 | 3443 |
classToCompileFor notNil ifTrue:[ |
1534 | 3444 |
msg := msg , classToCompileFor name , '>>' |
3445 |
]. |
|
3446 |
msg := msg , selector. |
|
1160 | 3447 |
] ifFalse:[ |
3448 |
classToCompileFor notNil ifTrue:[ |
|
1534 | 3449 |
msg := msg , ' (' , classToCompileFor name , ')' |
1160 | 3450 |
] |
3451 |
]. |
|
1534 | 3452 |
|
3453 |
UserInformation isHandled ifTrue:[ |
|
3454 |
UserInformation raiseErrorString:msg |
|
3455 |
] ifFalse:[ |
|
3456 |
Transcript showCR:msg. |
|
3457 |
] |
|
1160 | 3458 |
] |
0 | 3459 |
] |
273 | 3460 |
|
3461 |
"Modified: 18.5.1996 / 15:44:15 / cg" |
|
0 | 3462 |
! |
3463 |
||
171 | 3464 |
showErrorMessageForClass:aClass |
3465 |
"/ compiler parseError:'syntax error'. |
|
3466 |
Transcript show:' '. |
|
3467 |
aClass notNil ifTrue:[ |
|
1576 | 3468 |
Transcript show:aClass name , '>>' |
171 | 3469 |
]. |
3470 |
selector notNil ifTrue:[ |
|
1576 | 3471 |
Transcript show:(selector) |
171 | 3472 |
]. |
273 | 3473 |
Transcript showCR:' -> Error'. |
171 | 3474 |
|
3475 |
"Created: 13.12.1995 / 20:24:34 / cg" |
|
273 | 3476 |
"Modified: 18.5.1996 / 15:44:17 / cg" |
171 | 3477 |
! |
3478 |
||
0 | 3479 |
undefError:aName position:pos1 to:pos2 |
3 | 3480 |
"report an undefined variable error - return true, if it should be |
86 | 3481 |
corrected. If not corrected, only one warning is made per undefined |
3482 |
variable." |
|
3483 |
||
1495 | 3484 |
|ex doCorrect boldName| |
1400 | 3485 |
|
3486 |
ex := UndefinedVariableNotification newException. |
|
3487 |
ex parser:self. |
|
3488 |
ex parameter:aName. |
|
3489 |
ex suspendedContext:thisContext. |
|
3490 |
doCorrect := ex raiseRequest. |
|
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3491 |
doCorrect notNil ifTrue:[ |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3492 |
^ doCorrect |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3493 |
]. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
3494 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3495 |
parserFlags warnUndeclared ifFalse:[^ false]. |
915
d3add8c1bb04
dont rewarn for same missing namespace
Claus Gittinger <cg@exept.de>
parents:
903
diff
changeset
|
3496 |
ignoreWarnings ifTrue:[^ false]. |
607 | 3497 |
|
86 | 3498 |
" |
3499 |
alredy warned about this one ? |
|
3500 |
" |
|
3501 |
warnedUndefVars notNil ifTrue:[ |
|
877 | 3502 |
(warnedUndefVars includes:aName) ifTrue:[ |
3503 |
"already warned about this one" |
|
3504 |
^ false |
|
3505 |
]. |
|
86 | 3506 |
]. |
3507 |
||
131 | 3508 |
"/ (classToCompileFor notNil |
3509 |
"/ and:[classToCompileFor superclass notNil |
|
3510 |
"/ and:[classToCompileFor superclass instanceVariableString isNil]]) ifTrue:[ |
|
132
5be56a5e90b7
added methods for silent parsing (parseMethod / parseMethodSpec)
Claus Gittinger <cg@exept.de>
parents:
131
diff
changeset
|
3511 |
"/ 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
|
3512 |
"/ ^ false |
131 | 3513 |
"/ ]. |
3514 |
||
1285 | 3515 |
boldName := aName allBold. |
3516 |
||
131 | 3517 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
877 | 3518 |
aName first isUppercase ifFalse:[ |
1285 | 3519 |
self showErrorMessage:('Error: ''' , boldName , ''' is undefined') position:pos1. |
877 | 3520 |
]. |
3521 |
doCorrect := false. |
|
86 | 3522 |
] ifFalse:[ |
877 | 3523 |
" |
3524 |
ask requestor for correct/continue/abort ... |
|
3525 |
it is supposed to raise abort or return true/false. |
|
3526 |
True return means that correction is wanted. |
|
3527 |
" |
|
1495 | 3528 |
doCorrect := self |
3529 |
correctableError:((self errorMessageForUndefined:aName) bindWith:boldName) withCRs |
|
3530 |
position:pos1 to:pos2 |
|
86 | 3531 |
]. |
3532 |
||
877 | 3533 |
doCorrect == false ifTrue:[ |
3534 |
warnedUndefVars isNil ifTrue:[ |
|
3535 |
warnedUndefVars := Set new. |
|
3536 |
]. |
|
3537 |
warnedUndefVars add:aName. |
|
3 | 3538 |
]. |
0 | 3539 |
|
86 | 3540 |
^ doCorrect |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
3541 |
|
607 | 3542 |
"Modified: 7.9.1997 / 02:14:36 / cg" |
1160 | 3543 |
! |
3544 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3545 |
warnSTXHereExtensionUsedAt:position |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3546 |
ignoreWarnings ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3547 |
didWarnAboutSTXHereExtensionUsed ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3548 |
parserFlags warnSTXHereExtensionUsed ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3549 |
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
|
3550 |
position:position to:position+3. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3551 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3552 |
only warn once |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3553 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3554 |
didWarnAboutSTXHereExtensionUsed := true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3555 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3556 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3557 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3558 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3559 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3560 |
warnSTXNameSpaceUseAt:position |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3561 |
ignoreWarnings ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3562 |
didWarnAboutSTXNameSpaceUse ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3563 |
parserFlags warnSTXNameSpaceUse ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3564 |
self warning:'nameSpaces are a nonstandard feature of ST/X' |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3565 |
doNotShowAgainAction:[ ParserFlags warnSTXSpecials:false ] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3566 |
position:position to:(source position1Based). |
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 |
didWarnAboutSTXNameSpaceUse := false |
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 |
|
1160 | 3576 |
warnUnused:aNameCollection |
3577 |
"report an unused method variable" |
|
3578 |
||
1638 | 3579 |
|msg answer| |
1160 | 3580 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3581 |
(ignoreErrors not |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3582 |
and:[ignoreWarnings not |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3583 |
and:[parserFlags warnUnusedVars]]) ifTrue:[ |
1638 | 3584 |
msg := 'Unused method variable(s): '. |
1160 | 3585 |
aNameCollection asSortedCollection do:[:name| |
1638 | 3586 |
msg := msg , (' "',name allBold,'"'). |
3587 |
]. |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3588 |
|
1160 | 3589 |
(requestor isNil or:[requestor isStream]) ifTrue:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3590 |
self showErrorMessage:('Warning: ', msg) position:nil. |
1160 | 3591 |
] ifFalse:[ |
1167 | 3592 |
answer := requestor |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3593 |
unusedVariableWarning:msg |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
3594 |
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
|
3595 |
|
1167 | 3596 |
answer == true ifTrue:[ |
3597 |
"/ delete the definitions ... |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3598 |
aNameCollection do:[:eachName | |
1432
a85ce0ec6ee4
deleting multiple local variables
Claus Gittinger <cg@exept.de>
parents:
1427
diff
changeset
|
3599 |
self deleteDefinitionOf:eachName in:(localVarDefPosition first) to:(localVarDefPosition last). |
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3600 |
]. |
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3601 |
RestartCompilationSignal raise |
1167 | 3602 |
]. |
1160 | 3603 |
]. |
3604 |
]. |
|
1221
2768cbe3be2b
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
1220
diff
changeset
|
3605 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
3606 |
"Modified: / 17.11.2001 / 10:30:47 / cg" |
0 | 3607 |
! ! |
3608 |
||
1363 | 3609 |
!Parser methodsFor:'evaluating expressions'! |
3610 |
||
3611 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile |
|
3612 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3613 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3614 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3615 |
is non-nil, it is evaluated if an error occurs. |
|
3616 |
Finally, compile specifies if the string should be compiled down to |
|
3617 |
bytecode or instead be interpreted from the parseTree. |
|
3618 |
The first should be done for doIts etc, where a readable walkback is |
|
3619 |
required. |
|
3620 |
The latter is better done for constants, styleSheet and resource |
|
3621 |
reading and simple sends, where the overhead of compilation is bigger |
|
3622 |
than the interpretation overhead." |
|
3623 |
||
1548 | 3624 |
^ self |
3625 |
evaluate:aStringOrStream |
|
3626 |
in:aContext |
|
3627 |
receiver:anObject |
|
3628 |
notifying:requestor |
|
3629 |
logged:logged |
|
3630 |
ifFail:failBlock |
|
3631 |
compile:compile |
|
3632 |
checkForEndOfInput:true |
|
3633 |
! |
|
3634 |
||
3635 |
evaluate:aStringOrStream in:aContext receiver:anObject notifying:requestor logged:logged ifFail:failBlock compile:compile checkForEndOfInput:checkForEndOfInput |
|
3636 |
"return the result of evaluating aStringOrStream, errors are reported to requestor. |
|
3637 |
Allow access to anObject as self and to its instVars (used in the inspector). |
|
3638 |
If logged is true, an entry is added to the change-file. If the failBlock argument |
|
3639 |
is non-nil, it is evaluated if an error occurs. |
|
3640 |
Finally, compile specifies if the string should be compiled down to |
|
3641 |
bytecode or instead be interpreted from the parseTree. |
|
3642 |
The first should be done for doIts etc, where a readable walkback is |
|
3643 |
required. |
|
3644 |
The latter is better done for constants, styleSheet and resource |
|
3645 |
reading and simple sends, where the overhead of compilation is bigger |
|
3646 |
than the interpretation overhead." |
|
3647 |
||
1363 | 3648 |
|tree mustBackup loggedString chgStream value s sReal spc |
3649 |
nameSpaceQuerySignal compiler| |
|
3650 |
||
3651 |
aStringOrStream isNil ifTrue:[ |
|
3652 |
EmptySourceNotificationSignal raiseRequest. |
|
3653 |
^ nil |
|
3654 |
]. |
|
3655 |
(mustBackup := aStringOrStream isStream) ifTrue:[ |
|
3656 |
s := aStringOrStream. |
|
3657 |
] ifFalse:[ |
|
3658 |
loggedString := aStringOrStream. |
|
3659 |
s := ReadStream on:aStringOrStream. |
|
3660 |
]. |
|
3661 |
||
3662 |
self source:s. |
|
3663 |
||
3664 |
self parseForCode. |
|
3665 |
self foldConstants:nil. |
|
3666 |
self setSelf:anObject. |
|
3667 |
self setContext:aContext. |
|
3668 |
aContext notNil ifTrue:[ |
|
3669 |
self setSelf:(aContext receiver). |
|
3670 |
"/ aContext method notNil ifTrue:[ |
|
3671 |
"/ cls := aContext method mclass |
|
3672 |
"/ ]. |
|
3673 |
"/ self setClassToCompileFor:(cls ? aContext receiver class). |
|
3674 |
self setClassToCompileFor:(aContext receiver class). |
|
3675 |
]. |
|
3676 |
self notifying:requestor. |
|
3677 |
self nextToken. |
|
3678 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3679 |
tree := self parseMethodBodyOrEmpty. |
|
3680 |
||
1548 | 3681 |
checkForEndOfInput ifTrue:[self checkForEndOfInput]. |
1363 | 3682 |
|
3683 |
"if reading from a stream, backup for next expression" |
|
3684 |
mustBackup ifTrue:[ |
|
3685 |
self backupPosition |
|
3686 |
]. |
|
3687 |
||
3688 |
(self errorFlag or:[tree == #Error]) ifTrue:[ |
|
3689 |
failBlock notNil ifTrue:[ |
|
3690 |
^ failBlock value |
|
3691 |
]. |
|
3692 |
^ #Error |
|
3693 |
]. |
|
3694 |
||
3695 |
tree isNil ifTrue:[ |
|
3696 |
EmptySourceNotificationSignal raiseRequest. |
|
3697 |
^ nil |
|
3698 |
]. |
|
3699 |
||
3700 |
(logged |
|
3701 |
and:[loggedString notNil |
|
3702 |
and:[Smalltalk logDoits]]) ifTrue:[ |
|
3703 |
Class updateChangeFileQuerySignal query ifTrue:[ |
|
3704 |
chgStream := Class changesStream. |
|
3705 |
chgStream notNil ifTrue:[ |
|
3706 |
chgStream nextChunkPut:loggedString. |
|
3707 |
chgStream cr. |
|
3708 |
chgStream close |
|
3709 |
] |
|
3710 |
]. |
|
3711 |
Project notNil ifTrue:[ |
|
3712 |
Class updateChangeListQuerySignal query ifTrue:[ |
|
3713 |
Project addDoIt:loggedString |
|
3714 |
] |
|
3715 |
] |
|
3716 |
]. |
|
3717 |
||
3718 |
" |
|
3719 |
during the evaluation, handle nameSpace queries |
|
3720 |
from the value as defined by any namespace directive. |
|
3721 |
This, if its a class definition expression, the class will |
|
3722 |
be installed there. |
|
3723 |
" |
|
3724 |
nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
3725 |
||
3726 |
spc := self getNameSpace. |
|
3727 |
spc isNil ifTrue:[ |
|
3728 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
|
3729 |
spc := requestor currentNameSpace |
|
3730 |
] ifFalse:[ |
|
3731 |
spc := nameSpaceQuerySignal query. |
|
3732 |
] |
|
3733 |
]. |
|
3734 |
||
3735 |
nameSpaceQuerySignal answer:spc |
|
3736 |
do:[ |
|
3737 |
|method| |
|
3738 |
||
3739 |
" |
|
3740 |
if compile is false, or the parse tree is that of a constant, |
|
3741 |
or a variable, quickly return its value. |
|
3742 |
This is used for example, when reading simple objects |
|
3743 |
via #readFrom:. |
|
3744 |
The overhead of compiling a method is avoided in this case. |
|
3745 |
" |
|
3746 |
((SuppressDoItCompilation == true) |
|
3747 |
or:[compile not |
|
3748 |
or:[tree isConstant |
|
3749 |
or:[tree isVariable |
|
3750 |
or:[aStringOrStream isStream |
|
3751 |
or:[aContext notNil]]]]]) ifTrue:[ |
|
3752 |
^ tree evaluate |
|
3753 |
]. |
|
3754 |
||
3755 |
" |
|
3756 |
if I am the ByteCodeCompiler, |
|
3757 |
generate a dummy method, execute it and return the value. |
|
3758 |
otherwise, just evaluate the tree; slower, but not too bad ... |
|
3759 |
||
3760 |
This allows systems to be delivered without the ByteCodeCompiler, |
|
3761 |
and still evaluate expressions |
|
3762 |
(needed to read resource files or to process .rc files). |
|
3763 |
" |
|
3764 |
self == Parser ifTrue:[ |
|
3765 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3766 |
value := tree evaluate. |
|
3767 |
self evalExitBlock:nil. |
|
3768 |
] ifFalse:[ |
|
3769 |
s := self correctedSource. |
|
3770 |
s isNil ifTrue:[ |
|
3771 |
aStringOrStream isStream ifTrue:[ |
|
3772 |
s := self collectedSource. "/ does not work yet ... |
|
3773 |
] ifFalse:[ |
|
3774 |
s := aStringOrStream |
|
3775 |
]. |
|
3776 |
]. |
|
3777 |
||
3778 |
"/ actually, its a block, to allow |
|
3779 |
"/ easy return ... |
|
3780 |
||
1421
dcdc178254f0
preserve lineNumbers in compiled code (evaluate)
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
3781 |
sReal := 'doIt ^[ ' , s , '\] value' withCRs. |
1363 | 3782 |
|
1366
f91f6a0a56d5
when required to compile, use Compiler instead of self class.
Claus Gittinger <cg@exept.de>
parents:
1365
diff
changeset
|
3783 |
compiler := ByteCodeCompiler new. |
1363 | 3784 |
compiler initializeFlagsFrom:self. |
3785 |
method := compiler |
|
3786 |
compile:sReal |
|
3787 |
forClass:anObject class |
|
3788 |
inCategory:'_temporary_' |
|
3789 |
notifying:requestor |
|
3790 |
install:false |
|
3791 |
skipIfSame:false |
|
3792 |
silent:true |
|
3793 |
foldConstants:false. |
|
3794 |
||
3795 |
method notNil ifTrue:[ |
|
3796 |
method ~~ #Error ifTrue:[ |
|
3797 |
" |
|
3798 |
fake: patch the source string, to what the user expects |
|
3799 |
in the browser |
|
3800 |
" |
|
1421
dcdc178254f0
preserve lineNumbers in compiled code (evaluate)
Claus Gittinger <cg@exept.de>
parents:
1420
diff
changeset
|
3801 |
method source:"' ' , "s string. |
1363 | 3802 |
" |
3803 |
dont do any just-in-time compilation on it. |
|
3804 |
" |
|
3805 |
method checked:true. |
|
3806 |
||
3807 |
value := method |
|
3808 |
valueWithReceiver:anObject |
|
3809 |
arguments:nil "/ (Array with:m) |
|
1440 | 3810 |
selector:(requestor isNil ifTrue:#'doItX' ifFalse:#'doIt') "/ #doIt: |
1363 | 3811 |
search:nil |
3812 |
sender:nil. |
|
3813 |
] ifFalse:[ |
|
3814 |
self evalExitBlock:[:value | self release. ^ value]. |
|
3815 |
value := tree evaluate. |
|
3816 |
self evalExitBlock:nil. |
|
3817 |
] |
|
3818 |
]. |
|
3819 |
] |
|
3820 |
]. |
|
3821 |
self release. |
|
3822 |
^ value |
|
3823 |
||
3824 |
"Created: / 8.2.1997 / 19:34:44 / cg" |
|
3825 |
"Modified: / 18.3.1999 / 18:25:40 / stefan" |
|
3826 |
"Modified: / 6.2.2000 / 15:01:57 / cg" |
|
3827 |
! ! |
|
3828 |
||
0 | 3829 |
!Parser methodsFor:'parsing'! |
3830 |
||
141 | 3831 |
block |
3832 |
"parse a block; return a node-tree, nil or #Error" |
|
3833 |
||
883 | 3834 |
|node args argNames arg pos pos2 lno| |
141 | 3835 |
|
3836 |
lno := tokenLineNr. |
|
3837 |
self nextToken. |
|
3838 |
(tokenType == $: ) ifTrue:[ |
|
663 | 3839 |
[tokenType == $:] whileTrue:[ |
3840 |
pos := tokenPosition. |
|
3841 |
self nextToken. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3842 |
|
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3843 |
(pos == (tokenPosition - 1)) ifFalse:[ |
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3844 |
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
|
3845 |
]. |
883 | 3846 |
(tokenType ~~ #Identifier) ifTrue:[ |
663 | 3847 |
^ self identifierExpectedIn:'block-arg declaration' |
3848 |
]. |
|
883 | 3849 |
|
3850 |
pos2 := tokenPosition + tokenName size - 1. |
|
3851 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 3852 |
self checkBlockArgumentNameConventionsFor:tokenName. |
663 | 3853 |
arg := Variable name:tokenName. |
3854 |
args isNil ifTrue:[ |
|
3855 |
args := Array with:arg. |
|
3856 |
argNames := Array with:tokenName. |
|
3857 |
] ifFalse:[ |
|
3858 |
(argNames includes:tokenName) ifTrue:[ |
|
1259 | 3859 |
self blockArgRedefined:tokenName from:tokenPosition to:pos2 |
663 | 3860 |
]. |
3861 |
args := args copyWith:arg. |
|
3862 |
argNames := argNames copyWith:tokenName. |
|
3863 |
]. |
|
1394
93e75cb62f4f
incompatibility warning with space between colon and id in blockArgs.
Claus Gittinger <cg@exept.de>
parents:
1393
diff
changeset
|
3864 |
self nextToken. |
663 | 3865 |
]. |
3866 |
(tokenType ~~ $| ) ifTrue:[ |
|
3867 |
"ST-80 allows [:arg ]" |
|
3868 |
(tokenType == $] ) ifTrue:[ |
|
3869 |
node := BlockNode arguments:args home:currentBlock variables:nil. |
|
3870 |
node lineNumber:lno. |
|
3871 |
^ node |
|
3872 |
]. |
|
3873 |
self syntaxError:'| expected after block-arg declaration'. |
|
3874 |
^ #Error |
|
3875 |
]. |
|
3876 |
self nextToken |
|
141 | 3877 |
]. |
3878 |
node := self blockBody:args. |
|
3879 |
(node notNil and:[node ~~ #Error]) ifTrue:[ |
|
663 | 3880 |
node lineNumber:lno. |
141 | 3881 |
]. |
3882 |
^ node |
|
663 | 3883 |
|
3884 |
"Modified: / 31.3.1998 / 17:31:34 / cg" |
|
141 | 3885 |
! |
3886 |
||
3887 |
blockBody:args |
|
3888 |
"parse a blocks body; return a node-tree, nil or #Error" |
|
3889 |
||
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
3890 |
|stats node var vars lno pos2| |
141 | 3891 |
|
3892 |
lno := tokenLineNr. |
|
3893 |
(tokenType == $| ) ifTrue:[ |
|
668 | 3894 |
self nextToken. |
3895 |
[tokenType == $|] whileFalse:[ |
|
3896 |
(tokenType == #Identifier) ifFalse:[ |
|
3897 |
^ self identifierExpectedIn:'block-var declaration' |
|
3898 |
]. |
|
883 | 3899 |
pos2 := tokenPosition + tokenName size - 1. |
3900 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 3901 |
self checkBlockVariableNameConventionsFor:tokenName. |
668 | 3902 |
var := Variable name:tokenName. |
3903 |
vars isNil ifTrue:[ |
|
3904 |
vars := Array with:var. |
|
3905 |
] 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
|
3906 |
(vars contains:[:var | var name = tokenName]) ifTrue:[ |
883 | 3907 |
"/ varname reuse |
3908 |
self isSyntaxHighlighter ifTrue:[ |
|
3909 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
3910 |
] ifFalse:[ |
|
3911 |
self |
|
3912 |
parseError:'redefinition of ''' , tokenName , ''' in local variables' |
|
3913 |
position:tokenPosition to:pos2. |
|
3914 |
] |
|
668 | 3915 |
] ifFalse:[ |
3916 |
vars := vars copyWith:var. |
|
3917 |
] |
|
3918 |
]. |
|
3919 |
self nextToken. |
|
1471 | 3920 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3921 |
parserFlags allowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
1471 | 3922 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
3923 |
self nextToken. |
|
3924 |
"/ Q: should we allow literals only, or arbitrary expressions ? |
|
3925 |
self halt:'unimplemented feature'. |
|
3926 |
] |
|
3927 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
3928 |
parserFlags allowDomainVariables == true ifTrue:[ |
1471 | 3929 |
(tokenType == $() ifTrue:[ |
3930 |
self variableTypeDeclarationFor:var. |
|
3931 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
3932 |
]. |
668 | 3933 |
]. |
3934 |
self nextToken |
|
141 | 3935 |
]. |
382 | 3936 |
|
141 | 3937 |
node := BlockNode arguments:args home:currentBlock variables:vars. |
3938 |
node lineNumber:lno. |
|
3939 |
currentBlock := node. |
|
3940 |
stats := self blockStatementList. |
|
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3941 |
(stats == #Error) ifTrue:[^ #Error]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3942 |
|
382 | 3943 |
lineNumberInfo == #full ifTrue:[ |
668 | 3944 |
node endLineNumber:tokenLineNr |
382 | 3945 |
]. |
141 | 3946 |
node statements:stats. |
3947 |
currentBlock := node home. |
|
3948 |
^ node |
|
382 | 3949 |
|
668 | 3950 |
"Modified: / 31.3.1998 / 22:46:09 / cg" |
141 | 3951 |
! |
3952 |
||
3953 |
blockExpression |
|
3954 |
"parse a blockExpression; return a node-tree, nil or #Error. |
|
3955 |
Not used by ST/X's parser, but added for ST-80 compatibility." |
|
3956 |
||
3957 |
tokenType ~~ $[ ifTrue:[ |
|
1576 | 3958 |
self syntaxError:'[ expected'. |
3959 |
^ #Error. |
|
141 | 3960 |
]. |
3961 |
^ self block |
|
3962 |
! |
|
3963 |
||
3964 |
blockStatementList |
|
3965 |
"parse a blocks statementlist; return a node-tree, nil or #Error" |
|
3966 |
||
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
3967 |
|thisStatement prevStatement firstStatement eMsg| |
141 | 3968 |
|
3969 |
(tokenType == $] ) ifTrue:[^ nil]. |
|
3970 |
thisStatement := self statement. |
|
3971 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
3972 |
firstStatement := thisStatement. |
|
3973 |
[tokenType == $] ] whileFalse:[ |
|
673 | 3974 |
(tokenType == $.) ifFalse:[ |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3975 |
(tokenType == #EOF) ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
3976 |
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
|
3977 |
^ #Error. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3978 |
]. |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3979 |
|
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3980 |
(tokenType == $) ) ifTrue:[ |
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3981 |
eMsg := 'missing '']'' or bad '')'' in block' |
673 | 3982 |
] ifFalse:[ |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3983 |
eMsg := 'missing ''.'' between statements (i.e. ''' , tokenType printString , '''-token unexpected)' |
673 | 3984 |
]. |
1169
7204e72c7c3c
better error message with bad parentNesting in a block.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
3985 |
self syntaxError:eMsg position:tokenPosition to:tokenPosition. |
673 | 3986 |
^ #Error |
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3987 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3988 |
prevStatement := thisStatement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3989 |
self nextToken. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3990 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3991 |
tokenType == $] ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3992 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3993 |
*** 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
|
3994 |
*** 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
|
3995 |
*** 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
|
3996 |
*** became annoying |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3997 |
|
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
3998 |
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
|
3999 |
" |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4000 |
self markBracketAt:tokenPosition. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4001 |
^ firstStatement |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4002 |
]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4003 |
thisStatement := self statement. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4004 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4005 |
prevStatement nextStatement:thisStatement |
141 | 4006 |
]. |
673 | 4007 |
self markBracketAt:tokenPosition. |
141 | 4008 |
^ firstStatement |
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4009 |
|
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
4010 |
"Modified: / 16.7.1998 / 20:38:25 / cg" |
141 | 4011 |
! |
4012 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4013 |
checkForEndOfInput |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4014 |
|what| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4015 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4016 |
(tokenType ~~ #EOF) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4017 |
"/ just for the nicer error message |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4018 |
(#(Self Nil True False Super Here) includes:tokenType) ifTrue:[ |
1638 | 4019 |
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
|
4020 |
position:tokenPosition to:(tokenPosition + tokenName size - 1) |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4021 |
] ifFalse:[ |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4022 |
tokenType isCharacter ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4023 |
what := '''' , tokenType , ''''. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4024 |
] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4025 |
what := tokenType printString. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4026 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4027 |
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
|
4028 |
position:tokenPosition to:source position1Based-1. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4029 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4030 |
^#Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4031 |
] |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4032 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4033 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4034 |
checkReturnedValues |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4035 |
| returnsSelf returnsBoolean returnsNonBooleanLiteral| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4036 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4037 |
ignoreWarnings ifTrue:[^ self]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4038 |
returnedValues isNil ifTrue:[^ self]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4039 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4040 |
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
|
4041 |
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
|
4042 |
returnsSelf := returnedValues contains:[:node | node isSelf]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4043 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4044 |
returnsBoolean ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4045 |
(returnsNonBooleanLiteral or:[returnsSelf]) ifTrue:[ |
1455 | 4046 |
self |
4047 |
warning:'Possible Error Warning:\\Method returns both boolean and non-boolean values.' withCRs |
|
4048 |
position:1 to:tokenPosition |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4049 |
] |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4050 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4051 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4052 |
"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
|
4053 |
"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
|
4054 |
! |
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 |
checkUnusedMethodVars |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4057 |
| unused| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4058 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4059 |
ignoreWarnings ifFalse:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4060 |
methodVars notNil ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4061 |
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
|
4062 |
]. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4063 |
unused size > 0 ifTrue:[ |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4064 |
self warnUnused:unused. |
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:23:47 / cg" |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4069 |
! |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4070 |
|
1224
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4071 |
parseExceptionOrContextPragma |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4072 |
|pragmaType| |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4073 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4074 |
"/ < resource: has already been parsed. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4075 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4076 |
pragmaType := tokenName. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4077 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4078 |
self nextToken. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4079 |
(tokenType ~~ #Symbol) ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4080 |
self parseError:'symbol expected'. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4081 |
^ #Error |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4082 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4083 |
|
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4084 |
((pragmaType = 'exception:' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4085 |
and:[tokenValue == #'handle' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4086 |
or:[tokenValue == #'raise' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4087 |
or:[tokenValue == #'unwind']]]) |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4088 |
or:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4089 |
pragmaType = 'context:' |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4090 |
and:[(tokenValue == #'return')]]) |
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 |
ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4093 |
primitiveContextInfo isNil ifTrue:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4094 |
primitiveContextInfo := Set new. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4095 |
]. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4096 |
primitiveContextInfo add:(pragmaType->tokenValue). |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4097 |
] ifFalse:[ |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4098 |
self parseError:'unrecognized exception pragma: ' , tokenValue. |
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 |
self nextToken. |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4101 |
! |
b4d80bd993f9
parse ST/C api pragma (as dummy)
Claus Gittinger <cg@exept.de>
parents:
1222
diff
changeset
|
4102 |
|
1006 | 4103 |
parseExpressionWithSelf:anObject notifying:someOne ignoreErrors:ignoreErrors ignoreWarnings:ignoreWarnings inNameSpace:aNameSpaceOrNil |
4104 |
"parse aString as an expression with self set to anObject; |
|
4105 |
Return the parseTree (if ok), nil (for an empty string |
|
4106 |
or comment only ) or #Error (syntactic error). |
|
4107 |
||
4108 |
Errors and warnings are forwarded to someOne (usually some |
|
4109 |
codeView) which can highlight it and show a popup box, |
|
4110 |
iff ignoreErrors/ignoreWarnings is true respectively." |
|
4111 |
||
4112 |
|tree token| |
|
4113 |
||
4114 |
aNameSpaceOrNil notNil ifTrue:[ |
|
4115 |
self currentNameSpace:aNameSpaceOrNil |
|
4116 |
]. |
|
4117 |
self setSelf:anObject. |
|
4118 |
self notifying:someOne. |
|
1365 | 4119 |
self ignoreErrors:ignoreErrors. |
4120 |
self ignoreWarnings:ignoreWarnings. |
|
1006 | 4121 |
token := self nextToken. |
4122 |
(token == $^) ifTrue:[ |
|
4123 |
self nextToken. |
|
4124 |
]. |
|
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4125 |
(token == #EOF) ifTrue:[ |
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4126 |
^ nil |
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4127 |
]. |
1006 | 4128 |
tree := self expression. |
4129 |
(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
|
4130 |
"/ tokenType ~~ #EOF ifTrue:[ |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4131 |
"/ 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
|
4132 |
"/ ]. |
1006 | 4133 |
^ tree |
4134 |
||
4135 |
"Created: / 14.12.1999 / 15:11:37 / cg" |
|
4136 |
! |
|
4137 |
||
1259 | 4138 |
parseExtendedMethodSpec |
4139 |
|pos1 pos2 var| |
|
4140 |
||
4141 |
"/ EXPERIMENTAL |
|
4142 |
false ifTrue:[ |
|
4143 |
(tokenType == #Symbol) ifTrue:[ |
|
4144 |
pos1 := tokenPosition. |
|
4145 |
selector := token asSymbol. |
|
4146 |
self nextToken. |
|
4147 |
self markMethodSelectorFrom:pos1 to:(tokenPosition-1). |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4148 |
beginOfBodyPosition := tokenPosition. |
1259 | 4149 |
|
4150 |
tokenType == $( ifTrue:[ |
|
4151 |
self nextToken. |
|
4152 |
[ tokenType ~~ $) ] whileTrue:[ |
|
4153 |
||
4154 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
|
4155 |
pos2 := tokenPosition+tokenName size-1. |
|
4156 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
4157 |
var := Variable name:tokenName. |
|
4158 |
methodArgs isNil ifTrue:[ |
|
4159 |
methodArgs := Array with:var. |
|
4160 |
methodArgNames := Array with:tokenName |
|
4161 |
] ifFalse:[ |
|
4162 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
4163 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
|
4164 |
]. |
|
4165 |
methodArgs := methodArgs copyWith:var. |
|
4166 |
methodArgNames := methodArgNames copyWith:tokenName |
|
4167 |
]. |
|
4168 |
self nextToken. |
|
4169 |
]. |
|
4170 |
self nextToken. |
|
4171 |
]. |
|
4172 |
||
4173 |
^ self |
|
4174 |
]. |
|
4175 |
]. |
|
4176 |
^ #Error |
|
4177 |
! |
|
4178 |
||
0 | 4179 |
parseMethod |
19 | 4180 |
"parse a method. |
4181 |
Return the parseTree or #Error. |
|
4182 |
||
4183 |
method ::= methodSpec methodBody |
|
4184 |
" |
|
0 | 4185 |
|
4186 |
|parseTree| |
|
4187 |
||
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4188 |
"/ self nextToken. |
0 | 4189 |
(self parseMethodSpec == #Error) ifTrue:[^ #Error]. |
4190 |
parseTree := self parseMethodBody. |
|
4191 |
(parseTree == #Error) ifFalse:[ |
|
1171
0c43ce981f1b
oops - remove unused vars does not work (yet)
Claus Gittinger <cg@exept.de>
parents:
1169
diff
changeset
|
4192 |
self tree:parseTree |
0 | 4193 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4194 |
self checkForEndOfInput. |
0 | 4195 |
^ parseTree |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4196 |
|
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4197 |
"Modified: 20.4.1996 / 20:09:26 / cg" |
0 | 4198 |
! |
4199 |
||
19 | 4200 |
parseMethodBody |
4201 |
"parse a methods body (locals & statements). |
|
4202 |
No more tokens may follow. |
|
4203 |
Return a node-tree, or #Error |
|
4204 |
||
4205 |
methodBody ::= '<' st80Primitive '>' #EOF |
|
883 | 4206 |
| '<' st80Primitive '>' methodBodyVarSpec statementList #EOF |
19 | 4207 |
|
4208 |
" |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4209 |
|stats| |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4210 |
|
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4211 |
stats := self parseMethodBodyOrEmpty. |
19 | 4212 |
(stats == #Error) ifFalse:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4213 |
self checkForEndOfInput. |
19 | 4214 |
]. |
1160 | 4215 |
ignoreWarnings ifFalse:[ |
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4216 |
self checkUnusedMethodVars. |
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4217 |
self checkReturnedValues. |
1160 | 4218 |
]. |
19 | 4219 |
^ stats |
165
213e3f12fc56
better error message when selector is missing
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
4220 |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4221 |
"Modified: / 17.11.2001 / 10:31:12 / cg" |
19 | 4222 |
! |
4223 |
||
79 | 4224 |
parseMethodBodyOrEmpty |
0 | 4225 |
"parse a methods body (locals & statements); |
19 | 4226 |
return a node-tree, nil or #Error. |
4227 |
empty (or comment only) input is accepted and returns nil. |
|
4228 |
||
4229 |
methodBodyOrNil ::= '<' st80Primitive '>' |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4230 |
| '<' st80Primitive '>' methodBodyVarSpec statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4231 |
| <empty> |
19 | 4232 |
" |
0 | 4233 |
|
265 | 4234 |
|stats| |
0 | 4235 |
|
4236 |
(self parseMethodBodyVarSpec == #Error) ifTrue:[^ #Error]. |
|
4237 |
||
4238 |
(tokenType ~~ #EOF) ifTrue:[ |
|
1182
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4239 |
stats := self statementList |
34aac67e6e72
care for unexpected stuff at the end (in a doit)
Claus Gittinger <cg@exept.de>
parents:
1180
diff
changeset
|
4240 |
]. |
1186
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4241 |
"/ (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
|
4242 |
"/ 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
|
4243 |
"/ ^ #Error |
014c3db76517
oops - end of input check should not be done when simply evaluating
Claus Gittinger <cg@exept.de>
parents:
1182
diff
changeset
|
4244 |
"/ ]. |
1231 | 4245 |
(stats notNil |
4246 |
and:[stats ~~ #Error]) ifTrue:[ |
|
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
4247 |
(self isStatementAnUnconditionalReturn:stats last) ifFalse:[ |
1231 | 4248 |
"/ remember a returned self here. |
1262 | 4249 |
self rememberReturnedValue:(self selfNode) |
1231 | 4250 |
]. |
4251 |
]. |
|
1551 | 4252 |
tree notNil ifTrue:[ |
4253 |
tree last nextStatement:stats. |
|
4254 |
^ tree. |
|
4255 |
]. |
|
0 | 4256 |
^ stats |
265 | 4257 |
|
4258 |
"Modified: 27.4.1996 / 16:57:56 / cg" |
|
0 | 4259 |
! |
4260 |
||
19 | 4261 |
parseMethodBodyVarSpec |
265 | 4262 |
"parse a methods local variable specification, handling |
4263 |
possible primitive or resourceSpecs. |
|
4264 |
. |
|
19 | 4265 |
Leave spec of locals in methodLocals as a side effect. |
4266 |
Return #Error or nil. |
|
0 | 4267 |
|
19 | 4268 |
methodBodyVarSpec ::= '|' { IDENTIFIER } '|' |
663 | 4269 |
| <empty> |
19 | 4270 |
" |
0 | 4271 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4272 |
|var pos pos2 msg classHint| |
0 | 4273 |
|
265 | 4274 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
663 | 4275 |
self parsePrimitiveOrResourceSpecOrEmpty. |
265 | 4276 |
]. |
4277 |
||
0 | 4278 |
(tokenType == $|) ifTrue:[ |
663 | 4279 |
"memorize position for declaration in correction" |
883 | 4280 |
|
1638 | 4281 |
localVarDefPosition := Array with:tokenPosition with:nil. |
663 | 4282 |
self nextToken. |
4283 |
pos := tokenPosition. |
|
4284 |
[tokenType == #Identifier] whileTrue:[ |
|
883 | 4285 |
pos2 := tokenPosition + tokenName size - 1. |
4286 |
self markLocalIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4287 |
self checkMethodVariableNameConventionsFor:tokenName. |
663 | 4288 |
var := Variable name:tokenName. |
883 | 4289 |
|
663 | 4290 |
methodVars isNil ifTrue:[ |
4291 |
methodVars := OrderedCollection with:var. |
|
4292 |
methodVarNames := OrderedCollection with:tokenName |
|
4293 |
] ifFalse:[ |
|
4294 |
(methodVarNames includes:tokenName) ifTrue:[ |
|
883 | 4295 |
"/ redefinition |
4296 |
self isSyntaxHighlighter ifTrue:[ |
|
4297 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
4298 |
] ifFalse:[ |
|
4299 |
self |
|
1638 | 4300 |
parseError:'redefinition of ''' , tokenName , ''' in local variables.' |
883 | 4301 |
position:tokenPosition to:pos2. |
4302 |
] |
|
663 | 4303 |
] ifFalse:[ |
4304 |
methodVars add:var. |
|
4305 |
methodVarNames add:tokenName |
|
4306 |
] |
|
4307 |
]. |
|
883 | 4308 |
|
1638 | 4309 |
parserFlags warnHiddenVariables ifTrue:[ |
4310 |
methodArgNames notNil ifTrue:[ |
|
4311 |
(methodArgNames includes:tokenName) ifTrue:[ |
|
4312 |
self |
|
4313 |
warning:'local variable "' , tokenName allBold , '" hides method argument.' |
|
4314 |
position:tokenPosition to:pos2 |
|
4315 |
] |
|
4316 |
]. |
|
4317 |
classToCompileFor notNil ifTrue:[ |
|
4318 |
(self classesInstVarNames includes:tokenName) ifTrue:[ |
|
4319 |
self |
|
4320 |
warning:'local variable "' , tokenName allBold , '" hides instance variable.' |
|
4321 |
position:tokenPosition to:pos2 |
|
4322 |
] |
|
4323 |
]. |
|
663 | 4324 |
]. |
1638 | 4325 |
|
663 | 4326 |
self nextToken. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4327 |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4328 |
classHint := nil. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4329 |
lastDirective notNil ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4330 |
lastDirective isClassHintDirective ifTrue:[ |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4331 |
var classHint:lastDirective className. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4332 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4333 |
lastDirective := nil. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4334 |
]. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
4335 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4336 |
parserFlags allowLocalVariableDeclarationWithInitializerExpression == true ifTrue:[ |
1471 | 4337 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
4338 |
self nextToken. |
|
4339 |
"/ Q: should we allow literals only, or arbitrary expressions ? |
|
4340 |
self halt:'unimplemented feature'. |
|
4341 |
] |
|
4342 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4343 |
parserFlags allowDomainVariables == true ifTrue:[ |
1471 | 4344 |
(tokenType == $() ifTrue:[ |
4345 |
self variableTypeDeclarationFor:var. |
|
4346 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4347 |
]. |
663 | 4348 |
pos := tokenPosition |
4349 |
]. |
|
883 | 4350 |
|
663 | 4351 |
(tokenType ~~ $|) ifTrue:[ |
4352 |
(#(True False Self Nil Super ThisContext) includes:tokenType) ifTrue:[ |
|
1638 | 4353 |
msg := 'reserved keyword "',tokenName allBold,'" in local var declaration'. |
883 | 4354 |
pos2 := tokenPosition + tokenName size - 1. |
4355 |
self markBadIdentifierFrom:tokenPosition to:pos2. |
|
663 | 4356 |
] ifFalse:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4357 |
pos2 := source position1Based-1. |
663 | 4358 |
msg := 'Identifier or | expected in local var declaration' |
4359 |
]. |
|
883 | 4360 |
self syntaxError:msg position:tokenPosition to:pos2. |
663 | 4361 |
^ #Error |
4362 |
]. |
|
1638 | 4363 |
localVarDefPosition at:2 put:tokenPosition. |
663 | 4364 |
self nextToken |
0 | 4365 |
]. |
984 | 4366 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4367 |
parserFlags allowSqueakExtensions ifTrue:[ |
984 | 4368 |
"/ allow for primitiveSpec after local-var decl. |
4369 |
||
4370 |
((tokenType == #BinaryOperator) and:[tokenName = '<']) ifTrue:[ |
|
4371 |
self parsePrimitiveOrResourceSpecOrEmpty. |
|
4372 |
] |
|
4373 |
]. |
|
4374 |
||
0 | 4375 |
^ nil |
139
65eaf1a009f5
warn if method local hides method arg
Claus Gittinger <cg@exept.de>
parents:
135
diff
changeset
|
4376 |
|
663 | 4377 |
"Modified: / 31.3.1998 / 17:30:33 / cg" |
0 | 4378 |
! |
4379 |
||
141 | 4380 |
parseMethodSpec |
4381 |
"parse a methods selector & arg specification; |
|
4382 |
Set selector and methodArgs in the receiver as a side effect. |
|
4383 |
Return the receiver or #Error. |
|
4384 |
||
4385 |
methodSpec ::= { KEYWORD IDENTIFIER } |
|
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4386 |
| binaryOperator IDENTIFIER |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4387 |
| IDENTIFIER |
141 | 4388 |
" |
4389 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4390 |
|arg pos2| |
141 | 4391 |
|
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4392 |
tokenType isNil ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4393 |
self nextToken. |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4394 |
]. |
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4395 |
|
141 | 4396 |
(tokenType == #Keyword) ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4397 |
selector := ''. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4398 |
[tokenType == #Keyword] whileTrue:[ |
663 | 4399 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4400 |
selector := selector , tokenName. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4401 |
self nextToken. |
883 | 4402 |
|
1259 | 4403 |
(tokenType ~~ #Identifier) ifTrue:[ |
4404 |
"/ ^ #Error]. |
|
4405 |
^ self identifierExpectedIn:'method-arg declaration' |
|
4406 |
]. |
|
4407 |
||
883 | 4408 |
pos2 := tokenPosition+tokenName size-1. |
4409 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
|
1519 | 4410 |
self checkMethodArgumentNameConventionsFor:tokenName. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4411 |
arg := Variable name:tokenName. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4412 |
methodArgs isNil ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4413 |
methodArgs := Array with:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4414 |
methodArgNames := Array with:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4415 |
] ifFalse:[ |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4416 |
(methodArgNames includes:tokenName) ifTrue:[ |
1259 | 4417 |
self methodArgRedefined:tokenName from:tokenPosition to:pos2 |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4418 |
]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4419 |
methodArgs := methodArgs copyWith:arg. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4420 |
methodArgNames := methodArgNames copyWith:tokenName |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4421 |
]. |
1638 | 4422 |
parserFlags warnHiddenVariables ifTrue:[ |
1642
751a220b67be
ChangesBrowser: compress changes didn't work if there were changes
Stefan Vogel <sv@exept.de>
parents:
1640
diff
changeset
|
4423 |
classToCompileFor isBehavior ifTrue:[ |
1638 | 4424 |
(self classesInstVarNames includes:tokenName) ifTrue:[ |
4425 |
self |
|
4426 |
warning:'argument "' , tokenName allBold , '" hides instance variable.' |
|
4427 |
position:tokenPosition to:pos2 |
|
4428 |
] |
|
4429 |
]. |
|
4430 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4431 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4432 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4433 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4434 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4435 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4436 |
]. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4437 |
selector := selector asSymbol. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4438 |
endOfSelectorPosition := pos2. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4439 |
beginOfBodyPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4440 |
^ self |
141 | 4441 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4442 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4443 |
(self isValidUnarySelector:tokenType) ifTrue:[ |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4444 |
pos2 := tokenPosition+tokenName size-1. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4445 |
self markMethodSelectorFrom:tokenPosition to:pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4446 |
selector := tokenName asSymbol. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4447 |
endOfSelectorPosition := pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4448 |
self nextToken. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4449 |
beginOfBodyPosition := tokenPosition. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4450 |
^ self |
141 | 4451 |
]. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
4452 |
|
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4453 |
"/ 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
|
4454 |
tokenType == $| ifTrue:[ |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4455 |
tokenType := #BinaryOperator. |
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4456 |
token := tokenName := '|' |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4457 |
]. |
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4458 |
|
141 | 4459 |
(tokenType == #BinaryOperator) ifTrue:[ |
663 | 4460 |
self markMethodSelectorFrom:tokenPosition to:(tokenPosition+tokenName size-1). |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4461 |
selector := tokenName asSymbol. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4462 |
self nextToken. |
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4463 |
(tokenType ~~ #Identifier) ifTrue:[^ #Error]. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4464 |
pos2 := tokenPosition+tokenName size-1. |
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4465 |
self markArgumentIdentifierFrom:tokenPosition to:pos2. |
1519 | 4466 |
self checkMethodArgumentNameConventionsFor:tokenName. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4467 |
arg := Variable name:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4468 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4469 |
methodArgs := Array with:arg. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4470 |
methodArgNames := Array with:tokenName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4471 |
|
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4472 |
endOfSelectorPosition := pos2. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4473 |
self nextToken. |
1581
a2a4645fe3b8
keep endOfSelectorSpec and begonOfBody separate
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
4474 |
beginOfBodyPosition := tokenPosition. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4475 |
"/ ((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4476 |
"/ self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4477 |
"/ arg domain:nil. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4478 |
"/ ]. |
660
f68ddffc6921
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
647
diff
changeset
|
4479 |
^ self |
141 | 4480 |
]. |
461
1d24cc165fac
oops - did not allow | as method-selector
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
4481 |
|
1259 | 4482 |
^ self parseExtendedMethodSpec |
255
13a059f6569d
no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents:
229
diff
changeset
|
4483 |
|
663 | 4484 |
"Modified: / 31.3.1998 / 17:31:59 / cg" |
141 | 4485 |
! |
4486 |
||
713 | 4487 |
statement |
4488 |
"parse a statement; return a node-tree or #Error. |
|
4489 |
||
4490 |
statement ::= '^' expression |
|
4491 |
| PRIMITIVECODE |
|
4492 |
| expression |
|
4493 |
" |
|
4494 |
||
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4495 |
|expr node lnr code| |
713 | 4496 |
|
4497 |
(tokenType == $^) ifTrue:[ |
|
837 | 4498 |
self markReturnAt:tokenPosition. |
713 | 4499 |
lnr := tokenLineNr. |
4500 |
self nextToken. |
|
4501 |
expr := self expression. |
|
4502 |
(expr == #Error) ifTrue:[^ #Error]. |
|
4503 |
node := ReturnNode expression:expr. |
|
4504 |
node home:self blockHome:currentBlock. |
|
4505 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4506 |
|
1231 | 4507 |
self rememberReturnedValue:expr. |
713 | 4508 |
^ node |
4509 |
]. |
|
4510 |
||
4511 |
(tokenType == #Primitive) ifTrue:[ |
|
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4512 |
code := tokenValue. |
713 | 4513 |
self nextToken. |
1276
f7f6e0c1aff9
code could be wrong in a primitive node
Claus Gittinger <cg@exept.de>
parents:
1275
diff
changeset
|
4514 |
node := PrimitiveNode code:code. |
713 | 4515 |
node isOptional ifFalse:[ |
4516 |
hasNonOptionalPrimitiveCode := true |
|
4517 |
]. |
|
4518 |
hasPrimitiveCode := true. |
|
4519 |
^ node |
|
4520 |
]. |
|
4521 |
||
4522 |
(tokenType == #EOF) ifTrue:[ |
|
733
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4523 |
currentBlock notNil ifTrue:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4524 |
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
|
4525 |
] ifFalse:[ |
6859b56d5bd2
better error message for missing ']' at end of block.
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4526 |
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
|
4527 |
]. |
713 | 4528 |
^ #Error |
4529 |
]. |
|
4530 |
||
984 | 4531 |
(tokenType == $.) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4532 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
984 | 4533 |
"/ allow empty statement |
4534 |
^ StatementNode expression:nil. |
|
4535 |
]. |
|
4536 |
]. |
|
4537 |
||
713 | 4538 |
expr := self expression. |
4539 |
(expr == #Error) ifTrue:[^ #Error]. |
|
4540 |
||
4541 |
"/ classToCompileFor notNil ifTrue:[ |
|
4542 |
"/ currentBlock isNil ifTrue:[ |
|
4543 |
"/ expr isPrimary ifTrue:[ |
|
4544 |
"/ self warning:'useless computation - missing ^ ?' |
|
4545 |
"/ ] |
|
4546 |
"/ ] |
|
4547 |
"/ ]. |
|
4548 |
||
4549 |
node := StatementNode expression:expr. |
|
4550 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
4551 |
^ node |
|
4552 |
||
1222
f3f602267070
check if returning both boolean / non-boolean
Claus Gittinger <cg@exept.de>
parents:
1221
diff
changeset
|
4553 |
"Modified: / 17.11.2001 / 10:22:33 / cg" |
713 | 4554 |
! |
4555 |
||
4556 |
statementList |
|
4557 |
"parse a statementlist; return a node-tree, nil or #Error. |
|
4558 |
Statements must be separated by periods. |
|
4559 |
||
4560 |
statementList ::= <statement> |
|
988 | 4561 |
| <statementList> . <statement> |
713 | 4562 |
" |
4563 |
||
4564 |
|thisStatement prevStatement firstStatement correctIt periodPos |
|
4565 |
prevExpr| |
|
4566 |
||
4567 |
thisStatement := self statement. |
|
4568 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4569 |
firstStatement := thisStatement. |
|
4570 |
[tokenType == $.] whileTrue:[ |
|
988 | 4571 |
prevExpr := thisStatement expression. |
4572 |
(prevExpr notNil |
|
4573 |
and:[prevExpr isMessage |
|
4574 |
and:[thisStatement isReturnNode not]]) ifTrue:[ |
|
4575 |
(#(#'=' #'==') includes:prevExpr selector) ifTrue:[ |
|
1487 | 4576 |
self warning:'useless computation - mistyped assignment (i.e. did you mean '':='') ?' position:prevExpr selectorPosition |
988 | 4577 |
]. |
4578 |
]. |
|
4579 |
||
4580 |
periodPos := tokenPosition. |
|
4581 |
self nextToken. |
|
4582 |
(tokenType == $]) ifTrue:[ |
|
4583 |
currentBlock isNil ifTrue:[ |
|
4584 |
self parseError:'block nesting error'. |
|
713 | 4585 |
" |
988 | 4586 |
*** I had a warning here (since it was not defined |
4587 |
*** in the blue-book; but PD-code contains a lot of |
|
4588 |
*** code with periods at the end so that the warnings |
|
4589 |
*** became annoying |
|
4590 |
||
4591 |
] ifFalse:[ |
|
4592 |
self warning:'period after last statement' position:periodPos |
|
713 | 4593 |
" |
988 | 4594 |
]. |
4595 |
^ firstStatement |
|
4596 |
]. |
|
4597 |
(tokenType == #EOF) ifTrue:[ |
|
4598 |
currentBlock notNil ifTrue:[ |
|
4599 |
self parseError:'block nesting error (expected '']'')'. |
|
713 | 4600 |
" |
988 | 4601 |
*** I had a warning here (since it was not defined |
4602 |
*** in the blue-book; but PD-code contains a lot of |
|
4603 |
*** code with periods at the end so that the warnings |
|
4604 |
*** became annoying |
|
4605 |
||
4606 |
] ifFalse:[ |
|
4607 |
self warning:'period after last statement' position:periodPos |
|
713 | 4608 |
" |
988 | 4609 |
]. |
4610 |
^ firstStatement |
|
4611 |
]. |
|
4612 |
||
4613 |
prevStatement := thisStatement. |
|
4614 |
prevStatement isReturnNode ifTrue:[ |
|
4615 |
self warning:'statements after return' position:tokenPosition |
|
4616 |
]. |
|
713 | 4617 |
" |
988 | 4618 |
periodPos := tokenPosition. |
4619 |
self nextToken. |
|
713 | 4620 |
" |
4621 |
||
988 | 4622 |
((tokenType == $]) or:[tokenType == #EOF]) ifTrue:[ |
4623 |
(currentBlock isNil and:[tokenType == $]]) ifTrue:[ |
|
4624 |
self parseError:'block nesting error'. |
|
4625 |
] ifFalse:[ |
|
4626 |
correctIt := self correctableError:'period after last statement in block' |
|
4627 |
position:periodPos to:(periodPos + 1). |
|
4628 |
correctIt ifTrue:[ |
|
4629 |
(self correctByDeleting == #Error) ifTrue:[ |
|
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
4630 |
self errorFlag:true |
988 | 4631 |
] |
4632 |
] |
|
4633 |
]. |
|
4634 |
^ firstStatement |
|
4635 |
]. |
|
4636 |
thisStatement := self statement. |
|
4637 |
(thisStatement == #Error) ifTrue:[^ #Error]. |
|
4638 |
prevStatement nextStatement:thisStatement |
|
713 | 4639 |
]. |
4640 |
^ firstStatement |
|
4641 |
||
4642 |
"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
|
4643 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4644 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4645 |
variableTypeDeclarationFor:aVariable |
1471 | 4646 |
"experimental support for Domain variables (constraint programming support): |
4647 |
a variable-declaration of the form |
|
4648 |
|var (domain) ... | |
|
4649 |
declares var as a domainVariable. |
|
4650 |
Valid domains are: |
|
4651 |
min %% max - integer range domain |
|
4652 |
Bool - boolean domain |
|
4653 |
Nat - positive integer domain |
|
4654 |
Int - integer domain |
|
4655 |
#sym1 ... #sym2 - enumerated symbolic domain |
|
4656 |
" |
|
4657 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4658 |
|min max domain enumValues| |
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 |
(tokenType == $() ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4661 |
self syntaxError:'''('' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4662 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4663 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4664 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4665 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4666 |
(tokenType == #Integer) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4667 |
min := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4668 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4669 |
((tokenType == #BinaryOperator) and:[token = '%%']) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4670 |
self syntaxError:'''%%'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4671 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4672 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4673 |
(tokenType == #Integer) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4674 |
self syntaxError:'Integer (upper bound) expected' position:tokenPosition. |
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 |
max := token. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4677 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4678 |
domain := IntegerDomain min:min max:max. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4679 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4680 |
((tokenType == #Identifier) and:[token first isUppercase]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4681 |
token = 'Bool' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4682 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4683 |
domain := BooleanDomain new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4684 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4685 |
token = 'Nat' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4686 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4687 |
domain := IntegerDomain min:0 max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4688 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4689 |
token = 'Int' ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4690 |
self nextToken. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4691 |
domain := IntegerDomain min:(SmallInteger minVal) max:(SmallInteger maxVal). |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4692 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4693 |
] ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4694 |
((tokenType == #Symbol) or:[(tokenType == #Identifier)]) ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4695 |
enumValues := OrderedCollection new. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4696 |
[((tokenType == #Symbol) or:[(tokenType == #Identifier)])] whileTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4697 |
enumValues add:token. |
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 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4700 |
domain := EnumeratedDomain new values:enumValues. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4701 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4702 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4703 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4704 |
domain isNil ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4705 |
self syntaxError:'invalid domain' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4706 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4707 |
aVariable domain:domain. |
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 |
(tokenType == $)) ifFalse:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4710 |
self syntaxError:''')'' expected' position:tokenPosition. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4711 |
^ #Error |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4712 |
]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
4713 |
self nextToken. |
713 | 4714 |
! ! |
4715 |
||
4716 |
!Parser methodsFor:'parsing-expressions'! |
|
4717 |
||
4718 |
array |
|
4719 |
|arr elements elem pos1| |
|
4720 |
||
4721 |
pos1 := tokenPosition. |
|
4722 |
elements := OrderedCollection new:20. |
|
4723 |
[tokenType ~~ $) ] whileTrue:[ |
|
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4724 |
elem := self arrayConstant. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
4725 |
|
1062 | 4726 |
"/ (elem == #Error) ifTrue:[ |
4727 |
"/ (tokenType == #EOF) ifTrue:[ |
|
4728 |
"/ self syntaxError:'unterminated array-constant; '')'' expected' |
|
4729 |
"/ position:pos1 to:tokenPosition |
|
4730 |
"/ ]. |
|
4731 |
"/ ^ #Error |
|
4732 |
"/ ]. |
|
713 | 4733 |
elem isSymbol ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
4734 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
713 | 4735 |
]. |
4736 |
elements add:elem. |
|
4737 |
self nextToken |
|
4738 |
]. |
|
4739 |
arr := Array withAll:elements. |
|
4740 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4741 |
parserFlags arraysAreImmutable ifTrue:[ |
1615 | 4742 |
^ self makeImmutableArray:arr |
713 | 4743 |
]. |
4744 |
^ arr |
|
4745 |
||
4746 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
4747 |
! |
|
4748 |
||
4749 |
arrayConstant |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4750 |
|val| |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4751 |
|
713 | 4752 |
(tokenType == #Nil) ifTrue:[ |
4753 |
^ nil |
|
4754 |
]. |
|
4755 |
((tokenType == #Integer) |
|
4756 |
or:[tokenType == #Float]) ifTrue:[ |
|
4757 |
^ tokenValue |
|
4758 |
]. |
|
1615 | 4759 |
(tokenType == #String) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4760 |
parserFlags stringsAreImmutable ifTrue:[^ self makeImmutableString:tokenValue]. |
1615 | 4761 |
^ tokenValue |
4762 |
]. |
|
4763 |
(tokenType == #Character) ifTrue:[ |
|
713 | 4764 |
^ tokenValue |
4765 |
]. |
|
4766 |
(tokenType == #True) ifTrue:[ |
|
4767 |
^ true |
|
4768 |
]. |
|
4769 |
(tokenType == #False) ifTrue:[ |
|
4770 |
^ false |
|
4771 |
]. |
|
4772 |
(tokenType == #Error) ifTrue:[ |
|
1062 | 4773 |
^ ParseErrorSignal raise. |
713 | 4774 |
]. |
4775 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
1604
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4776 |
val := tokenName asSymbol. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4777 |
parseForCode ifFalse:[ |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4778 |
self rememberSymbolUsed:val. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4779 |
]. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4780 |
^ val |
713 | 4781 |
]. |
4782 |
||
4783 |
"/ some more special symbol consts ... |
|
4784 |
(tokenType == $| ) ifTrue:[ |
|
4785 |
^ #| |
|
4786 |
]. |
|
4787 |
(tokenType == #Self ) ifTrue:[ |
|
4788 |
^ #'self' |
|
4789 |
]. |
|
4790 |
(tokenType == #Super ) ifTrue:[ |
|
4791 |
^ #'super' |
|
4792 |
]. |
|
4793 |
(tokenType == #Here ) ifTrue:[ |
|
4794 |
^ #'here' |
|
4795 |
]. |
|
4796 |
(tokenType == #ThisContext ) ifTrue:[ |
|
4797 |
^ #'thisContext' |
|
4798 |
]. |
|
4799 |
||
4800 |
((tokenType == #Keyword) |
|
4801 |
or:[tokenType == #Identifier]) ifTrue:[ |
|
1604
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4802 |
val := tokenName asSymbol. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4803 |
parseForCode ifFalse:[ |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4804 |
self rememberSymbolUsed:val. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4805 |
]. |
841e69c7bdaf
usedSymbols: also remember symbols in literal arrays
Claus Gittinger <cg@exept.de>
parents:
1601
diff
changeset
|
4806 |
^ val |
713 | 4807 |
]. |
4808 |
((tokenType == $() |
|
4809 |
or:[tokenType == #HashLeftParen]) ifTrue:[ |
|
4810 |
self nextToken. |
|
4811 |
^ self array |
|
4812 |
]. |
|
4813 |
((tokenType == $[) |
|
4814 |
or:[tokenType == #HashLeftBrack]) ifTrue:[ |
|
4815 |
self nextToken. |
|
4816 |
^ self byteArray |
|
4817 |
]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4818 |
(tokenType == #HashLeftBrace) ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4819 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4820 |
val := QualifiedName for:val name. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4821 |
^ val |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
4822 |
]. |
713 | 4823 |
(tokenType == #Symbol) ifTrue:[ |
1066
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4824 |
parseForCode ifFalse:[ |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4825 |
self rememberSymbolUsed:tokenValue. |
ba626f00f709
remember symbols used in arrayConstant
Claus Gittinger <cg@exept.de>
parents:
1065
diff
changeset
|
4826 |
]. |
713 | 4827 |
^ tokenValue |
4828 |
]. |
|
4829 |
(tokenType == #EOF) ifTrue:[ |
|
4830 |
"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
|
4831 |
self syntaxError:'error in array-constant; EOF unexpected'. |
1062 | 4832 |
^ ParseErrorSignal raise. |
713 | 4833 |
]. |
4834 |
self syntaxError:('error in array-constant; ' |
|
4835 |
, tokenType printString |
|
4836 |
, ' unexpected'). |
|
1062 | 4837 |
^ ParseErrorSignal raise. |
713 | 4838 |
|
4839 |
"Modified: / 14.4.1998 / 18:22:54 / cg" |
|
4840 |
! |
|
4841 |
||
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4842 |
arrayIndexingExpression |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4843 |
"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
|
4844 |
foo[idx] is syntactic sugar for foo matrixAt:x |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4845 |
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
|
4846 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4847 |
|receiver argList selectorStream valNode| |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4848 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4849 |
receiver := self functionCallExpression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4850 |
tokenType == $[ ifFalse:[^ receiver]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
4851 |
parserFlags allowArrayIndexSyntaxExtension == true ifFalse:[^ receiver.]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4852 |
(receiver == #Error) ifTrue:[^ #Error]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4853 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4854 |
selectorStream := WriteStream on: (String new: 32). |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4855 |
argList := OrderedCollection new. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4856 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4857 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4858 |
[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4859 |
|indexNode| |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4860 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4861 |
self nextToken. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4862 |
indexNode := self primary. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4863 |
argList isEmpty ifTrue:[selectorStream nextPutAll:'_']. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4864 |
selectorStream nextPutAll:'at:'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4865 |
argList add: indexNode. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4866 |
(tokenType == #BinaryOperator ) and:[ token = ','] |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4867 |
] whileTrue. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4868 |
|
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4869 |
tokenType == $] ifFalse:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4870 |
self parseError:''']'' expected'. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4871 |
^ #Error |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4872 |
]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4873 |
self nextToken. |
1412
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 |
tokenType == $[ ifTrue:[ |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4876 |
receiver := MessageNode |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4877 |
receiver:receiver |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4878 |
selector:(selectorStream contents) |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4879 |
args:argList. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4880 |
selectorStream := WriteStream on: (String new: 32). |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4881 |
]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4882 |
tokenType == $[ |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4883 |
] whileTrue. |
1411 | 4884 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4885 |
tokenType == #':=' ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4886 |
self nextToken. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4887 |
selectorStream nextPutAll:'put:'. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4888 |
valNode := self expression. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4889 |
valNode == #Error ifTrue:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4890 |
^ valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4891 |
]. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4892 |
"/ 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
|
4893 |
"/ (valNode isKindOf: BlockNode) ifFalse:[ |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4894 |
"/ valNode _ BlockNode new |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4895 |
"/ arguments: #() |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4896 |
"/ statements: (OrderedCollection with: valNode) |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4897 |
"/ returns: false |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4898 |
"/ from: encoder. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4899 |
"/ ]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4900 |
argList add: valNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4901 |
]. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4902 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4903 |
^ MessageNode |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4904 |
receiver:receiver |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4905 |
selector:selectorStream contents |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4906 |
args:argList. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4907 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4908 |
" |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4909 |
AllowArrayIndexSyntaxExtension := true. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4910 |
AllowArrayIndexSyntaxExtension := false. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4911 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4912 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4913 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4914 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4915 |
|
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4916 |
foo := Array new:10 withAll:2. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4917 |
1 + foo[1]. |
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 |
" |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4920 |
|foo| |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4921 |
|
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4922 |
foo := Array new:10. |
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4923 |
foo[1] := 'hello'. |
1412
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4924 |
foo[2]. |
af3ec9f24a38
array indexing extension (experimental)
Claus Gittinger <cg@exept.de>
parents:
1411
diff
changeset
|
4925 |
foo[1]. |
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
4926 |
" |
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 |
|
713 | 4929 |
binaryExpression |
4930 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
4931 |
||
1328 | 4932 |
|receiver| |
713 | 4933 |
|
4934 |
receiver := self unaryExpression. |
|
4935 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 4936 |
^ self binaryExpressionFor:receiver |
4937 |
! |
|
4938 |
||
4939 |
binaryExpressionFor:receiverArg |
|
4940 |
"parse a binary-expression; return a node-tree, nil or #Error" |
|
4941 |
||
1547 | 4942 |
|receiver expr arg sel pos1 pos2 lno note| |
1328 | 4943 |
|
4944 |
receiver := receiverArg. |
|
4945 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
713 | 4946 |
|
4947 |
"special kludge: since Scanner cannot know if -digit is a binary |
|
4948 |
expression or a negative constant, handle cases here" |
|
4949 |
||
4950 |
[(tokenType == #BinaryOperator) |
|
4951 |
or:[(tokenType == $|) |
|
4952 |
or:[((tokenType == #Integer) or:[tokenType == #Float]) |
|
4953 |
and:[tokenValue < 0]]] |
|
4954 |
] whileTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4955 |
"/ 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
|
4956 |
inFunctionCallArgument == true ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4957 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4958 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4959 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4960 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4961 |
|
1547 | 4962 |
pos1 := tokenPosition. |
713 | 4963 |
lno := tokenLineNr. |
4964 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4965 |
"/ kludge alarm: bar and minus are not scanned as binop |
713 | 4966 |
(tokenType == $|) ifTrue:[ |
4967 |
sel := '|'. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
4968 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:tokenPosition. |
713 | 4969 |
self nextToken |
4970 |
] ifFalse:[ |
|
4971 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
4972 |
sel := tokenName. |
1022 | 4973 |
sel := self selectorCheck:sel for:receiver position:tokenPosition to:(tokenPosition + tokenName size - 1). |
713 | 4974 |
self nextToken |
4975 |
] ifFalse:[ |
|
4976 |
sel := '-'. |
|
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
4977 |
token := tokenValue := tokenValue negated |
713 | 4978 |
] |
4979 |
]. |
|
1547 | 4980 |
|
4981 |
pos2 := pos1 + sel size - 1. |
|
4982 |
self markSelector:sel from:pos1 to:pos2 receiverNode:receiver. |
|
713 | 4983 |
|
4984 |
arg := self unaryExpression. |
|
4985 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
4986 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
4987 |
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
|
4988 |
expr isErrorNode ifTrue:[ |
1547 | 4989 |
self parseError:(expr errorString) position:pos1 to:tokenPosition. |
713 | 4990 |
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
|
4991 |
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
|
4992 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
4993 |
note := self plausibilityCheck:expr. |
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4994 |
note notNil ifTrue:[ |
1547 | 4995 |
self warning:note position:pos1 to:pos2 |
903
038c2c447dcf
always do plausibility checks
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
4996 |
]. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
4997 |
expr lineNumber:lno. |
1547 | 4998 |
expr selectorPosition:pos1. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
4999 |
parseForCode ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5000 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5001 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5002 |
receiver := expr. "/ for next message |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5003 |
|
713 | 5004 |
]. |
5005 |
^ receiver |
|
5006 |
||
5007 |
"Modified: / 9.1.1998 / 19:05:18 / stefan" |
|
1022 | 5008 |
"Modified: / 19.1.2000 / 16:22:04 / cg" |
713 | 5009 |
! |
5010 |
||
5011 |
byteArray |
|
5012 |
"started with ST-80 R4 - allow byteArray constants as #[ ... ]" |
|
5013 |
||
5014 |
|bytes index limit newArray elem pos1 pos2| |
|
5015 |
||
5016 |
pos1 := tokenPosition. |
|
5017 |
bytes := ByteArray uninitializedNew:5000. |
|
5018 |
index := 0. limit := 5000. |
|
5019 |
[tokenType ~~ $] ] whileTrue:[ |
|
1576 | 5020 |
pos2 := tokenPosition. |
5021 |
" |
|
5022 |
this is not good programming style, but speeds up |
|
5023 |
reading of huge byte arrays (i.e. stored Images ...) |
|
5024 |
" |
|
5025 |
(tokenType == #Integer) ifTrue:[ |
|
5026 |
elem := tokenValue |
|
5027 |
] ifFalse:[ |
|
5028 |
elem := self arrayConstant. |
|
5029 |
(elem == #Error) ifTrue:[ |
|
5030 |
(tokenType == #EOF) ifTrue:[ |
|
5031 |
self syntaxError:'unterminated bytearray-constant; '']'' expected' |
|
5032 |
position:pos1 to:tokenPosition |
|
5033 |
]. |
|
5034 |
^ #Error |
|
5035 |
]. |
|
5036 |
]. |
|
5037 |
((elem isMemberOf:SmallInteger) and:[elem between:0 and:255]) ifTrue:[ |
|
5038 |
index := index + 1. |
|
5039 |
bytes at:index put:elem. |
|
5040 |
index == limit ifTrue:[ |
|
5041 |
newArray := ByteArray uninitializedNew:(limit * 2). |
|
5042 |
newArray replaceFrom:1 to:limit with:bytes startingAt:1. |
|
5043 |
limit := limit * 2. |
|
5044 |
bytes := newArray |
|
5045 |
]. |
|
5046 |
] ifFalse:[ |
|
5047 |
self parseError:'invalid ByteArray element' position:pos2 to:tokenPosition - 1 |
|
5048 |
]. |
|
5049 |
self nextToken. |
|
713 | 5050 |
]. |
5051 |
newArray := ByteArray uninitializedNew:index. |
|
5052 |
newArray replaceFrom:1 to:index with:bytes startingAt:1. |
|
5053 |
^ newArray |
|
5054 |
! |
|
5055 |
||
5056 |
degeneratedKeywordExpressionForSelector |
|
1406 | 5057 |
"parse a keyword-expression without receiver - for the selector only. |
5058 |
Return the selector or nil (if it cannot be determined). |
|
5059 |
This is not used in normal parsing, but instead to extract the selector from a code fragment. |
|
5060 |
(for example, the system browsers 'implementors'-function uses this to extract a selector from |
|
5061 |
the selection)" |
|
713 | 5062 |
|
5063 |
|sel arg rec| |
|
5064 |
||
5065 |
(tokenType == #Keyword) ifTrue:[ |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5066 |
sel := tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5067 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5068 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5069 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5070 |
[tokenType == #Keyword] whileTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5071 |
sel := sel , tokenName. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5072 |
self nextToken. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5073 |
arg := self binaryExpression. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5074 |
(arg == #Error) ifTrue:[^ sel]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5075 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5076 |
^ sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5077 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5078 |
|
1406 | 5079 |
(rec := self arrayIndexingExpression) == #Error ifTrue:[ ^ nil]. |
5080 |
sel := self degeneratedKeywordExpressionForSelector. |
|
5081 |
sel notNil ifTrue:[ ^ sel]. |
|
5082 |
||
1407 | 5083 |
rec isAssignment ifTrue:[ |
5084 |
rec := rec expression |
|
5085 |
]. |
|
1406 | 5086 |
rec isMessage ifTrue:[ |
5087 |
^ rec selector |
|
5088 |
]. |
|
5089 |
^ nil |
|
1524 | 5090 |
|
5091 |
" |
|
5092 |
(self new source:'hello:world:') nextToken; degeneratedKeywordExpressionForSelector |
|
5093 |
(self new source:'hello:world') nextToken; degeneratedKeywordExpressionForSelector |
|
5094 |
(self new source:'hello:') nextToken; degeneratedKeywordExpressionForSelector |
|
5095 |
" |
|
713 | 5096 |
! |
5097 |
||
5098 |
expression |
|
5099 |
"parse a cascade-expression; return a node-tree, nil or #Error. |
|
5100 |
||
5101 |
expression ::= keywordExpression |
|
5102 |
| keywordExpression cascade |
|
5103 |
||
5104 |
cascade ::= ';' expressionSendPart |
|
5105 |
| cascade ';' expressionSendPart |
|
5106 |
||
5107 |
expressionSendPart ::= { KEYWORD binaryExpression } |
|
5108 |
| BINARYOPERATOR unaryExpression |
|
5109 |
| IDENTIFIER |
|
5110 |
" |
|
5111 |
||
864 | 5112 |
|receiver arg sel args pos pos2 lno tokenEnd realReceiver positions| |
713 | 5113 |
|
5114 |
pos := tokenPosition. |
|
5115 |
receiver := self keywordExpression. |
|
5116 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
5117 |
(tokenType == $;) ifTrue:[ |
|
743
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5118 |
receiver isMessage ifFalse:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5119 |
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
|
5120 |
position:pos to:tokenPosition. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5121 |
realReceiver := receiver. "/ only to allow continuing. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5122 |
] ifTrue:[ |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5123 |
realReceiver := receiver receiver. |
3ced4791090c
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
739
diff
changeset
|
5124 |
]. |
713 | 5125 |
[tokenType == $;] whileTrue:[ |
5126 |
self nextToken. |
|
5127 |
(tokenType == #Identifier) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5128 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5129 |
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
|
5130 |
sel := tokenName. |
1022 | 5131 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 5132 |
receiver := CascadeNode receiver:receiver selector:sel. |
5133 |
receiver lineNumber:tokenLineNr. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5134 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5135 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5136 |
]. |
713 | 5137 |
self nextToken. |
5138 |
] ifFalse:[ |
|
5139 |
(tokenType == #BinaryOperator) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5140 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5141 |
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
|
5142 |
sel := tokenName. |
1022 | 5143 |
sel := self selectorCheck:tokenName for:realReceiver position:tokenPosition to:tokenEnd. |
713 | 5144 |
lno := tokenLineNr. |
5145 |
self nextToken. |
|
5146 |
arg := self unaryExpression. |
|
5147 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5148 |
receiver := CascadeNode receiver:receiver selector:sel arg:arg. |
|
5149 |
receiver lineNumber:lno. |
|
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 |
] ifFalse:[ |
5154 |
(tokenType == #Keyword) ifTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5155 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5156 |
positions := OrderedCollection with:(tokenPosition to:tokenEnd). |
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5157 |
pos := tokenPosition. |
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5158 |
pos2 := tokenEnd. |
713 | 5159 |
lno := tokenLineNr. |
5160 |
sel := tokenName. |
|
5161 |
self nextToken. |
|
5162 |
arg := self binaryExpression. |
|
5163 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5164 |
args := Array with:arg. |
|
5165 |
[tokenType == #Keyword] whileTrue:[ |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5166 |
tokenEnd := tokenPosition + tokenName size - 1. |
864 | 5167 |
positions add:(tokenPosition to:tokenEnd). |
713 | 5168 |
sel := sel , tokenName. |
5169 |
self nextToken. |
|
5170 |
arg := self binaryExpression. |
|
5171 |
(arg == #Error) ifTrue:[^ #Error]. |
|
5172 |
args := args copyWith:arg. |
|
739
18bce3ea44f5
fixed syntax-highlight for cascade-selectors.
Claus Gittinger <cg@exept.de>
parents:
738
diff
changeset
|
5173 |
pos2 := tokenEnd |
713 | 5174 |
]. |
864 | 5175 |
positions do:[:p | |
5176 |
self markSelector:sel from:p start to:p stop receiverNode:realReceiver. |
|
5177 |
]. |
|
1597
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5178 |
|
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5179 |
sel := self selectorCheck:sel for:realReceiver position:pos to:pos2. |
4866fce1e050
inplausible selector marking
Claus Gittinger <cg@exept.de>
parents:
1581
diff
changeset
|
5180 |
|
713 | 5181 |
receiver := CascadeNode receiver:receiver selector:sel args:args. |
5182 |
receiver lineNumber:lno. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5183 |
parseForCode ifFalse:[ |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5184 |
self rememberSelectorUsed:sel |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
5185 |
]. |
713 | 5186 |
] ifFalse:[ |
5187 |
(tokenType == #Error) ifTrue:[^ #Error]. |
|
5188 |
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
|
5189 |
position:tokenPosition to:source position1Based - 1. |
713 | 5190 |
^ #Error |
5191 |
] |
|
5192 |
] |
|
5193 |
] |
|
5194 |
]. |
|
5195 |
||
5196 |
"obscure (unspecified ?) if selector follows; Question: |
|
5197 |
||
5198 |
is |
|
5199 |
'expr sel1; sel2 sel3' |
|
5200 |
||
5201 |
to be parsed as: |
|
5202 |
(t := expr. |
|
5203 |
t sel1. |
|
5204 |
t sel2) sel3 |
|
5205 |
||
5206 |
or: |
|
5207 |
(t := expr. |
|
5208 |
t sel1. |
|
5209 |
t sel2 sel3) |
|
5210 |
" |
|
5211 |
((tokenType == #Identifier) |
|
5212 |
or:[(tokenType == #BinaryOperator) |
|
5213 |
or:[tokenType == #Keyword]]) ifTrue:[ |
|
1328 | 5214 |
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
|
5215 |
position:tokenPosition to:source position1Based - 1. |
713 | 5216 |
^ #Error |
1328 | 5217 |
"/ self warning: "syntaxError:" 'possibly ambigous cascade - please group using (...)' |
5218 |
"/ position:tokenPosition to:source position - 1. |
|
5219 |
"/ tokenType == #Identifier ifTrue:[ |
|
5220 |
"/ ^ self unaryExpressionFor:receiver |
|
5221 |
"/ ]. |
|
5222 |
"/ tokenType == #BinaryOperator ifTrue:[ |
|
5223 |
"/ ^ self binaryExpressionFor:receiver |
|
5224 |
"/ ]. |
|
5225 |
"/ ^ self keywordExpressionFor:receiver |
|
713 | 5226 |
] |
5227 |
]. |
|
5228 |
^ receiver |
|
5229 |
||
1022 | 5230 |
"Modified: / 19.1.2000 / 16:22:16 / cg" |
713 | 5231 |
! |
5232 |
||
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5233 |
functionCallArgList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5234 |
|argList arg prevInFunctionCallArgument| |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5235 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5236 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5237 |
tokenType == $) ifTrue:[ self nextToken. ^ #() ]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5238 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5239 |
argList := OrderedCollection new. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5240 |
[ true ] whileTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5241 |
prevInFunctionCallArgument := inFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5242 |
inFunctionCallArgument := true. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5243 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5244 |
arg := self expression. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5245 |
argList add:arg. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5246 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5247 |
inFunctionCallArgument := prevInFunctionCallArgument. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5248 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5249 |
tokenType == $) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5250 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5251 |
^ argList |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5252 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5253 |
((tokenType == #BinaryOperator) and:[tokenName = ',']) ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5254 |
self parseError:'"," or ")" expected'. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5255 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5256 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5257 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5258 |
! |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5259 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5260 |
functionCallExpression |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5261 |
"parse a functionCall; |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5262 |
this is an st/x extension. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5263 |
foo(x) |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5264 |
is syntactic sugar for |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5265 |
foo value:x |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5266 |
" |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5267 |
|
1342
65f8f4d0ce09
only autoDefine workspace vars on the top level (i.e. not within blocks)
Claus Gittinger <cg@exept.de>
parents:
1341
diff
changeset
|
5268 |
|receiver numArgs argList evalSelectors evalSelector| |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5269 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5270 |
receiver := self primary. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5271 |
tokenType == $( ifFalse:[^ receiver]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5272 |
parserFlags allowFunctionCallSyntaxForBlockEvaluation ifFalse:[^ receiver.]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5273 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5274 |
(receiver == #Error) ifTrue:[^ #Error]. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5275 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5276 |
receiver isVariable ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5277 |
((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
|
5278 |
receiver isBlock ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5279 |
^ receiver |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5280 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5281 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5282 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5283 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5284 |
argList := self functionCallArgList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5285 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5286 |
"/ make it a block evaluation |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5287 |
numArgs := argList size. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5288 |
numArgs == 0 ifTrue:[ |
1341 | 5289 |
^ UnaryNode receiver:receiver selector:#value |
5290 |
]. |
|
1579 | 5291 |
evalSelectors := #(#'value:' |
1341 | 5292 |
#'value:value:' |
5293 |
#'value:value:value:' |
|
5294 |
#'value:value:value:value:' |
|
5295 |
#'value:value:value:value:value:' |
|
5296 |
#'value:value:value:value:value:value:' |
|
5297 |
#'value:value:value:value:value:value:value:' |
|
5298 |
#'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
|
5299 |
). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5300 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5301 |
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
|
5302 |
evalSelector := evalSelectors at:numArgs. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5303 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5304 |
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
|
5305 |
selector:evalSelector |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5306 |
args:argList. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5307 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5308 |
"/ gen argument vector |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5309 |
^ MessageNode |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5310 |
receiver:receiver |
1341 | 5311 |
selector:#valueWithArguments: |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5312 |
args:(self genMakeArrayWith:argList). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5313 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5314 |
" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5315 |
Parser allowFunctionCallSyntaxForBlockEvaluation:true. |
1337
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 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5318 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5319 |
|foo| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5320 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5321 |
foo := [:x | x + 1]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5322 |
1 + foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5323 |
foo(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5324 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5325 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5326 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5327 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5328 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5329 |
add1 := addN(1). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5330 |
add1(10). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5331 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5332 |
"AllowFunctionCallSyntaxForBlockEvaluation := false." |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5333 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5334 |
|addN add1| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5335 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5336 |
addN := [:n | [:x | x + n]]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5337 |
add1 := addN value:1. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5338 |
add1 value:10 |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5339 |
" |
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 |
genMakeArrayWith:elementExpressions |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5343 |
"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
|
5344 |
Will generate: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5345 |
Array with:el1 ... with:elN (if N <= 5) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5346 |
or: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5347 |
(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
|
5348 |
" |
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 |
|numEl arrRec sel expr| |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5351 |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5352 |
arrRec := VariableNode globalNamed:#Array. |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5353 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5354 |
numEl := elementExpressions size. |
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 |
(numEl between:1 and:8) ifTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5357 |
sel := #( |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5358 |
#'with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5359 |
#'with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5360 |
#'with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5361 |
#'with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5362 |
#'with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5363 |
#'with:with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5364 |
#'with:with:with:with:with:with:with:' |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
5365 |
#'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
|
5366 |
) at:numEl. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5367 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5368 |
^ MessageNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5369 |
receiver:arrRec |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5370 |
selector:sel |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5371 |
args:elementExpressions. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5372 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5373 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5374 |
"/ array creation expression ... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5375 |
expr := MessageNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5376 |
receiver:arrRec |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5377 |
selector:#new: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5378 |
arg:(ConstantNode type:#Integer value:numEl). |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5379 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5380 |
numEl == 0 ifTrue:[ |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5381 |
^ expr. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5382 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5383 |
"/ followed by a bunch of #at:put: messages... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5384 |
elementExpressions keysAndValuesDo:[:idx :e | |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5385 |
expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5386 |
receiver:expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5387 |
selector:#at:put: |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5388 |
arg1:(ConstantNode type:#Integer value:idx) |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5389 |
arg2:e |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5390 |
fold:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5391 |
]. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5392 |
"/ followed by a #yourself: message... |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5393 |
expr := CascadeNode |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5394 |
receiver:expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5395 |
selector:#yourself. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5396 |
^ expr |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5397 |
! |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
5398 |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5399 |
isValidUnarySelector:tokenType |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5400 |
tokenType == #Identifier ifTrue:[^true]. |
1373 | 5401 |
tokenType == #Here ifTrue:[^true]. |
5402 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5403 |
parserFlags allowReservedWordsAsSelectors == true ifTrue:[ |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5404 |
tokenType == #Self ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5405 |
tokenType == #Nil ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5406 |
tokenType == #True ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5407 |
tokenType == #False ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5408 |
tokenType == #Super ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5409 |
tokenType == #ThisContext ifTrue:[^true]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5410 |
]. |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5411 |
^ false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5412 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5413 |
" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5414 |
ParserFlags allowReservedWordsAsSelectors:true. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5415 |
1234 self. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5416 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5417 |
ParserFlags allowReservedWordsAsSelectors:false |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5418 |
1234 self. |
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5419 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5420 |
|
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5421 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5422 |
1234 self |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5423 |
1234 nil |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5424 |
1234 true |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5425 |
1234 false |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5426 |
1234 here |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5427 |
1234 super |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5428 |
1234 thisContext |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5429 |
" |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5430 |
! |
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
5431 |
|
713 | 5432 |
keywordExpression |
5433 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5434 |
||
5435 |
keywordExpression ::= binaryexpression |
|
5436 |
| { KEYWORD-PART binaryExpression } |
|
5437 |
" |
|
5438 |
||
1328 | 5439 |
|receiver| |
5440 |
||
713 | 5441 |
receiver := self binaryExpression. |
5442 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1328 | 5443 |
^ self keywordExpressionFor:receiver |
5444 |
! |
|
5445 |
||
5446 |
keywordExpressionFor:receiverArg |
|
5447 |
"parse a keyword-expression; return a node-tree, nil or #Error. |
|
5448 |
||
5449 |
keywordExpression ::= binaryexpression |
|
5450 |
| { KEYWORD-PART binaryExpression } |
|
5451 |
" |
|
5452 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5453 |
|expr receiver sel arg args posR1 posR2 pos1 pos2 lno note positions| |
1328 | 5454 |
|
5455 |
receiver := receiverArg. |
|
5456 |
posR1 := tokenPosition. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5457 |
(tokenType == #Keyword) ifFalse:[^ receiver]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5458 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5459 |
pos1 := posR2 := tokenPosition. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5460 |
pos2 := tokenPosition + tokenName size - 1. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5461 |
positions := OrderedCollection with:(pos1 to:pos2). |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5462 |
sel := tokenName. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5463 |
lno := tokenLineNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5464 |
self nextToken. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5465 |
arg := self binaryExpression. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5466 |
(arg == #Error) ifTrue:[^ #Error]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5467 |
args := Array with:arg. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5468 |
[tokenType == #Keyword] whileTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5469 |
sel := sel , tokenName. |
713 | 5470 |
pos2 := tokenPosition + tokenName size - 1. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5471 |
positions add:(tokenPosition to:pos2). |
713 | 5472 |
self nextToken. |
5473 |
arg := self binaryExpression. |
|
5474 |
(arg == #Error) ifTrue:[^ #Error]. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5475 |
args := args copyWith:arg. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5476 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5477 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5478 |
positions do:[:p | |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5479 |
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
|
5480 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5481 |
sel := self selectorCheck:sel for:receiver positions:positions. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5482 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5483 |
ignoreErrors ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5484 |
(Class definitionSelectors includes:sel) ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5485 |
receiver isVariable ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5486 |
receiver isUndeclared ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5487 |
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
|
5488 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5489 |
] |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5490 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5491 |
]. |
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 |
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
|
5494 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5495 |
self parseError:(expr errorString) position:pos1 to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5496 |
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
|
5497 |
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
|
5498 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5499 |
expr lineNumber:lno. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5500 |
note := self plausibilityCheck:expr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5501 |
note notNil ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5502 |
self warning:note position:pos1 to:pos2 |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5503 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5504 |
parseForCode ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5505 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5506 |
]. |
713 | 5507 |
|
1193 | 5508 |
"/ (contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
5509 |
"/ receiver isSuper ifTrue:[ |
|
5510 |
"/ sel ~= selector ifTrue:[ |
|
5511 |
"/ self warnCommonMistake:'possible bad super message (selector should be same as in current method) ?' |
|
5512 |
"/ position:posR1 to:posR2-1 |
|
5513 |
"/ ]. |
|
5514 |
"/ ]. |
|
5515 |
"/ ]. |
|
5516 |
"/ |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5517 |
(sel = #and: or:[sel = #or:]) ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5518 |
expr arg1 isBlock ifFalse:[ |
1575 | 5519 |
(expr arg1 isVariable |
5520 |
and:[ (expr arg1 name asLowercase includesString:'block')]) ifFalse:[ |
|
5521 |
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
|
5522 |
position:pos2+1 to:tokenPosition-1 |
1575 | 5523 |
] |
5524 |
]. |
|
5525 |
^ expr. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5526 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5527 |
(sel = #whileTrue: or:[sel = #whileFalse:]) ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5528 |
expr receiver isBlock ifFalse:[ |
1575 | 5529 |
(expr receiver isVariable |
5530 |
and:[ (expr receiver name asLowercase includesString:'block')]) ifFalse:[ |
|
5531 |
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
|
5532 |
position:posR1 to:posR2-1 |
1575 | 5533 |
] |
5534 |
]. |
|
5535 |
^ expr. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5536 |
]. |
1576 | 5537 |
(sel = #ifTrue: or:[sel = #ifFalse:]) ifTrue:[ |
5538 |
expr receiver isMessage ifTrue:[ |
|
5539 |
(expr receiver selector = #whileTrue or:[expr receiver selector = #whileFalse]) ifTrue:[ |
|
5540 |
self warnCommonMistake:'strange receiver expression' |
|
5541 |
position:posR1 to:posR2-1 |
|
5542 |
]. |
|
5543 |
] |
|
5544 |
]. |
|
5545 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
5546 |
^ expr. |
713 | 5547 |
|
1022 | 5548 |
"Modified: / 19.1.2000 / 16:22:22 / cg" |
713 | 5549 |
! |
5550 |
||
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5551 |
nodeForMethodArg:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5552 |
|varIndex var| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5553 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5554 |
methodArgNames isNil ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5555 |
varIndex := methodArgNames indexOf:varName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5556 |
varIndex == 0 ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5557 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5558 |
var := methodArgs at:varIndex. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5559 |
"/ var used:true. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5560 |
^ VariableNode type:#MethodArg |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5561 |
name:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5562 |
token:var |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5563 |
index:varIndex |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5564 |
! |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5565 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5566 |
nodeForMethodVariable:varName |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5567 |
|varIndex var| |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5568 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5569 |
methodVarNames isNil ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5570 |
varIndex := methodVarNames indexOf:varName. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5571 |
varIndex == 0 ifTrue:[^ nil]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5572 |
|
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5573 |
var := methodVars at:varIndex. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5574 |
var used:true. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5575 |
parseForCode ifFalse:[self rememberLocalUsed:varName]. |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5576 |
^ VariableNode type:#MethodVariable |
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 |
|
0 | 5582 |
primary |
1028 | 5583 |
"parse a primary-expression; return a node-tree, nil or #Error. |
5584 |
This also cares for namespace-access-pathes." |
|
0 | 5585 |
|
1227 | 5586 |
|val pos node eMsg| |
924 | 5587 |
|
44 | 5588 |
(tokenType == #Self) ifTrue:[ |
1227 | 5589 |
^ self primary_self. |
5590 |
]. |
|
5591 |
||
5592 |
pos := tokenPosition. |
|
0 | 5593 |
(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
|
5594 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5595 |
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
|
5596 |
with other smalltalks. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5597 |
" |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5598 |
tokenName = 'here' ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5599 |
(self variableOrError:tokenName) == #Error ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5600 |
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
|
5601 |
tokenType := #Here. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5602 |
^ 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
|
5603 |
] |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5604 |
]. |
1227 | 5605 |
^ self primary_identifier |
0 | 5606 |
]. |
49 | 5607 |
|
44 | 5608 |
((tokenType == #Integer) |
120 | 5609 |
or:[(tokenType == #String) |
44 | 5610 |
or:[(tokenType == #Character) |
5611 |
or:[(tokenType == #Float) |
|
5612 |
or:[(tokenType == #Symbol)]]]]) ifTrue:[ |
|
1227 | 5613 |
^ self primary_simpleLiteral. |
0 | 5614 |
]. |
924 | 5615 |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5616 |
(tokenType == #FixedPoint) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5617 |
parserFlags allowFixedPointLiterals == true ifFalse:[ |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5618 |
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
|
5619 |
^ #Error |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5620 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5621 |
^ self primary_simpleLiteral. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1342
diff
changeset
|
5622 |
]. |
0 | 5623 |
(tokenType == #Nil) ifTrue:[ |
1227 | 5624 |
^ self primary_nil. |
5625 |
]. |
|
0 | 5626 |
(tokenType == #True) ifTrue:[ |
1227 | 5627 |
^ self primary_true |
0 | 5628 |
]. |
5629 |
(tokenType == #False) ifTrue:[ |
|
1227 | 5630 |
^ self primary_false |
5631 |
]. |
|
0 | 5632 |
(tokenType == #Super) ifTrue:[ |
1227 | 5633 |
^ self primary_super. |
5634 |
]. |
|
924 | 5635 |
|
0 | 5636 |
(tokenType == #ThisContext) ifTrue:[ |
1262 | 5637 |
^ self primary_thisContext |
0 | 5638 |
]. |
924 | 5639 |
|
0 | 5640 |
(tokenType == #HashLeftParen) ifTrue:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5641 |
self nextToken. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5642 |
self inArrayLiteral:true. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5643 |
ParseErrorSignal handle:[:ex | |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5644 |
self inArrayLiteral:false. |
1165
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5645 |
^ #Error |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5646 |
] do:[ |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5647 |
val := self array. |
09d40e1ff75d
oops - invalid literal array const was not signalling an error
Claus Gittinger <cg@exept.de>
parents:
1164
diff
changeset
|
5648 |
]. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1200
diff
changeset
|
5649 |
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
|
5650 |
self nextToken. |
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
5651 |
(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
|
5652 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5653 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5654 |
^ ConstantNode type:#Array value:val |
0 | 5655 |
]. |
924 | 5656 |
|
5657 |
(tokenType == #HashLeftBrace) ifTrue:[ |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5658 |
val := self qualifiedName. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5659 |
self nextToken. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
5660 |
^ val. |
924 | 5661 |
]. |
5662 |
||
0 | 5663 |
(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
|
5664 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5665 |
val := self byteArray. |
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 |
]. |
924 | 5670 |
^ ConstantNode type:#ByteArray value:val |
0 | 5671 |
]. |
432 | 5672 |
|
0 | 5673 |
(tokenType == $() ifTrue:[ |
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5674 |
parenthesisLevel := parenthesisLevel + 1. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5675 |
self markParenthesisAt:tokenPosition. |
1227 | 5676 |
^ self primary_expression. |
0 | 5677 |
]. |
924 | 5678 |
|
0 | 5679 |
(tokenType == $[ ) ifTrue:[ |
673 | 5680 |
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
|
5681 |
val := self block. |
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:'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
|
5684 |
^ #Error |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5685 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5686 |
^ val |
0 | 5687 |
]. |
19 | 5688 |
|
1262 | 5689 |
"/ EXPERIMENTAL - may be in next release |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5690 |
parserFlags allowVariableReferences == true ifTrue:[ |
1295 | 5691 |
((tokenType == #BinaryOperator) and:[token = '&']) ifTrue:[ |
5692 |
self nextToken. |
|
5693 |
node := self primary_identifier. |
|
5694 |
"/ generate a Reference |
|
5695 |
^ self makeReferenceFor:node |
|
5696 |
]. |
|
5697 |
]. |
|
5698 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5699 |
(tokenType == ${ ) ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5700 |
parserFlags allowSqueakExtensions == true ifFalse:[ |
1335 | 5701 |
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
|
5702 |
errorFlag := false. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5703 |
]. |
1227 | 5704 |
^ self primary_squeakComputedArray. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5705 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
5706 |
|
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5707 |
(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
|
5708 |
self nextToken. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5709 |
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
|
5710 |
hasNonOptionalPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5711 |
hasPrimitiveCode := true. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5712 |
^ node |
502
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5713 |
]. |
410af1c0df1d
parse primitive-primary expression
Claus Gittinger <cg@exept.de>
parents:
501
diff
changeset
|
5714 |
|
1227 | 5715 |
tokenType == #HashHashLeftParen ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5716 |
self halt. |
1295 | 5717 |
self nextToken. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5718 |
parserFlags allowDolphinExtensions == true ifFalse:[ |
1335 | 5719 |
self parseError:'non-Standard Dolphin extension: ##(..). Enable in settings.' position:pos to:tokenPosition. |
1227 | 5720 |
^ #Error |
5721 |
]. |
|
5722 |
^ self primary_dolphinComputedLiteral. |
|
5723 |
]. |
|
1299 | 5724 |
tokenType == #ExclaLeftBrack ifTrue:[ |
1295 | 5725 |
self nextToken. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5726 |
parserFlags allowLazyValueExtension == true ifFalse:[ |
1335 | 5727 |
self parseError:'non-Standard LazyValue extension. Enable in classVariable.' position:pos to:tokenPosition. |
1295 | 5728 |
^ #Error |
5729 |
]. |
|
5730 |
^ self primary_lazyValue. |
|
5731 |
]. |
|
5732 |
tokenType == #HashHash ifTrue:[ |
|
1301
677ca6e364d4
+ warnPossible incompatibility
Claus Gittinger <cg@exept.de>
parents:
1299
diff
changeset
|
5733 |
self warnPossibleIncompatibility:'''##'' might be interpreted differently in other smalltalk systems' position:pos to:tokenPosition. |
1295 | 5734 |
tokenType := #Symbol. |
5735 |
token := tokenValue := tokenName := '#'. |
|
5736 |
^ self primary_simpleLiteral. |
|
5737 |
]. |
|
1227 | 5738 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5739 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5740 |
((tokenType == #BinaryOperator) and:[token = '#']) ifTrue:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5741 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5742 |
(tokenType == $( ) ifFalse:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5743 |
self parseError:'''('' expected after #.' position:pos to:tokenPosition. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5744 |
^ self. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5745 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5746 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5747 |
self inArrayLiteral:true. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5748 |
ParseErrorSignal handle:[:ex | |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5749 |
self inArrayLiteral:false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5750 |
^ #Error |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5751 |
] do:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5752 |
val := self array. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5753 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5754 |
self inArrayLiteral:false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5755 |
self nextToken. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5756 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5757 |
^ #Error |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5758 |
]. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5759 |
^ ConstantNode type:#Array value:val |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5760 |
]. |
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 |
|
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5763 |
((tokenType == #BinaryOperator) and:[token = '-']) ifTrue:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5764 |
self nextToken. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5765 |
((tokenType == #Integer) |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5766 |
or:[(tokenType == #Float)]) ifFalse:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5767 |
self parseError:'number expected after sign.' position:pos to:tokenPosition. |
1539 | 5768 |
^ #Error. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5769 |
]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5770 |
parserFlags allowSqueakExtensions == true ifFalse:[ |
1538
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5771 |
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
|
5772 |
errorFlag := false. |
c55990043eb6
squeak allow space between '#" and '('
Claus Gittinger <cg@exept.de>
parents:
1537
diff
changeset
|
5773 |
]. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5774 |
|
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5775 |
node := self primary_simpleLiteral. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5776 |
node isConstant ifFalse:[ |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5777 |
self parseError:'number expected after sign.' position:pos to:tokenPosition. |
1539 | 5778 |
^ #Error. |
1537
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5779 |
]. |
1557
311e94185248
oops - parser clobbered Const1Node (negated)
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
5780 |
^ 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
|
5781 |
]. |
de5fc45c2f10
squeak allows whiteSpace between sign and number
Claus Gittinger <cg@exept.de>
parents:
1535
diff
changeset
|
5782 |
|
0 | 5783 |
(tokenType == #Error) ifTrue:[^ #Error]. |
44 | 5784 |
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
|
5785 |
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
|
5786 |
, tokenType printString , |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5787 |
' unexpected') position:tokenPosition to:tokenPosition |
0 | 5788 |
] ifFalse:[ |
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5789 |
(#(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
|
5790 |
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
|
5791 |
, tokenType printString , '(' , tokenName , ') ' , |
805 | 5792 |
' 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
|
5793 |
] ifFalse:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5794 |
eMsg := ('error in primary; ' |
1295 | 5795 |
, (token ? '') , ' (', tokenType printString , |
5796 |
') unexpected') |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5797 |
]. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1369
diff
changeset
|
5798 |
self syntaxError:eMsg position:tokenPosition to:source position1Based - 1 |
0 | 5799 |
]. |
5800 |
^ #Error |
|
120 | 5801 |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
5802 |
"Created: / 13.9.1995 / 12:50:50 / claus" |
1068 | 5803 |
"Modified: / 18.8.2000 / 20:51:22 / cg" |
0 | 5804 |
! |
5805 |
||
1227 | 5806 |
primary_dolphinComputedLiteral |
1273
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5807 |
"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
|
5808 |
In dolphin, these are written as: ##( expression ) |
3a9541cd8fef
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1272
diff
changeset
|
5809 |
and create a literal constant for the expressions value. |
1274 | 5810 |
Right now, only a subset is supported - Strings, ByteArrays and Characters. |
5811 |
WARNING: this is only supported to allow filing in dolphin code. |
|
5812 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
5813 |
if you ever plan to stc-compile it into a shared library" |
|
1227 | 5814 |
|
5815 |
|pos expr val| |
|
5816 |
||
5817 |
pos := tokenPosition. |
|
5818 |
||
5819 |
expr := self expression. |
|
5820 |
||
5821 |
tokenType ~~ $) ifTrue:[ |
|
5822 |
self parseError:''')'' expected' position:tokenPosition. |
|
5823 |
^ #Error |
|
5824 |
]. |
|
5825 |
self nextToken. |
|
5826 |
||
5827 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5828 |
^ #Error |
|
5829 |
]. |
|
5830 |
||
5831 |
val := expr evaluate. |
|
5832 |
||
5833 |
val isLiteral ifTrue:[ |
|
1272
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5834 |
val isString ifTrue:[ |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5835 |
^ ConstantNode type:#String value:val |
2a429e2293d1
dolphin compile-time constant strings
Claus Gittinger <cg@exept.de>
parents:
1271
diff
changeset
|
5836 |
]. |
1227 | 5837 |
val isByteArray ifTrue:[ |
5838 |
^ ConstantNode type:#ByteArray value:val |
|
5839 |
]. |
|
1234 | 5840 |
val isCharacter ifTrue:[ |
5841 |
^ ConstantNode type:#Character value:val |
|
5842 |
]. |
|
1295 | 5843 |
val isInteger ifTrue:[ |
5844 |
^ ConstantNode type:#Integer value:val |
|
5845 |
]. |
|
1328 | 5846 |
val isLimitedPrecisionReal ifTrue:[ |
5847 |
^ ConstantNode type:#Float value:val |
|
5848 |
]. |
|
1295 | 5849 |
val isArray ifTrue:[ |
5850 |
^ ConstantNode type:#Array value:val |
|
5851 |
]. |
|
1227 | 5852 |
] ifFalse:[ |
5853 |
self parseError:'must be representable as a literal (for now)' position:pos. |
|
5854 |
^ #Error |
|
5855 |
]. |
|
1326 | 5856 |
self halt:'unimplemented'. |
1227 | 5857 |
"/ "/ make it an array creation expression ... |
5858 |
"/ expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
5859 |
"/ receiver:(VariableNode globalNamed:#Array) |
1227 | 5860 |
"/ selector:#new: |
5861 |
"/ arg:(ConstantNode type:#Integer value:(exprList size)). |
|
5862 |
"/ |
|
5863 |
"/ exprList size == 0 ifTrue:[ |
|
5864 |
"/ ^ expr. |
|
5865 |
"/ ]. |
|
5866 |
"/ exprList keysAndValuesDo:[:idx :e | |
|
5867 |
"/ expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode]) |
|
5868 |
"/ receiver:expr |
|
5869 |
"/ selector:#at:put: |
|
5870 |
"/ arg1:(ConstantNode type:#Integer value:idx) |
|
5871 |
"/ arg2:e |
|
5872 |
"/ fold:false. |
|
5873 |
"/ ]. |
|
5874 |
"/ expr := CascadeNode |
|
5875 |
"/ receiver:expr |
|
5876 |
"/ selector:#yourself. |
|
5877 |
"/ ^ expr |
|
5878 |
! |
|
5879 |
||
5880 |
primary_expression |
|
5881 |
"parse a parentized expression primary; return a node-tree, or raise an Error." |
|
5882 |
||
5883 |
|pos val eMsg| |
|
5884 |
||
5885 |
pos := tokenPosition. |
|
5886 |
||
5887 |
self nextToken. |
|
5888 |
val := self expression. |
|
5889 |
(val == #Error) ifTrue:[^ #Error]. |
|
5890 |
(tokenType ~~ $) ) ifTrue:[ |
|
5891 |
tokenType isCharacter ifTrue:[ |
|
5892 |
eMsg := 'missing '')'' (i.e. ''' , tokenType asString , ''' unexpected)'. |
|
5893 |
] ifFalse:[ |
|
5894 |
eMsg := 'missing '')'''. |
|
5895 |
]. |
|
5896 |
self syntaxError:eMsg withCRs position:pos to:tokenPosition. |
|
5897 |
^ #Error |
|
5898 |
]. |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5899 |
self markParenthesisAt:tokenPosition. |
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
5900 |
parenthesisLevel := parenthesisLevel - 1. |
1227 | 5901 |
self nextToken. |
5902 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
5903 |
^ #Error |
|
5904 |
]. |
|
5905 |
val parenthized:true. |
|
5906 |
^ val |
|
5907 |
! |
|
5908 |
||
5909 |
primary_false |
|
5910 |
"parse a false primary; return a node-tree, or raise an Error." |
|
5911 |
||
5912 |
|pos| |
|
5913 |
||
5914 |
pos := tokenPosition. |
|
5915 |
||
5916 |
self nextToken. |
|
5917 |
(self noAssignmentAllowed:'assignment to ''false''' at:pos) ifFalse:[ |
|
5918 |
^ #Error |
|
5919 |
]. |
|
5920 |
self markBooleanConstantFrom:pos to:pos+4. |
|
5921 |
^ ConstantNode type:#False value:false |
|
5922 |
! |
|
5923 |
||
5924 |
primary_here |
|
5925 |
"parse a here primary; return a node-tree, nil or #Error." |
|
5926 |
||
5927 |
|pos| |
|
5928 |
||
5929 |
pos := tokenPosition. |
|
5930 |
||
5931 |
self nextToken. |
|
5932 |
(self noAssignmentAllowed:'assignment to pseudo variable ''here''' at:pos) ifFalse:[ |
|
5933 |
^ #Error |
|
5934 |
]. |
|
5935 |
classToCompileFor isNil ifTrue:[ |
|
5936 |
self warning:'in which class are you ?' position:pos to:(pos + 3). |
|
5937 |
]. |
|
5938 |
self markSelfFrom:pos to:pos+3. |
|
5939 |
^ SuperNode value:selfValue inClass:classToCompileFor here:true |
|
5940 |
! |
|
5941 |
||
5942 |
primary_identifier |
|
1638 | 5943 |
"parse a primary; return a node-tree, or raise an Error." |
1227 | 5944 |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5945 |
|pos1 pos2 expr varName rawName var globlName nameSpace nameSpaceGlobal |
1551 | 5946 |
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
|
5947 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5948 |
pos1 := tokenPosition. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5949 |
pos2 := tokenPosition + tokenName size - 1. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5950 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5951 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5952 |
|
1440 | 5953 |
(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
|
5954 |
and:[currentBlock isNil |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5955 |
and:[(requestor askFor:#isWorkspace) |
1359 | 5956 |
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
|
5957 |
var := self variableOrError:varName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5958 |
self nextToken. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5959 |
(var == #Error) ifTrue:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5960 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
1359 | 5961 |
autoHow == #workspace ifTrue:[ |
5962 |
holder := Workspace addWorkspaceVariable:varName. |
|
5963 |
var := VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
5964 |
] ifFalse:[ |
|
5965 |
holder := self addDoItTemporary:varName. |
|
5966 |
var := VariableNode type:#DoItTemporary holder:holder name:varName |
|
5967 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5968 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5969 |
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
|
5970 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5971 |
] |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5972 |
] ifFalse:[ |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5973 |
var := self variable. |
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 |
]. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5976 |
|
1227 | 5977 |
"/ errorFlag == true ifTrue:[self halt]. |
5978 |
(var == #Error) ifTrue:[ |
|
5979 |
errorFlag := true |
|
5980 |
]. |
|
5981 |
||
5982 |
(tokenType == #'::') ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5983 |
globlName := rawName := varName. |
1227 | 5984 |
|
5985 |
"is it in a namespace ?" |
|
5986 |
nameSpace := self findNameSpaceWith:globlName. |
|
5987 |
nameSpace notNil ifTrue:[ |
|
5988 |
globlName := nameSpace name , '::' , globlName |
|
5989 |
]. |
|
5990 |
||
5991 |
[tokenType == #'::'] whileTrue:[ |
|
5992 |
nameSpace := globlName. |
|
5993 |
||
5994 |
self nextToken. |
|
5995 |
(tokenType == #Identifier) ifTrue:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
5996 |
self warnSTXNameSpaceUseAt:pos1. |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5997 |
varName := tokenName. |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5998 |
|
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
5999 |
globlName := (nameSpace , '::' , varName). |
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6000 |
rawName := (rawName , '::' , varName). |
1227 | 6001 |
|
6002 |
nameSpaceGlobal := Smalltalk at:nameSpace asSymbol ifAbsent:nil. |
|
6003 |
nameSpaceGlobal isNil ifTrue:[ |
|
6004 |
warnedUnknownNamespaces isNil ifTrue:[ |
|
6005 |
warnedUnknownNamespaces := Set new. |
|
6006 |
]. |
|
6007 |
(warnedUnknownNamespaces includes:nameSpace) ifFalse:[ |
|
6008 |
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
|
6009 |
position:pos1 to:tokenPosition-1. |
1227 | 6010 |
"/ self parseError:('unknown nameSpace: ', nameSpace) position:pos to:tokenPosition-1. |
6011 |
warnedUnknownNamespaces add:nameSpace. |
|
6012 |
] |
|
6013 |
] ifFalse:[ |
|
6014 |
nameSpaceGlobal isNameSpace ifTrue:[ |
|
6015 |
"/ for now: only Smalltalk is allowed |
|
6016 |
nameSpaceGlobal ~~ Smalltalk ifTrue:[ |
|
6017 |
"/ self parseError:('(currently) the only valid nameSpace is `Smalltalk''') position:pos to:tokenPosition-1. |
|
6018 |
] ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6019 |
globlName := varName |
1227 | 6020 |
]. |
6021 |
] ifFalse:[ |
|
6022 |
nameSpaceGlobal isBehavior ifFalse:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6023 |
self parseError:('invalid nameSpace: ' , nameSpace) position:pos1 to:tokenPosition-1. |
1227 | 6024 |
] ifTrue:[ |
1391 | 6025 |
nameSpaceGlobal isLoaded ifTrue:[ |
6026 |
(nameSpaceGlobal privateClassesAt:varName asSymbol) isNil ifTrue:[ |
|
1570 | 6027 |
(Smalltalk at:rawName asSymbol) notNil ifTrue:[ |
6028 |
self warning:('Possible name clash (global: ' , rawName , ' vs. private: ' , (nameSpace , '::', varName) , ') - assume globl.') |
|
6029 |
position:pos1 to:tokenPosition-1. |
|
6030 |
globlName := rawName asSymbol. |
|
6031 |
] ifFalse:[ |
|
6032 |
self warning:('no private class: ' , varName , ' in class: ' , nameSpace) |
|
6033 |
position:pos1 to:tokenPosition-1. |
|
1391 | 6034 |
"/ self parseError:('no private class: ' , name , ' in class: ' , nameSpace) position:pos to:tokenPosition-1. |
1570 | 6035 |
] |
1391 | 6036 |
] |
1227 | 6037 |
] |
6038 |
] |
|
6039 |
]. |
|
6040 |
]. |
|
6041 |
self nextToken. |
|
6042 |
]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6043 |
var := VariableNode globalNamed:globlName. |
1227 | 6044 |
parseForCode ifFalse:[self rememberGlobalUsed:globlName]. |
6045 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6046 |
self markVariable:var from:pos1 to:pos1 + rawName size - 1. |
1227 | 6047 |
]. |
6048 |
||
6049 |
var == #Error ifTrue:[ |
|
6050 |
^ #Error |
|
6051 |
]. |
|
6052 |
||
6053 |
errorFlag ~~ true ifTrue:[ |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6054 |
self markVariable:var from:pos1 to:pos1 + varName size - 1. |
1227 | 6055 |
]. |
6056 |
(ignoreErrors or:[ignoreWarnings or:[parseForCode not]]) ifTrue:[ |
|
6057 |
errorFlag := false. |
|
6058 |
]. |
|
6059 |
||
6060 |
((tokenType ~~ $_) and:[tokenType ~~ #':=']) ifTrue:[ |
|
6061 |
parseForCode ifFalse:[ |
|
6062 |
var isInstanceVariable ifTrue:[ self rememberInstVarRead:var name]. |
|
6063 |
var isClassVariable ifTrue:[ self rememberClassVarRead:var name]. |
|
6064 |
]. |
|
6065 |
^ var |
|
6066 |
]. |
|
6067 |
||
1551 | 6068 |
"/ assignment... |
6069 |
||
1227 | 6070 |
"/ careful: it could already be an implicit self send |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6071 |
parserFlags implicitSelfSends ifTrue:[ |
1227 | 6072 |
var isMessage ifTrue:[ |
6073 |
self nextToken. |
|
6074 |
expr := self expression. |
|
6075 |
self isSyntaxHighlighter ifFalse:[ |
|
6076 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
6077 |
]. |
|
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6078 |
^ MessageNode receiver:(self selfNode) selector:('__' , varName , ':') asSymbol arg:expr. |
1227 | 6079 |
]. |
6080 |
]. |
|
6081 |
||
1551 | 6082 |
assignmentAllowed := true. |
6083 |
||
1227 | 6084 |
(var ~~ #Error) ifTrue:[ |
6085 |
t := var type. |
|
6086 |
t == #MethodVariable ifTrue:[ |
|
6087 |
modifiedLocalVars isNil ifTrue:[ |
|
6088 |
modifiedLocalVars := Set new. |
|
6089 |
]. |
|
6090 |
modifiedLocalVars add:var name. |
|
1551 | 6091 |
] ifFalse:[ (t == #InstanceVariable) ifTrue:[ |
6092 |
varName := self classesInstVarNames at:(var index). |
|
6093 |
||
6094 |
"/ ca once did this to "name" and wondered what happened to his class ... |
|
6095 |
"/ (not really a beginners bug, but may happen as a typo or missing local variable; |
|
6096 |
"/ and is hard to track down later) |
|
6097 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6098 |
parserFlags warnCommonMistakes ifTrue:[ |
1551 | 6099 |
classToCompileFor isMeta ifTrue:[ |
6100 |
(classToCompileFor isSubclassOf:Class) ifTrue:[ |
|
6101 |
(Class allInstVarNames includes:(var name)) ifTrue:[ |
|
6102 |
self warning:'assignment to a classInstanceVariable\(see hierarchy of "Class")' withCRs position:pos1 to:pos2. |
|
6103 |
] |
|
6104 |
] |
|
6105 |
] |
|
6106 |
]. |
|
6107 |
parseForCode ifFalse:[ |
|
6108 |
modifiedInstVars isNil ifTrue:[ |
|
6109 |
modifiedInstVars := Set new |
|
6110 |
]. |
|
6111 |
modifiedInstVars add:varName |
|
6112 |
] |
|
6113 |
] ifFalse:[ (t == #ClassVariable) ifTrue:[ |
|
6114 |
varName := var name. |
|
6115 |
varName := varName copyFrom:((varName indexOf:$:) + 1). |
|
6116 |
parseForCode ifFalse:[ |
|
6117 |
modifiedClassVars isNil ifTrue:[ |
|
6118 |
modifiedClassVars := Set new |
|
6119 |
]. |
|
6120 |
modifiedClassVars add:varName |
|
6121 |
] |
|
6122 |
] ifFalse:[ (t == #GlobalVariable) ifTrue:[ |
|
6123 |
(cls := Smalltalk classNamed:var name) notNil ifTrue:[ |
|
6124 |
cls name = var name ifTrue:[ |
|
6125 |
self warning:'assignment to global which refers to a class' position:pos1 to:pos2. |
|
6126 |
] |
|
6127 |
]. |
|
6128 |
parseForCode ifFalse:[ |
|
6129 |
modifiedGlobals isNil ifTrue:[ |
|
6130 |
modifiedGlobals := Set new |
|
6131 |
]. |
|
6132 |
modifiedGlobals add:var name |
|
6133 |
] |
|
6134 |
] ifFalse:[ |
|
6135 |
(t == #PrivateClass) ifTrue:[ |
|
6136 |
assignmentAllowed := false. |
|
6137 |
self parseError:'assignment to private class' position:pos1 to:pos2. |
|
6138 |
] ifFalse:[ (t == #MethodArg) ifTrue:[ |
|
6139 |
assignmentAllowed := false. |
|
6140 |
self parseError:'assignment to method argument' position:pos1 to:pos2. |
|
6141 |
] ifFalse:[ (t == #BlockArg) ifTrue:[ |
|
6142 |
assignmentAllowed := false. |
|
6143 |
self parseError:'assignment to block argument' position:pos1 to:pos2. |
|
6144 |
] ifFalse:[ (t == #PoolVariable) ifTrue:[ |
|
6145 |
self isDoIt ifTrue:[ |
|
6146 |
self warning:'assignment to pool variable' position:pos1 to:pos2. |
|
6147 |
assignmentAllowed := true. |
|
6148 |
] ifFalse:[ |
|
6149 |
self parseError:'assignment to pool variable' position:pos1 to:pos2. |
|
6150 |
] |
|
6151 |
]]]]]]] |
|
1227 | 6152 |
]. |
6153 |
]. |
|
6154 |
||
6155 |
lnr := tokenLineNr. |
|
6156 |
||
6157 |
self nextToken. |
|
6158 |
pos2 := tokenPosition. |
|
6159 |
expr := self expression. |
|
6160 |
||
6161 |
"/ a typical beginner error: |
|
6162 |
"/ expr ifTrue:[ |
|
6163 |
"/ var := super |
|
6164 |
"/ ] ifFalse:[ |
|
6165 |
"/ var := something-else |
|
6166 |
"/ ]. |
|
6167 |
"/ var messageSend |
|
6168 |
"/ |
|
6169 |
"/ does not what a beginner might think. |
|
6170 |
||
6171 |
self isSyntaxHighlighter ifTrue:[ |
|
6172 |
(expr == #Error) ifTrue:[^ #Error]. |
|
6173 |
] ifFalse:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6174 |
parserFlags warnCommonMistakes ifTrue:[ |
1227 | 6175 |
(expr ~~ #Error and:[expr isSuper]) ifTrue:[ |
1551 | 6176 |
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 | 6177 |
]. |
6178 |
]. |
|
6179 |
||
6180 |
(errorFlag or:[expr == #Error]) ifTrue:[^ #Error]. |
|
6181 |
expr isVariable ifTrue:[ |
|
6182 |
expr name = var name ifTrue:[ |
|
1551 | 6183 |
self warning:('useless assignment to "' , var name, '"' ) position:pos1 to:pos2-1. |
1227 | 6184 |
]. |
6185 |
]. |
|
6186 |
]. |
|
1551 | 6187 |
assignmentAllowed ifTrue:[ |
6188 |
node := AssignmentNode variable:var expression:expr. |
|
6189 |
(lineNumberInfo == #full) ifTrue:[node lineNumber:lnr]. |
|
6190 |
] ifFalse:[ |
|
6191 |
self parseError:('assignment to "' , var name, '" suppressed' ) position:pos1 to:pos2-1. |
|
6192 |
node := expr. |
|
6193 |
]. |
|
1227 | 6194 |
^ node |
6195 |
! |
|
6196 |
||
1295 | 6197 |
primary_lazyValue |
6198 |
|pos block expr| |
|
6199 |
||
6200 |
pos := tokenPosition. |
|
6201 |
||
6202 |
(tokenType == $: ) ifTrue:[ |
|
6203 |
self parseError:'lazyValues have no arguments' position:tokenPosition. |
|
6204 |
^ #Error |
|
6205 |
]. |
|
6206 |
||
6207 |
block := self blockBody:#(). |
|
6208 |
self nextToken. |
|
6209 |
||
6210 |
expr := MessageNode |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6211 |
receiver:(VariableNode globalNamed:#LazyValue) |
1295 | 6212 |
selector:#'block:' |
6213 |
arg:block. |
|
6214 |
^ expr |
|
6215 |
! |
|
6216 |
||
1227 | 6217 |
primary_nil |
6218 |
"parse a nil primary; return a node-tree, nil or #Error." |
|
6219 |
||
6220 |
|pos| |
|
6221 |
||
6222 |
pos := tokenPosition. |
|
6223 |
||
6224 |
self nextToken. |
|
6225 |
(self noAssignmentAllowed:'assignment to ''nil''' at:pos) ifFalse:[ |
|
6226 |
^ #Error |
|
6227 |
]. |
|
6228 |
"/ self markConstantFrom:pos to:pos+2. |
|
6229 |
nilNode isNil ifTrue:[ |
|
6230 |
nilNode := ConstantNode type:#Nil value:nil |
|
6231 |
]. |
|
6232 |
^ nilNode |
|
6233 |
! |
|
6234 |
||
6235 |
primary_self |
|
6236 |
"parse a self primary; return a node-tree, nil or #Error." |
|
6237 |
||
6238 |
|pos| |
|
6239 |
||
6240 |
pos := tokenPosition. |
|
6241 |
||
6242 |
self nextToken. |
|
6243 |
(self noAssignmentAllowed:'assignment to pseudo variable ''self''' at:pos) ifFalse:[ |
|
6244 |
^ ParseError raise |
|
6245 |
]. |
|
6246 |
self markSelfFrom:pos to:pos+3. |
|
1262 | 6247 |
^ self selfNode |
1227 | 6248 |
! |
6249 |
||
6250 |
primary_simpleLiteral |
|
6251 |
"parse a simple literal primary; return a node-tree, or raise an Error." |
|
6252 |
||
6253 |
|pos val| |
|
6254 |
||
6255 |
pos := tokenPosition. |
|
6256 |
||
6257 |
"/ |
|
6258 |
"/ ImmutableStrings are experimental |
|
6259 |
"/ |
|
6260 |
((tokenType == #String) |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6261 |
and:[(parserFlags stringsAreImmutable)]) ifTrue:[ |
1615 | 6262 |
token := tokenValue := self makeImmutableString:tokenValue. |
1227 | 6263 |
]. |
6264 |
(tokenType == #Symbol) ifTrue:[ |
|
6265 |
parseForCode ifFalse:[ |
|
6266 |
self rememberSymbolUsed:tokenValue |
|
6267 |
]. |
|
6268 |
]. |
|
6269 |
val := ConstantNode type:tokenType value:tokenValue. |
|
6270 |
||
6271 |
tokenValue isSymbol ifTrue:[ |
|
6272 |
self markSymbolFrom:tokenPosition to:tokenPosition+tokenValue size-1. |
|
6273 |
]. |
|
6274 |
||
6275 |
self nextToken. |
|
6276 |
(self noAssignmentAllowed:'assignment to a constant' at:pos) ifFalse:[ |
|
6277 |
^ #Error |
|
6278 |
]. |
|
6279 |
^ val |
|
6280 |
! |
|
6281 |
||
6282 |
primary_squeakComputedArray |
|
1274 | 6283 |
"parse a squeak computed array literal; return a node-tree, or raise an Error. |
6284 |
In squeak, these are written as: { expr1 . expr2 . ... exprN ) |
|
6285 |
and create a literalArray containing the exprI values. |
|
6286 |
WARNING: this is only supported to allow filing in squeak code. |
|
6287 |
since stc cannot handle this (at the moment), you should rewrite the code |
|
6288 |
if you ever plan to stc-compile it into a shared library" |
|
6289 |
||
1227 | 6290 |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6291 |
|pos exprList| |
1227 | 6292 |
|
6293 |
pos := tokenPosition. |
|
6294 |
||
6295 |
self nextToken. |
|
6296 |
exprList := self squeakComputedArray. |
|
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6297 |
(exprList == #Error) ifTrue:[ ^ #Error ]. |
1227 | 6298 |
|
6299 |
tokenType ~~ $} ifTrue:[ |
|
6300 |
self parseError:'''}'' expected' position:tokenPosition. |
|
6301 |
^ #Error |
|
6302 |
]. |
|
6303 |
self nextToken. |
|
6304 |
(self noAssignmentAllowed:'invalid assignment' at:pos) ifFalse:[ |
|
6305 |
^ #Error |
|
6306 |
]. |
|
6307 |
||
6308 |
"/ make it an array creation expression ... |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6309 |
^ self genMakeArrayWith:exprList |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6310 |
|
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6311 |
" |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6312 |
Compiler allowSqueakExtensions:true. |
1299 | 6313 |
" |
6314 |
||
6315 |
" |
|
6316 |
{ 1@2. 10 factorial. Date today }. |
|
6317 |
" |
|
6318 |
||
6319 |
" |
|
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6320 |
Compiler allowSqueakExtensions:false. |
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6321 |
" |
1227 | 6322 |
! |
6323 |
||
6324 |
primary_super |
|
6325 |
"parse a super primary; return a node-tree, nil or #Error." |
|
6326 |
||
6327 |
|pos| |
|
6328 |
||
6329 |
pos := tokenPosition. |
|
6330 |
||
6331 |
usesSuper := true. |
|
6332 |
self nextToken. |
|
6333 |
(self noAssignmentAllowed:'assignment to pseudo variable ''super''' at:pos) ifFalse:[ |
|
6334 |
^ #Error |
|
6335 |
]. |
|
6336 |
(classToCompileFor isNil or:[classToCompileFor superclass isNil]) ifTrue:[ |
|
6337 |
self warning:'superclass is (currently ?) nil' position:pos to:(pos + 4). |
|
6338 |
]. |
|
6339 |
superNode isNil ifTrue:[ |
|
6340 |
superNode := SuperNode value:selfValue inClass:classToCompileFor |
|
6341 |
]. |
|
6342 |
self markSelfFrom:pos to:pos+4. |
|
6343 |
^ superNode |
|
6344 |
! |
|
6345 |
||
1262 | 6346 |
primary_thisContext |
6347 |
"parse a thisContext primary; return a node-tree, or raise an Error." |
|
6348 |
||
6349 |
|pos| |
|
6350 |
||
6351 |
pos := tokenPosition. |
|
6352 |
||
6353 |
self nextToken. |
|
6354 |
(self noAssignmentAllowed:'assignment to pseudo variable ''thisContext''' at:pos) ifFalse:[ |
|
6355 |
^ #Error |
|
6356 |
]. |
|
6357 |
self markIdentifierFrom:pos to:pos+10. |
|
6358 |
^ VariableNode type:#ThisContext context:contextToEvaluateIn. "/ often nil |
|
6359 |
! |
|
6360 |
||
1227 | 6361 |
primary_true |
6362 |
"parse a true primary; return a node-tree, or raise an Error." |
|
6363 |
||
6364 |
|pos| |
|
6365 |
||
6366 |
pos := tokenPosition. |
|
6367 |
||
6368 |
self nextToken. |
|
6369 |
(self noAssignmentAllowed:'assignment to ''true''' at:pos) ifFalse:[ |
|
6370 |
^ #Error |
|
6371 |
]. |
|
6372 |
self markBooleanConstantFrom:pos to:pos+3. |
|
6373 |
^ ConstantNode type:#True value:true |
|
6374 |
! |
|
6375 |
||
924 | 6376 |
qualifiedName |
6377 |
"a vw3.x (and later) feature: QualifiedName is #{ id ... id } |
|
6378 |
and mapped to a global variable here. |
|
6379 |
The initial #{ is supposed to be not yet skipped." |
|
6380 |
||
1436 | 6381 |
|elements elem pos1 nm| |
924 | 6382 |
|
6383 |
pos1 := tokenPosition. |
|
6384 |
self nextToken. |
|
6385 |
elements := OrderedCollection new. |
|
1436 | 6386 |
[ tokenType ~~ $} ] whileTrue:[ |
6387 |
(tokenType == #Identifier) ifFalse:[ |
|
6388 |
self syntaxError:'bad qualifiedName; Identifier expected' |
|
924 | 6389 |
position:pos1 to:tokenPosition |
6390 |
]. |
|
1436 | 6391 |
elem := tokenName. |
924 | 6392 |
elements add:elem. |
1028 | 6393 |
|
6394 |
self nextToken. |
|
1436 | 6395 |
tokenType = $} ifTrue:[ |
1028 | 6396 |
] ifFalse:[ |
1436 | 6397 |
tokenType == #'::' ifTrue:[ |
6398 |
"/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
6399 |
"/(which is a kludge) |
|
6400 |
self nextToken. |
|
6401 |
] ifFalse:[ |
|
1028 | 6402 |
self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
6403 |
position:pos1 to:tokenPosition. |
|
6404 |
]. |
|
6405 |
]. |
|
1436 | 6406 |
|
6407 |
"/ elem := self variable. |
|
6408 |
"/ (elem == #Error) ifTrue:[ |
|
6409 |
"/ (tokenType == #EOF) ifTrue:[ |
|
6410 |
"/ self syntaxError:'unterminated qualifiedName; ''}'' expected' |
|
6411 |
"/ position:pos1 to:tokenPosition |
|
6412 |
"/ ]. |
|
6413 |
"/ ^ #Error |
|
6414 |
"/ ]. |
|
6415 |
"/ errorFlag := false. |
|
6416 |
"/ (elem isVariable and:[elem isGlobal]) ifFalse:[ |
|
6417 |
"/ self warning:'elements of a qualifiedName should be globalIdentifiers' |
|
6418 |
"/ position:pos1 to:tokenPosition |
|
6419 |
"/ ]. |
|
6420 |
"/ elements add:elem. |
|
6421 |
"/ |
|
6422 |
"/ self nextToken. |
|
6423 |
"/ tokenType == #'::' ifTrue:[ |
|
6424 |
"/ "/ notice that Foo.Bar has already been scanned as Foo::Bar |
|
6425 |
"/ "/(which is a kludge) |
|
6426 |
"/ self nextToken. |
|
6427 |
"/ ] ifFalse:[ |
|
6428 |
"/ tokenType ~~ $} ifTrue:[ |
|
6429 |
"/ self syntaxError:'bad qualifiedName syntax; ''.'' or ''}'' expected' |
|
6430 |
"/ position:pos1 to:tokenPosition. |
|
6431 |
"/ ^ #Error |
|
6432 |
"/ ]. |
|
6433 |
"/ ]. |
|
6434 |
]. |
|
1437 | 6435 |
nm := (elements asStringWith:'::') asSymbol. |
1436 | 6436 |
^ ConstantNode type:#Symbol value:nm |
6437 |
||
6438 |
"/ elements size > 1 ifTrue:[ |
|
6439 |
"/ self syntaxError:'Sorry: qualified names are not yet implemented.'. |
|
6440 |
"/ ]. |
|
6441 |
"/ ^ elements first. |
|
924 | 6442 |
|
6443 |
"Modified: / 14.4.1998 / 17:03:29 / cg" |
|
6444 |
! |
|
6445 |
||
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6446 |
squeakComputedArray |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6447 |
|expressions elem pos1| |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6448 |
|
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6449 |
tokenType == $} ifTrue:[ |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6450 |
^ #() |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6451 |
]. |
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6452 |
|
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6453 |
pos1 := tokenPosition. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6454 |
expressions := OrderedCollection new:20. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6455 |
[true] whileTrue:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6456 |
elem := self expression. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6457 |
(elem == #Error) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6458 |
(tokenType == #EOF) ifTrue:[ |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6459 |
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
|
6460 |
position:pos1 to:tokenPosition |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6461 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6462 |
^ #Error |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6463 |
]. |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6464 |
expressions add:elem. |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6465 |
tokenType == $. ifFalse:[ |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6466 |
^ expressions |
1277
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6467 |
]. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6468 |
self nextToken. |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6469 |
tokenType == $} ifTrue:[ |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6470 |
^ expressions |
f7c21ebe1520
squeak computed arrays again
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
6471 |
]. |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6472 |
]. |
1275
91a0eead9e0e
oops - stc bug workaround - scans keyword selectors
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
6473 |
"/ not reached |
894
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6474 |
! |
943b6d0d26b3
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
6475 |
|
141 | 6476 |
unaryExpression |
6477 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6478 |
||
1328 | 6479 |
|receiver| |
141 | 6480 |
|
1405
f888caa1f2d8
refactored primitive-decl parsing;
Claus Gittinger <cg@exept.de>
parents:
1400
diff
changeset
|
6481 |
receiver := self arrayIndexingExpression. |
141 | 6482 |
(receiver == #Error) ifTrue:[^ #Error]. |
1328 | 6483 |
^ self unaryExpressionFor:receiver |
6484 |
! |
|
6485 |
||
6486 |
unaryExpressionFor:receiverArg |
|
6487 |
"parse a unary-expression; return a node-tree, nil or #Error" |
|
6488 |
||
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6489 |
|receiver expr sel pos pos2 note lNr arguments| |
1328 | 6490 |
|
6491 |
receiver := receiverArg. |
|
6492 |
(receiver == #Error) ifTrue:[^ #Error]. |
|
1306
90f45715a0d7
optionally allow nil, true, false etc. as unary selector
Claus Gittinger <cg@exept.de>
parents:
1304
diff
changeset
|
6493 |
[ self isValidUnarySelector:tokenType ] whileTrue:[ |
663 | 6494 |
pos := tokenPosition. |
6495 |
pos2 := pos + tokenName size - 1. |
|
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6496 |
lNr := tokenLineNr. |
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
6497 |
sel := tokenName. |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6498 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6499 |
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
|
6500 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6501 |
self nextToken. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6502 |
tokenType == $( ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6503 |
parserFlags allowSqueakExtensions == true ifTrue:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6504 |
"/ croquet/squeak extension - c/java-style arguments |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6505 |
arguments := self functionCallArgList. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6506 |
"/ synthetic selector: foo[:[with:[with:[...]]]] |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6507 |
arguments notEmpty ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6508 |
sel := sel , ':'. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6509 |
arguments size - 1 timesRepeat:[ sel := sel , 'with:' ]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6510 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6511 |
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
|
6512 |
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
|
6513 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6514 |
self parseError:(expr errorString) position:pos to:pos2. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6515 |
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
|
6516 |
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
|
6517 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6518 |
expr lineNumber:lNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6519 |
note := self plausibilityCheck:receiver. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6520 |
note notNil ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6521 |
self warning:note position:pos to:pos2 |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6522 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6523 |
parseForCode ifFalse:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6524 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6525 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6526 |
^ expr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6527 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6528 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6529 |
|
1022 | 6530 |
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
|
6531 |
expr := UnaryNode receiver:receiver selector:sel fold:foldConstants. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6532 |
expr isErrorNode ifTrue:[ |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6533 |
self parseError:(expr errorString) position:pos to:pos2. |
663 | 6534 |
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
|
6535 |
expr := UnaryNode receiver:receiver selector:sel fold:nil. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6536 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6537 |
expr lineNumber:lNr. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6538 |
|
1193 | 6539 |
note := self plausibilityCheck:receiver. |
6540 |
note notNil ifTrue:[ |
|
6541 |
self warning:note position:pos to:pos2 |
|
6542 |
]. |
|
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
6543 |
parseForCode ifFalse:[ |
1531
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6544 |
self rememberSelectorUsed:sel receiver:receiver |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6545 |
]. |
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6546 |
|
47f714bc1981
squeak extension: c/java style arguments
Claus Gittinger <cg@exept.de>
parents:
1525
diff
changeset
|
6547 |
receiver := expr. "/ for next message |
141 | 6548 |
]. |
6549 |
^ receiver |
|
210
b22f4472833b
allow enable/disable of constantFolding
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
6550 |
|
1032
f97183aecb4e
oops - super-send-doIt in a debugger used receivers class
Claus Gittinger <cg@exept.de>
parents:
1028
diff
changeset
|
6551 |
"Modified: / 6.2.2000 / 14:54:20 / cg" |
141 | 6552 |
! |
6553 |
||
6554 |
variable |
|
1028 | 6555 |
"parse a simple (i.e. non-namespace-access path) variable; |
6556 |
return a node-tree, nil or #Error. |
|
6557 |
Does not advance to next token. |
|
6558 |
If undefined, notify error and correct if user wants to" |
|
141 | 6559 |
|
864 | 6560 |
|v pos1 pos2| |
687 | 6561 |
|
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6562 |
v := self variableOrError:tokenName. |
664 | 6563 |
(v ~~ #Error) ifTrue:[ |
663 | 6564 |
(v isMemberOf:VariableNode) ifTrue:[ |
687 | 6565 |
self markVariable:v. |
663 | 6566 |
]. |
6567 |
^ v |
|
6568 |
]. |
|
865 | 6569 |
|
687 | 6570 |
pos1 := tokenPosition. |
864 | 6571 |
pos2 := pos1+tokenName size-1. |
6572 |
self markUnknownIdentifierFrom:pos1 to:pos2. |
|
664 | 6573 |
|
1089 | 6574 |
parseForCode == true ifTrue:[ |
1337
b558251f5e77
function call is now compiled into an #eval: message
Claus Gittinger <cg@exept.de>
parents:
1336
diff
changeset
|
6575 |
v := self correctVariable:tokenName atPosition:pos1 to:pos2. |
1089 | 6576 |
(v ~~ #Error) ifTrue:[^ v]. |
6577 |
]. |
|
6578 |
||
1564
fa3538426964
empty expression -> nil handling
Claus Gittinger <cg@exept.de>
parents:
1562
diff
changeset
|
6579 |
self errorFlag:true. |
664 | 6580 |
|
141 | 6581 |
parseForCode ifFalse:[ |
1304
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
6582 |
self rememberGlobalUsed:(Smalltalk undeclaredPrefix) , tokenName. |
ade15708e7c1
undeclared variable handling was broken (to allow reference search)
penk
parents:
1301
diff
changeset
|
6583 |
self rememberGlobalUsed:tokenName. |
141 | 6584 |
] ifTrue:[ |
663 | 6585 |
tokenName first isLowercase ifTrue:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
6586 |
parserFlags implicitSelfSends ifTrue:[ |
1271
47c443af9bb9
better code for squeak computed array;
Claus Gittinger <cg@exept.de>
parents:
1262
diff
changeset
|
6587 |
^ UnaryNode receiver:(self selfNode) selector:('__' , tokenName) asSymbol. |
663 | 6588 |
]. |
6589 |
^ #Error |
|
6590 |
] |
|
141 | 6591 |
]. |
865 | 6592 |
|
869 | 6593 |
"/ self markGlobalIdentifierFrom:pos1 to:pos2. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6594 |
^ VariableNode globalNamed:tokenName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6595 |
|
687 | 6596 |
"Modified: / 16.4.1998 / 18:46:45 / cg" |
141 | 6597 |
! |
6598 |
||
0 | 6599 |
variableOrError |
1028 | 6600 |
"parse a simple (i.e. non-namespace-access path) variable; |
6601 |
return a node-tree, nil or #Error. |
|
6602 |
Does not advance to next token." |
|
0 | 6603 |
|
21 | 6604 |
^ self variableOrError:tokenName |
6605 |
! |
|
6606 |
||
6607 |
variableOrError:varName |
|
1028 | 6608 |
"parse a simple (i.e. non-namespace-access path) variable; |
6609 |
return a node-tree, nil or #Error. |
|
6610 |
Does not advance to next token." |
|
21 | 6611 |
|
1551 | 6612 |
|varIndex aClass searchBlock args vars sharedPools |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6613 |
tokenSymbol space classVarIndex holder node| |
0 | 6614 |
|
6615 |
"is it a block-arg or block-var ?" |
|
6616 |
searchBlock := currentBlock. |
|
6617 |
[searchBlock notNil] whileTrue:[ |
|
628 | 6618 |
vars := searchBlock variables. |
6619 |
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
|
6620 |
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
|
6621 |
varIndex ~~ 0 ifTrue:[ |
628 | 6622 |
^ VariableNode type:#BlockVariable |
6623 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6624 |
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
|
6625 |
index:varIndex |
628 | 6626 |
block:searchBlock |
6627 |
from:currentBlock |
|
6628 |
]. |
|
6629 |
]. |
|
6630 |
||
6631 |
args := searchBlock arguments. |
|
6632 |
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
|
6633 |
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
|
6634 |
varIndex ~~ 0 ifTrue:[ |
628 | 6635 |
^ VariableNode type:#BlockArg |
6636 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6637 |
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
|
6638 |
index:varIndex |
628 | 6639 |
block:searchBlock |
6640 |
from:currentBlock |
|
6641 |
]. |
|
6642 |
||
6643 |
]. |
|
6644 |
||
6645 |
searchBlock := searchBlock home |
|
0 | 6646 |
]. |
6647 |
||
6648 |
"is it a method-variable ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6649 |
(node := self nodeForMethodVariable:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6650 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6651 |
^ node |
0 | 6652 |
]. |
6653 |
||
6654 |
"is it a method-argument ?" |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6655 |
(node := self nodeForMethodArg:varName) notNil |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6656 |
ifTrue:[ |
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6657 |
^ node |
0 | 6658 |
]. |
6659 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6660 |
contextToEvaluateIn notNil ifTrue:[ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6661 |
|con varNames| |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6662 |
|
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6663 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6664 |
"/ 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
|
6665 |
"/ |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6666 |
con := contextToEvaluateIn. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6667 |
[con notNil] whileTrue:[ |
1446
ac887ee4881a
** changed access to blockContexts source, args and vars -- please watch out
penk
parents:
1445
diff
changeset
|
6668 |
varNames := con argAndVarNames. |
690 | 6669 |
varNames size > 0 ifTrue:[ |
6670 |
varIndex := varNames lastIndexOf:varName. |
|
6671 |
varIndex ~~ 0 ifTrue:[ |
|
6672 |
^ VariableNode type:#ContextVariable |
|
6673 |
name:varName |
|
6674 |
context:con |
|
6675 |
index:varIndex |
|
6676 |
]. |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6677 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6678 |
con := con home. |
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 |
]. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6681 |
|
0 | 6682 |
classToCompileFor notNil ifTrue:[ |
628 | 6683 |
"is it an instance-variable ?" |
6684 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6685 |
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
|
6686 |
varIndex ~~ 0 ifTrue:[ |
628 | 6687 |
classToCompileFor isMeta ifTrue:[ |
6688 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
6689 |
classVarIndex ~~ 0 ifTrue:[ |
|
6690 |
"/ give a warning - that maybe a common error |
|
825 | 6691 |
alreadyWarnedClassInstVarRefs isNil ifTrue:[ |
6692 |
alreadyWarnedClassInstVarRefs := Set new |
|
6693 |
]. |
|
6694 |
(alreadyWarnedClassInstVarRefs includes:varName) ifFalse:[ |
|
6695 |
self warning:('there is both a class variable and a class-instance variable named ''' , varName , '''.\\Refering to the class-instance variable here.') withCRs. |
|
6696 |
alreadyWarnedClassInstVarRefs add:varName. |
|
6697 |
]. |
|
628 | 6698 |
]. |
6699 |
]. |
|
6700 |
parseForCode ifFalse:[self rememberInstVarUsed:varName]. |
|
6701 |
^ VariableNode type:#InstanceVariable |
|
6702 |
name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6703 |
index:varIndex |
628 | 6704 |
selfValue:selfValue |
6705 |
]. |
|
6706 |
||
6707 |
"/ see if there is a corresponding classVar (for the warning) |
|
6708 |
classVarIndex := (self classesClassVarNames) lastIndexOf:varName. |
|
6709 |
||
6710 |
"/ "is it a class-instance-variable ?" |
|
6711 |
"/ |
|
6712 |
"/ Notice: |
|
6713 |
"/ it is no longer allowed to fetch class-instance variables |
|
6714 |
"/ from instance methods ... |
|
6715 |
"/ (used to be in previous ST/X versions) |
|
6716 |
"/ |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6717 |
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
|
6718 |
varIndex ~~ 0 ifTrue:[ |
628 | 6719 |
aClass := self inWhichClassIsClassInstVar:varName. |
6720 |
aClass notNil ifTrue:[ |
|
6721 |
classToCompileFor isMeta ifFalse:[ |
|
6722 |
classVarIndex == 0 ifTrue:[ |
|
705
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6723 |
"/ there is no corresponding classVar; |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6724 |
"/ wants to access classInstVar ? |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6725 |
contextToEvaluateIn notNil ifTrue:[ |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6726 |
"/ allow it in a doIt ... |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6727 |
|
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6728 |
^ VariableNode type:#ClassInstanceVariable |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6729 |
name:varName |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6730 |
index:varIndex |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6731 |
selfClass:aClass |
e22927413fe5
allow access to class-instVars from doIts;
Claus Gittinger <cg@exept.de>
parents:
694
diff
changeset
|
6732 |
]. |
628 | 6733 |
self parseError:'access to class-inst-var from inst method is not allowed'. |
6734 |
^ #Error. |
|
6735 |
] ifFalse:[ |
|
6736 |
"/ give a warning - that maybe a common error |
|
738 | 6737 |
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 | 6738 |
] |
6739 |
]. |
|
6740 |
||
6741 |
"/ OLD CODE: |
|
6742 |
"/ 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
|
6743 |
"/ |
628 | 6744 |
"/ parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
6745 |
"/ ^ VariableNode type:#ClassInstanceVariable |
|
6746 |
"/ name:varName |
|
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6747 |
"/ index:varIndex |
628 | 6748 |
"/ selfClass:aClass |
6749 |
"/ ]. |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6750 |
] ifFalse:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6751 |
"/ self halt:'oops - should not happen'. |
628 | 6752 |
] |
6753 |
]. |
|
6754 |
||
6755 |
"is it a class-variable ?" |
|
6756 |
||
640
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6757 |
varIndex := classVarIndex. |
c3be1ba89df0
handle passed-in context (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
637
diff
changeset
|
6758 |
varIndex ~~ 0 ifTrue:[ |
628 | 6759 |
aClass := self inWhichClassIsClassVar:varName. |
6760 |
aClass notNil ifTrue:[ |
|
6761 |
parseForCode ifFalse:[self rememberClassVarUsed:varName]. |
|
6762 |
^ 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
|
6763 |
]. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
6764 |
"/ self halt:'oops - should not happen'. |
628 | 6765 |
]. |
6766 |
||
6767 |
"is it a private-class ?" |
|
6768 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
6769 |
aClass := self classToLookForClassVars. |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6770 |
aClass := aClass theNonMetaclass. |
628 | 6771 |
(aClass privateClassesAt:varName) notNil ifTrue:[ |
6772 |
parseForCode ifFalse:[self rememberGlobalUsed:(aClass name , '::' , varName)]. |
|
6773 |
^ VariableNode type:#PrivateClass class:aClass name:varName |
|
6774 |
]. |
|
1551 | 6775 |
|
6776 |
" is it a pool-variable ?" |
|
6777 |
sharedPools := classToCompileFor theNonMetaclass sharedPools. |
|
6778 |
sharedPools notNil ifTrue:[ |
|
6779 |
sharedPools do:[:eachPoolName | |
|
6780 |
|sharedPool| |
|
6781 |
||
6782 |
sharedPool := Smalltalk classNamed:eachPoolName. |
|
1556 | 6783 |
sharedPool isNil ifTrue:[ |
6784 |
self warning:('No such pool: ' , eachPoolName). |
|
6785 |
] ifFalse:[ |
|
6786 |
(sharedPool includesKey:varName) ifTrue:[ |
|
6787 |
parseForCode ifFalse:[self rememberGlobalUsed:(sharedPool name , ':' , varName)]. |
|
6788 |
^ VariableNode type:#PoolVariable class:sharedPool name:varName |
|
6789 |
]. |
|
1551 | 6790 |
]. |
6791 |
]. |
|
6792 |
]. |
|
418 | 6793 |
]. |
6794 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6795 |
"is it in a namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6796 |
space := self findNameSpaceWith:varName. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6797 |
space notNil ifTrue:[ |
628 | 6798 |
space ~~ Smalltalk ifTrue:[ |
6799 |
parseForCode ifFalse:[self rememberGlobalUsed:(space name , '::' , varName)]. |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
6800 |
space isNameSpace ifTrue:[ |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6801 |
^ VariableNode globalNamed:(space name , '::' , varName) |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6802 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6803 |
^ VariableNode type:#PrivateClass class:space name:varName |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6804 |
]. |
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6805 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6806 |
^ VariableNode globalNamed:varName |
454
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6807 |
]. |
00a079c9832f
handle uses: usedNameSpace info
Claus Gittinger <cg@exept.de>
parents:
451
diff
changeset
|
6808 |
|
0 | 6809 |
"is it a global-variable ?" |
63 | 6810 |
tokenSymbol := varName asSymbolIfInterned. |
6811 |
tokenSymbol notNil ifTrue:[ |
|
628 | 6812 |
(Smalltalk includesKey:tokenSymbol) ifTrue:[ |
6813 |
parseForCode ifFalse:[self rememberGlobalUsed:varName]. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
6814 |
^ VariableNode globalNamed:tokenSymbol |
628 | 6815 |
] |
0 | 6816 |
]. |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
6817 |
|
877 | 6818 |
"is it a workspace variable ?" |
6819 |
(requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
6820 |
"/ when parsing doits, this is done twice; |
|
6821 |
"/ first, for the parse, then as a block-code |
|
6822 |
"/ for the code. |
|
6823 |
"/ We only care for WorkspaceVars in doIts |
|
1440 | 6824 |
(self isDoIt) ifTrue:[ |
1295 | 6825 |
(Workspace notNil |
6826 |
and:[(holder := Workspace workspaceVariableAt:varName) notNil]) |
|
6827 |
ifTrue:[ |
|
6828 |
^ VariableNode type:#WorkspaceVariable holder:holder name:varName |
|
877 | 6829 |
] |
6830 |
] |
|
6831 |
]. |
|
1295 | 6832 |
"is it a doIt variable ?" |
6833 |
||
6834 |
"/ (requestor notNil and:[requestor isStream not]) ifTrue:[ |
|
6835 |
"/ when parsing doits, this is done twice; |
|
6836 |
"/ first, for the parse, then as a block-code |
|
6837 |
"/ for the code. |
|
6838 |
"/ We only care for WorkspaceVars in doIts |
|
6839 |
||
1440 | 6840 |
(self isDoIt) ifTrue:[ |
1295 | 6841 |
(doItTemporaries notNil |
6842 |
and:[(holder := doItTemporaries at:varName asSymbol ifAbsent:nil) notNil]) |
|
6843 |
ifTrue:[ |
|
6844 |
^ VariableNode type:#DoItTemporary holder:holder name:varName |
|
6845 |
] |
|
6846 |
]. |
|
6847 |
"/ ]. |
|
0 | 6848 |
^ #Error |
1212
082618467e2c
isMeta/soleInstance -> theMetaclass / theNonMetaclass
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
6849 |
"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
|
6850 |
! ! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
6851 |
|
1410 | 6852 |
!Parser methodsFor:'parsing-primitives & pragmas'! |
6853 |
||
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6854 |
checkForClosingAngle |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6855 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6856 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6857 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6858 |
self parseError:'bad primitive definition (''>'' expected)'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6859 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6860 |
! |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6861 |
|
1551 | 6862 |
parseExternalFunctionCallDeclaration |
6863 |
|callType cString cStream cParser returnType |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6864 |
functionName argTypes moduleName fn node args sel| |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6865 |
|
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6866 |
"callType is one of C: / cdecl: / api: / apicall:" |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6867 |
callType := tokenName asSymbol. |
1410 | 6868 |
|
6869 |
cString := source upTo:$>. |
|
6870 |
self nextToken. |
|
6871 |
cStream := cString readStream. |
|
6872 |
||
1551 | 6873 |
CParser isNil ifTrue:[ |
6874 |
self parseError:'no parser for cdecl'. |
|
1410 | 6875 |
^ -1 |
6876 |
]. |
|
1551 | 6877 |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6878 |
callType = #'cdecl:' ifTrue:[ |
1551 | 6879 |
cParser := CParser new. |
6880 |
cParser source:cStream scannerClass:CDeclScanner. |
|
6881 |
cParser nextToken. |
|
6882 |
returnType := cParser type. |
|
6883 |
||
6884 |
cParser tokenType ~~ #String ifTrue:[ |
|
6885 |
self parseError:'invalid cdecl - functionName expected'. |
|
6886 |
^ -1 |
|
6887 |
]. |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6888 |
functionName := cParser token asSymbol. |
1551 | 6889 |
cParser nextToken. |
6890 |
argTypes := cParser parseFunctionArgumentSpec. |
|
6891 |
||
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6892 |
(cParser tokenType == #Identifier and:[cParser token = #module]) ifTrue:[ |
1551 | 6893 |
cParser nextToken. |
6894 |
cParser tokenType ~~ $: ifTrue:[ |
|
6895 |
self parseError:'colon expected'. |
|
6896 |
^ -1 |
|
6897 |
]. |
|
6898 |
cParser nextToken. |
|
6899 |
cParser tokenType ~~ #String ifTrue:[ |
|
6900 |
self parseError:'invalid cdecl - moduleName expected'. |
|
6901 |
^ -1 |
|
6902 |
]. |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6903 |
moduleName := cParser token asSymbol. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6904 |
]. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6905 |
(argTypes size == 1 and:[argTypes first isCVoid]) ifTrue:[ |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6906 |
argTypes := #() |
1551 | 6907 |
]. |
6908 |
argTypes size ~~ methodArgNames size ifTrue:[ |
|
6909 |
self parseError:'number of method args does not match function arg list'. |
|
6910 |
]. |
|
6911 |
fn := ExternalLibraryFunction |
|
6912 |
name:functionName |
|
6913 |
module:moduleName |
|
6914 |
callType:callType |
|
6915 |
returnType:returnType |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6916 |
argumentTypes:argTypes asArray. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6917 |
|
1551 | 6918 |
args := (methodArgNames ? #()) collect:[:eachArgName | node := self nodeForMethodArg:eachArgName]. |
6919 |
sel := #( |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6920 |
invoke |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6921 |
invokeWith: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6922 |
invokeWith:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6923 |
invokeWith:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6924 |
invokeWith:with:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6925 |
invokeWith:with:with:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6926 |
invokeWith:with:with:with:with:with: |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6927 |
invokeWith:with:with:with:with:with:with: |
1551 | 6928 |
) at:args size+1 ifAbsent:nil. |
6929 |
sel isNil ifTrue:[ |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6930 |
sel := #invokeWithArguments:. |
1551 | 6931 |
self halt. |
6932 |
||
6933 |
]. |
|
1601
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6934 |
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
|
6935 |
tree := ReturnNode new expression:node. |
54b1efc9dfd5
#parseExternalFunctionDeclaration
Stefan Vogel <sv@exept.de>
parents:
1599
diff
changeset
|
6936 |
"/ self isSyntaxHighlighter ifFalse:[ self halt ]. |
1551 | 6937 |
^ -1 |
6938 |
]. |
|
6939 |
||
6940 |
self parseError:'unsupported external function call type: ' , callType. |
|
1410 | 6941 |
^ -1 |
1551 | 6942 |
|
6943 |
" |
|
6944 |
(Parser for:'foo <cdecl: void ''glFlush'' (void) module: ''GL''>') |
|
6945 |
nextToken; |
|
6946 |
parseMethod |
|
6947 |
" |
|
1410 | 6948 |
! |
6949 |
||
6950 |
parsePrimitive |
|
6951 |
"parse an ST-80 type primitive as '< primitive: nr >'; |
|
6952 |
return primitive number or #Error. |
|
6953 |
or a Squeak-style primitive, as '< primitive: string >'; |
|
6954 |
return primitive name or #Error. |
|
6955 |
||
6956 |
Also, ST-80 style resource specs are parsed; the result is |
|
6957 |
left (as side effect) in primitiveResource. |
|
6958 |
(maybe someone else knows what to do with it ...) |
|
6959 |
Well, as we now have this mechanism, I'll use it to mark methods which |
|
6960 |
do keyboard processing ... <resource: keyboard ( keys )> |
|
6961 |
For faster finding of used keyboard accelerators, |
|
6962 |
and to mark resource methods (image, menu or canvas resources). |
|
6963 |
||
6964 |
prim ::= st80Primitive | st80Pragma | stxPragma |
|
6965 |
squeakPrimitive | newSTXPrimitive | resourceDecl |
|
6966 |
||
6967 |
st80Primitive ::= 'primitive:' INTEGER |
|
6968 |
st80Pragma ::= 'exception:' ( 'handle | 'raise' | 'unwind' ) |
|
6969 |
stxPragma ::= 'context:' 'return' |
|
6970 |
||
6971 |
squeakPrimitive ::= 'primitive:' STRING |
|
6972 |
||
6973 |
newSTXPrimitive ::= 'primitive' |
|
6974 |
||
6975 |
resourceDecl ::= 'resource:' SYMBOL - leave SYMBOL in primitiveResource |
|
6976 |
| 'resource:' SYMBOL (...) - leave (SYMBOL (...)) in primitiveResource |
|
6977 |
" |
|
6978 |
||
6979 |
(tokenType == #Keyword or:[tokenType == #Identifier]) ifFalse:[ |
|
6980 |
self parseError:'bad primitive definition (keyword expected)'. |
|
6981 |
^ #Error |
|
6982 |
]. |
|
6983 |
||
6984 |
(tokenName = 'primitive:') ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6985 |
^ self parseTraditionalPrimitive. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6986 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6987 |
(tokenName = 'primitive') ifTrue:[ |
1410 | 6988 |
self nextToken. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6989 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6990 |
^ 0. "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6991 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6992 |
(tokenName = 'resource:') ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6993 |
self parseResourcePragma. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6994 |
^ nil. "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6995 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6996 |
(tokenName = 'exception:' |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6997 |
or:[tokenName = 'context:']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6998 |
self parseExceptionOrContextPragma. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
6999 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7000 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7001 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7002 |
(tokenName = 'C:') ifTrue:[ |
1551 | 7003 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7004 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7005 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7006 |
(tokenName = 'api:') ifTrue:[ |
1551 | 7007 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7008 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7009 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7010 |
(tokenName = 'apicall:') ifTrue:[ |
1551 | 7011 |
self parseExternalFunctionCallDeclaration. |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7012 |
^ nil "/ no primitive number |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7013 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7014 |
(tokenName = 'cdecl:') ifTrue:[ |
1551 | 7015 |
self parseExternalFunctionCallDeclaration. |
1420
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 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7019 |
self parseError:'unrecognized pragma: ' , tokenName. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7020 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7021 |
"/ skip |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7022 |
[tokenType ~~ #EOF] whileTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7023 |
((tokenType == #BinaryOperator) and:[tokenName = '>']) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7024 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7025 |
^ nil "/ no primitive number |
1410 | 7026 |
]. |
7027 |
self nextToken. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7028 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7029 |
^ nil "/ no primitive number |
1410 | 7030 |
! |
7031 |
||
7032 |
parsePrimitiveOrResourceSpecOrEmpty |
|
7033 |
"parse a methods primitive or resource spec" |
|
7034 |
||
7035 |
|pos wmsg primNr primNrOrString| |
|
7036 |
||
7037 |
[(tokenType == #BinaryOperator) and:[tokenName = '<']] whileTrue:[ |
|
7038 |
pos := tokenPosition. |
|
7039 |
self nextToken. |
|
7040 |
primNrOrString := self parsePrimitive. |
|
7041 |
||
7042 |
(primNrOrString == #Error) ifTrue:[^ #Error]. |
|
7043 |
wmsg := nil. |
|
7044 |
||
7045 |
primNrOrString isString ifTrue:[ |
|
7046 |
primNr := self primitiveNumberFromName:primNrOrString |
|
7047 |
] ifFalse:[ |
|
7048 |
primNr := primNrOrString |
|
7049 |
]. |
|
7050 |
||
7051 |
primNr notNil ifTrue:[ |
|
7052 |
primNr < 0 ifTrue:[ |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7053 |
parserFlags warnST80Directives == true ifTrue:[ |
1410 | 7054 |
wmsg := 'ST-80/Squeak directive ignored'. |
7055 |
]. |
|
7056 |
] ifFalse:[ |
|
7057 |
primNr > 0 ifTrue:[ |
|
7058 |
primitiveNr := primNr. |
|
7059 |
wmsg := 'ST-80 primitive may not work' |
|
7060 |
] ifFalse:[ |
|
7061 |
primitiveNr := primNr. |
|
7062 |
wmsg := 'ST/X primitives only work in rel5 and newer' |
|
7063 |
] |
|
7064 |
]. |
|
1551 | 7065 |
wmsg notNil ifTrue:[self warning:wmsg position:pos] |
7066 |
]. |
|
1410 | 7067 |
]. |
7068 |
||
7069 |
"Created: 27.4.1996 / 16:55:55 / cg" |
|
7070 |
"Modified: 29.5.1996 / 17:25:52 / cg" |
|
7071 |
! |
|
7072 |
||
7073 |
parseResourcePragma |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7074 |
" '< resource:' has already been parsed." |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7075 |
|
1410 | 7076 |
|keys resource resourceValue| |
7077 |
||
7078 |
self nextToken. |
|
7079 |
(tokenType ~~ #Symbol) ifTrue:[ |
|
7080 |
self parseError:'symbol expected'. |
|
7081 |
^ #Error |
|
7082 |
]. |
|
7083 |
||
7084 |
resource := tokenValue. |
|
7085 |
resourceValue := true. |
|
7086 |
||
7087 |
self nextToken. |
|
7088 |
||
7089 |
tokenType == $( ifTrue:[ |
|
7090 |
self nextToken. |
|
7091 |
keys := OrderedCollection new. |
|
7092 |
[(tokenType == $)) or:[tokenType == #EOF] ] whileFalse:[ |
|
7093 |
keys add:tokenValue. |
|
7094 |
self nextToken. |
|
7095 |
]. |
|
7096 |
resourceValue := keys. |
|
7097 |
(tokenType == $)) ifFalse:[ |
|
7098 |
self parseError:'unterminated primitive/spec (missing '')'')'. |
|
7099 |
]. |
|
7100 |
self nextToken. |
|
7101 |
]. |
|
7102 |
||
7103 |
primitiveResource isNil ifTrue:[ |
|
7104 |
primitiveResource := IdentityDictionary new. |
|
7105 |
]. |
|
7106 |
primitiveResource at:(resource asSymbol) put:resourceValue. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7107 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7108 |
! |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7109 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7110 |
parseTraditionalPrimitive |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7111 |
"parse everything after the initial '<primitive:'" |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7112 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7113 |
|primNumber| |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7114 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7115 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7116 |
(tokenType == #Integer) ifFalse:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7117 |
parserFlags allowSqueakExtensions ifTrue:[ |
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7118 |
(tokenType == #String) ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7119 |
self parseError:'primitive number or name expected'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7120 |
^ #Error |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7121 |
] |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7122 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7123 |
self parseError:'primitive number expected'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7124 |
^ #Error |
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 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7127 |
primitiveNr notNil ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7128 |
self parseError:'only one primitive spec allowed'. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7129 |
primNumber := -1. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7130 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7131 |
primNumber := tokenValue. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7132 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7133 |
self nextToken. |
1556 | 7134 |
|
7135 |
(tokenType == #Keyword) ifTrue:[ |
|
7136 |
(tokenName = 'errorCode:') ifTrue:[ |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7137 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7138 |
(tokenType == #Identifier) ifTrue:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7139 |
self nextToken. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7140 |
] ifFalse:[ |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7141 |
self error:'not yet implemented'. |
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 |
]. |
1556 | 7144 |
(tokenName = 'module:') ifTrue:[ |
7145 |
self nextToken. |
|
7146 |
(tokenType == #String) ifTrue:[ |
|
7147 |
self nextToken. |
|
7148 |
] ifFalse:[ |
|
7149 |
self error:'not yet implemented'. |
|
7150 |
] |
|
7151 |
]. |
|
1420
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7152 |
]. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7153 |
|
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7154 |
self checkForClosingAngle. |
57f3f5c8a070
more for exotic primitives/pragmas
Claus Gittinger <cg@exept.de>
parents:
1419
diff
changeset
|
7155 |
^ primNumber |
1410 | 7156 |
! |
7157 |
||
7158 |
primitiveNumberFromName:aPrimitiveName |
|
7159 |
"for future compatibility with Squeak ..." |
|
7160 |
||
7161 |
^ nil |
|
7162 |
! ! |
|
7163 |
||
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7164 |
!Parser methodsFor:'private'! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7165 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7166 |
currentNameSpace |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7167 |
|spc| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7168 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7169 |
spc := currentNamespace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7170 |
spc isNil ifTrue:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7171 |
(requestor respondsTo:#currentNameSpace) ifTrue:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7172 |
spc := requestor currentNameSpace |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7173 |
] ifFalse:[ |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7174 |
spc := Class nameSpaceQuerySignal query. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7175 |
]. |
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7176 |
currentNamespace := spc. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7177 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7178 |
^ spc |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7179 |
|
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7180 |
"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
|
7181 |
"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
|
7182 |
"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
|
7183 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7184 |
|
492
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7185 |
currentNameSpace:aNameSpace |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7186 |
currentNamespace := aNameSpace. |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7187 |
|
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7188 |
"Created: 8.2.1997 / 19:37:03 / cg" |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7189 |
! |
fe778fd0ce46
additional entry, passing the namespace
Claus Gittinger <cg@exept.de>
parents:
489
diff
changeset
|
7190 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7191 |
currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7192 |
|pkg| |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7193 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7194 |
pkg := currentPackage. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7195 |
pkg isNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7196 |
(requestor respondsTo:#currentPackage) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7197 |
pkg := requestor currentPackage |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7198 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7199 |
pkg := Class packageQuerySignal query. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7200 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7201 |
currentPackage := pkg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7202 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7203 |
^ pkg |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7204 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7205 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7206 |
currentPackage:aPackageName |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7207 |
currentPackage := aPackageName. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7208 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
7209 |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7210 |
currentUsedNameSpaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7211 |
|spaces| |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7212 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7213 |
spaces := currentUsedNamespaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7214 |
spaces isNil ifTrue:[ |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7215 |
(requestor respondsTo:#usedNameSpaces) ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7216 |
spaces := requestor usedNameSpaces |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7217 |
] ifFalse:[ |
832
553c25252a78
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
825
diff
changeset
|
7218 |
spaces := Class usedNameSpaceQuerySignal query. |
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7219 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7220 |
spaces isNil ifTrue:[ |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7221 |
spaces := #() |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7222 |
]. |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7223 |
currentUsedNamespaces := spaces. |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7224 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7225 |
^ spaces |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7226 |
|
679
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7227 |
"Created: / 19.12.1996 / 23:49:10 / cg" |
6a60e6d0ccd1
avoid redoing work in #currentUsedNameSpaces
Claus Gittinger <cg@exept.de>
parents:
673
diff
changeset
|
7228 |
"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
|
7229 |
"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
|
7230 |
! |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7231 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7232 |
findNameSpaceWith:aVariableName |
692 | 7233 |
|ns currentSpace usedSpaces| |
486
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
7234 |
|
e894035d5223
fixed name resolving for private classes when accessing
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
7235 |
"/ 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
|
7236 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7237 |
classToCompileFor notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7238 |
"/ Q: |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7239 |
"/ consider private classes of superclasses. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7240 |
"/ 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
|
7241 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7242 |
"/ 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
|
7243 |
"/ known to the corresponding ownerClass. |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7244 |
|
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7245 |
"is it in the classes namespace ?" |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7246 |
|
1315 | 7247 |
ns := classToCompileFor topNameSpace. |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7248 |
(ns notNil |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7249 |
and:[ns ~~ Smalltalk]) ifTrue:[ |
1142 | 7250 |
ns isNameSpace ifTrue:[ |
7251 |
(ns at:aVariableName) notNil ifTrue:[ |
|
7252 |
^ ns |
|
7253 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7254 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7255 |
]. |
494
bb3e71c90dfd
currentClasses nameSpace is first to look for globals.
Claus Gittinger <cg@exept.de>
parents:
493
diff
changeset
|
7256 |
|
495 | 7257 |
"/ ns := classToCompileFor nameSpace. |
7258 |
"/ ns notNil ifTrue:[ |
|
7259 |
"/ "is it in the current classes namespace ?" |
|
7260 |
"/ (ns at:aVariableName asSymbol) notNil ifTrue:[ |
|
7261 |
"/ ^ ns |
|
7262 |
"/ ] |
|
7263 |
"/ ]. |
|
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7264 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7265 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7266 |
"is it in the current namespace ?" |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7267 |
currentSpace := self currentNameSpace. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7268 |
(currentSpace notNil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7269 |
and:[currentSpace ~~ Smalltalk]) ifTrue:[ |
1043 | 7270 |
currentSpace isNameSpace ifTrue:[ |
7271 |
(currentSpace at:aVariableName) notNil ifTrue:[ |
|
7272 |
^ currentSpace |
|
7273 |
] |
|
7274 |
] ifFalse:[ |
|
7275 |
(currentSpace privateClassesAt:aVariableName) notNil ifTrue:[ |
|
7276 |
^ currentSpace |
|
7277 |
] |
|
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7278 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7279 |
]. |
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 |
"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
|
7282 |
usedSpaces := self currentUsedNameSpaces. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7283 |
usedSpaces notNil ifTrue:[ |
1042
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7284 |
usedSpaces do:[:aNameSpace | |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7285 |
(aNameSpace at:aVariableName) notNil ifTrue:[ |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7286 |
^ aNameSpace |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7287 |
] |
d192446cb745
fixed qualifiedName handling (as array constant)
Claus Gittinger <cg@exept.de>
parents:
1041
diff
changeset
|
7288 |
] |
455
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7289 |
]. |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7290 |
^ nil |
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7291 |
|
2e234d3bc96d
fixed parsing of private classes within a nameSpace
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
7292 |
"Created: 19.12.1996 / 23:51:02 / cg" |
619 | 7293 |
"Modified: 14.10.1997 / 20:56:35 / cg" |
713 | 7294 |
! |
7295 |
||
1327 | 7296 |
implementedInAnyClass:selector |
7297 |
Smalltalk allClassesAndMetaclassesDo:[:cls | |
|
1518 | 7298 |
(cls includesSelector:selector) ifTrue:[^ true]. |
1327 | 7299 |
]. |
7300 |
^ false |
|
7301 |
! |
|
7302 |
||
713 | 7303 |
inWhichClassIsClassInstVar:aString |
7304 |
"search class-chain for the class-instance variable named aString |
|
7305 |
- return the class or nil if not found" |
|
7306 |
||
7307 |
|aClass| |
|
7308 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7309 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7310 |
|
713 | 7311 |
[aClass notNil] whileTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7312 |
(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
|
7313 |
aClass := aClass superclass |
713 | 7314 |
]. |
7315 |
^ nil |
|
7316 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7317 |
"Modified: / 18.6.1998 / 15:45:34 / cg" |
713 | 7318 |
! |
7319 |
||
7320 |
inWhichClassIsClassVar:aString |
|
7321 |
"search class-chain for the classvariable named aString |
|
7322 |
- return the class or nil if not found" |
|
7323 |
||
7324 |
|aClass className baseClass| |
|
7325 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7326 |
aClass := self classToLookForClassVars. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7327 |
|
713 | 7328 |
aClass isMeta ifTrue:[ |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7329 |
className := aClass name copyWithoutLast:6. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7330 |
baseClass := Smalltalk at:(className asSymbol). |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7331 |
baseClass notNil ifTrue:[ |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7332 |
aClass := baseClass |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7333 |
] |
713 | 7334 |
]. |
7335 |
^ aClass whichClassDefinesClassVar:aString |
|
7336 |
||
7337 |
"/ [aClass notNil] whileTrue:[ |
|
7338 |
"/ (aClass classVarNames includes:aString) ifTrue:[ ^ aClass]. |
|
7339 |
"/ aClass := aClass superclass |
|
7340 |
"/ ]. |
|
7341 |
"/ ^ nil |
|
7342 |
||
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7343 |
"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
|
7344 |
"Modified: / 18.6.1998 / 15:45:29 / cg" |
787 | 7345 |
! |
7346 |
||
1512
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7347 |
isStatementAnUnconditionalReturn:aStatementNode |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7348 |
|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
|
7349 |
|
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7350 |
aStatementNode isReturnNode ifTrue:[^ true ]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7351 |
((expr := aStatementNode expression) notNil |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7352 |
and:[expr isMessage]) ifTrue:[ |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7353 |
selector := expr selector. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7354 |
(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
|
7355 |
block1 := expr arg1. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7356 |
block2 := expr arguments at:2. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7357 |
(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
|
7358 |
stats1 := block1 statements. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7359 |
stats2 := block2 statements. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7360 |
(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
|
7361 |
^ (self isStatementAnUnconditionalReturn:stats1 last) |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7362 |
and:[self isStatementAnUnconditionalReturn:stats2 last] |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7363 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7364 |
]. |
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 |
]. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7367 |
^ false. |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7368 |
! |
52986e9b02af
better isReturn (used when checking for consistent return value)
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
7369 |
|
1615 | 7370 |
makeImmutableArray:anArray |
1621 | 7371 |
^ self class makeImmutableArray:anArray |
1615 | 7372 |
! |
7373 |
||
7374 |
makeImmutableString:aString |
|
1621 | 7375 |
^ self class makeImmutableString:aString |
1615 | 7376 |
! |
7377 |
||
1262 | 7378 |
makeReferenceFor:aNode |
7379 |
|rec sel indexNode contextNode arg1 arg2| |
|
7380 |
||
7381 |
contextNode := VariableNode type:#ThisContext context:contextToEvaluateIn. |
|
7382 |
indexNode := ConstantNode type:#Integer value:aNode index. |
|
7383 |
||
7384 |
aNode isArgument ifTrue:[ |
|
7385 |
sel := #forArgument:in:. |
|
7386 |
arg1 := indexNode. |
|
7387 |
arg2 := contextNode. |
|
7388 |
] ifFalse:[ |
|
7389 |
aNode isLocal ifTrue:[ |
|
7390 |
sel := #forLocal:in:. |
|
7391 |
arg1 := indexNode. |
|
7392 |
arg2 := contextNode. |
|
7393 |
] ifFalse:[ |
|
7394 |
self parseError:'unsupported variable reference (must be local or argument)'. |
|
7395 |
^ aNode |
|
7396 |
] |
|
7397 |
]. |
|
7398 |
||
7399 |
parseForCode ifFalse:[self rememberGlobalUsed:'Reference']. |
|
1309
f85561a7b90e
preps for nonDeterministic and FD variables.
Claus Gittinger <cg@exept.de>
parents:
1306
diff
changeset
|
7400 |
rec := VariableNode globalNamed:'Reference'. |
1262 | 7401 |
|
7402 |
^ MessageNode receiver:rec selector:sel arg1:arg1 arg2:arg2. |
|
7403 |
! |
|
7404 |
||
1003
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7405 |
noAssignmentAllowed:eMsg at:pos |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7406 |
((tokenType == $_) or:[tokenType == #':=']) ifTrue:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7407 |
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
|
7408 |
self isSyntaxHighlighter ifFalse:[ |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7409 |
^ false |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7410 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7411 |
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
|
7412 |
]. |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7413 |
^ true |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7414 |
! |
37badd2eb5b0
dont stop syntaxHighlighting when a bad assignment is encountered
Claus Gittinger <cg@exept.de>
parents:
997
diff
changeset
|
7415 |
|
787 | 7416 |
plausibilityCheck:aNode |
1193 | 7417 |
|note| |
7418 |
||
7419 |
note := aNode plausibilityCheck. |
|
7420 |
note isNil ifTrue:[ |
|
7421 |
aNode isMessage ifTrue:[ |
|
7422 |
(contextToEvaluateIn isNil and:[selfValue isNil]) ifTrue:[ "/ do not check this for doits |
|
7423 |
aNode receiver isSuper ifTrue:[ |
|
1535 | 7424 |
aNode receiver isHere ifFalse:[ |
7425 |
aNode selector ~= selector ifTrue:[ |
|
7426 |
^ 'possible bad super message (selector should be same as in current method) ?' |
|
7427 |
] |
|
1193 | 7428 |
]. |
7429 |
]. |
|
7430 |
]. |
|
7431 |
]. |
|
7432 |
]. |
|
7433 |
^ note |
|
1262 | 7434 |
! |
7435 |
||
7436 |
selfNode |
|
7437 |
selfNode isNil ifTrue:[ |
|
7438 |
selfNode := SelfNode value:selfValue |
|
7439 |
]. |
|
7440 |
^ selfNode |
|
141 | 7441 |
! ! |
7442 |
||
7443 |
!Parser methodsFor:'queries'! |
|
7444 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7445 |
classToLookForClassVars |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7446 |
"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
|
7447 |
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
|
7448 |
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
|
7449 |
class of the receiver." |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7450 |
|
1160 | 7451 |
|m who| |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7452 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7453 |
contextToEvaluateIn notNil ifTrue:[ |
748 | 7454 |
m := contextToEvaluateIn method. |
7455 |
m notNil ifTrue:[ |
|
7456 |
who := contextToEvaluateIn method who. |
|
7457 |
who notNil ifTrue:[ |
|
7458 |
^ who methodClass. |
|
7459 |
] |
|
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7460 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7461 |
"/ mhmh - might be a doIt ... |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7462 |
]. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7463 |
^ classToCompileFor |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7464 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7465 |
"Created: / 18.6.1998 / 15:43:42 / cg" |
748 | 7466 |
"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
|
7467 |
! |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7468 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7469 |
classesClassInstVarNames |
141 | 7470 |
"caching allInstVarNames for next compilation saves time ..." |
7471 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7472 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7473 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7474 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7475 |
|cls| |
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 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7478 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7479 |
(PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7480 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7481 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7482 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7483 |
PrevClass := cls. |
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7484 |
|
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7485 |
PrevClassInstVarNames := cls class allInstVarNames. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7486 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7487 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7488 |
names := PrevClassInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7489 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7490 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7491 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7492 |
"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
|
7493 |
"Modified: / 18.6.1998 / 15:44:41 / cg" |
0 | 7494 |
! |
7495 |
||
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7496 |
classesClassVarNames |
141 | 7497 |
"caching allClassVarNames for next compilation saves time ..." |
7498 |
||
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7499 |
|names| |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7500 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7501 |
[ |
735
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7502 |
|cls aClass| |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7503 |
|
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7504 |
cls := self classToLookForClassVars. |
4012fa1611b1
code cleanup & fix for doIt (implementing class)
Claus Gittinger <cg@exept.de>
parents:
733
diff
changeset
|
7505 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7506 |
(PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[ |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7507 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7508 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7509 |
]. |
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7510 |
aClass := PrevClass := cls. |
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7511 |
aClass isMeta ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7512 |
aClass := aClass soleInstance. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7513 |
aClass isNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7514 |
aClass := classToCompileFor |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7515 |
] |
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 |
PrevClassVarNames := aClass allClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7518 |
PrevClass addDependent:Parser. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7519 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7520 |
names := PrevClassVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7521 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7522 |
^ names |
290
d1650b17b9e9
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
285
diff
changeset
|
7523 |
|
732
c36e5ef1e6ce
oops - when evaluating in a context, classVars must be
Claus Gittinger <cg@exept.de>
parents:
725
diff
changeset
|
7524 |
"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
|
7525 |
"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
|
7526 |
"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
|
7527 |
! |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7528 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7529 |
classesInstVarNames |
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7530 |
"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
|
7531 |
|
694
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7532 |
|names| |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7533 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7534 |
[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7535 |
(PrevInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7536 |
PrevClass notNil ifTrue:[ |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7537 |
PrevClass removeDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7538 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7539 |
PrevClass := classToCompileFor. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7540 |
PrevInstVarNames := classToCompileFor allInstVarNames. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7541 |
PrevClassInstVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7542 |
PrevClassVarNames := nil. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7543 |
PrevClass addDependent:Parser |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7544 |
]. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7545 |
names := PrevInstVarNames |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7546 |
] valueUninterruptably. |
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7547 |
|
1ec57d3a2592
must manage the PrevClass cached instVars/classInstVars
Claus Gittinger <cg@exept.de>
parents:
692
diff
changeset
|
7548 |
^ names |
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7549 |
|
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
7550 |
"Created: 14.10.1996 / 18:00:26 / cg" |
0 | 7551 |
! |
7552 |
||
934
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7553 |
contextMustBeReturnable |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7554 |
^ primitiveContextInfo notNil |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7555 |
and:[ ^ primitiveContextInfo includes:('context:' -> #return) ] |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7556 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7557 |
|
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7558 |
! |
716f9c76b06b
pass down returnable-context flag via method.
Claus Gittinger <cg@exept.de>
parents:
931
diff
changeset
|
7559 |
|
141 | 7560 |
hasNonOptionalPrimitiveCode |
7561 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
7562 |
||
7563 |
^ hasNonOptionalPrimitiveCode |
|
0 | 7564 |
! |
7565 |
||
141 | 7566 |
hasPrimitiveCode |
7567 |
"return true if there was any ST/X style primitive code (valid after parsing)" |
|
7568 |
||
7569 |
^ hasPrimitiveCode |
|
98 | 7570 |
! |
7571 |
||
1440 | 7572 |
isDoIt |
7573 |
^ (selector isNil or:[selector == #'doIt' or:[selector == #'doIt:']]) |
|
7574 |
! |
|
7575 |
||
883 | 7576 |
isSyntaxHighlighter |
7577 |
^ false |
|
7578 |
! |
|
7579 |
||
385 | 7580 |
lineNumberInfo |
7581 |
^ lineNumberInfo |
|
7582 |
||
7583 |
"Created: 21.10.1996 / 17:06:16 / cg" |
|
7584 |
! |
|
7585 |
||
391
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7586 |
lineNumberInfo:how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7587 |
lineNumberInfo := how |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7588 |
|
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7589 |
"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
|
7590 |
! |
c556973a4b47
added method to extract a block, given a lineNumber within the
Claus Gittinger <cg@exept.de>
parents:
390
diff
changeset
|
7591 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7592 |
messagesSent |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7593 |
"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
|
7594 |
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
|
7595 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7596 |
^ (messagesSent ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7597 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7598 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7599 |
messagesSentToSelf |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7600 |
"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
|
7601 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7602 |
^ (messagesSentToSelf ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7603 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7604 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7605 |
messagesSentToSuper |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7606 |
"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
|
7607 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7608 |
^ (messagesSentToSuper ? #()) collect:[:each | each asSymbol] |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7609 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7610 |
|
141 | 7611 |
methodArgs |
7612 |
"return an array with methodarg names (valid after parsing spec)" |
|
7613 |
||
7614 |
^ methodArgNames |
|
7615 |
! |
|
7616 |
||
7617 |
methodVars |
|
7618 |
"return a collection with method variablenames (valid after parsing)" |
|
7619 |
||
7620 |
^ methodVarNames |
|
23 | 7621 |
! |
7622 |
||
141 | 7623 |
modifiedClassVars |
7624 |
"return a collection with classvariablenames modified by method (valid after parsing)" |
|
7625 |
||
541 | 7626 |
^ modifiedClassVars ? #() |
7627 |
||
7628 |
"Modified: 19.6.1997 / 17:54:48 / cg" |
|
141 | 7629 |
! |
7630 |
||
7631 |
modifiedGlobals |
|
7632 |
"return a collection with globalnames modified by method (valid after parsing)" |
|
7633 |
||
541 | 7634 |
^ modifiedGlobals ? #() |
7635 |
||
7636 |
"Modified: 19.6.1997 / 17:54:51 / cg" |
|
141 | 7637 |
! |
7638 |
||
7639 |
modifiedInstVars |
|
7640 |
"return a collection with instvariablenames modified by method (valid after parsing)" |
|
7641 |
||
541 | 7642 |
^ modifiedInstVars ? #() |
7643 |
||
7644 |
"Modified: 19.6.1997 / 17:54:27 / cg" |
|
0 | 7645 |
! |
7646 |
||
141 | 7647 |
numberOfMethodArgs |
7648 |
"return the number of methodargs (valid after parsing spec)" |
|
7649 |
||
7650 |
^ methodArgs size |
|
7651 |
! |
|
7652 |
||
7653 |
numberOfMethodVars |
|
7654 |
"return the number of method variables (valid after parsing)" |
|
7655 |
||
7656 |
^ methodVars size |
|
7657 |
! |
|
7658 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7659 |
readClassVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7660 |
"return a collection with classvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7661 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7662 |
^ readClassVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7663 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7664 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7665 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7666 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7667 |
readInstVars |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7668 |
"return a collection with instvariablenames read by method (valid after parsing)" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7669 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7670 |
^ readInstVars ? #() |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7671 |
|
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7672 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7673 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7674 |
|
141 | 7675 |
selector |
7676 |
"return the selector (valid after parsing spec)" |
|
7677 |
||
7678 |
^ selector |
|
0 | 7679 |
! |
7680 |
||
141 | 7681 |
usedClassVars |
7682 |
"return a collection with classvariablenames refd by method (valid after parsing)" |
|
7683 |
||
541 | 7684 |
^ usedClassVars ? #() |
7685 |
||
7686 |
"Modified: 19.6.1997 / 17:54:56 / cg" |
|
141 | 7687 |
! |
7688 |
||
7689 |
usedGlobals |
|
7690 |
"return a collection with globalnames refd by method (valid after parsing)" |
|
7691 |
||
541 | 7692 |
^ usedGlobals ? #() |
7693 |
||
7694 |
"Modified: 19.6.1997 / 17:55:00 / cg" |
|
141 | 7695 |
! |
7696 |
||
7697 |
usedInstVars |
|
7698 |
"return a collection with instvariablenames refd by method (valid after parsing)" |
|
7699 |
||
541 | 7700 |
^ usedInstVars ? #() |
7701 |
||
7702 |
"Modified: 19.6.1997 / 17:54:38 / cg" |
|
141 | 7703 |
! |
7704 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7705 |
usedSymbols |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7706 |
"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
|
7707 |
|
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7708 |
^ (usedSymbols ? #()) |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7709 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7710 |
|
141 | 7711 |
usedVars |
7712 |
"return a collection with variablenames refd by method (valid after parsing)" |
|
7713 |
||
541 | 7714 |
^ usedVars ? #() |
7715 |
||
7716 |
"Modified: 19.6.1997 / 17:55:04 / cg" |
|
0 | 7717 |
! |
7718 |
||
141 | 7719 |
usesSuper |
7720 |
"return true if the parsed method uses super (valid after parsing)" |
|
7721 |
||
7722 |
^ usesSuper |
|
7723 |
! ! |
|
7724 |
||
7725 |
!Parser methodsFor:'setup'! |
|
7726 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7727 |
arraysAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7728 |
^ parserFlags arraysAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7729 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7730 |
|
1615 | 7731 |
arraysAreImmutable:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7732 |
parserFlags arraysAreImmutable:aBoolean. |
1615 | 7733 |
! |
7734 |
||
1220
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7735 |
classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7736 |
^ classToCompileFor |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7737 |
|
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7738 |
"Created: / 15.11.2001 / 17:21:10 / cg" |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7739 |
! |
53e6eeadee72
added declare instVar and classInstVar
Claus Gittinger <cg@exept.de>
parents:
1215
diff
changeset
|
7740 |
|
229
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7741 |
foldConstants:aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7742 |
"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
|
7743 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7744 |
foldConstants := aSymbolOrNil |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7745 |
|
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7746 |
"Created: 21.3.1996 / 16:03:22 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7747 |
"Modified: 21.3.1996 / 16:05:04 / cg" |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7748 |
! |
7aecb52d907d
dont fold constants with immediate evaluations
Claus Gittinger <cg@exept.de>
parents:
223
diff
changeset
|
7749 |
|
141 | 7750 |
initialize |
7751 |
super initialize. |
|
7752 |
||
7753 |
hasPrimitiveCode := hasNonOptionalPrimitiveCode := false. |
|
7754 |
usesSuper := false. |
|
7755 |
parseForCode := false. |
|
377 | 7756 |
foldConstants := FoldConstants. |
7757 |
lineNumberInfo := LineNumberInfo. |
|
1640
261459ccc704
emphasize parenthesis nesting
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
7758 |
parenthesisLevel := 0. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7759 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7760 |
didWarnAboutSTXNameSpaceUse := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7761 |
didWarnAboutSTXHereExtensionUsed := false. |
607 | 7762 |
|
7763 |
"Modified: 7.9.1997 / 02:04:34 / cg" |
|
141 | 7764 |
! |
7765 |
||
7766 |
parseForCode |
|
7767 |
"turns off certain statistics (keeping referenced variables, modified vars etc.) |
|
7768 |
Use this when parsing for compilation or evaluation" |
|
7769 |
||
7770 |
parseForCode := true |
|
0 | 7771 |
! |
7772 |
||
141 | 7773 |
setClassToCompileFor:aClass |
7774 |
"set the class to be used for parsing/evaluating" |
|
7775 |
||
7776 |
classToCompileFor := aClass. |
|
7777 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
1576 | 7778 |
PrevClass notNil ifTrue:[ |
7779 |
Parser update:PrevClass |
|
7780 |
] |
|
141 | 7781 |
] |
7782 |
! |
|
7783 |
||
7784 |
setContext:aContext |
|
7785 |
"set the context used while evaluating" |
|
7786 |
||
7787 |
contextToEvaluateIn := aContext |
|
7788 |
! |
|
7789 |
||
7790 |
setSelf:anObject |
|
7791 |
"set the value to be used for self while evaluating" |
|
7792 |
||
7793 |
selfValue := anObject. |
|
7794 |
classToCompileFor := anObject class. |
|
7795 |
(classToCompileFor ~~ PrevClass) ifTrue:[ |
|
1576 | 7796 |
PrevClass notNil ifTrue:[ |
7797 |
Parser update:PrevClass |
|
7798 |
] |
|
141 | 7799 |
] |
607 | 7800 |
! |
7801 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7802 |
stringsAreImmutable |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7803 |
^ parserFlags stringsAreImmutable. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7804 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7805 |
|
1615 | 7806 |
stringsAreImmutable:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7807 |
parserFlags stringsAreImmutable:aBoolean. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7808 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7809 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7810 |
warnUndeclared |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7811 |
^ parserFlags warnUndeclared |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7812 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7813 |
"Created: 7.9.1997 / 02:05:00 / cg" |
1615 | 7814 |
! |
7815 |
||
607 | 7816 |
warnUndeclared:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7817 |
parserFlags warnUndeclared:aBoolean. |
607 | 7818 |
|
7819 |
"Created: 7.9.1997 / 02:05:00 / cg" |
|
1160 | 7820 |
! |
7821 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7822 |
warnUnusedVars |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7823 |
^ parserFlags warnUnusedVars |
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 |
|
1160 | 7826 |
warnUnusedVars:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1632
diff
changeset
|
7827 |
parserFlags warnUnusedVars:aBoolean. |
0 | 7828 |
! ! |
7829 |
||
84 | 7830 |
!Parser methodsFor:'statistic'! |
7831 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7832 |
rememberClassVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7833 |
readClassVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7834 |
readClassVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7835 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7836 |
readClassVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7837 |
self rememberClassVarUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7838 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7839 |
|
141 | 7840 |
rememberClassVarUsed:name |
7841 |
usedClassVars isNil ifTrue:[ |
|
1576 | 7842 |
usedClassVars := Set new |
141 | 7843 |
]. |
7844 |
usedClassVars add:name. |
|
7845 |
self rememberVariableUsed:name |
|
7846 |
! |
|
7847 |
||
7848 |
rememberGlobalUsed:name |
|
7849 |
usedGlobals isNil ifTrue:[ |
|
1576 | 7850 |
usedGlobals := Set new |
141 | 7851 |
]. |
7852 |
usedGlobals add:name. |
|
7853 |
self rememberVariableUsed:name |
|
7854 |
! |
|
7855 |
||
1077
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7856 |
rememberInstVarRead:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7857 |
readInstVars isNil ifTrue:[ |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7858 |
readInstVars := Set new |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7859 |
]. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7860 |
readInstVars add:name. |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7861 |
self rememberVariableUsed:name |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7862 |
! |
e34f711bd1d1
#readInstVars & #readClassVars
Claus Gittinger <cg@exept.de>
parents:
1070
diff
changeset
|
7863 |
|
141 | 7864 |
rememberInstVarUsed:name |
7865 |
usedInstVars isNil ifTrue:[ |
|
1576 | 7866 |
usedInstVars := Set new |
141 | 7867 |
]. |
7868 |
usedInstVars add:name. |
|
7869 |
self rememberVariableUsed:name |
|
7870 |
! |
|
7871 |
||
977
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7872 |
rememberLocalUsed:name |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7873 |
usedLocalVars isNil ifTrue:[ |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7874 |
usedLocalVars := Set new |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7875 |
]. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7876 |
usedLocalVars add:name. |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7877 |
|
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7878 |
! |
c1afbaf48a23
remember used & modified local vars;
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
7879 |
|
1231 | 7880 |
rememberReturnedValue:anExpressionNode |
7881 |
|expr| |
|
7882 |
||
7883 |
returnedValues isNil ifTrue:[returnedValues := Set new]. |
|
7884 |
||
7885 |
expr := anExpressionNode. |
|
7886 |
expr isAssignment ifTrue:[ |
|
7887 |
expr := expr expression. |
|
7888 |
]. |
|
7889 |
(expr isConstant or:[expr isSelf]) ifTrue:[ |
|
7890 |
returnedValues add:expr |
|
7891 |
]. |
|
7892 |
! |
|
7893 |
||
84 | 7894 |
rememberSelectorUsed:sel |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7895 |
messagesSent isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7896 |
messagesSent := IdentitySet new. |
84 | 7897 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7898 |
messagesSent add:sel |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7899 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7900 |
|
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7901 |
rememberSelectorUsed:sel receiver:receiverNode |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7902 |
self rememberSelectorUsed:sel. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7903 |
receiverNode isSuper ifTrue:[ |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7904 |
self rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7905 |
] ifFalse:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7906 |
receiverNode isSelf ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7907 |
self rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7908 |
]. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7909 |
]. |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7910 |
! |
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7911 |
|
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7912 |
rememberSelectorUsedInSelfSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7913 |
messagesSentToSelf isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7914 |
messagesSentToSelf := IdentitySet new. |
1060
9978f9d22dde
more queries (remember super messages)
Claus Gittinger <cg@exept.de>
parents:
1052
diff
changeset
|
7915 |
]. |
1082
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7916 |
messagesSentToSelf add:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7917 |
! |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7918 |
|
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7919 |
rememberSelectorUsedInSuperSend:sel |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7920 |
messagesSentToSuper isNil ifTrue:[ |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7921 |
messagesSentToSuper := IdentitySet new. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7922 |
]. |
f795099895c5
keep track of messages sent to self (for checker)
Claus Gittinger <cg@exept.de>
parents:
1078
diff
changeset
|
7923 |
messagesSentToSuper add:sel |
84 | 7924 |
! |
7925 |
||
1064
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7926 |
rememberSymbolUsed:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7927 |
usedSymbols isNil ifTrue:[ |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7928 |
usedSymbols := IdentitySet new. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7929 |
]. |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7930 |
usedSymbols add:aSymbol |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7931 |
! |
ecd50cdfb881
added #usedSymbols statistic
Claus Gittinger <cg@exept.de>
parents:
1063
diff
changeset
|
7932 |
|
84 | 7933 |
rememberVariableUsed:name |
7934 |
usedVars isNil ifTrue:[ |
|
1576 | 7935 |
usedVars := Set new |
84 | 7936 |
]. |
7937 |
usedVars add:name |
|
7938 |
! ! |
|
7939 |
||
1340 | 7940 |
!Parser::ParseError methodsFor:'accessing'! |
7941 |
||
1386 | 7942 |
description |
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7943 |
|s| |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7944 |
|
1461 | 7945 |
s := super description. |
7946 |
s last isSeparator ifFalse:[ |
|
7947 |
errorMessage size > 0 ifTrue:[ |
|
7948 |
s := s , ' ' |
|
7949 |
] |
|
7950 |
]. |
|
7951 |
s := s , (errorMessage ? ''). |
|
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7952 |
lineNumber notNil ifTrue:[ |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7953 |
s := s , ' [' , lineNumber asString , ']' |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7954 |
]. |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7955 |
^ s |
1386 | 7956 |
! |
7957 |
||
1340 | 7958 |
endPosition |
7959 |
^ endPosition |
|
7960 |
! |
|
7961 |
||
7962 |
errorMessage |
|
7963 |
^ errorMessage |
|
7964 |
! |
|
7965 |
||
1460 | 7966 |
errorMessage:errorMessageArg startPosition:startPositionArg |
7967 |
errorMessage := errorMessageArg. |
|
7968 |
startPosition := startPositionArg. |
|
7969 |
! |
|
7970 |
||
1340 | 7971 |
errorMessage:errorMessageArg startPosition:startPositionArg endPosition:endPositionArg |
7972 |
errorMessage := errorMessageArg. |
|
7973 |
startPosition := startPositionArg. |
|
7974 |
endPosition := endPositionArg. |
|
7975 |
! |
|
7976 |
||
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7977 |
lineNumber:something |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7978 |
lineNumber := something. |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7979 |
! |
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
7980 |
|
1340 | 7981 |
parser |
7982 |
^ originator |
|
7983 |
! |
|
7984 |
||
7985 |
startPosition |
|
7986 |
^ startPosition |
|
7987 |
! ! |
|
7988 |
||
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7989 |
!Parser::UndefinedVariableNotification methodsFor:'accessing'! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7990 |
|
1514 | 7991 |
description |
1516 | 7992 |
^ 'undefined variable: ' , self variableName |
1514 | 7993 |
! |
7994 |
||
1399
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7995 |
parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7996 |
"return the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7997 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7998 |
^ parser |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
7999 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8000 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8001 |
parser:something |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8002 |
"set the value of the instance variable 'parser' (automatically generated)" |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8003 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8004 |
parser := something. |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8005 |
! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8006 |
|
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8007 |
variableName |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8008 |
^ parameter |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8009 |
! ! |
95b2eaa4e457
undefinedVariableNotification fix
Claus Gittinger <cg@exept.de>
parents:
1398
diff
changeset
|
8010 |
|
358
78b0d8954c49
removed possible conflict between #classVarNames here and in Class.
Claus Gittinger <cg@exept.de>
parents:
354
diff
changeset
|
8011 |
!Parser class methodsFor:'documentation'! |
148 | 8012 |
|
8013 |
version |
|
1643 | 8014 |
^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.472 2005-12-02 11:28:55 cg Exp $' |
148 | 8015 |
! ! |
1322
da25e31f423c
autodefine workspace variables
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
8016 |
|
141 | 8017 |
Parser initialize! |