author | Claus Gittinger <cg@exept.de> |
Thu, 30 May 2019 12:03:06 +0200 | |
changeset 4425 | 87133d993838 |
parent 4422 | a06688034985 |
child 4426 | 49123df91ffa |
permissions | -rw-r--r-- |
4414 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
4 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4188 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1073 | 14 |
"{ Package: 'stx:libcomp' }" |
15 |
||
3551 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
Object subclass:#Scanner |
1595 | 19 |
instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition |
2612
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
20 |
tokenValue tokenName tokenLineNr tokenLastEndPosition hereChar |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
21 |
peekChar peekChar2 requestor exitBlock errorFlag ignoreErrors |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
22 |
ignoreWarnings saveComments currentComments collectedSource |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
23 |
scanColonAsKeyword outStream outCol inArrayLiteral lastDirective |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
24 |
parserFlags didWarnAboutSTXSpecialComment |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
25 |
didWarnAboutUnderscoreInIdentifier didWarnAboutOldStyleAssignment |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
26 |
didWarnAboutDollarInIdentifier didWarnAboutPeriodInSymbol |
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
27 |
unicodeActions' |
4334 | 28 |
classVariableNames:'DefaultActionArray DefaultTypeArray DefaultUnicodeActions |
29 |
EmptySourceNotificationSignal' |
|
1595 | 30 |
poolDictionaries:'' |
2485 | 31 |
category:'System-Compiler' |
0 | 32 |
! |
33 |
||
2484 | 34 |
Scanner class instanceVariableNames:'TypeArray ActionArray UnicodeActions' |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
35 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
36 |
" |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
37 |
No other class instance variables are inherited by this class. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
38 |
" |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
39 |
! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
40 |
|
648 | 41 |
Object subclass:#Comment |
3551 | 42 |
instanceVariableNames:'commentType commentString startPosition endPosition' |
1595 | 43 |
classVariableNames:'' |
44 |
poolDictionaries:'' |
|
45 |
privateIn:Scanner |
|
648 | 46 |
! |
47 |
||
1596 | 48 |
Object subclass:#Directive |
49 |
instanceVariableNames:'' |
|
50 |
classVariableNames:'' |
|
51 |
poolDictionaries:'' |
|
52 |
privateIn:Scanner |
|
53 |
! |
|
54 |
||
55 |
Scanner::Directive subclass:#ClassDirective |
|
56 |
instanceVariableNames:'className' |
|
57 |
classVariableNames:'' |
|
58 |
poolDictionaries:'' |
|
59 |
privateIn:Scanner::Directive |
|
60 |
! |
|
61 |
||
62 |
Scanner::Directive::ClassDirective subclass:#ClassHintDirective |
|
63 |
instanceVariableNames:'' |
|
64 |
classVariableNames:'' |
|
65 |
poolDictionaries:'' |
|
66 |
privateIn:Scanner::Directive |
|
67 |
! |
|
68 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
69 |
!Scanner class methodsFor:'documentation'! |
20 | 70 |
|
901 | 71 |
bugs |
72 |
" |
|
73 |
array constant containing keywords as in: |
|
4188 | 74 |
#( |
75 |
foo:bar: |
|
76 |
fee:baz: |
|
77 |
) |
|
901 | 78 |
|
79 |
is scanned as 4-element array containing ( #foo: #bar: #fee: #baz: ) |
|
80 |
this MUST be fixed. |
|
81 |
||
82 |
workaround: |
|
4188 | 83 |
#( |
84 |
#'foo:bar:' |
|
85 |
#'fee:baz:' |
|
86 |
) |
|
87 |
||
901 | 88 |
" |
89 |
! |
|
90 |
||
20 | 91 |
copyright |
92 |
" |
|
93 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4188 | 94 |
All Rights Reserved |
20 | 95 |
|
96 |
This software is furnished under a license and may be used |
|
97 |
only in accordance with the terms of that license and with the |
|
98 |
inclusion of the above copyright notice. This software may not |
|
99 |
be provided or otherwise made available to, or used by, any |
|
100 |
other person. No title to or ownership of the software is |
|
101 |
hereby transferred. |
|
102 |
" |
|
103 |
! |
|
104 |
||
105 |
documentation |
|
106 |
" |
|
107 |
Scanner reads from a stream and returns individual smalltalk tokens |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
108 |
Its main method is #nextToken, which reads and returns the next token |
4188 | 109 |
Possibly placing additional information (such as tokenValue) into |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
110 |
instance variables as a side effect. |
75 | 111 |
|
4188 | 112 |
TODO: |
113 |
some testers noticed that ST-80's scanner methods are called |
|
114 |
xLetter, xDigit etc. For code using these (internals), the nextNumber, |
|
115 |
nextIdentifier etc. methods should be renamed. |
|
116 |
(to me, these seem to be internal private methods; |
|
117 |
their public use is not a good idea ..) |
|
118 |
||
119 |
Scanner is typically subclassed for parsing and #nextToken |
|
120 |
invoked via #self-sends. |
|
121 |
This should be changed and scanner ought to be an instance variable |
|
122 |
of Parser - this allows more flexible use of the scanner/parser |
|
123 |
framework (i.e. changing the scanner without affecting the parser). |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
124 |
|
1302 | 125 |
Extensions: |
4188 | 126 |
this scanner allows for 3-character binary selectors. |
127 |
also, # is a valid selector. (however, ## is currently scanned as a symbol literal). |
|
1302 | 128 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
129 |
[author:] |
4188 | 130 |
Claus Gittinger |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
131 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
132 |
[see also:] |
4188 | 133 |
Parser |
20 | 134 |
" |
41 | 135 |
! ! |
136 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
137 |
!Scanner class methodsFor:'initialization'! |
33 | 138 |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
139 |
binarySelectorCharacters |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
140 |
"return a collection of characters which are allowed in binary selectors" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
141 |
|
3643 | 142 |
^ Method binarySelectorCharacters. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
143 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
144 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
145 |
extendedBinarySelectorCharacters |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
146 |
"return a collection of characters which are optionally allowed in binary selectors" |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
147 |
|
4414 | 148 |
"/ ^ '±×·÷«»'. |
2487 | 149 |
^ String |
4188 | 150 |
with:(Character value:16rB1) "/ plus-minus |
151 |
with:(Character value:16rD7) "/ times |
|
152 |
with:(Character value:16rB7) "/ centered dot |
|
153 |
with:(Character value:16rF7) "/ divide |
|
154 |
with:(Character value:16rAB) "/ << |
|
155 |
with:(Character value:16rBB). "/ >> |
|
4042 | 156 |
|
157 |
"Modified (comment): / 17-11-2016 / 09:22:42 / cg" |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
158 |
! |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
159 |
|
33 | 160 |
setupActions |
4042 | 161 |
"initialize the scanner's actionTables - these are used to dispatch |
2141 | 162 |
into scanner methods as characters are read. |
163 |
Compatibility note: in previous versions, these tables used to be kept |
|
164 |
in classVariables, which made reuse hard as subclasses had no easy way of |
|
165 |
defining their own tables. These are now class instance variables." |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
166 |
|
4157 | 167 |
|block actionArray typeArray unicodeActions unicodeTypes| |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
168 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
169 |
actionArray := Array new:256. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
170 |
typeArray := Array new:256. |
2484 | 171 |
unicodeActions := Dictionary new. |
4157 | 172 |
unicodeTypes := Dictionary new. |
33 | 173 |
|
1303 | 174 |
"/ TODO: later versions should be configurable w.r.t separators. |
175 |
"/ #(9 10 12 13 26 32) do: [:i | TypeArray at:(i+1) put: #separator]. |
|
33 | 176 |
block := [:s :char | s nextNumber]. |
3521 | 177 |
actionArray from:($0 codePoint) to:($9 codePoint) put:block. |
33 | 178 |
|
87 | 179 |
block := [:s :char | s nextSpecial]. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
180 |
self binarySelectorCharacters do:[:binop | |
4291 | 181 |
|codePoint| |
182 |
codePoint := binop codePoint. |
|
183 |
codePoint <= typeArray size ifTrue:[ |
|
184 |
typeArray at:codePoint put:#special. |
|
185 |
actionArray at:codePoint put:block |
|
186 |
] ifFalse:[ |
|
187 |
unicodeTypes at:codePoint put:#extendedSpecial. |
|
188 |
unicodeActions at:codePoint put:block |
|
189 |
]. |
|
87 | 190 |
]. |
4188 | 191 |
|
2146 | 192 |
block := [:s :char | s nextExtendedSpecial:char]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
193 |
self extendedBinarySelectorCharacters do:[:binop | |
4291 | 194 |
|codePoint| |
195 |
codePoint := binop codePoint. |
|
196 |
codePoint <= typeArray size ifTrue:[ |
|
197 |
typeArray at:codePoint put:#extendedSpecial. |
|
198 |
actionArray at:codePoint put:block |
|
199 |
] ifFalse:[ |
|
200 |
unicodeTypes at:codePoint put:#extendedSpecial. |
|
201 |
unicodeActions at:codePoint put:block |
|
202 |
]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
203 |
]. |
87 | 204 |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
205 |
"/ that one is a special case (both binarySelector AND syntax). |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
206 |
typeArray at:($| codePoint) put:nil. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
207 |
|
87 | 208 |
block := [:s :char | s nextToken:char]. |
1510
875c90576897
Fix duplicate assignment to ActionArray for sh
Stefan Vogel <sv@exept.de>
parents:
1509
diff
changeset
|
209 |
';.^|()[]{}' do:[:ch | |
4291 | 210 |
actionArray at:(ch codePoint) put:block |
87 | 211 |
]. |
212 |
||
33 | 213 |
block := [:s :char | s nextIdentifier]. |
3521 | 214 |
actionArray from:($a codePoint) to:($z codePoint) put:block. |
215 |
actionArray from:($A codePoint) to:($Z codePoint) put:block. |
|
33 | 216 |
|
217 |
"kludge: action is characterToken, but type is special" |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
218 |
typeArray at:($| codePoint) put:#special. |
33 | 219 |
|
80 | 220 |
"kludge: action is nextColonOrAssign, but type is special" |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
221 |
typeArray at:($: codePoint) put:#special. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
222 |
|
4334 | 223 |
actionArray at:($' codePoint) put:[:s :char | s nextString:char escapeStyle:nil]. |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
224 |
actionArray at:($$ codePoint) put:[:s :char | s nextCharacter]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
225 |
actionArray at:($# codePoint) put:[:s :char | s nextHash]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
226 |
actionArray at:($!! codePoint) put:[:s :char | s nextExcla]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
227 |
actionArray at:($% codePoint) put:[:s :char | s nextPrimitive]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
228 |
actionArray at:($: codePoint) put:[:s :char | s nextColonOrAssign]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
229 |
actionArray at:($_ codePoint) put:[:s :char | s nextUnderline]. |
4291 | 230 |
"/ an experiment to allow 'special' identifiers (in backticks, allowing arbitrary characters inside) |
231 |
"/ actionArray at:($` codePoint) put:[:s :char | s nextBacktickIdentifier]. |
|
232 |
||
2486 | 233 |
unicodeActions at:2190 "<- left arrow" put:[:s :char | s nextAssignmentArrow]. |
2484 | 234 |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
235 |
ActionArray := DefaultActionArray := actionArray. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
236 |
TypeArray := DefaultTypeArray := typeArray. |
2484 | 237 |
UnicodeActions := DefaultUnicodeActions := unicodeActions. |
33 | 238 |
|
239 |
" |
|
240 |
Scanner setupActions |
|
2182 | 241 |
Scanner withAllSubclassesDo:[:cls | cls setupActions ] |
33 | 242 |
" |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
243 |
|
4157 | 244 |
"Modified: / 02-07-2017 / 01:11:27 / cg" |
4334 | 245 |
"Modified: / 08-02-2019 / 19:13:32 / Claus Gittinger" |
33 | 246 |
! ! |
247 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
248 |
!Scanner class methodsFor:'instance creation'! |
141 | 249 |
|
250 |
for:aStringOrStream |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
251 |
"create & return a new scanner reading from aStringOrStream" |
141 | 252 |
|
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
253 |
^ self basicNew initializeFor:aStringOrStream |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
254 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
255 |
"Modified: 23.5.1997 / 12:08:42 / cg" |
854 | 256 |
! |
257 |
||
4188 | 258 |
new |
854 | 259 |
"create & return a new scanner" |
260 |
||
859 | 261 |
^ self basicNew initialize. |
854 | 262 |
|
263 |
"Modified: / 23.5.1997 / 12:08:42 / cg" |
|
264 |
"Created: / 26.5.1999 / 12:02:16 / stefan" |
|
141 | 265 |
! ! |
266 |
||
717 | 267 |
!Scanner class methodsFor:'Signal constants'! |
268 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
269 |
doNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
270 |
^ DoNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
271 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
272 |
|
717 | 273 |
emptySourceNotificationSignal |
274 |
^ EmptySourceNotificationSignal |
|
275 |
||
276 |
"Created: / 16.5.1998 / 15:55:14 / cg" |
|
277 |
! ! |
|
278 |
||
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
279 |
!Scanner class methodsFor:'accessing'! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
280 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
281 |
actionArray |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
282 |
ActionArray isNil ifTrue:[ |
4188 | 283 |
self setupActions |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
284 |
]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
285 |
^ ActionArray ? DefaultActionArray |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
286 |
! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
287 |
|
2146 | 288 |
flushActionArray |
289 |
ActionArray := DefaultActionArray := nil. |
|
290 |
TypeArray := DefaultTypeArray := nil. |
|
4320 | 291 |
UnicodeActions := DefaultUnicodeActions := nil. |
292 |
||
2146 | 293 |
" |
294 |
Scanner flushActionArray |
|
295 |
Parser flushActionArray |
|
296 |
ByteCodeCompiler flushActionArray |
|
297 |
Explainer flushActionArray |
|
298 |
" |
|
4320 | 299 |
|
300 |
"Modified: / 11-12-2018 / 11:25:53 / Claus Gittinger" |
|
2146 | 301 |
! |
302 |
||
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
303 |
typeArray |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
304 |
TypeArray isNil ifTrue:[ |
4188 | 305 |
self setupActions |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
306 |
]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
307 |
^ TypeArray ? DefaultTypeArray |
2484 | 308 |
! |
309 |
||
310 |
unicodeActions |
|
311 |
UnicodeActions isNil ifTrue:[ |
|
4188 | 312 |
self setupActions |
2484 | 313 |
]. |
314 |
^ UnicodeActions ? DefaultUnicodeActions |
|
315 |
||
316 |
"Created: / 25-03-2011 / 13:57:34 / cg" |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
317 |
! ! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
318 |
|
717 | 319 |
!Scanner class methodsFor:'class initialization'! |
320 |
||
321 |
initialize |
|
322 |
"initialize the classes defaults. Typically, these are changed |
|
323 |
later in the 'private.rc' file." |
|
324 |
||
325 |
EmptySourceNotificationSignal isNil ifTrue:[ |
|
4188 | 326 |
EmptySourceNotificationSignal := QuerySignal new mayProceed:true. |
327 |
EmptySourceNotificationSignal notifierString:'empty source given to evaluate'. |
|
328 |
EmptySourceNotificationSignal nameClass:self message:#emptySourceNotificationSignal. |
|
717 | 329 |
]. |
330 |
||
331 |
" |
|
332 |
self initialize |
|
333 |
" |
|
334 |
||
335 |
"Modified: / 16.5.1998 / 15:55:41 / cg" |
|
336 |
! ! |
|
337 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
338 |
!Scanner class methodsFor:'defaults'! |
141 | 339 |
|
608 | 340 |
allowDollarInIdentifier |
4304 | 341 |
<resource: #obsolete> |
608 | 342 |
"return true, if $-characters are allowed in identifiers. |
343 |
Notice, that dollars are NEVER allowed as the first character in an identifier." |
|
344 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
345 |
^ ParserFlags allowDollarInIdentifier |
608 | 346 |
|
347 |
"Created: 7.9.1997 / 01:32:18 / cg" |
|
348 |
"Modified: 7.9.1997 / 01:39:44 / cg" |
|
349 |
! |
|
350 |
||
351 |
allowDollarInIdentifier:aBoolean |
|
352 |
"this allows turning on/off $-characters in identifiers. |
|
353 |
Notice, that dollars are NEVER allowed as the first character in an identifier. |
|
354 |
If turned off (the default), dollars are not allowed in identifiers, |
|
355 |
but instead are scanned as character-constant prefix. |
|
356 |
If turned on, dollars are in identifiers are allowed, while extra |
|
357 |
dollars are still scanned as constant character prefix. |
|
358 |
If you have to fileIn old VW-Vsn2.x classes, turn this off |
|
359 |
before filing them in; i.e.: |
|
4188 | 360 |
Compiler allowDollarInIdentifiers:false" |
608 | 361 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
362 |
ParserFlags allowDollarInIdentifier:aBoolean. |
608 | 363 |
|
364 |
"Created: 7.9.1997 / 01:34:49 / cg" |
|
365 |
"Modified: 7.9.1997 / 01:39:30 / cg" |
|
366 |
! |
|
367 |
||
1226 | 368 |
allowDolphinExtensions |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
369 |
"return true, if ##(..) computed literal Arrays are allowed" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
370 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
371 |
^ ParserFlags allowDolphinExtensions |
1226 | 372 |
! |
373 |
||
374 |
allowDolphinExtensions:aBoolean |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
375 |
"this allows turning on/off support for computed literal Arrays ##(..) as in dolphin. |
1226 | 376 |
If you want to fileIn Dolphin classes, enable this with: |
4188 | 377 |
Compiler allowDolphinComputedArrays:true" |
1226 | 378 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
379 |
ParserFlags allowDolphinExtensions:aBoolean. |
1226 | 380 |
|
381 |
" |
|
382 |
self allowDolphinExtensions:true |
|
383 |
self allowDolphinExtensions:false |
|
384 |
" |
|
385 |
! |
|
386 |
||
1572 | 387 |
allowLiteralNameSpaceSymbols |
4304 | 388 |
<resource: #obsolete> |
1572 | 389 |
"return true, if literal nameSpace symbols are allowed (#foo::bar) are allowed" |
390 |
||
3327 | 391 |
^ ParserFlags allowLiteralNameSpaceSymbols |
1572 | 392 |
! |
393 |
||
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
394 |
allowOldStyleAssignment |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
395 |
"return true, if underscore-assignment (pre ST-80v4 syntax) are to be allowed" |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
396 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
397 |
^ ParserFlags allowOldStyleAssignment |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
398 |
! |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
399 |
|
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
400 |
allowOldStyleAssignment:aBoolean |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
401 |
"this allows turning on/off recognition of underscore-assignment (pre ST-80v4 syntax). |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
402 |
You must turn this off, if code with variables named '_' is to be filedIn" |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
403 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
404 |
ParserFlags allowOldStyleAssignment:aBoolean |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
405 |
! |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
406 |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
407 |
allowQualifiedNames |
4304 | 408 |
<resource: #obsolete> |
4303 | 409 |
"return true, if '#{..}' and 'namespace.varName' qualified names are allowed" |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
410 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
411 |
^ ParserFlags allowQualifiedNames |
4303 | 412 |
|
413 |
"Modified (comment): / 23-09-2018 / 01:08:26 / Claus Gittinger" |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
414 |
! |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
415 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
416 |
allowQualifiedNames:aBoolean |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
417 |
"this allows turning on/off support for qualifiedNames #{ .., } as in vw3. |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
418 |
If you want to fileIn vw3 or later classes, enable this with: |
4188 | 419 |
Compiler allowQualifiedNames:true |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
420 |
Notice, that qualified names are not really supported semantically |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
421 |
(they are parsed, but treated like regular globals) |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
422 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
423 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
424 |
ParserFlags allowQualifiedNames:aBoolean. |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
425 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
426 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
427 |
self allowQualifiedNames:true |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
428 |
self allowQualifiedNames:false |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
429 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
430 |
! |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
431 |
|
895 | 432 |
allowSqueakExtensions |
4304 | 433 |
<resource: #obsolete> |
1530 | 434 |
"return true, if support for squeak extensions |
4188 | 435 |
computed arrays { .., } |
436 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
1530 | 437 |
is enabled." |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
438 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
439 |
^ ParserFlags allowSqueakExtensions |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
440 |
! |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
441 |
|
895 | 442 |
allowSqueakExtensions:aBoolean |
1530 | 443 |
"this allows turning on/off support for squeak extensions: |
4188 | 444 |
computed arrays { .., } |
445 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
1530 | 446 |
|
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
447 |
If you want to fileIn Squeak classes, enable this with: |
4188 | 448 |
Compiler allowSqueakComputedArrays:true" |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
449 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
450 |
ParserFlags allowSqueakExtensions:aBoolean. |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
451 |
|
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
452 |
" |
895 | 453 |
self allowSqueakExtensions:true |
454 |
self allowSqueakExtensions:false |
|
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
455 |
" |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
456 |
! |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
457 |
|
141 | 458 |
allowUnderscoreInIdentifier |
4304 | 459 |
<resource: #obsolete> |
141 | 460 |
"return true, if underscores are allowed in identifiers" |
461 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
462 |
^ ParserFlags allowUnderscoreInIdentifier |
141 | 463 |
! |
464 |
||
465 |
allowUnderscoreInIdentifier:aBoolean |
|
466 |
"this allows turning on/off underscores in identifiers. |
|
467 |
If turned off (the default), underscores are not allowed in identifiers, |
|
468 |
but instead scanned as assignment character (old ST/80 syntax). |
|
469 |
If turned on, underscores are in identifiers are allowed, while extra |
|
470 |
underscores are still scanned as assignment. |
|
4188 | 471 |
If you have to fileIn old VW-Vsn2.x classes, |
608 | 472 |
turn them off with: |
4188 | 473 |
Compiler allowUnderscoreInIdentifiers:false" |
141 | 474 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
475 |
ParserFlags allowUnderscoreInIdentifier:aBoolean. |
608 | 476 |
|
477 |
"Modified: 7.9.1997 / 01:35:19 / cg" |
|
141 | 478 |
! |
479 |
||
1644
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
480 |
maxBinarySelectorSize |
3643 | 481 |
^ Method maxBinarySelectorSize |
1644
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
482 |
! |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
483 |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
484 |
warnCommonMistakes |
4304 | 485 |
<resource: #obsolete> |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
486 |
"return true, if common beginners mistakes are to be warned about" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
487 |
|
1663 | 488 |
^ ParserFlags warnCommonMistakes |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
489 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
490 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
491 |
warnCommonMistakes:aBoolean |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
492 |
"this allows turning on/off warnings about common beginners mistakes. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
493 |
Those are not really errors in the strict sense, but often lead to |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
494 |
run time errors later. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
495 |
Examples are: expr or:expr2, where expr2 is not a block. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
496 |
If you get bored by those warnings, turn them off by adding |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
497 |
a line as: |
4188 | 498 |
Compiler warnCommonMistakes:false |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
499 |
in your 'private.rc' file" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
500 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
501 |
ParserFlags warnCommonMistakes:aBoolean |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
502 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
503 |
|
608 | 504 |
warnDollarInIdentifier |
4304 | 505 |
<resource: #obsolete> |
608 | 506 |
"return true, if $-characters in identifiers are to be warned about" |
507 |
||
1663 | 508 |
^ ParserFlags warnDollarInIdentifier |
608 | 509 |
|
510 |
"Created: 7.9.1997 / 01:36:17 / cg" |
|
511 |
! |
|
512 |
||
513 |
warnDollarInIdentifier:aBoolean |
|
514 |
"this allows turning on/off warnings about $-characters in identifiers. |
|
515 |
You may find those warnings useful, to make certain that your code |
|
516 |
is portable to other smalltalk versions, which do not allow this |
|
517 |
(i.e. VW releases 2.x and maybe others). |
|
518 |
Notice, that dollars are NEVER allowed as the first character in an identifier. |
|
519 |
If you get bored by those warnings, turn them off by adding |
|
520 |
a line as: |
|
4188 | 521 |
Compiler warnDollarInIdentifier:false |
608 | 522 |
in your 'private.rc' file" |
523 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
524 |
ParserFlags warnDollarInIdentifier:aBoolean |
608 | 525 |
|
526 |
"Created: 7.9.1997 / 01:37:42 / cg" |
|
527 |
"Modified: 7.9.1997 / 01:40:02 / cg" |
|
528 |
! |
|
529 |
||
141 | 530 |
warnOldStyleAssignment |
4304 | 531 |
<resource: #obsolete> |
141 | 532 |
"return true, if underscore-assignment (pre ST-80v4 syntax) are to be warned about" |
533 |
||
1663 | 534 |
^ ParserFlags warnOldStyleAssignment |
141 | 535 |
! |
536 |
||
537 |
warnOldStyleAssignment:aBoolean |
|
538 |
"this allows turning on/off warnings about underscore-assignment (pre ST-80v4 syntax). |
|
539 |
If you get bored by those warnings, turn them off by adding |
|
540 |
a line as: |
|
4188 | 541 |
Compiler warnOldStyleAssignment:false |
141 | 542 |
in your 'private.rc' file" |
543 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
544 |
ParserFlags warnOldStyleAssignment:aBoolean |
141 | 545 |
! |
546 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
547 |
warnPossibleIncompatibilities |
4304 | 548 |
<resource: #obsolete> |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
549 |
"return true, if possible incompatibilities (with other ST systems) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
550 |
are to be warned about" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
551 |
|
1663 | 552 |
^ ParserFlags warnPossibleIncompatibilities |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
553 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
554 |
"Modified: 23.5.1997 / 12:02:02 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
555 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
556 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
557 |
warnPossibleIncompatibilities:aBoolean |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
558 |
"this turns warnings about possible incompatibilities (with other ST systems) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
559 |
on or off. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
560 |
If you get bored by those warnings, turn them off by adding |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
561 |
a line as: |
4188 | 562 |
Compiler warnPossibleIncompatibilities:false |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
563 |
in your 'private.rc' file." |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
564 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
565 |
ParserFlags warnPossibleIncompatibilities:aBoolean |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
566 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
567 |
"Created: 23.5.1997 / 12:02:45 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
568 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
569 |
|
141 | 570 |
warnSTXSpecials |
4304 | 571 |
<resource: #obsolete> |
141 | 572 |
"return true, if ST/X specials are to be warned about" |
573 |
||
1663 | 574 |
^ ParserFlags warnSTXSpecials |
141 | 575 |
! |
576 |
||
577 |
warnSTXSpecials:aBoolean |
|
578 |
"this allows turning on/off warnings about stx specials. |
|
579 |
If you get bored by those warnings, turn them off by adding |
|
580 |
a line as: |
|
4188 | 581 |
Compiler warnSTXSpecials:false |
141 | 582 |
in your 'private.rc' file" |
583 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
584 |
ParserFlags warnSTXSpecials:aBoolean |
141 | 585 |
! |
586 |
||
587 |
warnUnderscoreInIdentifier |
|
4304 | 588 |
<resource: #obsolete> |
141 | 589 |
"return true, if underscores in identifiers are to be warned about" |
590 |
||
1663 | 591 |
^ ParserFlags warnUnderscoreInIdentifier |
141 | 592 |
! |
593 |
||
594 |
warnUnderscoreInIdentifier:aBoolean |
|
595 |
"this allows turning on/off warnings about underscores in identifiers. |
|
608 | 596 |
You may find those warnings useful, to make certain that your code |
597 |
is portable to other smalltalk versions, which do not allow this |
|
598 |
(i.e. VW releases 2.x). |
|
141 | 599 |
If you get bored by those warnings, turn them off by adding |
600 |
a line as: |
|
4188 | 601 |
Compiler warnUnderscoreInIdentifier:false |
141 | 602 |
in your 'private.rc' file" |
603 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
604 |
ParserFlags warnUnderscoreInIdentifier:aBoolean |
608 | 605 |
|
606 |
"Modified: 7.9.1997 / 01:37:13 / cg" |
|
141 | 607 |
! |
608 |
||
609 |
warnings |
|
610 |
"return true, if any warnings are to be shown" |
|
611 |
||
1663 | 612 |
^ ParserFlags warnings |
141 | 613 |
! |
614 |
||
615 |
warnings:aBoolean |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
616 |
"this allows turning on/off all warnings; the default is on. |
141 | 617 |
You can turn off warnings in your 'private.rc' file with |
4188 | 618 |
Compiler warnings:false |
141 | 619 |
" |
620 |
||
1663 | 621 |
ParserFlags warnings:aBoolean |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
622 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
623 |
"Modified: 23.5.1997 / 12:03:05 / cg" |
141 | 624 |
! ! |
625 |
||
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
626 |
!Scanner class methodsFor:'utility scanning'! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
627 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
628 |
scanNumberFrom:aStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
629 |
"utility - helper for Number>>readSmalltalkSyntaxFrom:" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
630 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
631 |
^ self basicNew scanNumberFrom:aStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
632 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
633 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
634 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
635 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
636 |
s := '12345abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
637 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
638 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
639 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
640 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
641 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
642 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
643 |
s := '16rffffxabcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
644 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
645 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
646 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
647 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
648 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
649 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
650 |
s := '1.2345abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
651 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
652 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
653 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
654 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
655 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
656 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
657 |
s := '1.abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
658 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
659 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
660 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
661 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
662 |
"Modified: / 18.6.1998 / 23:10:39 / cg" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
663 |
! ! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
664 |
|
1417 | 665 |
!Scanner methodsFor:'Compatibility-ST80'! |
98 | 666 |
|
667 |
endOfLastToken |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
668 |
"return the position of the token which was just read. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
669 |
This method was required by some PD program. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
670 |
It is not maintained and may be removed without notice." |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
671 |
|
3268 | 672 |
^ source position + 1 |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
673 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
674 |
"Modified: 23.5.1997 / 12:14:27 / cg" |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
675 |
! |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
676 |
|
4188 | 677 |
scan:aStringOrStream |
630 | 678 |
"initialize the scanner: set the source-stream and |
679 |
preread the first token" |
|
680 |
||
681 |
self initializeFor:aStringOrStream. |
|
682 |
self nextToken |
|
683 |
||
684 |
"Created: / 30.10.1997 / 16:59:39 / cg" |
|
685 |
! |
|
686 |
||
2139 | 687 |
scanDoing:aBlock |
688 |
"scan, evaluating aBlock for every scanned token." |
|
689 |
||
690 |
|t| |
|
691 |
||
692 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
4188 | 693 |
aBlock value:t. |
2139 | 694 |
]. |
695 |
! |
|
696 |
||
630 | 697 |
scanToken |
698 |
"read the next token from my input stream" |
|
699 |
||
700 |
^ self nextToken |
|
701 |
||
702 |
"Created: / 30.10.1997 / 17:00:16 / cg" |
|
703 |
! |
|
704 |
||
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
705 |
scanTokens:aStringOrStream |
3056 | 706 |
"return a collection of symbolic tokens from the passed input, |
707 |
similar to what would be read when reading '#( <string> )'" |
|
708 |
||
709 |
|tokens readArray| |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
710 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
711 |
self initializeFor:aStringOrStream. |
3056 | 712 |
|
4188 | 713 |
readArray := |
3056 | 714 |
[ |
715 |
|elements| |
|
716 |
||
717 |
elements := OrderedCollection new. |
|
4188 | 718 |
[ (token ~~ $) ) and:[ token notNil ] ] whileTrue:[ |
3056 | 719 |
token == $( ifTrue:[ |
720 |
self nextToken. |
|
721 |
elements add:(readArray value) |
|
722 |
] ifFalse:[ |
|
723 |
elements add:token. |
|
724 |
]. |
|
725 |
self nextToken. |
|
726 |
]. |
|
727 |
elements asArray |
|
728 |
]. |
|
729 |
||
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
730 |
tokens := OrderedCollection new. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
731 |
self nextToken. |
3056 | 732 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
733 |
[token notNil] whileTrue:[ |
4189 | 734 |
token == $( ifTrue:[ |
735 |
self nextToken. |
|
736 |
tokens add:(readArray value) |
|
737 |
] ifFalse:[ |
|
738 |
tokens add:token |
|
739 |
]. |
|
740 |
self nextToken |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
741 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
742 |
^ tokens |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
743 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
744 |
" |
4188 | 745 |
Scanner new scanTokens:'name ident #sym ''string'' 8r12' |
746 |
||
747 |
Scanner new scanTokens:'translate (200px 100px)' |
|
3056 | 748 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
749 |
Scanner new |
4189 | 750 |
scanTokens:'Boolean subclass:#True |
751 |
instanceVariableNames:'''' |
|
752 |
classVariableNames:'''' |
|
753 |
poolDictionaries:'''' |
|
754 |
category:''Kernel-Objects'' |
|
755 |
' |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
756 |
" |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
757 |
|
4188 | 758 |
"Modified: / 23-08-2017 / 23:58:03 / cg" |
98 | 759 |
! ! |
760 |
||
3730 | 761 |
!Scanner methodsFor:'Compatibility-Squeak'! |
762 |
||
763 |
notify:message at:codeStreamPosition |
|
764 |
"Squeak compatibility" |
|
4188 | 765 |
|
3730 | 766 |
^ self notifyWarning:message position:codeStreamPosition to:nil |
767 |
! ! |
|
768 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
769 |
!Scanner methodsFor:'accessing'! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
770 |
|
3755 | 771 |
atEnd |
772 |
"true if the scanned source stream's end has been reached" |
|
773 |
||
774 |
^ source atEnd |
|
775 |
! |
|
776 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
777 |
comments |
1584 | 778 |
^ currentComments ? #() |
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
779 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
780 |
|
1509 | 781 |
exitBlock:aBlock |
782 |
exitBlock := aBlock |
|
783 |
! |
|
784 |
||
4418 | 785 |
expectToken:expectedToken |
786 |
token = expectedToken ifFalse:[ |
|
787 |
self parseError:('expected "',expectedToken asString,'"'). |
|
788 |
^ false. |
|
789 |
]. |
|
790 |
self nextToken. |
|
791 |
^ true. |
|
792 |
||
793 |
"Created: / 25-05-2019 / 23:32:54 / Claus Gittinger" |
|
794 |
! |
|
795 |
||
2742
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
796 |
getCollectedComments |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
797 |
"retrieve the so far collected comments, reset comment collection" |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
798 |
|
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
799 |
|comments| |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
800 |
|
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
801 |
(comments := currentComments) isEmptyOrNil ifTrue:[^ nil]. |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
802 |
currentComments := nil. |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
803 |
^ comments |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
804 |
|
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
805 |
"Created: / 05-10-2011 / 10:09:01 / cg" |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
806 |
! |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
807 |
|
4414 | 808 |
hasError |
809 |
"return true if there where any errors (valid after parsing)" |
|
810 |
||
811 |
^ errorFlag |
|
812 |
||
813 |
"Created: / 23-05-2019 / 09:26:39 / Claus Gittinger" |
|
814 |
! |
|
815 |
||
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
816 |
inArrayLiteral:aBoolean |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
817 |
inArrayLiteral := aBoolean |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
818 |
! |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
819 |
|
859 | 820 |
lineNumber |
821 |
^ lineNr |
|
822 |
! |
|
823 |
||
795 | 824 |
newSourceStream:aStream |
825 |
source := aStream. |
|
826 |
self nextToken. |
|
827 |
||
828 |
"Created: / 29.10.1998 / 21:59:33 / cg" |
|
829 |
! |
|
830 |
||
1497 | 831 |
outStream:aStream |
4419 | 832 |
"if set, this stream gets the parsed comments as it is read. |
833 |
Useful to collect comments while reading" |
|
4418 | 834 |
|
1497 | 835 |
outStream := aStream. |
836 |
outCol := outCol ? 1. |
|
4418 | 837 |
|
4419 | 838 |
"Modified (comment): / 25-05-2019 / 23:45:57 / Claus Gittinger" |
1497 | 839 |
! |
840 |
||
3283 | 841 |
requestor |
842 |
^ requestor |
|
843 |
! |
|
844 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
845 |
saveComments:aBoolean |
1582
701f40070c8a
comments returns a collection
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
846 |
saveComments := aBoolean. |
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
847 |
|
2737 | 848 |
"Created: / 20-04-1996 / 20:03:56 / cg" |
849 |
"Modified: / 23-05-1997 / 12:14:49 / cg" |
|
850 |
"Modified (comment): / 04-10-2011 / 15:35:51 / cg" |
|
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
851 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
852 |
|
1242 | 853 |
sourcePosition |
3268 | 854 |
^ source position + 1 |
1242 | 855 |
! |
856 |
||
2678
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
857 |
sourcePositionWithoutPeeks |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
858 |
|
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
859 |
| pos | |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
860 |
pos := self sourcePosition. |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
861 |
peekChar2 notNil ifTrue:[^ pos - 2]. |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
862 |
peekChar notNil ifTrue:[^ pos - 1]. |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
863 |
^pos |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
864 |
|
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
865 |
"Created: / 25-08-2011 / 11:19:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
866 |
! |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
867 |
|
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
868 |
sourceStream |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
869 |
^ source |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
870 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
871 |
"Created: 20.4.1996 / 19:59:58 / cg" |
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
872 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
873 |
|
3334 | 874 |
tokenEndPosition |
3335 | 875 |
^ tokenPosition + tokenName size - 1. |
3334 | 876 |
|
877 |
"Created: / 22-10-2013 / 00:30:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3335 | 878 |
"Modified: / 22-10-2013 / 03:11:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3334 | 879 |
! |
880 |
||
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
881 |
tokenLineNr |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
882 |
^ tokenLineNr |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
883 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
884 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
885 |
tokenName |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
886 |
^ tokenName |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
887 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
888 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
889 |
tokenPosition |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
890 |
^ tokenPosition |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
891 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
892 |
|
3334 | 893 |
tokenStartPosition |
894 |
^ tokenPosition |
|
895 |
||
896 |
"Created: / 22-10-2013 / 00:29:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
897 |
! |
|
898 |
||
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
899 |
tokenType |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
900 |
^ tokenType |
1238 | 901 |
! |
902 |
||
903 |
tokenValue |
|
904 |
^ tokenValue |
|
905 |
||
906 |
"Created: / 21.12.2001 / 22:38:08 / cg" |
|
1362 | 907 |
! ! |
908 |
||
909 |
!Scanner methodsFor:'accessing-flags'! |
|
910 |
||
911 |
allowDollarInIdentifier |
|
4304 | 912 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
913 |
^ parserFlags allowDollarInIdentifier |
1362 | 914 |
! |
915 |
||
1511 | 916 |
allowDollarInIdentifier:something |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
917 |
parserFlags allowDollarInIdentifier:something |
1511 | 918 |
! |
919 |
||
1572 | 920 |
allowLiteralNameSpaceSymbols |
4304 | 921 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
922 |
^ parserFlags allowLiteralNameSpaceSymbols |
1572 | 923 |
! |
924 |
||
925 |
allowLiteralNameSpaceSymbols:aBoolean |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
926 |
parserFlags allowLiteralNameSpaceSymbols:aBoolean |
1572 | 927 |
! |
928 |
||
1362 | 929 |
allowOldStyleAssignment |
4304 | 930 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
931 |
^ parserFlags allowOldStyleAssignment |
1362 | 932 |
! |
933 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
934 |
allowOldStyleAssignment:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
935 |
parserFlags allowOldStyleAssignment:aBoolean |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
936 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
937 |
|
1362 | 938 |
allowSqueakExtensions |
4304 | 939 |
<resource: #obsolete> |
1530 | 940 |
"return true, if support for squeak extensions |
4188 | 941 |
computed arrays { .., } |
942 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
1530 | 943 |
is enabled." |
944 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
945 |
^ parserFlags allowSqueakExtensions |
1362 | 946 |
! |
947 |
||
948 |
allowSqueakExtensions:aBoolean |
|
1530 | 949 |
"this allows turning on/off support for squeak extensions: |
4188 | 950 |
computed arrays { .., } |
951 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
1530 | 952 |
" |
953 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
954 |
parserFlags allowSqueakExtensions:aBoolean |
1362 | 955 |
! |
956 |
||
957 |
allowUnderscoreInIdentifier |
|
4304 | 958 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
959 |
^ parserFlags allowUnderscoreInIdentifier |
1362 | 960 |
! |
961 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
962 |
allowUnderscoreInIdentifier:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
963 |
parserFlags allowUnderscoreInIdentifier:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
964 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
965 |
|
4188 | 966 |
didWarnAboutOldStyleAssignment |
3571 | 967 |
^ didWarnAboutOldStyleAssignment ? false |
968 |
! |
|
969 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
970 |
parserFlags |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
971 |
^ parserFlags |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
972 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
973 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
974 |
parserFlags:aParserFlagsInstance |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
975 |
parserFlags := aParserFlagsInstance |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
976 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
977 |
|
1362 | 978 |
scanColonAsKeyword |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
979 |
"/ not used here, but eases subclassing for other languages. |
1362 | 980 |
^ scanColonAsKeyword |
981 |
! |
|
982 |
||
983 |
warnCommonMistakes |
|
4304 | 984 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
985 |
^ parserFlags warnCommonMistakes |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
986 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
987 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
988 |
warnCommonMistakes:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
989 |
parserFlags warnCommonMistakes:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
990 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
991 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
992 |
warnDollarInIdentifier |
4304 | 993 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
994 |
^ parserFlags warnDollarInIdentifier |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
995 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
996 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
997 |
warnDollarInIdentifier:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
998 |
parserFlags warnDollarInIdentifier:aBoolean |
1362 | 999 |
! |
1000 |
||
1001 |
warnOldStyleAssignment |
|
4304 | 1002 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1003 |
^ parserFlags warnOldStyleAssignment |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1004 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1005 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1006 |
warnOldStyleAssignment:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1007 |
parserFlags warnOldStyleAssignment:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1008 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1009 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1010 |
warnPossibleIncompatibilities |
4304 | 1011 |
<resource: #obsolete> |
2058 | 1012 |
"return true, if possible incompatibilities (with other ST systems) |
1013 |
are to be warned about" |
|
1014 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1015 |
^ parserFlags warnPossibleIncompatibilities |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1016 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1017 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1018 |
warnPossibleIncompatibilities:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1019 |
parserFlags warnPossibleIncompatibilities:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1020 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1021 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1022 |
warnSTXNameSpaceUse |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1023 |
^ parserFlags warnSTXNameSpaceUse |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1024 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1025 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1026 |
warnSTXNameSpaceUse:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1027 |
parserFlags warnSTXNameSpaceUse:aBoolean |
1362 | 1028 |
! |
1029 |
||
1030 |
warnSTXSpecialComment |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1031 |
^ parserFlags warnSTXSpecialComment |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1032 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1033 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1034 |
warnSTXSpecialComment:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1035 |
parserFlags warnSTXSpecialComment:aBoolean |
1362 | 1036 |
! |
1037 |
||
1038 |
warnUnderscoreInIdentifier |
|
4304 | 1039 |
<resource: #obsolete> |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1040 |
^ parserFlags warnUnderscoreInIdentifier |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1041 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1042 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1043 |
warnUnderscoreInIdentifier:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1044 |
parserFlags warnUnderscoreInIdentifier:aBoolean |
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
1045 |
! ! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
1046 |
|
81 | 1047 |
!Scanner methodsFor:'directives'! |
1048 |
||
1596 | 1049 |
parseClassDirective |
1050 |
" |
|
1051 |
Class: className |
|
1052 |
" |
|
4188 | 1053 |
|
1596 | 1054 |
|className| |
1055 |
||
1056 |
className := self parseDirectiveClassNameArg. |
|
1057 |
className isNil ifTrue:[ |
|
4188 | 1058 |
Transcript showCR:'Scanner [warning]: unrecognized ''Class'' directive'. |
1059 |
^ false |
|
1596 | 1060 |
]. |
1061 |
lastDirective := Directive newClassDirective className:className. |
|
1062 |
^ true |
|
1063 |
! |
|
1064 |
||
1065 |
parseClassHintDirective |
|
1066 |
" |
|
1067 |
ClassHint: className |
|
1068 |
" |
|
4188 | 1069 |
|
1596 | 1070 |
|className| |
1071 |
||
1072 |
className := self parseDirectiveClassNameArg. |
|
1073 |
className isNil ifTrue:[ |
|
4188 | 1074 |
Transcript showCR:'Scanner [warning]: unrecognized ''ClassHint'' directive'. |
1075 |
^ false |
|
1596 | 1076 |
]. |
1077 |
lastDirective := Directive newClassHintDirective className:className. |
|
1078 |
^ true |
|
1079 |
! |
|
1080 |
||
74 | 1081 |
parseDirective |
1596 | 1082 |
"parse a directive inside a comment (introduced with '{'). |
1083 |
This is an ST/X special" |
|
1084 |
||
1085 |
|directive| |
|
74 | 1086 |
|
1087 |
source next. |
|
1088 |
source skipSeparatorsExceptCR. |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1089 |
hereChar := source peekOrNil. |
74 | 1090 |
hereChar isLetter ifTrue:[ |
4188 | 1091 |
directive := source nextAlphaNumericWord asLowercase. |
1092 |
source peekOrNil == $: ifTrue:[ |
|
1093 |
source next. |
|
1094 |
source skipSeparatorsExceptCR. |
|
1095 |
hereChar := source peekOrNil. |
|
1096 |
||
1097 |
" |
|
1098 |
Package: 'name-of-package' |
|
1099 |
Package: packageId |
|
1100 |
" |
|
1101 |
directive = 'package' ifTrue:[ |
|
1102 |
self parsePackageDirective. |
|
1103 |
]. |
|
1104 |
||
1105 |
" |
|
1106 |
Namespace: 'nameSpaceIdentifier' |
|
1107 |
Namespace: nameSpaceIdentifier |
|
1108 |
" |
|
1109 |
(directive = 'namespace') ifTrue:[ |
|
1110 |
self parseNamespaceDirective. |
|
1111 |
]. |
|
1112 |
||
1113 |
" |
|
1114 |
Uses: 'nameSpace1', ... , 'nameSpaceN' |
|
1115 |
Uses: nameSpaceId1, ... , nameSpaceIdN |
|
1116 |
" |
|
1117 |
directive = 'uses' ifTrue:[ |
|
1118 |
self parseUsesDirective. |
|
1119 |
]. |
|
1120 |
||
1121 |
" |
|
1122 |
reuires: 'name-of-feature' |
|
1123 |
" |
|
1124 |
directive = 'requires' ifTrue:[ |
|
1125 |
self parseRequiresDirective. |
|
1126 |
]. |
|
1127 |
||
1128 |
" |
|
1129 |
Prerequisites: 'name-of-package', ... , 'name-of-package' |
|
1130 |
" |
|
1131 |
directive = 'prerequisites' ifTrue:[ |
|
1132 |
self parsePrerequisitesDirective. |
|
1133 |
]. |
|
1134 |
||
1135 |
" |
|
1136 |
Syntax: 'name-of-dialect' |
|
1137 |
" |
|
1138 |
directive = 'syntax' ifTrue:[ |
|
1139 |
self parseSyntaxDirective. |
|
1140 |
]. |
|
1141 |
||
1142 |
" |
|
1143 |
Class: className |
|
1144 |
" |
|
1145 |
directive = 'class' ifTrue:[ |
|
1146 |
self parseClassDirective. |
|
1147 |
]. |
|
1148 |
" |
|
1149 |
ClassHint: className |
|
1150 |
" |
|
1151 |
directive = 'classhint' ifTrue:[ |
|
1152 |
self parseClassHintDirective. |
|
1153 |
]. |
|
1154 |
] |
|
74 | 1155 |
]. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1156 |
hereChar := source peekOrNil. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1157 |
^ true. |
413 | 1158 |
|
1960 | 1159 |
"Modified: / 06-12-2006 / 16:14:54 / cg" |
141 | 1160 |
! |
1161 |
||
1596 | 1162 |
parseDirectiveClassNameArg |
1163 |
"helper for parsing a directive" |
|
1164 |
||
4188 | 1165 |
^ self |
1166 |
parseDirectiveStringArg:[:ch | ch isLetterOrUnderline] |
|
1167 |
rest:[:ch | ch isLetterOrDigit or:[ch == $_ or:[ch == $:]]] |
|
1949
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1168 |
|
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1169 |
"Modified: / 18-11-2006 / 14:48:07 / cg" |
1596 | 1170 |
! |
1171 |
||
141 | 1172 |
parseDirectiveStringArg |
3624 | 1173 |
"helper for parsing a directive. |
1174 |
scans a word starting with a letter or underline, |
|
1175 |
and consisting of letters, digits, underlines or dots." |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1176 |
|
3577 | 1177 |
^ self parseDirectiveStringArg:[:ch | ch isLetterOrUnderline] |
4188 | 1178 |
rest:[:ch | ch isLetterOrDigit or:[ch == $_ or:[ch == $.]]] |
1949
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1179 |
|
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1180 |
"Modified: / 18-11-2006 / 14:47:12 / cg" |
1596 | 1181 |
! |
1182 |
||
1949
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1183 |
parseDirectiveStringArg:firstCharacterCheckBlock rest:restCharacterCheckBlock |
1596 | 1184 |
"helper for parsing a directive" |
1185 |
||
1186 |
|strBuffer| |
|
1187 |
||
3994 | 1188 |
strBuffer := WriteStream on:''. |
1596 | 1189 |
|
141 | 1190 |
hereChar == $' ifTrue:[ |
4188 | 1191 |
hereChar := source nextPeek. |
1192 |
[hereChar ~~ $'] whileTrue:[ |
|
1193 |
strBuffer nextPut:hereChar. |
|
1194 |
hereChar := source nextPeek. |
|
1195 |
]. |
|
1196 |
hereChar := source nextPeek. |
|
1197 |
^ strBuffer contents |
|
141 | 1198 |
]. |
1596 | 1199 |
|
1949
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1200 |
(firstCharacterCheckBlock value:hereChar) ifTrue:[ |
4188 | 1201 |
strBuffer nextPut:hereChar. |
1202 |
hereChar := source nextPeek. |
|
1203 |
[restCharacterCheckBlock value:hereChar] whileTrue:[ |
|
1204 |
strBuffer nextPut:hereChar. |
|
1205 |
hereChar := source nextPeek. |
|
1206 |
]. |
|
1207 |
^ strBuffer contents |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1208 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1209 |
|
141 | 1210 |
^ nil |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1211 |
|
1949
709ca062cf98
oops: namespace directive scanned the ns-argument wrong (ignored digits)
Claus Gittinger <cg@exept.de>
parents:
1948
diff
changeset
|
1212 |
"Created: / 18-11-2006 / 14:46:09 / cg" |
141 | 1213 |
! |
1214 |
||
1215 |
parseDirectiveStringListArg |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1216 |
"helper for parsing a directive" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1217 |
|
141 | 1218 |
|list| |
1219 |
||
1220 |
list := OrderedCollection new. |
|
1221 |
||
1222 |
[hereChar == $'] whileTrue:[ |
|
4188 | 1223 |
list addLast:self parseDirectiveStringArg. |
1224 |
source skipSeparatorsExceptCR. |
|
1225 |
hereChar := source peekOrNil. |
|
1226 |
(hereChar == $,) ifTrue:[ |
|
1227 |
source next. |
|
1228 |
source skipSeparatorsExceptCR. |
|
1229 |
hereChar := source peekOrNil. |
|
1230 |
]. |
|
141 | 1231 |
]. |
1232 |
^ list |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1233 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1234 |
"Modified: / 5.3.1998 / 02:55:40 / cg" |
1596 | 1235 |
! |
1236 |
||
1237 |
parseNamespaceDirective |
|
1238 |
" |
|
1239 |
Namespace: 'nameSpace' |
|
1240 |
Namespace: nameSpace |
|
1241 |
" |
|
4188 | 1242 |
|
1596 | 1243 |
|namespace target| |
1244 |
||
1245 |
namespace := self parseDirectiveStringArg. |
|
1246 |
namespace isNil ifTrue:[ |
|
4188 | 1247 |
Transcript showCR:'Scanner [warning]: unrecognized ''Namespace'' directive'. |
1248 |
^ false |
|
1596 | 1249 |
]. |
1649 | 1250 |
target := (requestor notNil and:[ requestor respondsTo:#setNameSpace: ]) ifTrue:[requestor] ifFalse:[self]. |
3360 | 1251 |
Error handle:[:ex | |
4188 | 1252 |
ParseError raiseErrorString:ex description |
3360 | 1253 |
] do:[ |
4188 | 1254 |
target setNameSpace:namespace. |
3360 | 1255 |
]. |
1596 | 1256 |
^ true |
1257 |
! |
|
1258 |
||
1259 |
parsePackageDirective |
|
1260 |
" |
|
1261 |
Package: 'name-of-package' |
|
1262 |
Package: packageId |
|
1263 |
" |
|
4188 | 1264 |
|
1596 | 1265 |
|packageName target| |
1266 |
||
1267 |
packageName := self parseDirectiveStringArg. |
|
1268 |
packageName isNil ifTrue:[ |
|
4188 | 1269 |
Transcript showCR:'Scanner [warning]: unrecognized ''Package'' directive'. |
1270 |
^ false |
|
1596 | 1271 |
]. |
1272 |
packageName := packageName asSymbol. |
|
1649 | 1273 |
target := (requestor notNil and:[ requestor respondsTo:#setPackage: ]) ifTrue:[requestor] ifFalse:[self]. |
1596 | 1274 |
target setPackage:packageName. |
1275 |
^ true |
|
1276 |
! |
|
1277 |
||
1278 |
parsePrerequisitesDirective |
|
1279 |
" |
|
1280 |
Prerequisites: 'name-of-package1', ... , 'name-of-packageN' |
|
1281 |
" |
|
4188 | 1282 |
|
1596 | 1283 |
|list| |
1284 |
||
1285 |
list := self parseDirectiveStringListArg. |
|
1286 |
list isNil ifTrue:[ |
|
4188 | 1287 |
Transcript showCR:'Scanner [warning]: unrecognized ''Prerequisites'' directive'. |
1288 |
^ false |
|
1596 | 1289 |
]. |
1290 |
(requestor notNil and:[requestor respondsTo:#requirePackages:]) ifTrue:[ |
|
4188 | 1291 |
requestor requirePackages:list |
1596 | 1292 |
]. |
1293 |
^ true |
|
1294 |
! |
|
1295 |
||
1960 | 1296 |
parseRequiresDirective |
1297 |
" |
|
1298 |
Require: 'name-of-feature', ... , 'name-of-featureN' |
|
1299 |
" |
|
4188 | 1300 |
|
1960 | 1301 |
|list| |
1302 |
||
1303 |
list := self parseDirectiveStringListArg. |
|
1304 |
list isNil ifTrue:[ |
|
4188 | 1305 |
Transcript showCR:'Scanner [warning]: unrecognized ''Requires'' directive'. |
1306 |
^ false |
|
1960 | 1307 |
]. |
2064 | 1308 |
"/ self halt. |
1960 | 1309 |
(requestor notNil and:[requestor respondsTo:#requireFeatures:]) ifTrue:[ |
4188 | 1310 |
requestor requireFeatures:list |
1960 | 1311 |
]. |
1312 |
^ true |
|
1313 |
||
1314 |
"Created: / 06-12-2006 / 16:14:43 / cg" |
|
1315 |
! |
|
1316 |
||
1596 | 1317 |
parseSyntaxDirective |
1318 |
" |
|
1319 |
Syntax: 'st-syntax-id' |
|
1320 |
" |
|
4188 | 1321 |
|
1596 | 1322 |
|syntax target| |
1323 |
||
1324 |
syntax := self parseDirectiveStringArg. |
|
1325 |
syntax isNil ifTrue:[ |
|
4188 | 1326 |
Transcript showCR:'Scanner [warning]: unrecognized ''Syntax'' directive'. |
1327 |
^ false |
|
1596 | 1328 |
]. |
1649 | 1329 |
target := (requestor notNil and:[ requestor respondsTo:#setSyntax: ]) ifTrue:[requestor] ifFalse:[self]. |
1596 | 1330 |
target setSyntax:syntax. |
1331 |
^ true |
|
1332 |
! |
|
1333 |
||
1334 |
parseUsesDirective |
|
1335 |
" |
|
1336 |
Uses: 'nameSpace1', ... , 'nameSpaceN' |
|
1337 |
Uses: nameSpaceId1, ... , nameSpaceIdN |
|
1338 |
" |
|
4188 | 1339 |
|
1596 | 1340 |
|list| |
1341 |
||
1342 |
list := self parseDirectiveStringListArg. |
|
1343 |
list isNil ifTrue:[ |
|
4188 | 1344 |
Transcript showCR:'Scanner [warning]: unrecognized ''Uses'' directive'. |
1345 |
^ false |
|
1596 | 1346 |
]. |
1347 |
(requestor notNil and:[requestor respondsTo:#addNameSpaces:]) ifTrue:[ |
|
4188 | 1348 |
requestor addNameSpaces:list |
1596 | 1349 |
]. |
1350 |
^ true |
|
0 | 1351 |
! ! |
1352 |
||
1418 | 1353 |
!Scanner methodsFor:'dummy-syntax highlighting'! |
659
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
1354 |
|
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
1355 |
markCommentFrom:pos1 to:pos2 |
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
1356 |
|
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
1357 |
"Created: / 31.3.1998 / 13:34:45 / cg" |
661 | 1358 |
! |
1359 |
||
671 | 1360 |
markConstantFrom:pos1 to:pos2 |
1361 |
||
1362 |
"Created: / 1.4.1998 / 13:02:56 / cg" |
|
1363 |
! |
|
1364 |
||
4262 | 1365 |
markErrorFrom:pos1 to:pos2 |
1366 |
||
1367 |
"Created: / 31.3.1998 / 13:34:45 / cg" |
|
1368 |
! |
|
1369 |
||
661 | 1370 |
markStringFrom:pos1 to:pos2 |
1371 |
||
1372 |
"Created: / 31.3.1998 / 16:37:18 / cg" |
|
671 | 1373 |
! |
1374 |
||
1375 |
markSymbolFrom:pos1 to:pos2 |
|
1376 |
||
1377 |
"Created: / 1.4.1998 / 12:58:42 / cg" |
|
659
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
1378 |
! ! |
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
1379 |
|
0 | 1380 |
!Scanner methodsFor:'error handling'! |
1381 |
||
3449 | 1382 |
clearErrorFlag |
1383 |
errorFlag := false. |
|
1384 |
! |
|
1385 |
||
709 | 1386 |
correctableError:message position:pos1 to:pos2 |
1387 |
"report an error which can be corrected by compiler - |
|
4188 | 1388 |
return non-false, if correction is wanted |
3449 | 1389 |
(there is more than true/false returned here)" |
709 | 1390 |
|
1391 |
|correctIt| |
|
1392 |
||
1393 |
requestor isNil ifTrue:[ |
|
4274 | 1394 |
"/ self showErrorMessage:message position:pos1. |
1395 |
correctIt := false |
|
709 | 1396 |
] ifFalse:[ |
4274 | 1397 |
self isDoIt ifTrue:[ |
4276 | 1398 |
requestor warning:message position:pos1 to:pos2 from:self. |
4274 | 1399 |
correctIt := false. |
1400 |
] ifFalse:[ |
|
1401 |
correctIt := requestor correctableError:message position:pos1 to:pos2 from:self |
|
1402 |
]. |
|
709 | 1403 |
]. |
1492 | 1404 |
|
3449 | 1405 |
("correctIt == false or:["correctIt == #Error"]") ifTrue:[ |
4274 | 1406 |
self setErrorFlag. |
1407 |
exitBlock value |
|
709 | 1408 |
]. |
1409 |
^ correctIt |
|
1410 |
||
2877
8575935bb3b5
changed: #correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2876
diff
changeset
|
1411 |
"Created: / 13-05-1998 / 16:45:56 / cg" |
4274 | 1412 |
"Modified: / 13-06-2018 / 12:46:32 / Claus Gittinger" |
4276 | 1413 |
"Modified: / 15-06-2018 / 14:55:26 / Stefan Vogel" |
709 | 1414 |
! |
1415 |
||
1023 | 1416 |
correctableSelectorWarning:message position:pos1 to:pos2 |
1417 |
"report a warning which can be corrected by compiler - |
|
1418 |
return non-false, if correction is wanted (there is more than |
|
1419 |
true/false returned here)" |
|
1420 |
||
1421 |
|correctIt| |
|
1422 |
||
1423 |
requestor isNil ifTrue:[ |
|
4188 | 1424 |
correctIt := false |
1023 | 1425 |
] ifFalse:[ |
4188 | 1426 |
DoNotShowCompilerWarningAgainActionQuery handle:[:ex | |
1427 |
parserFlags warnAboutPossiblyUnimplementedSelectors:false. |
|
1428 |
ParserFlags warnAboutPossiblyUnimplementedSelectors:false. |
|
1429 |
ex proceed. |
|
1430 |
] do:[ |
|
1431 |
correctIt := requestor correctableSelectorWarning:message position:pos1 to:pos2 from:self |
|
1432 |
] |
|
1023 | 1433 |
]. |
1434 |
correctIt == false ifTrue:[ |
|
4188 | 1435 |
exitBlock value |
1023 | 1436 |
]. |
1437 |
^ correctIt |
|
1438 |
||
2831 | 1439 |
"Created: / 19-01-2000 / 16:28:03 / cg" |
1023 | 1440 |
! |
1441 |
||
3283 | 1442 |
correctableWarning:aMessage doNotShowAgainAction:doNotShowAgainAction doNotShowAgainForThisMethodAction:doNotShowAgainForThisMethodAction position:position to:endPos |
1443 |
"notify requestor of a warning - if there is no requestor, just ignore it. |
|
1444 |
Return the result passed back from the requestor (or false, if there is none)." |
|
1445 |
||
1446 |
|answer warnAction realAction real2Action| |
|
1447 |
||
1448 |
ignoreWarnings ifTrue:[ ^ false ]. |
|
1449 |
parserFlags warnings ifFalse:[^ false]. |
|
1450 |
||
1451 |
requestor isNil ifTrue:[ |
|
4188 | 1452 |
^ false |
3283 | 1453 |
]. |
1454 |
||
1455 |
warnAction := [ answer := requestor correctableWarning:aMessage position:position to:endPos from:self ]. |
|
1456 |
||
1457 |
doNotShowAgainAction notNil ifTrue:[ |
|
4188 | 1458 |
realAction := warnAction. |
1459 |
warnAction := |
|
1460 |
[ |
|
1461 |
DoNotShowCompilerWarningAgainActionQuery |
|
1462 |
answer:doNotShowAgainAction |
|
1463 |
do:realAction |
|
1464 |
]. |
|
3283 | 1465 |
]. |
1466 |
(doNotShowAgainForThisMethodAction notNil and:[ self isDoIt not ]) ifTrue:[ |
|
4188 | 1467 |
real2Action := warnAction. |
1468 |
warnAction := |
|
1469 |
[ |
|
1470 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery |
|
1471 |
answer:doNotShowAgainForThisMethodAction |
|
1472 |
do:real2Action |
|
1473 |
]. |
|
3283 | 1474 |
]. |
1475 |
||
1476 |
warnAction value. |
|
1477 |
^ answer |
|
1478 |
||
1479 |
"Created: / 28-02-2012 / 08:42:01 / cg" |
|
1480 |
! |
|
1481 |
||
2452
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1482 |
correctableWarning:message position:pos1 to:pos2 |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1483 |
"report an error which can be corrected by compiler - |
4188 | 1484 |
return non-false, if correction is wanted |
3283 | 1485 |
(there is more than true/false returned here - i.e. a symbol, describing how to fix it)" |
2452
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1486 |
|
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1487 |
|correctIt| |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1488 |
|
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1489 |
requestor isNil ifTrue:[ |
4188 | 1490 |
"/ self showErrorMessage:message position:pos1. |
1491 |
correctIt := false |
|
2452
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1492 |
] ifFalse:[ |
4188 | 1493 |
correctIt := requestor correctableWarning:message position:pos1 to:pos2 from:self |
2452
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1494 |
]. |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1495 |
|
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1496 |
(correctIt == false or:[correctIt == #Error]) ifTrue:[ |
4188 | 1497 |
exitBlock value |
2452
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1498 |
]. |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1499 |
^ correctIt |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1500 |
|
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1501 |
"Created: / 02-11-2010 / 13:32:32 / cg" |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1502 |
! |
68a907bd9bd1
added: #correctableWarning:position:to:
Claus Gittinger <cg@exept.de>
parents:
2395
diff
changeset
|
1503 |
|
2831 | 1504 |
disableWarningsOnCurrentMethodFor:flagName |
1505 |
"ignored here" |
|
1506 |
||
1507 |
"Created: / 28-02-2012 / 14:44:43 / cg" |
|
1508 |
! |
|
1509 |
||
3449 | 1510 |
errorFlag:flagArg |
1511 |
errorFlag := flagArg |
|
1512 |
! |
|
1513 |
||
1073 | 1514 |
errorMessagePrefix |
1515 |
^ 'Error:' |
|
1516 |
! |
|
1517 |
||
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
1518 |
ignorableParseError:message |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
1519 |
self parseError:message. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
1520 |
"/ if proceeded, install method anyway (used with non-st/x primitives) |
3449 | 1521 |
self clearErrorFlag |
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
1522 |
! |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
1523 |
|
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1524 |
invalidCharacter:ch |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1525 |
|errMsg v| |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1526 |
|
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1527 |
v := ch codePoint. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1528 |
ch isPrintable ifTrue:[ |
4188 | 1529 |
errMsg := 'Invalid character: ''' , ch asString , ''' ', '(' , (v radixPrintStringRadix:16) , ').'. |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1530 |
] ifFalse:[ |
4188 | 1531 |
errMsg := 'Invalid character: ' , (v radixPrintStringRadix:16) , '.'. |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1532 |
]. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1533 |
v > 16r7F ifTrue:[ |
4188 | 1534 |
errMsg := errMsg , ' |
4042 | 1535 |
|
1536 |
Notice: |
|
1537 |
Only 7-bit ascii allowed (for compatibility with other Smalltalk dialects). |
|
1538 |
You can enable some of the special characters via the compiler-settings dialog.'. |
|
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1539 |
]. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1540 |
self syntaxError:errMsg position:tokenPosition to:tokenPosition. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1541 |
source next. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1542 |
tokenName := token := nil. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1543 |
tokenType := #Error. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1544 |
^ #Error |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1545 |
|
4042 | 1546 |
"Modified: / 17-11-2016 / 09:37:52 / cg" |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1547 |
! |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1548 |
|
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1549 |
lastTokenLineNumber |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1550 |
"return the line number of the token which was just read." |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1551 |
|
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1552 |
^ tokenLineNr |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1553 |
|
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1554 |
"Created: 8.11.1996 / 18:46:36 / cg" |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1555 |
"Modified: 23.5.1997 / 12:16:12 / cg" |
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1556 |
! |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1557 |
|
0 | 1558 |
notifyError:aMessage position:position to:endPos |
1559 |
"notify requestor of an error - if there is no requestor |
|
53 | 1560 |
put it on the transcript. Requestor is typically the CodeView |
1561 |
in which the accept/doIt was triggered, or the PositionableStream |
|
1562 |
which does the fileIn. The requestor may decide how to highlight the |
|
1563 |
error (and/or to abort the compile). |
|
0 | 1564 |
Return the result passed back by the requestor." |
1565 |
||
4331 | 1566 |
^ self notifyError:aMessage position:position to:endPos lineNr:nil |
1567 |
||
1568 |
"Modified: / 18-01-2012 / 14:54:22 / Alexander Zottnick" |
|
1569 |
"Modified: / 19-01-2012 / 10:18:36 / cg" |
|
1570 |
"Modified: / 02-05-2014 / 14:51:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1571 |
"Modified: / 19-04-2018 / 10:39:56 / stefan" |
|
1572 |
"Modified: / 08-02-2019 / 11:15:59 / Claus Gittinger" |
|
1573 |
! |
|
1574 |
||
1575 |
notifyError:aMessage position:position to:endPos lineNr:lineNrOrNil |
|
1576 |
"notify requestor of an error - if there is no requestor |
|
1577 |
put it on the transcript. Requestor is typically the CodeView |
|
1578 |
in which the accept/doIt was triggered, or the PositionableStream |
|
1579 |
which does the fileIn. The requestor may decide how to highlight the |
|
1580 |
error (and/or to abort the compile). |
|
1581 |
Return the result passed back by the requestor." |
|
1582 |
||
4228 | 1583 |
(Smalltalk isInitialized not and:[Smalltalk isDebuggableApp]) ifTrue:[ |
1584 |
"/ error during startup, but sometimes we expect an error and want to suppress it |
|
1585 |
Parser parseWarningSignal query ~~ #ignore ifTrue:[ |
|
1586 |
(self class name,' [error]: error during initialization:') errorPrint. |
|
1587 |
aMessage errorPrintCR. |
|
1588 |
thisContext fullPrintAll. |
|
1589 |
]. |
|
2785 | 1590 |
]. |
1591 |
||
3066 | 1592 |
ignoreErrors ifTrue:[ |
4228 | 1593 |
"/ usually done, when syntax highlighting or looking for used variables |
1594 |
"/ self halt. |
|
3066 | 1595 |
] ifFalse:[ |
4228 | 1596 |
"/ Raise an error. |
1597 |
"/ For backward compatibility, if error IS NOT handled and requestor |
|
1598 |
"/ IS set, then dispatch to requestor. |
|
1599 |
||
1600 |
"/ backward compatibility - will vanish eventually (use a handler, Luke) |
|
1601 |
("ParseError isHandled not and: ["requestor notNil"]") ifTrue:[ |
|
1602 |
requestor error:aMessage position:position to:endPos from:self. |
|
1603 |
^ self |
|
1604 |
]. |
|
1605 |
true "ParseError isHandled" ifTrue:[ |
|
1606 |
ParseError new |
|
1607 |
errorMessage:aMessage startPosition:position endPosition:endPos; |
|
1608 |
parameter:self; |
|
4331 | 1609 |
lineNumber:(lineNrOrNil ? tokenLineNr); "lineNr" |
4228 | 1610 |
raiseRequest. |
1611 |
^ self |
|
1612 |
]. |
|
1613 |
self showErrorMessage:aMessage position:position. |
|
0 | 1614 |
]. |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1615 |
|
4331 | 1616 |
"Created: / 08-02-2019 / 11:15:37 / Claus Gittinger" |
0 | 1617 |
! |
1618 |
||
2831 | 1619 |
notifyWarning:aMessage doNotShowAgainAction:doNotShowAgainAction doNotShowAgainForThisMethodAction:doNotShowAgainForThisMethodAction position:position to:endPos |
2455
acdcc9b42d41
comment/format in: #notifyWarning:doNotShowAgainAction:position:to:
Claus Gittinger <cg@exept.de>
parents:
2452
diff
changeset
|
1620 |
"notify requestor of a warning - if there is no requestor, just ignore it. |
1681 | 1621 |
Return the result passed back from the requestor (or false, if there is none)." |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1622 |
|
2831 | 1623 |
|answer warnAction realAction real2Action| |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1624 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1625 |
ignoreWarnings ifTrue:[ ^ false ]. |
2478
21ef13183fb5
changed: #notifyWarning:doNotShowAgainAction:position:to:
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1626 |
parserFlags warnings ifFalse:[^ false]. |
21ef13183fb5
changed: #notifyWarning:doNotShowAgainAction:position:to:
Claus Gittinger <cg@exept.de>
parents:
2455
diff
changeset
|
1627 |
|
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1628 |
requestor isNil ifTrue:[ |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1629 |
"/ self showErrorMessage:aMessage position:position. |
4188 | 1630 |
^ false |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1631 |
]. |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1632 |
|
2831 | 1633 |
warnAction := [ answer := requestor warning:aMessage position:position to:endPos from:self ]. |
1634 |
||
1457 | 1635 |
doNotShowAgainAction notNil ifTrue:[ |
4188 | 1636 |
realAction := warnAction. |
1637 |
warnAction := |
|
1638 |
[ |
|
1639 |
DoNotShowCompilerWarningAgainActionQuery |
|
1640 |
answer:doNotShowAgainAction |
|
1641 |
do:realAction |
|
1642 |
]. |
|
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1643 |
]. |
2846
d7ddf430ff69
changed: #notifyWarning:doNotShowAgainAction:doNotShowAgainForThisMethodAction:position:to:
Claus Gittinger <cg@exept.de>
parents:
2833
diff
changeset
|
1644 |
(doNotShowAgainForThisMethodAction notNil and:[ self isDoIt not ]) ifTrue:[ |
4188 | 1645 |
real2Action := warnAction. |
1646 |
warnAction := |
|
1647 |
[ |
|
1648 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery |
|
1649 |
answer:doNotShowAgainForThisMethodAction |
|
1650 |
do:real2Action |
|
1651 |
]. |
|
2831 | 1652 |
]. |
1653 |
||
1654 |
warnAction value. |
|
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1655 |
^ answer |
2455
acdcc9b42d41
comment/format in: #notifyWarning:doNotShowAgainAction:position:to:
Claus Gittinger <cg@exept.de>
parents:
2452
diff
changeset
|
1656 |
|
2831 | 1657 |
"Created: / 28-02-2012 / 08:42:01 / cg" |
1658 |
! |
|
1659 |
||
1660 |
notifyWarning:aMessage doNotShowAgainAction:doNotShowAgainAction position:position to:endPos |
|
1661 |
"notify requestor of a warning - if there is no requestor, just ignore it. |
|
1662 |
Return the result passed back from the requestor (or false, if there is none)." |
|
1663 |
||
1664 |
^ self |
|
4188 | 1665 |
notifyWarning:aMessage |
1666 |
doNotShowAgainAction:doNotShowAgainAction |
|
1667 |
doNotShowAgainForThisMethodAction:nil |
|
1668 |
position:position to:endPos |
|
2831 | 1669 |
|
1670 |
"Modified: / 28-02-2012 / 08:44:45 / cg" |
|
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1671 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1672 |
|
0 | 1673 |
notifyWarning:aMessage position:position to:endPos |
1674 |
"notify requestor of an warning - if there is no requestor |
|
1675 |
put it on the transcript. |
|
1676 |
Return the result passed back by the requestor." |
|
1677 |
||
4188 | 1678 |
^ self |
1679 |
notifyWarning:aMessage |
|
1680 |
doNotShowAgainAction:nil |
|
1681 |
position:position to:endPos. |
|
2831 | 1682 |
|
1683 |
"Modified (format): / 28-02-2012 / 08:44:13 / cg" |
|
0 | 1684 |
! |
1685 |
||
709 | 1686 |
parseError:aMessage |
1687 |
"report an error" |
|
1688 |
||
1689 |
^ self parseError:aMessage position:tokenPosition to:nil |
|
1690 |
||
1691 |
"Created: / 13.5.1998 / 16:45:13 / cg" |
|
1692 |
! |
|
1693 |
||
1900 | 1694 |
parseError:aMessage line:lNr |
1695 |
"report an error" |
|
1696 |
||
1697 |
|position| |
|
1698 |
||
1699 |
tokenLineNr := lNr. |
|
1948 | 1700 |
position := self positionFromLineNumber:lNr. |
1701 |
^ self parseError:aMessage position:position to:nil |
|
1702 |
||
1703 |
"Created: / 13-05-1998 / 16:45:05 / cg" |
|
1704 |
"Modified: / 16-11-2006 / 14:29:00 / cg" |
|
1900 | 1705 |
! |
1706 |
||
709 | 1707 |
parseError:aMessage position:position |
1708 |
"report an error" |
|
1709 |
||
1710 |
^ self parseError:aMessage position:position to:nil |
|
1711 |
||
1712 |
"Created: / 13.5.1998 / 16:45:05 / cg" |
|
1713 |
! |
|
1714 |
||
1715 |
parseError:aMessage position:position to:endPos |
|
1716 |
"report an error" |
|
1717 |
||
2047 | 1718 |
|fullMessage| |
1719 |
||
2961 | 1720 |
Smalltalk isInitialized ifFalse:[ |
4188 | 1721 |
(self class name,' [error]: error during initialization:') errorPrint. |
1722 |
aMessage errorPrintCR. |
|
1723 |
thisContext fullPrintAll. |
|
2047 | 1724 |
]. |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1725 |
|
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1726 |
"/ fullMessage := (self errorMessagePrefix) , ' ' , (aMessage ? '???'). |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1727 |
fullMessage := (aMessage ? 'Unspecified error'). |
3449 | 1728 |
self setErrorFlag. |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1729 |
self notifyError:fullMessage position:position to:endPos. |
1622 | 1730 |
exitBlock value. |
709 | 1731 |
^ false |
1732 |
||
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1733 |
"Created: / 13-05-1998 / 16:44:55 / cg" |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1734 |
"Modified: / 22-08-2006 / 14:13:11 / cg" |
709 | 1735 |
! |
1736 |
||
1948 | 1737 |
positionFromLineNumber:lNr |
1738 |
(requestor notNil and:[requestor isTextView]) ifTrue:[ |
|
4188 | 1739 |
^ requestor characterPositionOfLine:lNr col:1. |
1948 | 1740 |
]. |
1741 |
^ nil |
|
1742 |
||
1743 |
"Created: / 16-11-2006 / 14:28:37 / cg" |
|
1744 |
! |
|
1745 |
||
3449 | 1746 |
setErrorFlag |
1747 |
errorFlag := true. |
|
1748 |
! |
|
1749 |
||
141 | 1750 |
showErrorMessage:aMessage position:pos |
1751 |
"show an errormessage on the Transcript" |
|
0 | 1752 |
|
1976
d335a3fa358f
When writing error messages to Transcript, say who generated them
Stefan Vogel <sv@exept.de>
parents:
1972
diff
changeset
|
1753 |
(ignoreErrors or:[Smalltalk silentLoading]) ifFalse:[ |
4331 | 1754 |
Transcript showCR:('Scanner [<4p> line:<1p> off:<2p>]: <3p>' |
1755 |
expandMacrosWith:tokenLineNr |
|
1756 |
with:pos with:aMessage with:source). |
|
141 | 1757 |
] |
274 | 1758 |
|
4331 | 1759 |
"Modified: / 18-05-1996 / 15:44:35 / cg" |
1760 |
"Modified (format): / 08-02-2019 / 11:05:35 / Claus Gittinger" |
|
141 | 1761 |
! |
1762 |
||
1763 |
syntaxError:aMessage |
|
1764 |
"a syntax error happened - position is not known" |
|
1765 |
||
1766 |
^ self syntaxError:aMessage position:tokenPosition |
|
0 | 1767 |
! |
1768 |
||
1769 |
syntaxError:aMessage position:position |
|
1770 |
"a syntax error happened - only start position is known" |
|
1771 |
||
1772 |
^ self syntaxError:aMessage position:position to:nil |
|
1773 |
! |
|
1774 |
||
141 | 1775 |
syntaxError:aMessage position:position to:endPos |
2523
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1776 |
"a syntax error happened. |
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1777 |
Return true for correction, false if not" |
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1778 |
|
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1779 |
|fullMessage ret| |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1780 |
|
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1781 |
"/ fullMessage := self errorMessagePrefix , ' ' , aMessage. |
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
1782 |
fullMessage := aMessage. |
2523
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1783 |
ret := self notifyError:fullMessage position:position to:endPos. |
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1784 |
"/ exitBlock value. |
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1785 |
"/ ^ false |
3449 | 1786 |
self setErrorFlag. |
2523
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1787 |
^ ret. |
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1788 |
|
4fc32fe8edc7
changed: #syntaxError:position:to:
Claus Gittinger <cg@exept.de>
parents:
2487
diff
changeset
|
1789 |
"Modified: / 30-06-2011 / 19:49:19 / cg" |
87 | 1790 |
! |
1791 |
||
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1792 |
warnCommonMistake:msg at:position |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1793 |
"warn about a common beginners mistake" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1794 |
|
311 | 1795 |
self warnCommonMistake:msg position:position to:position |
1796 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1797 |
"Modified: 23.5.1997 / 12:16:34 / cg" |
311 | 1798 |
! |
1799 |
||
1800 |
warnCommonMistake:msg position:pos1 to:pos2 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1801 |
"warn about a common beginners mistake" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1802 |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1803 |
ignoreWarnings ifFalse:[ |
4188 | 1804 |
parserFlags warnings ifTrue:[ |
1805 |
parserFlags warnCommonMistakes ifTrue:[ |
|
1806 |
self |
|
1807 |
warning:msg |
|
1808 |
position:pos1 to:pos2. |
|
1809 |
] |
|
1810 |
] |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1811 |
] |
311 | 1812 |
|
1813 |
"Created: 18.7.1996 / 10:28:38 / cg" |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1814 |
"Modified: 23.5.1997 / 12:16:39 / cg" |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1815 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1816 |
|
608 | 1817 |
warnDollarAt:position |
1818 |
"warn about $-character in an identifier" |
|
1819 |
||
1820 |
ignoreWarnings ifFalse:[ |
|
4188 | 1821 |
didWarnAboutDollarInIdentifier ifFalse:[ |
1822 |
parserFlags warnDollarInIdentifier ifTrue:[ |
|
1823 |
self |
|
1824 |
warning:'$-characters in identifiers/symbols are nonportable' |
|
1825 |
doNotShowAgainAction:[ ParserFlags warnDollarInIdentifier:false ] |
|
1826 |
position:position to:position. |
|
1827 |
" |
|
1828 |
only warn once (per method) |
|
1829 |
" |
|
1830 |
didWarnAboutDollarInIdentifier := true |
|
1831 |
] |
|
1832 |
] |
|
608 | 1833 |
] |
1834 |
||
1835 |
"Created: 7.9.1997 / 01:50:24 / cg" |
|
1836 |
"Modified: 7.9.1997 / 01:51:13 / cg" |
|
1837 |
! |
|
1838 |
||
87 | 1839 |
warnOldStyleAssignmentAt:position |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1840 |
"warn about an oldStyle assignment" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1841 |
|
87 | 1842 |
ignoreWarnings ifFalse:[ |
4188 | 1843 |
didWarnAboutOldStyleAssignment ifFalse:[ |
1844 |
parserFlags warnOldStyleAssignment ifTrue:[ |
|
1845 |
self |
|
1846 |
warning:'Old style assignment - please change to use '':=''' |
|
1847 |
doNotShowAgainAction:[ ParserFlags warnOldStyleAssignment:false ] |
|
1848 |
position:position to:position. |
|
1849 |
]. |
|
1850 |
" |
|
1851 |
only warn once (per method) |
|
1852 |
" |
|
1853 |
didWarnAboutOldStyleAssignment := true |
|
1854 |
] |
|
87 | 1855 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1856 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1857 |
"Modified: 23.5.1997 / 12:16:48 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1858 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1859 |
|
4042 | 1860 |
warnParagraphAt:position |
4414 | 1861 |
"warn about §-character in an identifier" |
4042 | 1862 |
|
1863 |
ignoreWarnings ifFalse:[ |
|
4188 | 1864 |
"/ didWarnAboutParagraphInIdentifier ifFalse:[ |
1865 |
parserFlags warnParagraphInIdentifier ifTrue:[ |
|
1866 |
self |
|
4414 | 1867 |
warning:'§-characters in identifiers/symbols are nonportable' |
4188 | 1868 |
doNotShowAgainAction:[ ParserFlags warnParagraphInIdentifier:false ] |
1869 |
position:position to:position. |
|
1870 |
" |
|
1871 |
only warn once (per method) |
|
1872 |
" |
|
1873 |
parserFlags := parserFlags copy. |
|
1874 |
parserFlags warnParagraphInIdentifier:false. |
|
1875 |
"/ didWarnAboutParagraphInIdentifier := true |
|
1876 |
] |
|
1877 |
"/ ] |
|
4042 | 1878 |
] |
1879 |
||
1880 |
"Created: / 17-11-2016 / 09:16:22 / cg" |
|
1881 |
! |
|
1882 |
||
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1883 |
warnPeriodAt:position |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1884 |
"warn about a period in an identifier" |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1885 |
|
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1886 |
ignoreWarnings ifFalse:[ |
4188 | 1887 |
didWarnAboutPeriodInSymbol ifFalse:[ |
1888 |
parserFlags warnAboutPeriodInSymbol ifTrue:[ |
|
1889 |
self |
|
1890 |
warning:'Period in symbols are nonportable' |
|
1891 |
doNotShowAgainAction:[ ParserFlags warnAboutPeriodInSymbol:false ] |
|
1892 |
position:position to:position. |
|
1893 |
" |
|
1894 |
only warn once (per method) |
|
1895 |
" |
|
1896 |
didWarnAboutPeriodInSymbol := true |
|
1897 |
] |
|
1898 |
] |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1899 |
] |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1900 |
! |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1901 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1902 |
warnPossibleIncompatibility:msg position:pos1 to:pos2 |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1903 |
"warn about a possible incompatibility with other ST systems" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1904 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1905 |
ignoreWarnings ifFalse:[ |
4188 | 1906 |
parserFlags warnPossibleIncompatibilities ifTrue:[ |
1907 |
self |
|
1908 |
warning:('Possible incompatibility.\\' , msg) withCRs |
|
1909 |
doNotShowAgainAction:[ ParserFlags warnPossibleIncompatibilities:false. |
|
1910 |
parserFlags warnPossibleIncompatibilities:false ] |
|
1911 |
position:pos1 to:pos2. |
|
1912 |
] |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1913 |
] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1914 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1915 |
"Created: 23.5.1997 / 12:17:54 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1916 |
"Modified: 23.5.1997 / 12:22:37 / cg" |
87 | 1917 |
! |
1918 |
||
1653 | 1919 |
warnSTXSpecialCommentAt:position to:endPosition |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1920 |
ignoreWarnings ifFalse:[ |
4188 | 1921 |
"/ dfo |
1922 |
didWarnAboutSTXSpecialComment ifFalse:[ |
|
1923 |
parserFlags warnSTXSpecialComment ifTrue:[ |
|
1924 |
self |
|
1925 |
warning:'End-of-line comments are a nonstandard feature of ST/X' |
|
1926 |
doNotShowAgainAction:[ parserFlags warnSTXSpecialComment:false. ParserFlags warnSTXSpecials:false. ] |
|
1927 |
doNotShowAgainForThisMethodAction: [ self disableWarningsOnCurrentMethodFor: #warnSTXSpecials ] |
|
1928 |
position:position to:endPosition. |
|
1929 |
" |
|
1930 |
only warn once |
|
1931 |
" |
|
1932 |
didWarnAboutSTXSpecialComment := true |
|
1933 |
] |
|
1934 |
] |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1935 |
]. |
2831 | 1936 |
|
2854
64b0decefcec
changed: #warnSTXSpecialCommentAt:to:
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
1937 |
"Modified: / 16-03-2012 / 18:37:11 / cg" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1938 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1939 |
|
87 | 1940 |
warnUnderscoreAt:position |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1941 |
"warn about an underscore in an identifier" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1942 |
|
87 | 1943 |
ignoreWarnings ifFalse:[ |
4188 | 1944 |
didWarnAboutUnderscoreInIdentifier ifFalse:[ |
1945 |
parserFlags warnUnderscoreInIdentifier ifTrue:[ |
|
1946 |
self |
|
1947 |
warning:'Underscores in identifiers/symbols are nonportable' |
|
1948 |
doNotShowAgainAction:[ ParserFlags warnUnderscoreInIdentifier:false ] |
|
1949 |
position:position to:position. |
|
1950 |
" |
|
1951 |
only warn once (per method) |
|
1952 |
" |
|
1953 |
didWarnAboutUnderscoreInIdentifier := true |
|
1954 |
] |
|
1955 |
] |
|
87 | 1956 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1957 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1958 |
"Modified: 23.5.1997 / 12:17:06 / cg" |
141 | 1959 |
! |
1960 |
||
1961 |
warning:aMessage |
|
1962 |
"a warning - position is not known" |
|
1963 |
||
1964 |
^ self warning:aMessage position:tokenPosition |
|
1965 |
! |
|
1966 |
||
2831 | 1967 |
warning:aMessage doNotShowAgainAction:doNotShowAgainAction doNotShowAgainForThisMethodAction:doNotShowAgainForThisMethodAction position:position to:endPos |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1968 |
"a warning" |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1969 |
|
4188 | 1970 |
^ self |
1971 |
notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) |
|
1972 |
doNotShowAgainAction:doNotShowAgainAction |
|
1973 |
doNotShowAgainForThisMethodAction:doNotShowAgainForThisMethodAction |
|
1974 |
position:position to:endPos |
|
2831 | 1975 |
|
1976 |
"Created: / 28-02-2012 / 08:38:16 / cg" |
|
1977 |
! |
|
1978 |
||
1979 |
warning:aMessage doNotShowAgainAction:doNotShowAgainAction position:position to:endPos |
|
1980 |
"a warning" |
|
1981 |
||
4188 | 1982 |
^ self |
1983 |
warning:aMessage |
|
1984 |
doNotShowAgainAction:doNotShowAgainAction |
|
1985 |
doNotShowAgainForThisMethodAction:nil |
|
1986 |
position:position to:endPos |
|
2831 | 1987 |
|
1988 |
"Modified: / 28-02-2012 / 08:43:00 / cg" |
|
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1989 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1990 |
|
1948 | 1991 |
warning:aMessage line:lNr |
1992 |
"a warning - only start position is known" |
|
1993 |
||
1994 |
|position| |
|
1995 |
||
1996 |
position := self positionFromLineNumber:lNr. |
|
1997 |
^ self warning:aMessage position:position to:nil |
|
1998 |
||
1999 |
"Created: / 16-11-2006 / 14:29:30 / cg" |
|
2000 |
! |
|
2001 |
||
141 | 2002 |
warning:aMessage position:position |
2003 |
"a warning - only start position is known" |
|
2004 |
||
2005 |
^ self warning:aMessage position:position to:nil |
|
2006 |
! |
|
2007 |
||
2008 |
warning:aMessage position:position to:endPos |
|
2009 |
"a warning" |
|
2010 |
||
4188 | 2011 |
^ self |
2012 |
notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) |
|
2013 |
doNotShowAgainAction:nil |
|
2014 |
position:position to:endPos |
|
1073 | 2015 |
! |
2016 |
||
2017 |
warningMessagePrefix |
|
2018 |
^ 'Warning:' |
|
0 | 2019 |
! ! |
2020 |
||
17 | 2021 |
!Scanner methodsFor:'general scanning'! |
2022 |
||
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2023 |
scanNumberFrom:aStringOrStream |
3143 | 2024 |
"scan aSourceString for the next number in smalltalk syntax. |
3144 | 2025 |
Return the number or nil. Leave the position of the stream after the number |
3143 | 2026 |
or unchanged (if no number is coming) |
4188 | 2027 |
Extension: |
4415 | 2028 |
since constant fractions (int/int) are treated like lexical tokens (not messages) |
2029 |
in Smalltalk/X, this also reads fractions." |
|
3143 | 2030 |
|
3144 | 2031 |
|oldPos posAfter denominator numerator parentized sign| |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2032 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2033 |
self initializeFor:aStringOrStream. |
1430 | 2034 |
oldPos := source position. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2035 |
self nextToken. |
3144 | 2036 |
|
2037 |
sign := 1. |
|
2038 |
tokenType == #BinaryOperator ifTrue:[ |
|
4415 | 2039 |
tokenName = '+' ifTrue:[ |
2040 |
self nextToken. |
|
2041 |
] ifFalse:[ |
|
2042 |
tokenName = '-' ifTrue:[ |
|
2043 |
sign := -1. |
|
2044 |
self nextToken. |
|
2045 |
]. |
|
2046 |
]. |
|
3144 | 2047 |
]. |
2048 |
(parentized := tokenType == $( ) ifTrue:[ |
|
4415 | 2049 |
self nextToken. |
2050 |
tokenType == #BinaryOperator ifTrue:[ |
|
2051 |
tokenName = '+' ifTrue:[ |
|
2052 |
self nextToken. |
|
2053 |
] ifFalse:[ |
|
2054 |
tokenName = '-' ifTrue:[ |
|
2055 |
sign := sign negated. |
|
2056 |
self nextToken. |
|
2057 |
]. |
|
2058 |
]. |
|
2059 |
]. |
|
3144 | 2060 |
]. |
2061 |
||
3143 | 2062 |
(tokenValue isNumber) ifTrue:[ |
4415 | 2063 |
"/ must keep stream positioned correctly |
2064 |
"/ (undo lookahead) |
|
2065 |
posAfter := source position. |
|
2066 |
peekChar notNil ifTrue:[ |
|
2067 |
peekChar2 notNil ifTrue:[ |
|
2068 |
posAfter := posAfter - 1 |
|
2069 |
]. |
|
2070 |
posAfter := posAfter - 1 |
|
2071 |
]. |
|
2072 |
tokenValue isInteger ifTrue:[ |
|
2073 |
source skipSeparators. |
|
2074 |
source peekOrNil == $/ ifTrue:[ |
|
2075 |
numerator := tokenValue. |
|
2076 |
self nextToken. "/ skip / |
|
2077 |
"/ oops - must check for // |
|
2078 |
tokenName = '/' ifFalse:[ |
|
2079 |
parentized ifTrue:[ |
|
2080 |
"/ nothing at all |
|
2081 |
source position:oldPos. |
|
2082 |
^ nil. |
|
2083 |
]. |
|
2084 |
"/ only an integer |
|
2085 |
source position:posAfter. |
|
2086 |
^ tokenValue |
|
2087 |
]. |
|
2088 |
||
2089 |
self nextToken. "/ get denominator |
|
2090 |
tokenType == #BinaryOperator ifTrue:[ |
|
2091 |
tokenName = '+' ifTrue:[ |
|
2092 |
self nextToken. |
|
2093 |
] ifFalse:[ |
|
2094 |
tokenName = '-' ifTrue:[ |
|
2095 |
sign := sign negated. |
|
2096 |
self nextToken. |
|
2097 |
]. |
|
2098 |
]. |
|
2099 |
]. |
|
2100 |
(tokenType == #Integer and:[tokenValue isInteger]) ifTrue:[ |
|
2101 |
denominator := tokenValue. |
|
2102 |
tokenValue := Fraction numerator:numerator denominator:denominator. |
|
2103 |
posAfter := source position. |
|
2104 |
peekChar notNil ifTrue:[ |
|
2105 |
peekChar2 notNil ifTrue:[ |
|
2106 |
posAfter := posAfter - 1 |
|
2107 |
]. |
|
2108 |
posAfter := posAfter - 1 |
|
2109 |
]. |
|
2110 |
]. |
|
2111 |
]. |
|
2112 |
]. |
|
2113 |
parentized ifTrue:[ |
|
2114 |
tokenType == $) ifTrue:[ |
|
2115 |
self nextToken |
|
2116 |
] |
|
2117 |
] ifFalse:[ |
|
2118 |
source position:posAfter. |
|
2119 |
]. |
|
2120 |
sign == -1 ifTrue:[^ tokenValue negated]. |
|
2121 |
^ tokenValue |
|
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2122 |
]. |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
2123 |
"/ backup in case of error; return nil |
1430 | 2124 |
source position:oldPos. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2125 |
^ nil. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2126 |
|
4415 | 2127 |
"Created: / 18-06-1998 / 23:05:22 / cg" |
2128 |
"Modified: / 19-11-1999 / 18:25:52 / cg" |
|
2129 |
"Modified (comment): / 23-05-2019 / 11:06:51 / Claus Gittinger" |
|
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2130 |
! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
2131 |
|
17 | 2132 |
scanPositionsFor:aTokenString inString:aSourceString |
3712 | 2133 |
"scan aSourceString for occurrences of aTokenString. |
17 | 2134 |
Return a collection of start positions. |
1577 | 2135 |
Added for VW compatibility (to support simple syntax-highlight)." |
17 | 2136 |
|
2137 |
|searchType searchName searchValue positions t| |
|
2138 |
||
1577 | 2139 |
aTokenString notNil ifTrue:[ |
4188 | 2140 |
" |
2141 |
first, look what kind of token we have to search for |
|
2142 |
" |
|
2143 |
self initializeFor:(ReadStream on:aTokenString). |
|
2144 |
self nextToken. |
|
2145 |
searchType := tokenType. |
|
2146 |
searchName := tokenName. |
|
2147 |
searchValue := tokenValue. |
|
1577 | 2148 |
]. |
17 | 2149 |
|
2150 |
" |
|
2151 |
start the real work ... |
|
2152 |
" |
|
2153 |
self initializeFor:(ReadStream on:aSourceString). |
|
2154 |
positions := OrderedCollection new. |
|
2155 |
||
2156 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
4188 | 2157 |
searchType == t ifTrue:[ |
2158 |
(searchName isNil or:[tokenName = searchName]) ifTrue:[ |
|
2159 |
(searchValue isNil or:[tokenValue = searchValue]) ifTrue:[ |
|
2160 |
positions add:tokenPosition. |
|
2161 |
] |
|
2162 |
] |
|
2163 |
] |
|
17 | 2164 |
]. |
2165 |
||
2166 |
^ positions |
|
2167 |
||
2168 |
" |
|
4188 | 2169 |
Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello' |
2170 |
Scanner new scanPositionsFor:'3.14' inString:'foo 3.145 bar hello 3.14 baz hello 3.14' |
|
2171 |
Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000' |
|
17 | 2172 |
" |
2173 |
! ! |
|
2174 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2175 |
!Scanner methodsFor:'initialization'! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2176 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2177 |
initialize |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2178 |
"initialize the scanner" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2179 |
|
4121 | 2180 |
"/ <modifier: #super> "must be called if redefined" |
4112 | 2181 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2182 |
errorFlag := false. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2183 |
tokenPosition := 1. |
610 | 2184 |
tokenLineNr := lineNr := 1. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2185 |
currentComments := nil. |
2740 | 2186 |
"/ allow for these to be already set (kludge) |
2187 |
saveComments isNil ifTrue:[ saveComments := false ]. |
|
2188 |
parserFlags isNil ifTrue:[ parserFlags := ParserFlags new ]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2189 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2190 |
ignoreErrors := false. |
1930 | 2191 |
ignoreWarnings := parserFlags warnings not. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2192 |
didWarnAboutSTXSpecialComment := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2193 |
didWarnAboutUnderscoreInIdentifier := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2194 |
didWarnAboutDollarInIdentifier := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2195 |
didWarnAboutOldStyleAssignment := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2196 |
|
900 | 2197 |
"/ not used here, but eases subclassing for other languages. |
4188 | 2198 |
scanColonAsKeyword isNil ifTrue:[ scanColonAsKeyword := true ]. |
1930 | 2199 |
self initializeActionTable. |
2200 |
||
4121 | 2201 |
"Modified: / 13-02-2017 / 13:45:51 / cg" |
1930 | 2202 |
! |
2203 |
||
2204 |
initializeActionTable |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
2205 |
actionArray := self class actionArray. |
2484 | 2206 |
unicodeActions := self class unicodeActions. |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
2207 |
typeArray := self class typeArray. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2208 |
|
1930 | 2209 |
"Created: / 18-10-2006 / 23:10:55 / cg" |
2484 | 2210 |
"Modified: / 25-03-2011 / 13:57:50 / cg" |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2211 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2212 |
|
1362 | 2213 |
initializeFlagsFrom:aScanner |
2214 |
"initialize flags from another scanner" |
|
2215 |
||
2216 |
ignoreErrors := aScanner ignoreErrors. |
|
2217 |
ignoreWarnings := aScanner ignoreWarnings. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2218 |
parserFlags := aScanner parserFlags copy. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2219 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2220 |
"/ not used here, but eases subclassing for other languages. |
4188 | 2221 |
scanColonAsKeyword := aScanner scanColonAsKeyword. |
1362 | 2222 |
! |
2223 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2224 |
initializeFor:aStringOrStream |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2225 |
"initialize the new scanner & prepare for reading from aStringOrStream" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2226 |
|
2741 | 2227 |
actionArray isNil ifTrue:[ |
4188 | 2228 |
"/ if not already initialized... |
2229 |
self initialize. |
|
2741 | 2230 |
]. |
847 | 2231 |
self source:aStringOrStream. |
2741 | 2232 |
|
2233 |
"Modified: / 05-10-2011 / 09:24:00 / cg" |
|
847 | 2234 |
! |
2235 |
||
1962 | 2236 |
requestor:anObject |
2237 |
"set the requestor to be notified" |
|
2238 |
||
2239 |
requestor := anObject |
|
2240 |
||
2241 |
"Created: / 07-12-2006 / 18:13:13 / cg" |
|
2242 |
! |
|
2243 |
||
4420 | 2244 |
setSource:newSourceStream |
2245 |
source := newSourceStream |
|
1242 | 2246 |
|
4291 | 2247 |
"Modified: / 07-08-2018 / 07:46:57 / Claus Gittinger" |
4420 | 2248 |
"Modified (format): / 25-05-2019 / 23:47:16 / Claus Gittinger" |
1242 | 2249 |
! |
2250 |
||
847 | 2251 |
source:aStringOrStream |
2766 | 2252 |
"prepare for reading from aStringOrStream; |
2253 |
notice: if token is nonNil, it is preserved. This allows for scanning |
|
2254 |
across streams." |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2255 |
|
854 | 2256 |
errorFlag := false. |
2257 |
tokenPosition := 1. |
|
2258 |
tokenLineNr := lineNr := 1. |
|
2259 |
currentComments := nil. |
|
2260 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2261 |
aStringOrStream isStream ifFalse:[ |
4341 | 2262 |
source := ReadStream on:aStringOrStream string |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2263 |
] ifTrue:[ |
4341 | 2264 |
source := aStringOrStream. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2265 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2266 |
|
2762 | 2267 |
"Modified: / 26-05-1999 / 12:02:16 / stefan" |
2766 | 2268 |
"Modified: / 06-12-2011 / 00:45:50 / cg" |
4341 | 2269 |
"Modified: / 10-02-2019 / 15:49:28 / Claus Gittinger" |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2270 |
! ! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2271 |
|
1237
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2272 |
!Scanner methodsFor:'parser interface'! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2273 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2274 |
token |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2275 |
^ token |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2276 |
! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2277 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2278 |
tokenLineNr:lineNumberArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2279 |
tokenLineNr := lineNumberArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2280 |
! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2281 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2282 |
tokenPosition:positionArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2283 |
tokenPosition := positionArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2284 |
! ! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2285 |
|
141 | 2286 |
!Scanner methodsFor:'private'! |
3 | 2287 |
|
141 | 2288 |
backupPosition |
2289 |
"if reading from a stream, at the end we might have read |
|
2290 |
one token too many" |
|
20 | 2291 |
|
141 | 2292 |
(tokenType == #EOF) ifFalse:[ |
4188 | 2293 |
source position:tokenPosition-1 |
141 | 2294 |
] |
2295 |
! |
|
15 | 2296 |
|
141 | 2297 |
beginComment |
2298 |
^ self |
|
2299 |
! |
|
2300 |
||
4334 | 2301 |
characterNamed:name |
2302 |
|idx| |
|
2303 |
||
2304 |
idx := #( |
|
2305 |
'nul' 'soh' 'stx' 'etx' 'eot' 'enq' 'ack' 'bel' |
|
2306 |
'bs' 'ht' 'lf' 'vt' 'ff' 'cr' 'so' 'si' |
|
2307 |
'dle' 'dc1' 'dc2' 'dc3' 'dc4' 'nak' 'syn' 'etb' |
|
2308 |
'can' 'em' 'sub' 'esc' 'fs' 'gs' 'rs' 'us' ) indexOf:name. |
|
2309 |
idx == 0 ifTrue:[ |
|
2310 |
name = 'tab' ifTrue:[ ^ Character tab ]. |
|
2311 |
^ nil |
|
2312 |
]. |
|
2313 |
^ Character value:idx-1 |
|
2314 |
||
2315 |
"Created: / 08-02-2019 / 19:12:23 / Claus Gittinger" |
|
2316 |
! |
|
2317 |
||
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2318 |
checkForKeyword:string |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2319 |
"check if string is a keyword (as opposed to an identifier). |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2320 |
That is, its one of 'self', 'super', 'nil', 'true', 'false', |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2321 |
or 'thisContext'. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2322 |
'here' is handled elsewhere (since it must be treated as an |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2323 |
identifier, if declared locally." |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2324 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2325 |
|firstChar| |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2326 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2327 |
firstChar := string at:1. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2328 |
(firstChar == $s) ifTrue:[ |
4188 | 2329 |
(string = 'self') ifTrue:[tokenType := #Self. ^true]. |
2330 |
(string = 'super') ifTrue:[tokenType := #Super. ^true] |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2331 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2332 |
(firstChar == $n) ifTrue:[ |
4188 | 2333 |
(string = 'nil') ifTrue:[tokenType := #Nil. tokenValue := nil. ^true] |
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2334 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2335 |
(firstChar == $t) ifTrue:[ |
4188 | 2336 |
(string = 'true') ifTrue:[tokenType := #True. tokenValue := true. ^true]. |
2337 |
(string = 'thisContext') ifTrue:[tokenType := #ThisContext. ^true] |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2338 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2339 |
(firstChar == $f) ifTrue:[ |
4188 | 2340 |
(string = 'false') ifTrue:[tokenType := #False. tokenValue := false. ^true] |
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2341 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2342 |
^ false |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2343 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2344 |
"Modified: / 13.5.1998 / 14:59:55 / cg" |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2345 |
! |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2346 |
|
141 | 2347 |
collectedSource |
2348 |
^ collectedSource |
|
2349 |
! |
|
74 | 2350 |
|
1236 | 2351 |
eatPeekChar |
2352 |
peekChar isNil ifTrue:[ |
|
4188 | 2353 |
source next. |
1236 | 2354 |
] ifFalse:[ |
4188 | 2355 |
peekChar := nil. |
1236 | 2356 |
]. |
2357 |
||
2358 |
"Created: / 24.10.1998 / 17:25:39 / cg" |
|
2359 |
! |
|
2360 |
||
141 | 2361 |
endComment:comment |
2362 |
saveComments ifTrue:[ |
|
4188 | 2363 |
currentComments isNil ifTrue:[ |
2364 |
currentComments := OrderedCollection with:comment |
|
2365 |
] ifFalse:[ |
|
2366 |
currentComments add:comment |
|
2367 |
] |
|
3 | 2368 |
]. |
2369 |
! |
|
2370 |
||
648 | 2371 |
endComment:commentString type:commentType |
3551 | 2372 |
"obsolete; left for backward compatibility" |
2373 |
||
2374 |
^ self endComment:commentString type:commentType start:nil end:nil |
|
2375 |
! |
|
2376 |
||
2377 |
endComment:commentString type:commentType start:startPos end:endPos |
|
648 | 2378 |
|comment| |
2379 |
||
2380 |
saveComments ifTrue:[ |
|
4188 | 2381 |
comment := Comment new commentString:commentString commentType:commentType. |
2382 |
comment startPosition:startPos endPosition:endPos. |
|
2383 |
||
2384 |
currentComments isNil ifTrue:[ |
|
2385 |
currentComments := OrderedCollection with:comment |
|
2386 |
] ifFalse:[ |
|
2387 |
currentComments add:comment |
|
2388 |
] |
|
648 | 2389 |
]. |
2390 |
||
2391 |
"Created: / 17.2.1998 / 14:48:49 / cg" |
|
2392 |
! |
|
2393 |
||
2481 | 2394 |
eolIsWhiteSpace |
2395 |
^ true |
|
2396 |
||
2397 |
"Created: / 14-03-2011 / 14:11:46 / cg" |
|
2398 |
! |
|
2399 |
||
4345 | 2400 |
escapeCharacterFor:aCharacter escapeStyle:escapeStyle |
4414 | 2401 |
"only if AllowExtendedSTXSyntax or AllowCStrings |
2402 |
or AllowEStrings is true |
|
4345 | 2403 |
For now: only use c-style, since stc does not support others. |
2404 |
'c' - C-style escapes: |
|
2405 |
\n,\t,\r,\b,\xXX,\uXXXX,\UXXXXXX, |
|
1321 | 2406 |
|
2407 |
much like character escapes in C-literals; |
|
2408 |
expands: |
|
4334 | 2409 |
\n newLine |
2410 |
\r return |
|
2411 |
\t tab |
|
2412 |
\b backspace |
|
2413 |
\f formfeed |
|
2414 |
\g bell |
|
2415 |
\0 nul |
|
2416 |
||
2417 |
\\ backSlash |
|
2418 |
\ ...\ (backslash-separator) ignored up to next backslash |
|
2419 |
\xNN hexCharacter |
|
2420 |
\uNNNN hex UnicodeCharacter |
|
2421 |
\UNNNNNN hex UnicodeCharacter |
|
2422 |
\<name> named character |
|
1321 | 2423 |
" |
2424 |
||
4334 | 2425 |
|ascii nextChar fetchNext name pos1| |
1321 | 2426 |
|
2427 |
aCharacter == $n ifTrue:[^ Character nl]. |
|
2428 |
aCharacter == $r ifTrue:[^ Character return]. |
|
2429 |
aCharacter == $t ifTrue:[^ Character tab]. |
|
2430 |
aCharacter == $b ifTrue:[^ Character backspace]. |
|
2431 |
aCharacter == $f ifTrue:[^ Character ff]. |
|
2432 |
aCharacter == $g ifTrue:[^ Character bell]. |
|
4334 | 2433 |
aCharacter == $0 ifTrue:[^ Character null]. |
1681 | 2434 |
aCharacter == $\ ifTrue:[^ aCharacter]. |
4345 | 2435 |
|
4334 | 2436 |
aCharacter == $< ifTrue:[ |
2437 |
pos1 := source position. |
|
2438 |
name := ''. |
|
2439 |
nextChar := source next. |
|
2440 |
[nextChar notNil and:[nextChar ~~ $>]] whileTrue:[ |
|
2441 |
nextChar isLetter ifFalse:[ |
|
2442 |
self syntaxError:'letter expected in character name escape in string literal' |
|
2443 |
position:pos1 to:(source position). |
|
2444 |
]. |
|
2445 |
name size > 10 ifTrue:[ |
|
2446 |
self syntaxError:'long character name escape in string literal' |
|
2447 |
position:pos1 to:(source position). |
|
2448 |
]. |
|
2449 |
name := name , nextChar. |
|
2450 |
nextChar := source next. |
|
2451 |
]. |
|
2452 |
nextChar := self characterNamed:name. |
|
2453 |
nextChar isNil ifTrue:[ |
|
2454 |
self syntaxError:'invalid character name escape in string literal' |
|
2455 |
position:pos1 to:(source position). |
|
2456 |
]. |
|
2457 |
^ nextChar |
|
1321 | 2458 |
]. |
4334 | 2459 |
|
2460 |
aCharacter isSeparator ifTrue:[ |
|
2461 |
nextChar := source next. |
|
2462 |
[nextChar notNil and:[nextChar ~~ $\]] whileTrue:[ |
|
2463 |
(nextChar == Character cr) ifTrue:[ |
|
2464 |
lineNr := lineNr + 1 |
|
2465 |
]. |
|
2466 |
nextChar := source next. |
|
2467 |
]. |
|
2468 |
^ nil |
|
2469 |
]. |
|
2470 |
||
2471 |
(aCharacter == $x |
|
4414 | 2472 |
or:[ (aCharacter == $u) |
2473 |
or:[ (aCharacter == $U) ]] |
|
2474 |
) ifTrue:[ |
|
4334 | 2475 |
pos1 := source position. |
2476 |
||
2477 |
fetchNext := |
|
2478 |
[ |
|
2479 |
nextChar := source next. |
|
2480 |
(nextChar notNil and:[nextChar isDigitRadix:16]) ifFalse:[ |
|
2481 |
self syntaxError:'hex digit expected in string literal' |
|
2482 |
position:pos1 to:(source position). |
|
2483 |
]. |
|
2484 |
nextChar digitValue |
|
2485 |
]. |
|
2486 |
||
2487 |
ascii := fetchNext value. |
|
2488 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2489 |
||
2490 |
((aCharacter == $u ) or:[(aCharacter == $U )]) ifTrue:[ |
|
2491 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2492 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2493 |
(aCharacter == $U) ifTrue:[ |
|
2494 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2495 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2496 |
]. |
|
2497 |
]. |
|
2498 |
^ Character value:ascii. |
|
1321 | 2499 |
]. |
2500 |
^ aCharacter |
|
2501 |
||
2502 |
" |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2503 |
ParserFlags allowExtendedSTXSyntax:true |
1321 | 2504 |
" |
2505 |
" |
|
4188 | 2506 |
'hello\nworld' |
2507 |
'hello\x0Dworld' |
|
2508 |
'hello\x08world' |
|
1681 | 2509 |
'hello\ |
4188 | 2510 |
\world' |
2511 |
" |
|
1681 | 2512 |
" |
2513 |
ParserFlags allowExtendedSTXSyntax:false |
|
2514 |
" |
|
4334 | 2515 |
|
4345 | 2516 |
"Created: / 11-02-2019 / 12:27:25 / Claus Gittinger" |
4414 | 2517 |
"Modified (comment): / 23-05-2019 / 10:34:21 / Claus Gittinger" |
1321 | 2518 |
! |
2519 |
||
141 | 2520 |
ignoreErrors |
1365 | 2521 |
"return the flag which controls notification of errors" |
2522 |
||
2523 |
^ ignoreErrors |
|
2524 |
! |
|
2525 |
||
2526 |
ignoreErrors:aBoolean |
|
2527 |
"enable/disable notification of errors" |
|
2528 |
||
2529 |
ignoreErrors := aBoolean |
|
141 | 2530 |
! |
0 | 2531 |
|
141 | 2532 |
ignoreWarnings |
1365 | 2533 |
"return the flag which controls notification of warnings" |
2534 |
||
2535 |
^ ignoreWarnings |
|
2536 |
! |
|
2537 |
||
2538 |
ignoreWarnings:aBoolean |
|
2539 |
"enable/disable notification of warnings" |
|
2540 |
||
2541 |
ignoreWarnings := aBoolean |
|
141 | 2542 |
! |
0 | 2543 |
|
714 | 2544 |
isCommentCharacter:ch |
2545 |
"return true, if ch is the comment-start character. |
|
2546 |
Brought into a separate method to allow for easier subclassing" |
|
2547 |
||
2548 |
^ ch == $" |
|
2549 |
||
2550 |
"Created: / 14.5.1998 / 20:51:42 / cg" |
|
2551 |
"Modified: / 14.5.1998 / 20:53:01 / cg" |
|
2552 |
! |
|
2553 |
||
2983 | 2554 |
isDoIt |
2555 |
^ false |
|
2556 |
! |
|
2557 |
||
1722 | 2558 |
isSpecialOrExtendedSpecialCharacter:ch |
2027 | 2559 |
|code charType| |
2560 |
||
2561 |
code := ch codePoint. |
|
3621 | 2562 |
(code between:1 and: typeArray size) ifFalse:[^ false]. |
2027 | 2563 |
|
2564 |
charType := typeArray at:code. |
|
4188 | 2565 |
^ (charType == #special) |
2566 |
or:[ (charType == #extendedSpecial) and:[parserFlags allowExtendedBinarySelectors] ] |
|
2290 | 2567 |
|
2568 |
" |
|
2569 |
self basicNew isSpecialOrExtendedSpecialCharacter:$- |
|
2570 |
" |
|
1722 | 2571 |
! |
2572 |
||
141 | 2573 |
notifying:anObject |
2574 |
"set the requestor to be notified" |
|
2575 |
||
2576 |
requestor := anObject |
|
426
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2577 |
! |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2578 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2579 |
setNameSpace:aNameSpace |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2580 |
"/ ignored here |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2581 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2582 |
"Created: 8.11.1996 / 13:33:10 / cg" |
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2583 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2584 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2585 |
setPackage:aNameSpace |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2586 |
"/ ignored here |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2587 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2588 |
"Created: 8.11.1996 / 13:33:10 / cg" |
1572 | 2589 |
! |
2590 |
||
2591 |
setSyntax:aSyntax |
|
141 | 2592 |
! ! |
2593 |
||
2594 |
!Scanner methodsFor:'reading next token'! |
|
2595 |
||
4410 | 2596 |
continueEscapedString |
2597 |
"after escaping out of a string with \{, |
|
2598 |
an expression was read by the parser and it found the terminating $}. |
|
2599 |
It calls this to continue reading the string..." |
|
2600 |
||
2601 |
^ self xnextString:$' escapeStyle:'e' |
|
2602 |
||
2603 |
"Created: / 22-05-2019 / 20:24:51 / Claus Gittinger" |
|
2604 |
! |
|
2605 |
||
2484 | 2606 |
nextAssignmentArrow |
2607 |
"return a left-arrow" |
|
2608 |
||
2609 |
^ self nextToken:$_ |
|
2610 |
||
2611 |
"Created: / 25-03-2011 / 13:58:50 / cg" |
|
2612 |
! |
|
2613 |
||
4291 | 2614 |
nextBacktickIdentifier |
2615 |
"a single back-quote has been scanned; |
|
2616 |
scan up to the next back-tick, and return it as an identifier" |
|
2617 |
||
2618 |
self nextString:$`. |
|
2619 |
||
2620 |
tokenName := tokenValue. |
|
2621 |
tokenType := #Identifier. |
|
2622 |
^ tokenType |
|
2623 |
||
2624 |
"Created: / 07-08-2018 / 07:37:51 / Claus Gittinger" |
|
2625 |
! |
|
2626 |
||
141 | 2627 |
nextCharacter |
2628 |
"a $ has been read - return a character token" |
|
2629 |
||
1240 | 2630 |
|nextChar t| |
141 | 2631 |
|
0 | 2632 |
source next. |
141 | 2633 |
nextChar := source next. |
2634 |
nextChar notNil ifTrue:[ |
|
4188 | 2635 |
t := nextChar. |
2636 |
tokenType := #Character. |
|
141 | 2637 |
] ifFalse:[ |
4188 | 2638 |
t := nil. |
2639 |
tokenType := #EOF |
|
141 | 2640 |
]. |
1240 | 2641 |
tokenValue := token := t. |
0 | 2642 |
^ tokenType |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2643 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2644 |
"Modified: / 13.5.1998 / 15:09:50 / cg" |
0 | 2645 |
! |
2646 |
||
2647 |
nextColonOrAssign |
|
2648 |
"colon has been read - look for = to make it an assign" |
|
2649 |
||
3181 | 2650 |
|thirdChar| |
1722 | 2651 |
|
120 | 2652 |
"/ special kludge for identifier:= (without spaces inbetween) |
2653 |
"/ here we needed two characters lookahead after the identifier ... |
|
2654 |
||
2655 |
peekChar == $= ifTrue:[ |
|
4188 | 2656 |
source next. |
2657 |
peekChar := nil. |
|
2658 |
tokenType := token := #':='. |
|
2659 |
||
2660 |
thirdChar := source peek. |
|
2661 |
thirdChar notNil ifTrue:[ |
|
2662 |
(self isSpecialOrExtendedSpecialCharacter:thirdChar) ifTrue:[ |
|
2663 |
||
2664 |
] |
|
2665 |
]. |
|
2666 |
||
2667 |
^ tokenType |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2668 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2669 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2670 |
"/ special kludge for nameSpace:: (without spaces inbetween) |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2671 |
"/ here we needed two characters lookahead after the identifier ... |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2672 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2673 |
peekChar == $: ifTrue:[ |
4188 | 2674 |
source next. |
2675 |
peekChar := nil. |
|
2676 |
tokenType := token := #'::'. |
|
2677 |
^ tokenType |
|
120 | 2678 |
]. |
2679 |
||
0 | 2680 |
(source nextPeek == $=) ifTrue:[ |
4188 | 2681 |
source next. |
2682 |
tokenType := token := #':=' |
|
0 | 2683 |
] ifFalse:[ |
4188 | 2684 |
tokenType := token := $: |
0 | 2685 |
]. |
2686 |
^ tokenType |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2687 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2688 |
"Modified: / 13.5.1998 / 15:10:04 / cg" |
0 | 2689 |
! |
2690 |
||
1298 | 2691 |
nextExcla |
2692 |
"a !! has been read - return either |
|
4188 | 2693 |
the !! binarySelector, |
2694 |
ExclaLeftParen (for '!!('), |
|
2695 |
ExclaLeftBrack (for '!!['), |
|
2696 |
ExclaLeftBrace (for '!!{') |
|
1298 | 2697 |
" |
2698 |
||
2699 |
|nextChar| |
|
2700 |
||
2701 |
nextChar := source nextPeek. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2702 |
parserFlags allowExtendedSTXSyntax == true ifTrue:[ |
4188 | 2703 |
(nextChar == $( ) ifTrue:[ |
2704 |
source next. |
|
2705 |
token := '!!('. |
|
2706 |
tokenType := #ExclaLeftParen. |
|
2707 |
^ tokenType |
|
2708 |
]. |
|
2709 |
||
2710 |
(nextChar == $[ ) ifTrue:[ |
|
2711 |
source next. |
|
2712 |
token := '!!['. |
|
2713 |
tokenType := #ExclaLeftBrack. |
|
2714 |
^ tokenType |
|
2715 |
]. |
|
2716 |
||
2717 |
(nextChar == ${ ) ifTrue:[ |
|
2718 |
source next. |
|
2719 |
token := '!!{'. |
|
2720 |
tokenType := #ExclaLeftBrace. |
|
2721 |
^ tokenType |
|
2722 |
]. |
|
1298 | 2723 |
]. |
2724 |
||
2725 |
"this allows excla to be used as binop - |
|
4037 | 2726 |
I don't know, if this is correct ..." |
1298 | 2727 |
|
1307
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2728 |
"/ tokenName := token := '!!'. |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2729 |
"/ tokenType := #BinaryOperator. |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2730 |
"/ ^ tokenType |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2731 |
|
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2732 |
^ self nextSpecialWith:$!!. |
1298 | 2733 |
! |
2734 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2735 |
nextExtendedSpecial:ch |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2736 |
parserFlags allowExtendedBinarySelectors ifTrue:[ |
4188 | 2737 |
^ self nextSpecial |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2738 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2739 |
^ self invalidCharacter:source peek. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2740 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2741 |
|
141 | 2742 |
nextHash |
1226 | 2743 |
"a # has been read - return either |
4188 | 2744 |
a symbol, |
2745 |
HashLeftParen (for '#('), |
|
2746 |
HashLeftBrack (for '#['), |
|
2747 |
HashLeftBrace (for '#{' and AllowQualifiedNames) |
|
2748 |
HashHashLeftParen (for '##(' and AllowDolphinExtensions) |
|
2749 |
HashHashLeftBrack (for '##[' ) |
|
2750 |
HashHash (for '##' ) |
|
3948 | 2751 |
|
2752 |
extended syntax (scheme-style literal arrays): |
|
4188 | 2753 |
HashTypedArrayParen (for '#u8(', '#s8(' , '#u16(' ...) |
2754 |
type in tokenValue: u1, u8, u16, u32, u64, s8, s16, s32, s64, |
|
2755 |
f16, f32, f64, f, d, b, B |
|
1226 | 2756 |
" |
1026 | 2757 |
|
1656 | 2758 |
|nextChar string allowUnderscoreInIdentifier| |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2759 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2760 |
allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier. |
0 | 2761 |
|
141 | 2762 |
nextChar := source nextPeek. |
2763 |
nextChar notNil ifTrue:[ |
|
4188 | 2764 |
(nextChar == $( ) ifTrue:[ |
2765 |
source next. |
|
2766 |
token := '#('. |
|
2767 |
tokenType := #HashLeftParen. |
|
2768 |
^ tokenType |
|
2769 |
]. |
|
2770 |
||
2771 |
(nextChar == $[ ) ifTrue:[ |
|
2772 |
"ST-80 & ST/X support Constant ByteArrays as #[...]" |
|
2773 |
source next. |
|
2774 |
token := '#['. |
|
2775 |
tokenType := #HashLeftBrack. |
|
2776 |
^ tokenType |
|
2777 |
]. |
|
2778 |
||
2779 |
(nextChar == ${ ) ifTrue:[ |
|
2780 |
" #{ ... } is one of: |
|
2781 |
#{ Foo.Bar.Baz } VW3 and later qualified name |
|
2782 |
#{ xx-xx-xx-xx-...-xx } StAgents UUID |
|
2783 |
#{ URL } url object qualifier |
|
2784 |
" |
|
2785 |
source next. |
|
2786 |
token := '#{'. |
|
2787 |
tokenType := #HashLeftBrace. |
|
2788 |
^ tokenType |
|
2789 |
]. |
|
2790 |
||
2791 |
(nextChar == $' ) ifTrue:[ |
|
2792 |
"ST-80 and ST/X support arbitrary symbols as #'...'" |
|
2793 |
self nextString:nextChar. |
|
2794 |
self markSymbolFrom:tokenPosition to:(source position). |
|
2795 |
tokenType == #EOF ifFalse:[ |
|
2796 |
tokenValue isWideString ifTrue:[ |
|
2797 |
self syntaxError:'symbols which require 2-byte characters are not (yet) allowed' |
|
2798 |
position:tokenPosition to:(source position). |
|
2799 |
]. |
|
2800 |
tokenValue := token := tokenValue asSymbol. |
|
2801 |
tokenType := #Symbol. |
|
2802 |
]. |
|
2803 |
^ tokenType |
|
2804 |
]. |
|
2805 |
||
2806 |
(nextChar == $#) ifTrue:[ |
|
2807 |
nextChar := source nextPeek. |
|
2808 |
nextChar == $( ifTrue:[ |
|
2809 |
parserFlags allowDolphinExtensions == true ifTrue:[ |
|
2810 |
"dolphin does computed literals as ##( ... )" |
|
2811 |
source next. |
|
2812 |
token := '##('. |
|
2813 |
tokenType := #HashHashLeftParen. |
|
2814 |
^ tokenType |
|
2815 |
]. |
|
2816 |
]. |
|
2817 |
||
2818 |
nextChar == $[ ifTrue:[ |
|
2819 |
source next. |
|
2820 |
token := '##['. |
|
2821 |
tokenType := #HashHashLeftBrack. |
|
2822 |
^ tokenType |
|
2823 |
]. |
|
2824 |
||
2825 |
parserFlags allowVisualAgeESSymbolLiterals == true ifTrue:[ |
|
2826 |
(self nextSymbolAfterHash) notNil ifTrue:[ |
|
2827 |
tokenType := #ESSymbol. |
|
2828 |
^ #ESSymbol |
|
2829 |
]. |
|
2830 |
(nextChar == $') ifTrue:[ |
|
2831 |
source next. |
|
2832 |
self nextString:nextChar. |
|
2833 |
tokenType := #ESSymbol. |
|
2834 |
^ #ESSymbol |
|
2835 |
]. |
|
2836 |
]. |
|
2837 |
||
2838 |
token := '##'. |
|
2839 |
tokenType := #HashHash. |
|
2840 |
^ tokenType |
|
2841 |
]. |
|
2842 |
||
2843 |
parserFlags allowSTXExtendedArrayLiterals ifTrue:[ |
|
2844 |
"/ scheme-style typed literal array extension |
|
2845 |
('usfdbB' includes:nextChar) ifTrue:[ |
|
2846 |
|prefix| |
|
2847 |
||
2848 |
prefix := String with:nextChar. |
|
2849 |
nextChar := source nextPeek. |
|
2850 |
[nextChar notNil and:[nextChar isDigit]] whileTrue:[ |
|
2851 |
prefix := prefix copyWith:nextChar. |
|
2852 |
nextChar := source nextPeek. |
|
2853 |
]. |
|
2854 |
nextChar == $( ifTrue:[ |
|
2855 |
source next. |
|
2856 |
( |
|
2857 |
#( 'f' 'd' 'b' 'B' |
|
2858 |
'u1' 'u8' 'u16' 'u32' 'u64' |
|
2859 |
's8' 's16' 's32' 's64' |
|
2860 |
'f16' 'f32' 'f64' |
|
2861 |
) includes:prefix |
|
2862 |
) ifTrue:[ |
|
2863 |
tokenType := #HashTypedArrayParen. |
|
2864 |
tokenValue := prefix asSymbol. |
|
2865 |
^ tokenType |
|
2866 |
]. |
|
2867 |
self parseError:'unsupported literal array type: ',prefix. |
|
2868 |
tokenType := #HashLeftParen. |
|
2869 |
^ #HashLeftParen |
|
2870 |
]. |
|
2871 |
^ self nextSymbolAfterHash:prefix. |
|
2872 |
]. |
|
2873 |
]. |
|
2874 |
||
2875 |
(self nextSymbolAfterHash) notNil ifTrue:[ |
|
2876 |
^ #Symbol |
|
2877 |
]. |
|
2878 |
||
2879 |
(self isSpecialOrExtendedSpecialCharacter:nextChar) ifTrue:[ |
|
2880 |
string := source next asString. |
|
2881 |
nextChar := source peek. |
|
2882 |
nextChar notNil ifTrue:[ |
|
2883 |
(self isSpecialOrExtendedSpecialCharacter:nextChar) ifTrue:[ |
|
2884 |
source next. |
|
2885 |
string := string copyWith:nextChar |
|
2886 |
] |
|
2887 |
]. |
|
2888 |
self markSymbolFrom:tokenPosition to:(source position). |
|
2889 |
tokenValue := token := string asSymbol. |
|
2890 |
tokenType := #Symbol. |
|
2891 |
^ tokenType |
|
2892 |
] |
|
0 | 2893 |
]. |
1298 | 2894 |
|
141 | 2895 |
"this allows hash to be used as binop - |
4037 | 2896 |
I don't know, if this is correct ..." |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2897 |
tokenName := token := '#'. |
0 | 2898 |
tokenType := #BinaryOperator. |
2899 |
^ tokenType |
|
500 | 2900 |
|
1781 | 2901 |
"Modified: / 01-08-2006 / 14:57:19 / cg" |
2712
eddb351cf9c2
comment/format in: #nextHash
Claus Gittinger <cg@exept.de>
parents:
2678
diff
changeset
|
2902 |
"Modified (format): / 30-09-2011 / 12:23:04 / cg" |
0 | 2903 |
! |
2904 |
||
2905 |
nextId |
|
1026 | 2906 |
"no longer used here - remains for backwardCompatibility for |
2907 |
subclass users ... (sigh)" |
|
2908 |
||
4188 | 2909 |
|nextChar string oldString |
0 | 2910 |
index "{ Class: SmallInteger }" |
2911 |
max "{ Class: SmallInteger }" | |
|
2912 |
||
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2913 |
nextChar := source peekOrNil. |
1470
62844fc53a87
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
2914 |
string := String uninitializedNew:20. |
0 | 2915 |
index := 0. |
2916 |
max := 10. |
|
3405 | 2917 |
[ |
4188 | 2918 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[ |
2919 |
^ string copyTo:index |
|
2920 |
]. |
|
2921 |
(index == max) ifTrue:[ |
|
2922 |
oldString := string. |
|
2923 |
string := String basicNew:(max * 2). |
|
2924 |
string replaceFrom:1 to:max with:oldString. |
|
2925 |
max := max * 2 |
|
2926 |
]. |
|
2927 |
index := index + 1. |
|
2928 |
string at:index put:nextChar. |
|
2929 |
nextChar := source nextPeek |
|
3405 | 2930 |
] loop. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2931 |
|
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2932 |
"Modified: / 5.3.1998 / 02:53:57 / cg" |
0 | 2933 |
! |
2934 |
||
2935 |
nextIdentifier |
|
1510
875c90576897
Fix duplicate assignment to ActionArray for sh
Stefan Vogel <sv@exept.de>
parents:
1509
diff
changeset
|
2936 |
"an alpha character (or underscore if AllowUnderscore) has been read. |
1026 | 2937 |
Return the next identifier." |
2938 |
||
4188 | 2939 |
|nextChar string ok pos ch2 |
3449 | 2940 |
allowUnderscoreInIdentifier allowDollarInIdentifier |
2941 |
allowNationalCharactersInIdentifier| |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2942 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2943 |
allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier. |
3449 | 2944 |
allowDollarInIdentifier := parserFlags allowDollarInIdentifier. |
2945 |
allowNationalCharactersInIdentifier := parserFlags allowNationalCharactersInIdentifier. |
|
0 | 2946 |
|
87 | 2947 |
hereChar == $_ ifTrue:[ |
4334 | 2948 |
"/ |
2949 |
"/ no need to check for allowUnderscoreInIdentifier here; |
|
2950 |
"/ could not arrive here if it was off |
|
2951 |
"/ |
|
2952 |
nextChar := source nextPeek. |
|
2953 |
parserFlags allowOldStyleAssignment ifTrue:[ |
|
2954 |
(nextChar notNil and:[ nextChar isLetterOrDigit or:[nextChar == $_]]) ifFalse:[ |
|
2955 |
"oops: a single underscore is an old-style assignement" |
|
2956 |
nextChar == $: ifFalse:[ |
|
2957 |
self warnOldStyleAssignmentAt:tokenPosition. |
|
2958 |
tokenType := token := $_. |
|
2959 |
^ tokenType |
|
2960 |
] |
|
2961 |
]. |
|
2962 |
]. |
|
2963 |
string := '_'. |
|
2964 |
self warnUnderscoreAt:tokenPosition. |
|
2965 |
[nextChar == $_] whileTrue:[ |
|
2966 |
string := string copyWith:$_. |
|
2967 |
nextChar := source nextPeek. |
|
2968 |
]. |
|
2969 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[ |
|
2970 |
string := string , source nextAlphaNumericWord. |
|
2971 |
] |
|
87 | 2972 |
] ifFalse:[ |
4334 | 2973 |
nextChar := source peekOrNil. |
2974 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[ |
|
2975 |
string := source nextAlphaNumericWord "self nextId". |
|
2976 |
] ifFalse:[ |
|
2977 |
string := '' |
|
2978 |
] |
|
87 | 2979 |
]. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2980 |
nextChar := source peekOrNil. |
87 | 2981 |
|
4334 | 2982 |
((nextChar == $') |
4414 | 2983 |
and:[ (string size == 1) |
2984 |
and:[ (parserFlags allowCStrings |
|
2985 |
or:[parserFlags allowEStrings |
|
2986 |
or:[parserFlags allowExtendedSTXSyntax ]]) ]] |
|
2987 |
) ifTrue:[ |
|
4410 | 2988 |
source next. |
2989 |
^ self xnextString:$' escapeStyle:string |
|
4334 | 2990 |
]. |
2991 |
||
4188 | 2992 |
(((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
4042 | 2993 |
or:[ (allowDollarInIdentifier and:[nextChar == $$ ]) |
4414 | 2994 |
or:[ (nextChar == $§ and:[ parserFlags allowParagraphInIdentifier]) |
4042 | 2995 |
or:[ allowNationalCharactersInIdentifier and:[ nextChar notNil and:[nextChar isNationalLetter]]]]]) ifTrue:[ |
4334 | 2996 |
pos := source position + 1. |
2997 |
nextChar == $_ ifTrue:[ |
|
2998 |
self warnUnderscoreAt:pos. |
|
2999 |
] ifFalse:[ |
|
3000 |
nextChar == $$ ifTrue:[ |
|
3001 |
self warnDollarAt:pos. |
|
3002 |
] ifFalse:[ |
|
4414 | 3003 |
nextChar == $§ ifTrue:[ |
4334 | 3004 |
self warnParagraphAt:pos. |
3005 |
] ifFalse:[ |
|
3006 |
"/ self warnNationalCharacterAt:pos. |
|
3007 |
] |
|
3008 |
] |
|
3009 |
]. |
|
3010 |
ok := true. |
|
3011 |
[ok] whileTrue:[ |
|
3012 |
string := string copyWith:nextChar. |
|
3013 |
nextChar := source nextPeek. |
|
3014 |
nextChar isNil ifTrue:[ |
|
3015 |
ok := false |
|
3016 |
] ifFalse:[ |
|
3017 |
(nextChar isLetterOrDigit) ifTrue:[ |
|
3018 |
string := string , source nextAlphaNumericWord. |
|
3019 |
nextChar := source peekOrNil. |
|
3020 |
]. |
|
3021 |
ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
|
3022 |
or:[((nextChar == $$ ) and:[allowDollarInIdentifier]) |
|
4414 | 3023 |
or:[((nextChar == $§ ) and:[parserFlags allowParagraphInIdentifier]) |
4334 | 3024 |
or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]]. |
3025 |
] |
|
3026 |
]. |
|
60 | 3027 |
]. |
3028 |
||
785
14d0ec37a754
added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
3029 |
(nextChar == $: and:[scanColonAsKeyword]) ifTrue:[ |
4334 | 3030 |
source next. |
3031 |
ch2 := source peekOrNil. |
|
3032 |
"/ colon follows - care for '::' (nameSpace separator) or ':=' (assignment) |
|
3033 |
(ch2 == $=) ifFalse:[ |
|
3034 |
(ch2 == $:) ifFalse:[ |
|
3035 |
tokenName := token := string copyWith:nextChar. |
|
3036 |
tokenType := #Keyword. |
|
3037 |
inArrayLiteral == true ifTrue:[ |
|
3038 |
(ch2 isLetter |
|
3039 |
or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]) ifTrue:[ |
|
3040 |
"/ kludge: recurse to read the rest. |
|
3041 |
self nextIdentifier. |
|
3042 |
tokenName := token := (string copyWith:nextChar) , token. |
|
3043 |
tokenType ~~ #Keyword ifTrue:[ |
|
3044 |
self syntaxError:'invalid keyword symbol in array constant' |
|
3045 |
position:tokenPosition to:(source position). |
|
3046 |
]. |
|
3047 |
tokenType := #Keyword. |
|
3048 |
]. |
|
3049 |
]. |
|
3050 |
^ tokenType |
|
3051 |
]. |
|
3052 |
peekChar := $:. |
|
3053 |
peekChar2 := $:. |
|
3054 |
] ifTrue:[ |
|
3055 |
peekChar := $:. |
|
3056 |
peekChar2 := $=. |
|
3057 |
] |
|
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3058 |
] ifFalse:[ |
4334 | 3059 |
(nextChar == $. and:[parserFlags allowQualifiedNames]) ifTrue:[ |
3060 |
"/ period follows - if next-after character is an identifier character, |
|
3061 |
"/ make peekSym a #NameSpaceSeparator; otherwise a $. |
|
3062 |
source next. |
|
3063 |
ch2 := source peekOrNil. |
|
3064 |
(ch2 notNil |
|
3065 |
and:[ch2 isLetter or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]]) ifTrue:[ |
|
3066 |
peekChar := #'::'. |
|
3067 |
] ifFalse:[ |
|
3068 |
peekChar := $. |
|
3069 |
]. |
|
3070 |
]. |
|
0 | 3071 |
]. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3072 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3073 |
nextChar == $- ifTrue:[ |
4334 | 3074 |
pos := source position + 1. |
3075 |
self |
|
3076 |
warnPossibleIncompatibility:'add spaces around ''-'' for compatibility with other systems' |
|
3077 |
position:pos to:pos. |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3078 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3079 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3080 |
tokenName := token := string. |
1026 | 3081 |
(self checkForKeyword:string) ifFalse:[ |
4334 | 3082 |
tokenType := #Identifier. |
1026 | 3083 |
]. |
0 | 3084 |
^ tokenType |
120 | 3085 |
|
1954
3c20721e963c
care for end-of-text when parsing a single underline identifier.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
3086 |
"Created: / 13-09-1995 / 12:56:42 / claus" |
4042 | 3087 |
"Modified: / 17-11-2016 / 09:19:46 / cg" |
4414 | 3088 |
"Modified: / 23-05-2019 / 10:44:00 / Claus Gittinger" |
0 | 3089 |
! |
3090 |
||
141 | 3091 |
nextMantissa:radix |
1026 | 3092 |
"read the mantissa of a radix number" |
3093 |
||
1351 | 3094 |
<resource: #obsolete> |
3095 |
||
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3096 |
^ (self nextMantissaAndScaledPartWithRadix:radix) first |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3097 |
! |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3098 |
|
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3099 |
nextMantissaAndScaledPartWithRadix:radix |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3100 |
"read the mantissa of a radix number. |
4037 | 3101 |
Since we don't know yet if this is for a Float, LongFloat or a FixedPoint, |
1430 | 3102 |
return info which is useful for all: an array consisting of |
3103 |
the mantissa as float/longFloat, the numerator and the scale for a fixedPoint." |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3104 |
|
1972
f52b7e609f1f
common code with Number-reading
Claus Gittinger <cg@exept.de>
parents:
1971
diff
changeset
|
3105 |
^ Number readMantissaAndScaleFrom:source radix:radix |
141 | 3106 |
! |
3107 |
||
3108 |
nextNumber |
|
1026 | 3109 |
"scan a number; handles radix prefix, mantissa and exponent. |
4188 | 3110 |
Allows for |
4312 | 3111 |
e, d or q to be used as exponent limiter (for float or long float), |
3112 |
s for scaled fixpoint numbers, |
|
4422 | 3113 |
f for single precision floats (controlled by parserFlags). |
3114 |
||
4312 | 3115 |
i.e. 1e5 -> float (technically a double precision IEEE) |
3116 |
1d5 -> float (also, a double precision IEEE) |
|
3117 |
1q5 -> long float (a c-long double / quad precision IEEE) |
|
3118 |
1s -> a fixed point with precision from number of digits given. |
|
3119 |
1s5 -> a fixed point with 5 digits precision. |
|
3120 |
1d -> float (technically a double precision IEEE float). |
|
3121 |
1q -> long float (technically a c-long double / quad precision IEEE float). |
|
4422 | 3122 |
|
3123 |
1f5 -> shortFloat (technically a single precision IEEE float) or float. |
|
3124 |
1f -> shortFloat (technically a single precision IEEE float) or float. |
|
3705 | 3125 |
support for scaled decimals can be disabled, if code needs to be read, |
3126 |
which does not know about them (very unlikely)" |
|
1026 | 3127 |
|
4188 | 3128 |
|pos1 nextChar value integerPart sign |
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
3129 |
expSign tokenRadix mantissaAndScaledPart d type exp scale| |
141 | 3130 |
|
3131 |
tokenRadix := 10. |
|
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
3132 |
sign := 1. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3133 |
type := #Integer. |
3268 | 3134 |
pos1 := source position + 1. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3135 |
|
141 | 3136 |
value := Integer readFrom:source radix:tokenRadix. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
3137 |
nextChar := source peekOrNil. |
141 | 3138 |
(nextChar == $r) ifTrue:[ |
4312 | 3139 |
tokenRadix := value. |
3140 |
source next. |
|
3141 |
||
3142 |
(tokenRadix between:2 and:36) ifFalse:[ |
|
3143 |
self syntaxError:'bad radix (must be 2 .. 36)' |
|
3144 |
position:tokenPosition to:(source position). |
|
3145 |
]. |
|
3146 |
source peekOrNil == $- ifTrue:[ |
|
3147 |
source next. |
|
3148 |
sign := -1 |
|
3149 |
]. |
|
3150 |
value := Integer readFrom:source radix:tokenRadix. |
|
3151 |
nextChar := source peekOrNil. |
|
141 | 3152 |
]. |
821
bc543afcc1e6
give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
3153 |
|
141 | 3154 |
(nextChar == $.) ifTrue:[ |
4312 | 3155 |
nextChar := source nextPeek. |
3156 |
(nextChar notNil and:[nextChar isDigitRadix:tokenRadix]) ifTrue:[ |
|
3157 |
(tokenRadix > 13 and:[nextChar == $d or:[nextChar == $D]]) ifTrue:[ |
|
3158 |
self warning:'float with radix > 13 - (d/D are valid digits; not exponent-leaders)' |
|
3159 |
position:tokenPosition to:(source position). |
|
3160 |
]. |
|
3161 |
(tokenRadix > 14 and:[nextChar == $e or:[nextChar == $E]]) ifTrue:[ |
|
3162 |
self warning:'float with radix > 14 - (e/E are valid digits; not exponent-leaders)' |
|
3163 |
position:tokenPosition to:(source position). |
|
3164 |
]. |
|
3165 |
mantissaAndScaledPart := self nextMantissaAndScaledPartWithRadix:tokenRadix. |
|
3166 |
integerPart := value. |
|
3167 |
value := integerPart + (mantissaAndScaledPart first). "could be a longFloat now" |
|
3168 |
type := #Float. |
|
3169 |
nextChar := source peekOrNil |
|
3170 |
] ifFalse:[ |
|
3171 |
('eEdDqQfF' includes:nextChar) ifTrue:[ |
|
3172 |
"/ allow 5.e-3 - is this standard ? |
|
3173 |
||
3174 |
] ifFalse:[ |
|
1339
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
3175 |
"/ nextChar == (Character cr) ifTrue:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
3176 |
"/ lineNr := lineNr + 1. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
3177 |
"/ ]. |
4312 | 3178 |
nextChar := peekChar := $.. |
3179 |
] |
|
3180 |
] |
|
141 | 3181 |
]. |
821
bc543afcc1e6
give a warning if radix>14 and an e/E is encountered in a float
Claus Gittinger <cg@exept.de>
parents:
820
diff
changeset
|
3182 |
|
4148 | 3183 |
('eEdDqQfF' includes:nextChar) ifTrue:[ |
4312 | 3184 |
(nextChar == $q or:[nextChar == $Q]) ifTrue:[ |
3185 |
value := value asLongFloat |
|
3186 |
] ifFalse:[ |
|
4422 | 3187 |
((nextChar == $f or:[nextChar == $F]) and:[parserFlags singlePrecisionFloatF]) ifTrue:[ |
4312 | 3188 |
value := value asShortFloat |
3189 |
] ifFalse:[ |
|
3190 |
value := value asFloat. |
|
3191 |
]. |
|
3192 |
]. |
|
3193 |
type := #Float. |
|
3194 |
nextChar := source nextPeek. |
|
3195 |
(nextChar notNil and:[(nextChar isDigit"Radix:tokenRadix") or:['+-' includes:nextChar]]) ifTrue:[ |
|
3196 |
expSign := 1. |
|
3197 |
(nextChar == $+) ifTrue:[ |
|
3198 |
nextChar := source nextPeek |
|
3199 |
] ifFalse:[ |
|
3200 |
(nextChar == $-) ifTrue:[ |
|
3201 |
nextChar := source nextPeek. |
|
3202 |
expSign := -1 |
|
3203 |
] |
|
3204 |
]. |
|
3205 |
exp := (Integer readFrom:source) * expSign. |
|
3206 |
value := value * ((value class unity * tokenRadix) raisedToInteger:exp). |
|
3207 |
"/ due to a strange overflow, we might get a Nan, although we |
|
3208 |
"/ are actually still in the float range. |
|
3209 |
"/ happens eg. for 1.7976931348623157e+308 |
|
4314 | 3210 |
nextChar := source peek. |
4312 | 3211 |
value isInfinite ifTrue:[ |
4314 | 3212 |
PrimitiveFailure handle:[:ex | |
3213 |
"/ self halt. |
|
3214 |
] do:[ |
|
3215 |
value := Float fastFromString:source collection at:pos1. |
|
3216 |
]. |
|
4312 | 3217 |
]. |
3218 |
]. |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3219 |
] ifFalse:[ |
4312 | 3220 |
value isLimitedPrecisionReal ifTrue:[ |
3221 |
"/ no type specified - makes it a float |
|
3222 |
value := value asFloat. |
|
3223 |
]. |
|
3224 |
||
3225 |
parserFlags allowFixedPointLiterals == true ifTrue:[ |
|
3226 |
"/ ScaledDecimal numbers |
|
3227 |
('s' includes:nextChar) ifTrue:[ |
|
3228 |
nextChar := source nextPeek. |
|
3229 |
||
3230 |
(nextChar notNil and:[(nextChar isDigit)]) ifTrue:[ |
|
3231 |
scale := (Integer readFrom:source). |
|
3232 |
]. |
|
3233 |
||
3234 |
mantissaAndScaledPart isNil ifTrue:[ |
|
3235 |
value := value asFixedPoint:(scale ? 0) |
|
3236 |
] ifFalse:[ |
|
3237 |
d := 10 raisedTo:(mantissaAndScaledPart last). |
|
3238 |
value := FixedPoint |
|
3239 |
numerator:((integerPart * d) + mantissaAndScaledPart second) |
|
3240 |
denominator:d |
|
3241 |
scale:(scale ? mantissaAndScaledPart last). |
|
3242 |
]. |
|
3243 |
type := #FixedPoint. |
|
3244 |
self |
|
3245 |
warnPossibleIncompatibility:'fixedPoint literal might be incompatibile with other systems' |
|
3246 |
position:pos1 to:source position + 1. |
|
3247 |
]. |
|
3248 |
]. |
|
141 | 3249 |
]. |
4188 | 3250 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3251 |
nextChar == $- ifTrue:[ |
4312 | 3252 |
self |
3253 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems' |
|
3254 |
position:(source position + 1) to:(source position + 1). |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3255 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3256 |
|
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
3257 |
tokenValue := token := value * sign. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3258 |
tokenType := type. |
1596 | 3259 |
(tokenValue isLimitedPrecisionReal) ~~ (tokenType == #Float) ifTrue:[ |
4312 | 3260 |
self shouldImplement. |
1596 | 3261 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3262 |
|
671 | 3263 |
"/ self markConstantFrom:tokenPosition to:(source position - 1). |
141 | 3264 |
^ tokenType |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
3265 |
|
4148 | 3266 |
"Modified: / 15-06-2017 / 11:07:52 / cg" |
4422 | 3267 |
"Modified: / 26-05-2019 / 11:36:02 / Claus Gittinger" |
141 | 3268 |
! |
3269 |
||
0 | 3270 |
nextPrimitive |
1026 | 3271 |
"scan an inline C-primitive." |
3272 |
||
4188 | 3273 |
|nextChar inPrimitive string stringCollector |
0 | 3274 |
index "{ Class: SmallInteger }" |
3275 |
len "{ Class: SmallInteger }" | |
|
3276 |
||
3277 |
nextChar := source nextPeek. |
|
1302 | 3278 |
(nextChar == ${) ifFalse:[ |
4188 | 3279 |
^ self nextSpecialWith:$% |
1302 | 3280 |
]. |
3281 |
||
3705 | 3282 |
stringCollector := CharacterWriteStream new. |
1302 | 3283 |
nextChar := source nextPeek. |
3284 |
inPrimitive := true. |
|
3285 |
[inPrimitive] whileTrue:[ |
|
4188 | 3286 |
[nextChar == $%] whileFalse:[ |
3287 |
nextChar isNil ifTrue:[ |
|
3288 |
self syntaxError:'unterminated primitive' |
|
3289 |
position:tokenPosition to:source position + 1. |
|
3290 |
^ #Error |
|
3291 |
]. |
|
3292 |
stringCollector nextPut:nextChar. |
|
3293 |
nextChar := source next |
|
3294 |
]. |
|
3295 |
(source peekOrNil == $}) ifTrue:[ |
|
3296 |
inPrimitive := false |
|
3297 |
] ifFalse:[ |
|
3298 |
stringCollector nextPut:nextChar. |
|
3299 |
nextChar := source next |
|
3300 |
] |
|
0 | 3301 |
]. |
1302 | 3302 |
source next. |
3705 | 3303 |
tokenValue := token := stringCollector contents. |
1302 | 3304 |
tokenType := #Primitive. |
3305 |
lineNr := lineNr + (tokenValue occurrencesOf:(Character cr)). |
|
3306 |
^ tokenType |
|
0 | 3307 |
! |
3308 |
||
141 | 3309 |
nextSpecial |
3310 |
"a special character has been read, look for another one. |
|
3311 |
also -number is handled here" |
|
3312 |
||
1302 | 3313 |
|firstChar| |
0 | 3314 |
|
141 | 3315 |
firstChar := source next. |
1302 | 3316 |
^ self nextSpecialWith:firstChar |
3317 |
! |
|
3318 |
||
3319 |
nextSpecialWith:firstChar |
|
3320 |
"a special character has been read, look for another one. |
|
3321 |
also -number is handled here" |
|
3322 |
||
2155 | 3323 |
|secondChar thirdChar fourthChar string p| |
1302 | 3324 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
3325 |
secondChar := source peekOrNil. |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
3326 |
((firstChar == $-) and:[secondChar notNil]) ifTrue:[ |
4188 | 3327 |
secondChar isDigit ifTrue:[ |
3328 |
self nextNumber. |
|
3329 |
tokenValue := token := tokenValue negated. |
|
3330 |
^ tokenType |
|
3331 |
] |
|
0 | 3332 |
]. |
141 | 3333 |
string := firstChar asString. |
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3334 |
|
2155 | 3335 |
"/ changed: do not allow second char to be a hash |
3336 |
"/ unless the first is also. |
|
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3337 |
secondChar == $# ifTrue:[ |
4188 | 3338 |
(parserFlags allowHashAsBinarySelector |
3339 |
and:[firstChar == $#]) ifFalse:[ |
|
3340 |
tokenName := token := string. |
|
3341 |
tokenType := #BinaryOperator. |
|
3342 |
^ tokenType |
|
3343 |
]. |
|
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3344 |
]. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3345 |
|
141 | 3346 |
secondChar notNil ifTrue:[ |
4188 | 3347 |
(secondChar == $-) ifTrue:[ |
3348 |
"special- look if minus belongs to number following" |
|
3349 |
p := source position. |
|
3350 |
source next. |
|
3351 |
thirdChar := source peekOrNil. |
|
3352 |
source position:p. |
|
3353 |
(thirdChar notNil and:[thirdChar isDigit]) ifTrue:[ |
|
3354 |
tokenName := token := string. |
|
3355 |
tokenType := #BinaryOperator. |
|
3356 |
self |
|
3357 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with stc and other ST systems' |
|
3358 |
position:p+1 |
|
3359 |
to:p+1. |
|
3360 |
^ tokenType |
|
3361 |
] |
|
3362 |
]. |
|
3363 |
(self isSpecialOrExtendedSpecialCharacter:secondChar) ifTrue:[ |
|
3364 |
source next. |
|
3365 |
string := string copyWith:secondChar. |
|
3366 |
||
3367 |
thirdChar := source peekOrNil. |
|
3368 |
thirdChar notNil ifTrue:[ |
|
3369 |
(self isSpecialOrExtendedSpecialCharacter:thirdChar) ifTrue:[ |
|
3370 |
p := source position. |
|
3371 |
source next. |
|
3372 |
fourthChar := source peekOrNil. |
|
3373 |
source position:p. |
|
3374 |
||
3375 |
(thirdChar == $-) ifTrue:[ |
|
3376 |
"special- look if minus belongs to number following" |
|
3377 |
(fourthChar notNil and:[fourthChar isDigit]) ifTrue:[ |
|
3378 |
tokenName := token := string. |
|
3379 |
tokenType := #BinaryOperator. |
|
3380 |
self |
|
3381 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with stc and other ST systems' |
|
3382 |
position:p+1 |
|
3383 |
to:p+1. |
|
3384 |
^ tokenType |
|
3385 |
]. |
|
3386 |
]. |
|
3387 |
thirdChar == $# ifTrue:[ |
|
3388 |
(fourthChar notNil and:[fourthChar isSeparator]) ifFalse:[ |
|
3389 |
"/ in sth. like ->#foo, the binop is NOT -># |
|
3390 |
tokenName := token := string. |
|
3391 |
tokenType := #BinaryOperator. |
|
3392 |
^ tokenType |
|
3393 |
]. |
|
3394 |
]. |
|
3395 |
source next. |
|
3396 |
string := string copyWith:thirdChar. |
|
3397 |
]. |
|
3398 |
]. |
|
3399 |
]. |
|
141 | 3400 |
]. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3401 |
tokenName := token := string. |
45 | 3402 |
tokenType := #BinaryOperator. |
3 | 3403 |
^ tokenType |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
3404 |
|
4116 | 3405 |
"Modified: / 12-02-2017 / 11:02:51 / cg" |
0 | 3406 |
! |
3407 |
||
1781 | 3408 |
nextString:delimiter |
4291 | 3409 |
"a quote has been scanned; scan the string (caring for doubled quotes)" |
1026 | 3410 |
|
4410 | 3411 |
source next. |
3412 |
^ self xnextString:delimiter escapeStyle:nil |
|
4334 | 3413 |
|
3414 |
" |
|
3415 |
old style ST80 string (no escapes): |
|
3416 |
'hello\new world' |
|
3417 |
||
3418 |
ParserFlags allowCStrings:true. |
|
3419 |
||
3420 |
new style STX c-string (c escapes): |
|
3421 |
c'hello\nnew world' |
|
3422 |
c'hello\tnew world' |
|
3423 |
c'hello\<tab>new world' |
|
4336 | 3424 |
c'a\0b' |
4337 | 3425 |
c'a\n\\\nb' |
3426 |
c'a\r\\\nb' |
|
4334 | 3427 |
|
3428 |
ParserFlags allowCStrings:false. |
|
3429 |
" |
|
3430 |
||
3431 |
"Created: / 01-08-2006 / 14:56:07 / cg" |
|
3432 |
"Modified: / 22-08-2006 / 14:10:26 / cg" |
|
4410 | 3433 |
"Modified: / 22-05-2019 / 20:32:14 / Claus Gittinger" |
4334 | 3434 |
! |
3435 |
||
3436 |
nextString:delimiter escapeStyle:escapeStyle |
|
3437 |
"a quote has been scanned; scan the string (caring for doubled quotes). |
|
3438 |
escapeStyle may be: |
|
3439 |
nil - old style ST80 strings (no character escapes) |
|
4410 | 3440 |
ot a single char string: |
4345 | 3441 |
'c' - C-style escapes: |
4334 | 3442 |
\n,\t,\r,\b,\xXX,\uXXXX,\UXXXXXX, |
4410 | 3443 |
|
3444 |
'e' - C-style plus embedded escapes: |
|
4414 | 3445 |
e'...{ expr1 } ... { exprN }' will generate: |
4410 | 3446 |
'...%1 ... %N' bindWithArguments:{ expr1 . ... . exprN } |
3447 |
||
4345 | 3448 |
'x' - extended-style escapes: |
3449 |
as yet unsupported |
|
3450 |
'r' - regex |
|
3451 |
as yet unsupported |
|
3452 |
||
4334 | 3453 |
" |
3454 |
||
0 | 3455 |
source next. |
4410 | 3456 |
^ self xnextString:delimiter escapeStyle:escapeStyle |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3457 |
|
4334 | 3458 |
"Created: / 08-02-2019 / 19:07:57 / Claus Gittinger" |
4410 | 3459 |
"Modified: / 22-05-2019 / 20:33:04 / Claus Gittinger" |
4414 | 3460 |
"Modified (comment): / 23-05-2019 / 08:52:46 / Claus Gittinger" |
141 | 3461 |
! |
3462 |
||
1656 | 3463 |
nextSymbolAfterHash |
3464 |
"helper: a # has been read - return #Symbol token or nil" |
|
3465 |
||
3948 | 3466 |
^ self nextSymbolAfterHash:'' |
3467 |
! |
|
3468 |
||
3469 |
nextSymbolAfterHash:prefix |
|
3470 |
"helper: #<prefix> has been read - return #Symbol token or nil" |
|
3471 |
||
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3472 |
|nextChar string part isNameSpaceSymbol allowUnderscoreInIdentifier |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3473 |
allowPeriodInSymbol| |
1656 | 3474 |
|
3475 |
nextChar := source peek. |
|
3948 | 3476 |
(nextChar isNil and:[prefix isEmpty]) ifTrue:[^ nil]. |
1656 | 3477 |
|
3478 |
allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier. |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3479 |
allowPeriodInSymbol := parserFlags allowPeriodInSymbol. |
1656 | 3480 |
isNameSpaceSymbol := false. |
3481 |
||
3948 | 3482 |
prefix isEmpty ifTrue:[ |
4188 | 3483 |
nextChar isLetter ifFalse:[ |
3484 |
((nextChar == $_) and:[allowUnderscoreInIdentifier]) ifFalse:[ |
|
3485 |
((nextChar == $.) and:[allowPeriodInSymbol]) ifFalse:[ |
|
3486 |
(nextChar isDigit and:[parserFlags allowSymbolsStartingWithDigit]) ifFalse:[ |
|
3487 |
"/ just for the better error message |
|
3488 |
(nextChar isNationalAlphaNumeric) ifTrue:[ |
|
3489 |
|errMsg| |
|
3490 |
||
3491 |
errMsg := 'Invalid character: ''' , nextChar asString , ''' ', '(' , (nextChar codePoint radixPrintStringRadix:16) , ').'. |
|
3492 |
errMsg := errMsg , '\\Notice:\ Only 7-bit ascii allowed (for compatibility with other Smalltalk dialects).' withCRs. |
|
3493 |
errMsg := errMsg , '\ If you need symbols with 8-bit characters, use the #''...'' form, or ''...'' asSymbol.' withCRs. |
|
3494 |
self syntaxError:errMsg position:tokenPosition to:source position+1. |
|
3495 |
]. |
|
3496 |
^ nil |
|
3497 |
] |
|
3498 |
] |
|
3499 |
] |
|
3500 |
]. |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3501 |
]. |
1656 | 3502 |
|
3948 | 3503 |
string := prefix. |
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3504 |
[ |
4188 | 3505 |
nextChar notNil |
3506 |
and:[nextChar isLetterOrDigit |
|
3507 |
or:[(nextChar == $_ and:[allowUnderscoreInIdentifier]) |
|
3508 |
or:[nextChar == $. and:[allowPeriodInSymbol and:[source peek isLetter]]]] |
|
3509 |
] |
|
1656 | 3510 |
] whileTrue:[ |
4188 | 3511 |
nextChar == $_ ifTrue:[ |
3512 |
part := nil. |
|
3513 |
] ifFalse:[ |
|
3514 |
(allowPeriodInSymbol and:[nextChar == $.]) ifTrue:[ |
|
3515 |
part := nil. |
|
3516 |
] ifFalse:[ |
|
3517 |
part := source nextAlphaNumericWord. |
|
3518 |
] |
|
3519 |
]. |
|
3520 |
part notNil ifTrue:[ |
|
3521 |
string := string , part. |
|
3522 |
]. |
|
3523 |
nextChar := source peek. |
|
3524 |
||
3525 |
((allowUnderscoreInIdentifier and:[nextChar == $_]) |
|
3526 |
or:[ allowPeriodInSymbol and:[nextChar == $.] ]) ifTrue:[ |
|
3527 |
nextChar == $_ ifTrue:[ |
|
3528 |
self warnUnderscoreAt:source position + 1. |
|
3529 |
] ifFalse:[ |
|
3530 |
self warnPeriodAt:source position + 1. |
|
3531 |
]. |
|
3532 |
[(nextChar == $_) or:[(allowPeriodInSymbol and:[nextChar == $.])]] whileTrue:[ |
|
3533 |
string := string copyWith:nextChar. |
|
3534 |
nextChar := source nextPeek. |
|
3535 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[ |
|
3536 |
string := string , source nextAlphaNumericWord. |
|
3537 |
nextChar := source peek. |
|
3538 |
] ifFalse:[ |
|
3539 |
(allowPeriodInSymbol and:[string last == $.]) ifTrue:[ |
|
3540 |
peekChar := nextChar. |
|
3541 |
nextChar := $.. |
|
3542 |
string := string copyButLast:1. |
|
3543 |
tokenValue := token := string asSymbol. |
|
3544 |
tokenType := #Symbol. |
|
3545 |
^ tokenType |
|
3546 |
]. |
|
3547 |
]. |
|
3548 |
]. |
|
3549 |
]. |
|
3550 |
(nextChar == $:) ifFalse:[ |
|
3551 |
self markSymbolFrom:tokenPosition to:(source position). |
|
3552 |
tokenValue := token := string asSymbol. |
|
3553 |
tokenType := #Symbol. |
|
3554 |
^ tokenType |
|
3555 |
]. |
|
3556 |
string := string copyWith:nextChar. |
|
3557 |
nextChar := source nextPeek. |
|
3558 |
parserFlags allowLiteralNameSpaceSymbols ifTrue:[ |
|
3559 |
(nextChar == $:) ifTrue:[ |
|
3560 |
string := string copyWith:nextChar. |
|
3561 |
nextChar := source nextPeek. |
|
3562 |
isNameSpaceSymbol := true. |
|
3563 |
]. |
|
3564 |
]. |
|
3565 |
]. |
|
1656 | 3566 |
tokenValue := token := string asSymbol. |
3567 |
tokenType := #Symbol. |
|
3568 |
^ tokenType |
|
4150 | 3569 |
|
3570 |
"Modified (format): / 18-06-2017 / 16:31:56 / cg" |
|
1656 | 3571 |
! |
3572 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3573 |
nextToken |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3574 |
"return the next token from the source-stream" |
141 | 3575 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3576 |
|skipping actionBlock v ch tok| |
141 | 3577 |
|
4117 | 3578 |
source isPositionable ifTrue:[ |
4188 | 3579 |
tokenLastEndPosition := source position+1. |
4117 | 3580 |
]. |
2612
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
3581 |
|
3405 | 3582 |
[ |
4188 | 3583 |
peekChar notNil ifTrue:[ |
3584 |
"/ kludge - should be called peekSym. |
|
3585 |
"/ used when xlating Foo.Bar into Foo::Bar |
|
3586 |
peekChar isSymbol ifTrue:[ |
|
3587 |
token := nil. |
|
3588 |
tokenType := peekChar. |
|
3589 |
peekChar := nil. |
|
3590 |
^ tokenType |
|
3591 |
]. |
|
3592 |
||
3593 |
(peekChar isSeparator or:[ peekChar codePoint == 16rFEFF ]) ifTrue:[ |
|
3594 |
peekChar == (Character cr) ifTrue:[ |
|
3595 |
lineNr := lineNr + 1. |
|
3596 |
]. |
|
3597 |
hereChar := peekChar. |
|
3598 |
peekChar := peekChar2. |
|
3599 |
peekChar2 := nil. |
|
3600 |
(hereChar == Character cr) ifTrue:[ |
|
3601 |
(self eolIsWhiteSpace) ifFalse:[ |
|
3602 |
token := nil. |
|
3603 |
tokenType := #EOL. |
|
3604 |
^ tokenType |
|
3605 |
]. |
|
3606 |
]. |
|
3607 |
]. |
|
3608 |
]. |
|
3609 |
||
3610 |
peekChar notNil ifTrue:[ |
|
3611 |
ch := peekChar. |
|
3612 |
peekChar := peekChar2. |
|
3613 |
peekChar2 := nil. |
|
3614 |
hereChar := nil. |
|
3615 |
] ifFalse:[ |
|
3616 |
skipping := true. |
|
3617 |
[skipping] whileTrue:[ |
|
3618 |
||
3619 |
outStream notNil ifTrue:[ |
|
3620 |
[ |
|
3621 |
hereChar := source peekOrNil. |
|
3622 |
(hereChar notNil |
|
3623 |
and:[(hereChar == Character space) or:[hereChar isSeparator]]) |
|
3624 |
] whileTrue:[ |
|
3625 |
source next. |
|
3626 |
outStream space. |
|
3627 |
outCol := outCol + 1. |
|
3628 |
hereChar == (Character cr) ifTrue:[ |
|
3629 |
self eolIsWhiteSpace ifFalse:[ |
|
3630 |
source isPositionable ifTrue:[ |
|
3631 |
tokenPosition := source position. |
|
3632 |
]. |
|
3633 |
token := nil. |
|
3634 |
tokenType := #EOL. |
|
3635 |
^ tokenType |
|
3636 |
]. |
|
3637 |
] |
|
3638 |
] |
|
3639 |
] ifFalse:[ |
|
3640 |
hereChar := source skipSeparatorsExceptCR. |
|
3641 |
]. |
|
3642 |
||
3643 |
hereChar isNil ifTrue:[ |
|
3644 |
skipping := false |
|
3645 |
] ifFalse:[ |
|
3646 |
hereChar == (Character cr) ifTrue:[ |
|
3647 |
lineNr := lineNr + 1. |
|
3648 |
source next. |
|
3649 |
outStream notNil ifTrue:[ |
|
3650 |
outStream cr. |
|
3651 |
outCol := 1 |
|
3652 |
]. |
|
3653 |
self eolIsWhiteSpace ifFalse:[ |
|
3654 |
source isPositionable ifTrue:[ |
|
3655 |
tokenPosition := source position. |
|
3656 |
]. |
|
3657 |
token := nil. |
|
3658 |
tokenType := #EOL. |
|
3659 |
^ tokenType |
|
3660 |
]. |
|
3661 |
] ifFalse:[ |
|
3662 |
hereChar == (Character return) ifTrue:[ |
|
3663 |
outStream notNil ifTrue:[ |
|
3664 |
outStream nextPut:hereChar. |
|
3665 |
outCol := 1 |
|
3666 |
]. |
|
3667 |
source next. |
|
3668 |
] ifFalse:[ |
|
3669 |
(self isCommentCharacter:hereChar) ifTrue:[ |
|
3670 |
"start of a comment" |
|
3671 |
||
3672 |
self skipComment. |
|
3673 |
hereChar := source peekOrNil. |
|
3674 |
] ifFalse:[ |
|
3675 |
skipping := false |
|
3676 |
] |
|
3677 |
] |
|
3678 |
] |
|
3679 |
]. |
|
3680 |
]. |
|
3681 |
hereChar isNil ifTrue:[ |
|
3682 |
source isPositionable ifTrue:[ |
|
3683 |
tokenPosition := source position + 1. |
|
3684 |
]. |
|
3685 |
token := nil. |
|
3686 |
tokenType := #EOF. |
|
3687 |
^ tokenType |
|
3688 |
]. |
|
3689 |
ch := hereChar |
|
3690 |
]. |
|
3691 |
source isPositionable ifTrue:[ |
|
3692 |
tokenPosition := source position + 1. |
|
3693 |
]. |
|
3694 |
tokenLineNr := lineNr. |
|
3695 |
||
3696 |
(v := ch codePoint) == 0 ifTrue:[ |
|
3697 |
v := Character space codePoint |
|
3698 |
]. |
|
3699 |
v <= 16rFF ifTrue:[ |
|
3700 |
actionBlock := actionArray at:v. |
|
3701 |
] ifFalse:[ |
|
3702 |
actionBlock := unicodeActions at:v ifAbsent:nil |
|
3703 |
]. |
|
3704 |
actionBlock notNil ifTrue:[ |
|
3705 |
tok := actionBlock value:self value:ch. |
|
3706 |
tok notNil ifTrue:[ |
|
3707 |
^ tok |
|
3708 |
]. |
|
3709 |
"/ a nil token means: continue reading |
|
3710 |
] ifFalse:[ |
|
3711 |
(ch isNationalLetter and:[parserFlags allowNationalCharactersInIdentifier]) ifTrue:[ |
|
3712 |
tok := self nextIdentifier. |
|
3713 |
tok notNil ifTrue:[ |
|
3714 |
^ tok |
|
3715 |
]. |
|
3716 |
"/ a nil token means: continue reading |
|
3717 |
] ifFalse:[ |
|
4414 | 3718 |
(ch == $§ and:[parserFlags allowParagraphInIdentifier]) ifTrue:[ |
4188 | 3719 |
tok := self nextIdentifier. |
3720 |
tok notNil ifTrue:[ |
|
3721 |
^ tok |
|
3722 |
]. |
|
3723 |
"/ a nil token means: continue reading |
|
3724 |
] ifFalse:[ |
|
3725 |
^ self invalidCharacter:ch. |
|
3726 |
]. |
|
3727 |
]. |
|
3728 |
] |
|
3405 | 3729 |
] loop. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
546
diff
changeset
|
3730 |
|
2481 | 3731 |
"Modified: / 13-09-1995 / 12:56:14 / claus" |
2612
6c04d60c1403
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2523
diff
changeset
|
3732 |
"Modified: / 27-07-2011 / 15:36:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4117 | 3733 |
"Modified: / 12-02-2017 / 11:27:59 / cg" |
141 | 3734 |
! |
3735 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3736 |
nextToken:aCharacter |
1026 | 3737 |
"return a character token" |
3738 |
||
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
3739 |
tokenType := token := aCharacter. |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
546
diff
changeset
|
3740 |
hereChar notNil ifTrue:[source next]. |
141 | 3741 |
^ tokenType |
603
021722b8a427
correctly scan trailing period after a number in a block (as in x := x + 1.]
Claus Gittinger <cg@exept.de>
parents:
546
diff
changeset
|
3742 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
3743 |
"Modified: / 13.5.1998 / 15:10:23 / cg" |
141 | 3744 |
! |
3745 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3746 |
nextUnderline |
3380 | 3747 |
"return either an identifier, or an underline (sometimes an assignment) token" |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3748 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3749 |
parserFlags allowUnderscoreInIdentifier ifTrue:[ |
4188 | 3750 |
^ self nextIdentifier |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3751 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3752 |
^ self nextToken:$_ |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3753 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3754 |
|
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3755 |
skipComment |
4188 | 3756 |
"skip over a comment; |
3463 | 3757 |
handles ST/X eol comments (quote-slash) |
4173 | 3758 |
and multiline-delimiter comment (quote-less-less). |
3759 |
Multiline-delimiter comments start with ''<<TOKEN and end in a line which starts with TOKEN (quote-quote being a double quote here)" |
|
2983 | 3760 |
|
3761 |
|commentStream commentType commentText startPos endPos stillInComment anyNonBlank |
|
3456 | 3762 |
delimiter line| |
1653 | 3763 |
|
3764 |
anyNonBlank := false. |
|
141 | 3765 |
|
3766 |
saveComments ifTrue:[ |
|
4190 | 3767 |
commentStream := CharacterWriteStream on:''. |
3768 |
self beginComment. |
|
141 | 3769 |
]. |
3770 |
||
3771 |
outStream notNil ifTrue:[ |
|
4190 | 3772 |
outStream nextPut:Character doubleQuote. |
3773 |
outCol := outCol + 1 |
|
141 | 3774 |
]. |
3775 |
||
3268 | 3776 |
startPos := source position + 1. |
141 | 3777 |
source next. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
3778 |
hereChar := source peekOrNil. |
2983 | 3779 |
commentType := #regularComment. |
141 | 3780 |
|
3781 |
" |
|
3782 |
special ST/X addition: |
|
3783 |
a $/ right after the initial double quote makes it an up-to-end-of-line comment, |
|
3784 |
which is very useful to comment out parts of filed-in source code. |
|
3312 | 3785 |
Since this is non-standard, you loose compatibility with other Smalltalks, if you use it. |
3786 |
(however, it is so convenient - I don't want to miss it) |
|
3787 |
" |
|
1707
28a94a1701c2
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1705
diff
changeset
|
3788 |
(hereChar == $/ and:[parserFlags allowSTXEOLComments]) ifTrue:[ |
4190 | 3789 |
hereChar := source nextPeek. |
3790 |
||
3791 |
self skipToEndOfLineRememberingIn:commentStream. |
|
3792 |
endPos := source position. |
|
3793 |
self markCommentFrom:startPos to:endPos+1. |
|
3794 |
commentType := #eolComment. |
|
3795 |
self warnSTXSpecialCommentAt:startPos to:endPos. |
|
3796 |
outStream notNil ifTrue:[ |
|
3797 |
outStream cr. |
|
3798 |
outCol := 1 |
|
3799 |
]. |
|
3800 |
"skip cr" |
|
3801 |
source next. |
|
141 | 3802 |
] ifFalse:[ |
4190 | 3803 |
(hereChar == $< and:[parserFlags allowSTXDelimiterComments]) ifTrue:[ |
3804 |
hereChar := source nextPeek. |
|
3805 |
(hereChar == $<) ifTrue:[ |
|
3806 |
" |
|
3807 |
another special ST/X addition: |
|
3808 |
a << right after the initial double quote makes it a token delimited comment, |
|
3809 |
which continues up to a line starting with the token. |
|
3810 |
This is very useful to comment out which contain any other type of comment. |
|
3811 |
Since this is non-standard, you loose compatibility with other Smalltalks, if you use it. |
|
3812 |
" |
|
3813 |
commentStream notNil ifTrue:[ |
|
3814 |
commentStream nextPutAll:'<<' |
|
3815 |
]. |
|
3816 |
hereChar := source nextPeek. |
|
3817 |
||
3818 |
delimiter := String streamContents:[:s | self skipToEndOfLineRememberingIn:s]. |
|
3819 |
delimiter := delimiter withoutSeparators. |
|
3820 |
delimiter isEmpty ifTrue:[ |
|
3821 |
self parseError:'invalid delimiter in comment'. |
|
3822 |
^ self |
|
3823 |
]. |
|
3824 |
((delimiter first isLetterOrUnderline) |
|
3825 |
and:[delimiter from:2 conform:[:ch | ch isLetterOrDigit]]) ifFalse:[ |
|
3826 |
"/ treat as regular comment |
|
3827 |
commentType := #regularComment. |
|
3828 |
source position:startPos. |
|
3829 |
] ifTrue:[ |
|
3830 |
"/ delimiter comment |
|
3831 |
hereChar == Character cr ifTrue:[ |
|
3832 |
hereChar := source nextPeek. |
|
3833 |
]. |
|
3834 |
commentStream notNil ifTrue:[ |
|
3835 |
commentStream nextPutLine:delimiter |
|
3836 |
]. |
|
3837 |
stillInComment := true. |
|
3838 |
[stillInComment and:[hereChar notNil]] whileTrue:[ |
|
3839 |
line := String streamContents:[:s | self skipToEndOfLineRememberingIn:s]. |
|
3840 |
commentStream notNil ifTrue:[ |
|
3841 |
commentStream nextPutLine:line |
|
3842 |
]. |
|
3843 |
hereChar == Character cr ifTrue:[ |
|
3844 |
hereChar := source nextPeek. |
|
3845 |
]. |
|
3846 |
stillInComment := (line startsWith:delimiter) not. |
|
3847 |
]. |
|
3848 |
stillInComment ifTrue:[ |
|
3849 |
self markCommentFrom:startPos to:(source collectionSize). |
|
3850 |
self warning:'unclosed comment (missing delimiter: "',delimiter,'")' position:startPos to:(source position + 1) |
|
3851 |
]. |
|
3852 |
self markCommentFrom:startPos to:(source position + 1). |
|
3853 |
commentType := #delimiterComment. |
|
3854 |
] |
|
3855 |
] ifFalse:[ |
|
3856 |
commentStream notNil ifTrue:[ |
|
3857 |
commentStream nextPut:$< |
|
3858 |
]. |
|
3859 |
]. |
|
3860 |
]. |
|
3861 |
||
3862 |
(commentType == #regularComment) ifTrue:[ |
|
3863 |
hereChar == ${ ifTrue:[ |
|
3864 |
" |
|
3865 |
special ST/X addition: |
|
3866 |
a ${ right after the initial double quote starts a directive |
|
3867 |
" |
|
3868 |
self parseDirective |
|
3869 |
]. |
|
3870 |
||
3871 |
stillInComment := true. |
|
3872 |
[stillInComment] whileTrue:[ |
|
3873 |
stillInComment := false. |
|
3874 |
||
3875 |
[hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[ |
|
3876 |
hereChar isSeparator ifFalse:[ anyNonBlank := true ]. |
|
3877 |
hereChar == (Character cr) ifTrue:[ |
|
3878 |
lineNr := lineNr + 1. |
|
3879 |
]. |
|
3880 |
commentStream notNil ifTrue:[ |
|
3881 |
commentStream nextPut:hereChar |
|
3882 |
]. |
|
3883 |
outStream notNil ifTrue:[ |
|
3884 |
outStream nextPut:hereChar. |
|
3885 |
outCol := outCol + 1 |
|
3886 |
]. |
|
3887 |
hereChar := source nextPeek |
|
3888 |
]. |
|
3889 |
||
3890 |
hereChar isNil ifTrue:[ |
|
3891 |
self markCommentFrom:startPos to:(source collectionSize). |
|
3892 |
self warning:'unclosed comment' position:startPos to:(source position + 1) |
|
3893 |
] ifFalse:[ |
|
3894 |
self markCommentFrom:startPos to:(source position + 1). |
|
3895 |
outStream notNil ifTrue:[ |
|
3896 |
outStream nextPut:(Character doubleQuote). |
|
3897 |
outCol := outCol + 1 |
|
3898 |
]. |
|
3899 |
]. |
|
3900 |
endPos := source position. |
|
3901 |
"skip final dQuote" |
|
3902 |
source next. |
|
3903 |
||
3904 |
(source peek == Character doubleQuote) ifTrue:[ |
|
3905 |
stillInComment := true. |
|
3906 |
hereChar := source nextPeek. |
|
3907 |
]. |
|
3908 |
]. |
|
3909 |
] |
|
141 | 3910 |
]. |
3911 |
||
3912 |
saveComments ifTrue:[ |
|
4190 | 3913 |
commentText := commentStream contents. |
3914 |
self endComment:commentText type:commentType start:startPos end:endPos. |
|
1653 | 3915 |
]. |
3916 |
||
3288 | 3917 |
ignoreWarnings ifFalse:[ |
4190 | 3918 |
parserFlags warnAboutBadComments ifTrue:[ |
3919 |
anyNonBlank ifFalse:[ |
|
3920 |
commentType == #regularComment ifTrue:[ |
|
3921 |
self isDoIt ifFalse:[ |
|
3922 |
self |
|
3923 |
warning:'empty comment' |
|
3924 |
doNotShowAgainAction:[ ParserFlags warnAboutBadComments: false ] |
|
3925 |
position:startPos to:endPos+1. |
|
3926 |
parserFlags warnAboutBadComments:false. |
|
3927 |
] |
|
3928 |
]. |
|
3929 |
]. |
|
3930 |
]. |
|
141 | 3931 |
]. |
4173 | 3932 |
|
4190 | 3933 |
"Modified: / 30-08-2017 / 09:58:02 / cg" |
2138 | 3934 |
! |
3935 |
||
3936 |
skipToEndOfLineRememberingIn:commentStreamOrNil |
|
3937 |
[hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[ |
|
4188 | 3938 |
commentStreamOrNil notNil ifTrue:[ |
3939 |
commentStreamOrNil nextPut:hereChar |
|
3940 |
]. |
|
3941 |
outStream notNil ifTrue:[ |
|
3942 |
outStream nextPut:hereChar. |
|
3943 |
outCol := outCol + 1 |
|
3944 |
]. |
|
3945 |
hereChar := source nextPeek. |
|
2138 | 3946 |
]. |
2983 | 3947 |
lineNr := lineNr + 1. |
4410 | 3948 |
! |
3949 |
||
3950 |
xnextString:delimiter escapeStyle:escapeStyle |
|
3951 |
"a quote has been scanned; scan the string (caring for doubled quotes). |
|
3952 |
escapeStyle may be: |
|
3953 |
nil - old style ST80 strings (no character escapes) |
|
4414 | 3954 |
or a single char string: |
4410 | 3955 |
'c' - C-style escapes: |
3956 |
\n,\t,\r,\b,\xXX,\uXXXX,\UXXXXXX, |
|
3957 |
||
3958 |
'e' - C-style plus embedded escapes: |
|
4414 | 3959 |
e'...{ expr1 } ... { exprN }' will generate: |
4410 | 3960 |
'...%1 ... %N' bindWithArguments:{ expr1 . ... . exprN } |
3961 |
||
3962 |
'x' - extended-style escapes: |
|
3963 |
as yet unsupported |
|
3964 |
'r' - regex |
|
3965 |
as yet unsupported |
|
3966 |
||
3967 |
" |
|
3968 |
||
3969 |
|nextChar string pos |
|
3970 |
index "{ Class: SmallInteger }" |
|
3971 |
len "{ Class: SmallInteger }" |
|
4414 | 3972 |
inString peekChar |
3973 |
isCString isEString| |
|
3974 |
||
3975 |
isEString := (escapeStyle = 'e'). |
|
3976 |
isCString := (escapeStyle = 'c'). |
|
3977 |
||
4410 | 3978 |
string := String uninitializedNew:20. |
3979 |
len := 20. |
|
3980 |
index := 1. |
|
3981 |
pos := source position. |
|
3982 |
nextChar := source next. |
|
3983 |
inString := true. |
|
3984 |
||
3985 |
[inString] whileTrue:[ |
|
3986 |
nextChar isNil ifTrue:[ |
|
3987 |
self syntaxError:'unexpected end-of-input in String' |
|
3988 |
position:pos to:(source position). |
|
3989 |
self markStringFrom:pos to:source position. |
|
3990 |
token := nil. |
|
3991 |
tokenType := #EOF. |
|
3992 |
^ tokenType |
|
3993 |
]. |
|
3994 |
(nextChar == Character cr) ifTrue:[ |
|
3995 |
lineNr := lineNr + 1 |
|
3996 |
] ifFalse:[ |
|
3997 |
(nextChar == delimiter) ifTrue:[ |
|
3998 |
(source peekOrNil == delimiter) ifTrue:[ |
|
3999 |
source next |
|
4000 |
] ifFalse:[ |
|
4001 |
inString := false |
|
4002 |
] |
|
4003 |
] ifFalse:[ |
|
4414 | 4004 |
escapeStyle notNil ifTrue:[ |
4005 |
((nextChar == ${) and:[isEString]) ifTrue:[ |
|
4006 |
"/ bail out, to read one expression |
|
4007 |
tokenValue := token := string copyTo:(index - 1). |
|
4008 |
tokenType := #StringFragment. |
|
4009 |
^ tokenType |
|
4010 |
]. |
|
4410 | 4011 |
(nextChar == $\) ifTrue:[ |
4012 |
peekChar := source peekOrNil. |
|
4013 |
peekChar notNil ifTrue:[ |
|
4014 |
source next. |
|
4414 | 4015 |
nextChar := self escapeCharacterFor:peekChar escapeStyle:escapeStyle. |
4410 | 4016 |
] |
4017 |
] |
|
4018 |
] |
|
4019 |
]. |
|
4020 |
]. |
|
4021 |
inString ifTrue:[ |
|
4022 |
nextChar notNil ifTrue:[ |
|
4023 |
nextChar codePoint > 255 ifTrue:[ |
|
4024 |
string bitsPerCharacter < nextChar bitsPerCharacter ifTrue:[ |
|
4025 |
nextChar codePoint > 16rFFFF ifTrue:[ |
|
4026 |
string := string asUnicode32String |
|
4027 |
] ifFalse:[ |
|
4028 |
string := string asUnicode16String. |
|
4029 |
]. |
|
4030 |
]. |
|
4031 |
]. |
|
4032 |
string at:index put:nextChar. |
|
4033 |
(index == len) ifTrue:[ |
|
4034 |
string := string , (string species new:len). |
|
4035 |
len := len * 2 |
|
4036 |
]. |
|
4037 |
index := index + 1. |
|
4038 |
]. |
|
4039 |
nextChar := source next |
|
4040 |
] |
|
4041 |
]. |
|
4042 |
||
4043 |
tokenValue := token := string copyTo:(index - 1). |
|
4044 |
tokenType := #String. |
|
4045 |
^ tokenType |
|
4046 |
||
4047 |
"Created: / 22-05-2019 / 20:31:36 / Claus Gittinger" |
|
4414 | 4048 |
"Modified: / 23-05-2019 / 10:45:19 / Claus Gittinger" |
648 | 4049 |
! ! |
4050 |
||
4051 |
!Scanner::Comment methodsFor:'accessing'! |
|
4052 |
||
4053 |
commentString |
|
4054 |
"return the value of the instance variable 'commentString' (automatically generated)" |
|
4055 |
||
4056 |
^ commentString |
|
4057 |
||
4058 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
4059 |
! |
|
4060 |
||
4061 |
commentString:something |
|
4062 |
"set the value of the instance variable 'commentString' (automatically generated)" |
|
4063 |
||
4064 |
commentString := something. |
|
4065 |
||
4066 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
4067 |
! |
|
4068 |
||
1596 | 4069 |
commentString:commentStringArg commentType:commentTypeArg |
4070 |
commentString := commentStringArg. |
|
4071 |
commentType := commentTypeArg. |
|
4072 |
||
4073 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
4074 |
! |
|
4075 |
||
648 | 4076 |
commentType |
4077 |
^ commentType |
|
4078 |
||
4079 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
4080 |
! |
|
4081 |
||
4082 |
commentType:something |
|
4083 |
commentType := something. |
|
4084 |
||
4085 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
4086 |
! |
|
4087 |
||
3551 | 4088 |
endPosition |
4089 |
^ endPosition |
|
4090 |
! |
|
4091 |
||
4092 |
endPosition:something |
|
4093 |
endPosition := something. |
|
4094 |
! |
|
4095 |
||
4096 |
startPosition |
|
4097 |
^ startPosition |
|
4098 |
! |
|
4099 |
||
4100 |
startPosition:something |
|
4101 |
startPosition := something. |
|
4102 |
! |
|
4103 |
||
4188 | 4104 |
startPosition:startPositionArg endPosition:endPositionArg |
3551 | 4105 |
startPosition := startPositionArg. |
4106 |
endPosition := endPositionArg. |
|
4107 |
! |
|
4108 |
||
648 | 4109 |
string |
4110 |
^ commentString |
|
4111 |
||
4112 |
"Created: / 17.2.1998 / 14:49:52 / cg" |
|
0 | 4113 |
! ! |
141 | 4114 |
|
1580 | 4115 |
!Scanner::Comment methodsFor:'converting'! |
4116 |
||
4117 |
asString |
|
4118 |
^ commentString. |
|
1583 | 4119 |
! |
4120 |
||
4121 |
asStringCollection |
|
4122 |
^ commentString asStringCollection. |
|
1580 | 4123 |
! ! |
4124 |
||
1651 | 4125 |
!Scanner::Comment methodsFor:'queries'! |
4126 |
||
4127 |
isEndOfLineComment |
|
4128 |
^ commentType == #eolComment |
|
4129 |
! ! |
|
4130 |
||
1596 | 4131 |
!Scanner::Directive class methodsFor:'instance creation'! |
4132 |
||
4133 |
newClassDirective |
|
4134 |
^ ClassDirective new |
|
4135 |
! |
|
4136 |
||
4137 |
newClassHintDirective |
|
4138 |
^ ClassHintDirective new |
|
4139 |
! ! |
|
4140 |
||
1598 | 4141 |
!Scanner::Directive methodsFor:'queries'! |
4142 |
||
4143 |
isClassHintDirective |
|
4144 |
^ false |
|
4145 |
! ! |
|
4146 |
||
1596 | 4147 |
!Scanner::Directive::ClassDirective methodsFor:'accessing'! |
4148 |
||
4149 |
className |
|
4150 |
^ className |
|
4151 |
! |
|
4152 |
||
4153 |
className:something |
|
4154 |
className := something. |
|
4155 |
! ! |
|
4156 |
||
1598 | 4157 |
!Scanner::Directive::ClassHintDirective methodsFor:'queries'! |
4158 |
||
4159 |
isClassHintDirective |
|
4160 |
^ true |
|
4161 |
! ! |
|
4162 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
4163 |
!Scanner class methodsFor:'documentation'! |
148 | 4164 |
|
2740 | 4165 |
version |
3695 | 4166 |
^ '$Header$' |
2740 | 4167 |
! |
4168 |
||
2290 | 4169 |
version_CVS |
3695 | 4170 |
^ '$Header$' |
148 | 4171 |
! ! |
1321 | 4172 |
|
3056 | 4173 |
|
141 | 4174 |
Scanner initialize! |