author | Claus Gittinger <cg@exept.de> |
Tue, 19 Apr 2005 11:06:22 +0200 | |
changeset 1580 | c4b1c5e36c67 |
parent 1577 | 31648db46af5 |
child 1582 | 701f40070c8a |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
45 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
1073 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
0 | 15 |
Object subclass:#Scanner |
709 | 16 |
instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition |
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
17 |
tokenValue tokenName tokenLineNr hereChar peekChar peekChar2 |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
18 |
requestor exitBlock errorFlag ignoreErrors ignoreWarnings |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
19 |
saveComments currentComments collectedSource |
709 | 20 |
allowUnderscoreInIdentifier allowDollarInIdentifier |
1362 | 21 |
allowOldStyleAssignment scanColonAsKeyword allowSqueakExtensions |
22 |
warnSTXSpecialComment warnUnderscoreInIdentifier |
|
23 |
warnOldStyleAssignment warnCommonMistakes outStream outCol |
|
24 |
warnSTXNameSpaceUse warnPossibleIncompatibilities |
|
1572 | 25 |
warnDollarInIdentifier inArrayLiteral |
26 |
allowLiteralNameSpaceSymbols' |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
27 |
classVariableNames:'TypeArray ActionArray Warnings EmptySourceNotificationSignal |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
28 |
WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier |
608 | 29 |
WarnCommonMistakes WarnPossibleIncompatibilities |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
30 |
WarnDollarInIdentifier AllowUnderscoreInIdentifier |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
31 |
AllowDollarInIdentifier AllowSqueakExtensions AllowQualifiedNames |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
32 |
AllowDolphinExtensions AllowOldStyleAssignment |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
33 |
AllowExtendedBinarySelectors AllowExtendedSTXSyntax |
1572 | 34 |
AllowFixedPointLiterals AllowLiteralNameSpaceSymbols' |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
35 |
poolDictionaries:'' |
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
36 |
category:'System-Compiler' |
0 | 37 |
! |
38 |
||
648 | 39 |
Object subclass:#Comment |
40 |
instanceVariableNames:'commentType commentString' |
|
41 |
classVariableNames:'' |
|
42 |
poolDictionaries:'' |
|
43 |
privateIn:Scanner |
|
44 |
! |
|
45 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
46 |
Query subclass:#DoNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
47 |
instanceVariableNames:'' |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
48 |
classVariableNames:'' |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
49 |
poolDictionaries:'' |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
50 |
privateIn:Scanner |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
51 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
52 |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
53 |
!Scanner class methodsFor:'documentation'! |
20 | 54 |
|
901 | 55 |
bugs |
56 |
" |
|
57 |
array constant containing keywords as in: |
|
58 |
#( |
|
59 |
foo:bar: |
|
60 |
fee:baz: |
|
61 |
) |
|
62 |
||
63 |
is scanned as 4-element array containing ( #foo: #bar: #fee: #baz: ) |
|
64 |
this MUST be fixed. |
|
65 |
||
66 |
workaround: |
|
67 |
#( |
|
68 |
#'foo:bar:' |
|
69 |
#'fee:baz:' |
|
70 |
) |
|
71 |
||
72 |
" |
|
73 |
! |
|
74 |
||
20 | 75 |
copyright |
76 |
" |
|
77 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
45 | 78 |
All Rights Reserved |
20 | 79 |
|
80 |
This software is furnished under a license and may be used |
|
81 |
only in accordance with the terms of that license and with the |
|
82 |
inclusion of the above copyright notice. This software may not |
|
83 |
be provided or otherwise made available to, or used by, any |
|
84 |
other person. No title to or ownership of the software is |
|
85 |
hereby transferred. |
|
86 |
" |
|
87 |
! |
|
88 |
||
89 |
documentation |
|
90 |
" |
|
91 |
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
|
92 |
Its main method is #nextToken, which reads and returns the next token |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
93 |
Possibly placing additional information (such as tokenValue) into |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
94 |
instance variables as a side effect. |
75 | 95 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
96 |
TODO: |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
97 |
some testers noticed, that ST-80's scanner methods are called |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
98 |
xLetter, xDigit etc. For code using these (internals), the nextNumber, |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
99 |
nextIdentifier etc. methods should be renamed. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
100 |
(to me, these seem to be internal private methods; |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
101 |
their public use is not a good idea ..) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
102 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
103 |
Scanner is typically subclassed for parsing and #nextToken |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
104 |
invoked via #self-sends. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
105 |
This should be changed and scanner ought to be an instance variable |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
106 |
of Parser - this allows more flexible use of the scanner/parser |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
107 |
framework (i.e. changing the scanner without affecting the parser). |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
108 |
|
1302 | 109 |
Extensions: |
110 |
this scanner allows for 3-character binary selectors. |
|
111 |
also, # is a valid selector. (however, ## is currently scanned as a symbol literal). |
|
112 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
113 |
[author:] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
114 |
Claus Gittinger |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
115 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
116 |
[see also:] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
117 |
Parser |
20 | 118 |
" |
41 | 119 |
! ! |
120 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
121 |
!Scanner class methodsFor:'initialization'! |
33 | 122 |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
123 |
binarySelectorCharacters |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
124 |
"return a collection of characters which are allowed in |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
125 |
binary selectors" |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
126 |
|
1288 | 127 |
|characters| |
128 |
||
129 |
characters := #( $& $- $+ $= $* $/ $\ $< $> $~ $@ $, $? $!! $| $% $#). |
|
130 |
AllowExtendedBinarySelectors ifTrue:[ |
|
131 |
characters := characters asOrderedCollection. |
|
132 |
characters add:(Character value:16rB1). "/ plus-minus |
|
133 |
characters add:(Character value:16rD7). "/ times |
|
134 |
characters add:(Character value:16rB7). "/ centered dot |
|
135 |
characters add:(Character value:16rF7). "/ divide |
|
136 |
]. |
|
137 |
^ characters |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
138 |
|
650
a8bcb32d1665
added #% as binop in typeTable.
Claus Gittinger <cg@exept.de>
parents:
648
diff
changeset
|
139 |
"Created: / 4.1.1997 / 14:13:24 / cg" |
a8bcb32d1665
added #% as binop in typeTable.
Claus Gittinger <cg@exept.de>
parents:
648
diff
changeset
|
140 |
"Modified: / 27.2.1998 / 02:01:28 / cg" |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
141 |
! |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
142 |
|
33 | 143 |
setupActions |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
144 |
"initialize the scanners actionTables - these are used to dispatch |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
145 |
into scanner methods as characters are read" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
146 |
|
33 | 147 |
|block| |
148 |
||
149 |
ActionArray := Array new:256. |
|
150 |
TypeArray := Array new:256. |
|
151 |
||
1303 | 152 |
"/ TODO: later versions should be configurable w.r.t separators. |
153 |
"/ #(9 10 12 13 26 32) do: [:i | TypeArray at:(i+1) put: #separator]. |
|
154 |
||
33 | 155 |
block := [:s :char | s nextNumber]. |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
156 |
($0 codePoint) to:($9 codePoint) do:[:index | |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
157 |
ActionArray at:index put:block |
33 | 158 |
]. |
159 |
||
87 | 160 |
block := [:s :char | s nextSpecial]. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
161 |
self binarySelectorCharacters do:[:binop | |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
162 |
TypeArray at:(binop codePoint) put:#special. |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
163 |
ActionArray at:(binop codePoint) put:block |
87 | 164 |
]. |
165 |
||
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
166 |
"/ that one is a special case (both binarySelector AND syntax). |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
167 |
TypeArray at:($| codePoint) put:nil. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
168 |
|
87 | 169 |
block := [:s :char | s nextToken:char]. |
1510
875c90576897
Fix duplicate assignment to ActionArray for sh
Stefan Vogel <sv@exept.de>
parents:
1509
diff
changeset
|
170 |
';.^|()[]{}' do:[:ch | |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
171 |
ActionArray at:(ch codePoint) put:block |
87 | 172 |
]. |
173 |
||
33 | 174 |
block := [:s :char | s nextIdentifier]. |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
175 |
($a codePoint) to:($z codePoint) do:[:index | |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
176 |
ActionArray at:index put:block |
33 | 177 |
]. |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
178 |
($A codePoint) to:($Z codePoint) do:[:index | |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
179 |
ActionArray at:index put:block |
33 | 180 |
]. |
181 |
||
182 |
"kludge: action is characterToken, but type is special" |
|
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
183 |
TypeArray at:($| codePoint) put:#special. |
33 | 184 |
|
80 | 185 |
"kludge: action is nextColonOrAssign, but type is special" |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
186 |
TypeArray at:($: codePoint) put:#special. |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
187 |
|
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
188 |
ActionArray at:($' codePoint) put:[:s :char | s nextString]. |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
189 |
ActionArray at:($$ codePoint) put:[:s :char | s nextCharacter]. |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
190 |
ActionArray at:($# codePoint) put:[:s :char | s nextHash]. |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
191 |
ActionArray at:($!! codePoint) put:[:s :char | s nextExcla]. |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
192 |
ActionArray at:($% codePoint) put:[:s :char | s nextPrimitive]. |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
193 |
ActionArray at:($: codePoint) put:[:s :char | s nextColonOrAssign]. |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
194 |
ActionArray at:($_ codePoint) put:[:s :char | s nextUnderline]. |
33 | 195 |
|
196 |
" |
|
197 |
Scanner setupActions |
|
198 |
" |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
199 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
200 |
"Modified: 23.5.1997 / 12:07:55 / cg" |
33 | 201 |
! ! |
202 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
203 |
!Scanner class methodsFor:'instance creation'! |
141 | 204 |
|
205 |
for:aStringOrStream |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
206 |
"create & return a new scanner reading from aStringOrStream" |
141 | 207 |
|
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
208 |
^ self basicNew initializeFor:aStringOrStream |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
209 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
210 |
"Modified: 23.5.1997 / 12:08:42 / cg" |
854 | 211 |
! |
212 |
||
213 |
new |
|
214 |
"create & return a new scanner" |
|
215 |
||
859 | 216 |
^ self basicNew initialize. |
854 | 217 |
|
218 |
"Modified: / 23.5.1997 / 12:08:42 / cg" |
|
219 |
"Created: / 26.5.1999 / 12:02:16 / stefan" |
|
141 | 220 |
! ! |
221 |
||
717 | 222 |
!Scanner class methodsFor:'Signal constants'! |
223 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
224 |
doNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
225 |
^ DoNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
226 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
227 |
|
717 | 228 |
emptySourceNotificationSignal |
229 |
^ EmptySourceNotificationSignal |
|
230 |
||
231 |
"Created: / 16.5.1998 / 15:55:14 / cg" |
|
232 |
! ! |
|
233 |
||
234 |
!Scanner class methodsFor:'class initialization'! |
|
235 |
||
236 |
initialize |
|
237 |
"initialize the classes defaults. Typically, these are changed |
|
238 |
later in the 'private.rc' file." |
|
239 |
||
240 |
EmptySourceNotificationSignal isNil ifTrue:[ |
|
241 |
EmptySourceNotificationSignal := QuerySignal new mayProceed:true. |
|
242 |
EmptySourceNotificationSignal notifierString:'empty source given to evaluate'. |
|
243 |
EmptySourceNotificationSignal nameClass:self message:#emptySourceNotificationSignal. |
|
244 |
]. |
|
245 |
||
246 |
Warnings := true. |
|
1002
bf15e400f54e
default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
247 |
WarnSTXSpecials := false. |
bf15e400f54e
default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
248 |
WarnUnderscoreInIdentifier := false. |
717 | 249 |
WarnDollarInIdentifier := true. |
250 |
WarnOldStyleAssignment := true. |
|
251 |
WarnCommonMistakes := true. |
|
252 |
WarnPossibleIncompatibilities := false. |
|
1002
bf15e400f54e
default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
253 |
|
bf15e400f54e
default setting (allowUnderscoreInIdentifier is now true)
Claus Gittinger <cg@exept.de>
parents:
1001
diff
changeset
|
254 |
AllowUnderscoreInIdentifier := true. "/ underscores in identifiers |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
255 |
AllowDollarInIdentifier := false. "/ st80-vms dollars in identifiers |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
256 |
AllowOldStyleAssignment := true. "/ st80 underscore as assignment |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
257 |
AllowSqueakExtensions := false. "/ squeak computed array |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
258 |
AllowQualifiedNames := false. "/ vw3 qualified names |
1288 | 259 |
AllowExtendedBinarySelectors := false. "/ vw5.4 extended binary selectors |
1572 | 260 |
AllowLiteralNameSpaceSymbols := true. "/ st/x literal nameSpace-symbols (#foo::bar) |
717 | 261 |
|
262 |
" |
|
263 |
self initialize |
|
264 |
" |
|
265 |
||
266 |
"Modified: / 16.5.1998 / 15:55:41 / cg" |
|
267 |
! ! |
|
268 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
269 |
!Scanner class methodsFor:'defaults'! |
141 | 270 |
|
608 | 271 |
allowDollarInIdentifier |
272 |
"return true, if $-characters are allowed in identifiers. |
|
273 |
Notice, that dollars are NEVER allowed as the first character in an identifier." |
|
274 |
||
275 |
^ AllowDollarInIdentifier |
|
276 |
||
277 |
"Created: 7.9.1997 / 01:32:18 / cg" |
|
278 |
"Modified: 7.9.1997 / 01:39:44 / cg" |
|
279 |
! |
|
280 |
||
281 |
allowDollarInIdentifier:aBoolean |
|
282 |
"this allows turning on/off $-characters in identifiers. |
|
283 |
Notice, that dollars are NEVER allowed as the first character in an identifier. |
|
284 |
If turned off (the default), dollars are not allowed in identifiers, |
|
285 |
but instead are scanned as character-constant prefix. |
|
286 |
If turned on, dollars are in identifiers are allowed, while extra |
|
287 |
dollars are still scanned as constant character prefix. |
|
288 |
If you have to fileIn old VW-Vsn2.x classes, turn this off |
|
289 |
before filing them in; i.e.: |
|
290 |
Compiler allowDollarInIdentifiers:false" |
|
291 |
||
292 |
AllowDollarInIdentifier := aBoolean. |
|
293 |
||
294 |
"Created: 7.9.1997 / 01:34:49 / cg" |
|
295 |
"Modified: 7.9.1997 / 01:39:30 / cg" |
|
296 |
! |
|
297 |
||
1226 | 298 |
allowDolphinExtensions |
299 |
"return true, if ##(..) computed literals are allowed" |
|
300 |
||
301 |
^ AllowDolphinExtensions |
|
302 |
! |
|
303 |
||
304 |
allowDolphinExtensions:aBoolean |
|
305 |
"this allows turning on/off support for computed arrays ##(..) as in dolphin. |
|
306 |
If you want to fileIn Dolphin classes, enable this with: |
|
307 |
Compiler allowDolphinComputedArrays:true" |
|
308 |
||
309 |
AllowDolphinExtensions := aBoolean. |
|
310 |
||
311 |
" |
|
312 |
self allowDolphinExtensions:true |
|
313 |
self allowDolphinExtensions:false |
|
314 |
" |
|
315 |
! |
|
316 |
||
1572 | 317 |
allowLiteralNameSpaceSymbols |
318 |
"return true, if literal nameSpace symbols are allowed (#foo::bar) are allowed" |
|
319 |
||
320 |
^ AllowLiteralNameSpaceSymbols |
|
321 |
! |
|
322 |
||
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
323 |
allowOldStyleAssignment |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
324 |
"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
|
325 |
|
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
326 |
^ AllowOldStyleAssignment |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
327 |
! |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
328 |
|
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
329 |
allowOldStyleAssignment:aBoolean |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
330 |
"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
|
331 |
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
|
332 |
|
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
333 |
AllowOldStyleAssignment := aBoolean |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
334 |
! |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
335 |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
336 |
allowQualifiedNames |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
337 |
"return true, if #{..} qualified names are allowed" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
338 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
339 |
^ AllowQualifiedNames |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
340 |
! |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
341 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
342 |
allowQualifiedNames:aBoolean |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
343 |
"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
|
344 |
If you want to fileIn vw3 or later classes, enable this with: |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
345 |
Compiler allowQualifiedNames:true |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
346 |
Notice, that qualified names are not really supported semantically |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
347 |
(they are parsed, but treated like regular globals) |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
348 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
349 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
350 |
AllowQualifiedNames := aBoolean. |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
351 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
352 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
353 |
self allowQualifiedNames:true |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
354 |
self allowQualifiedNames:false |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
355 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
356 |
! |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
357 |
|
895 | 358 |
allowSqueakExtensions |
1530 | 359 |
"return true, if support for squeak extensions |
360 |
computed arrays { .., } |
|
361 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
362 |
is enabled." |
|
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
363 |
|
896 | 364 |
^ AllowSqueakExtensions |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
365 |
! |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
366 |
|
895 | 367 |
allowSqueakExtensions:aBoolean |
1530 | 368 |
"this allows turning on/off support for squeak extensions: |
369 |
computed arrays { .., } |
|
370 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
371 |
||
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
372 |
If you want to fileIn Squeak classes, enable this with: |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
373 |
Compiler allowSqueakComputedArrays:true" |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
374 |
|
896 | 375 |
AllowSqueakExtensions := aBoolean. |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
376 |
|
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
377 |
" |
895 | 378 |
self allowSqueakExtensions:true |
379 |
self allowSqueakExtensions:false |
|
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
380 |
" |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
381 |
! |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
382 |
|
141 | 383 |
allowUnderscoreInIdentifier |
384 |
"return true, if underscores are allowed in identifiers" |
|
385 |
||
386 |
^ AllowUnderscoreInIdentifier |
|
387 |
! |
|
388 |
||
389 |
allowUnderscoreInIdentifier:aBoolean |
|
390 |
"this allows turning on/off underscores in identifiers. |
|
391 |
If turned off (the default), underscores are not allowed in identifiers, |
|
392 |
but instead scanned as assignment character (old ST/80 syntax). |
|
393 |
If turned on, underscores are in identifiers are allowed, while extra |
|
394 |
underscores are still scanned as assignment. |
|
608 | 395 |
If you have to fileIn old VW-Vsn2.x classes, |
396 |
turn them off with: |
|
397 |
Compiler allowUnderscoreInIdentifiers:false" |
|
141 | 398 |
|
399 |
AllowUnderscoreInIdentifier := aBoolean. |
|
608 | 400 |
|
401 |
"Modified: 7.9.1997 / 01:35:19 / cg" |
|
141 | 402 |
! |
403 |
||
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
404 |
warnCommonMistakes |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
405 |
"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
|
406 |
|
1001 | 407 |
^ Warnings and:[WarnCommonMistakes] |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
408 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
409 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
410 |
warnCommonMistakes:aBoolean |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
411 |
"this allows turning on/off warnings about common beginners mistakes. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
412 |
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
|
413 |
run time errors later. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
414 |
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
|
415 |
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
|
416 |
a line as: |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
417 |
Compiler warnCommonMistakes:false |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
418 |
in your 'private.rc' file" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
419 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
420 |
WarnCommonMistakes := aBoolean |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
421 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
422 |
|
608 | 423 |
warnDollarInIdentifier |
424 |
"return true, if $-characters in identifiers are to be warned about" |
|
425 |
||
1001 | 426 |
^ Warnings and:[WarnDollarInIdentifier] |
608 | 427 |
|
428 |
"Created: 7.9.1997 / 01:36:17 / cg" |
|
429 |
! |
|
430 |
||
431 |
warnDollarInIdentifier:aBoolean |
|
432 |
"this allows turning on/off warnings about $-characters in identifiers. |
|
433 |
You may find those warnings useful, to make certain that your code |
|
434 |
is portable to other smalltalk versions, which do not allow this |
|
435 |
(i.e. VW releases 2.x and maybe others). |
|
436 |
Notice, that dollars are NEVER allowed as the first character in an identifier. |
|
437 |
If you get bored by those warnings, turn them off by adding |
|
438 |
a line as: |
|
439 |
Compiler warnDollarInIdentifier:false |
|
440 |
in your 'private.rc' file" |
|
441 |
||
442 |
WarnDollarInIdentifier := aBoolean |
|
443 |
||
444 |
"Created: 7.9.1997 / 01:37:42 / cg" |
|
445 |
"Modified: 7.9.1997 / 01:40:02 / cg" |
|
446 |
! |
|
447 |
||
141 | 448 |
warnOldStyleAssignment |
449 |
"return true, if underscore-assignment (pre ST-80v4 syntax) are to be warned about" |
|
450 |
||
1001 | 451 |
^ Warnings and:[WarnOldStyleAssignment] |
141 | 452 |
! |
453 |
||
454 |
warnOldStyleAssignment:aBoolean |
|
455 |
"this allows turning on/off warnings about underscore-assignment (pre ST-80v4 syntax). |
|
456 |
If you get bored by those warnings, turn them off by adding |
|
457 |
a line as: |
|
458 |
Compiler warnOldStyleAssignment:false |
|
459 |
in your 'private.rc' file" |
|
460 |
||
461 |
WarnOldStyleAssignment := aBoolean |
|
462 |
! |
|
463 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
464 |
warnPossibleIncompatibilities |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
465 |
"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
|
466 |
are to be warned about" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
467 |
|
1001 | 468 |
^ Warnings and:[WarnPossibleIncompatibilities] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
469 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
470 |
"Modified: 23.5.1997 / 12:02:02 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
471 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
472 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
473 |
warnPossibleIncompatibilities:aBoolean |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
474 |
"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
|
475 |
on or off. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
476 |
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
|
477 |
a line as: |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
478 |
Compiler warnPossibleIncompatibilities:false |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
479 |
in your 'private.rc' file." |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
480 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
481 |
WarnPossibleIncompatibilities := aBoolean |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
482 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
483 |
"Created: 23.5.1997 / 12:02:45 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
484 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
485 |
|
141 | 486 |
warnSTXSpecials |
487 |
"return true, if ST/X specials are to be warned about" |
|
488 |
||
1001 | 489 |
^ Warnings and:[WarnSTXSpecials] |
141 | 490 |
! |
491 |
||
492 |
warnSTXSpecials:aBoolean |
|
493 |
"this allows turning on/off warnings about stx specials. |
|
494 |
If you get bored by those warnings, turn them off by adding |
|
495 |
a line as: |
|
496 |
Compiler warnSTXSpecials:false |
|
497 |
in your 'private.rc' file" |
|
498 |
||
499 |
WarnSTXSpecials := aBoolean |
|
500 |
! |
|
501 |
||
502 |
warnUnderscoreInIdentifier |
|
503 |
"return true, if underscores in identifiers are to be warned about" |
|
504 |
||
1001 | 505 |
^ Warnings and:[WarnUnderscoreInIdentifier] |
141 | 506 |
! |
507 |
||
508 |
warnUnderscoreInIdentifier:aBoolean |
|
509 |
"this allows turning on/off warnings about underscores in identifiers. |
|
608 | 510 |
You may find those warnings useful, to make certain that your code |
511 |
is portable to other smalltalk versions, which do not allow this |
|
512 |
(i.e. VW releases 2.x). |
|
141 | 513 |
If you get bored by those warnings, turn them off by adding |
514 |
a line as: |
|
608 | 515 |
Compiler warnUnderscoreInIdentifier:false |
141 | 516 |
in your 'private.rc' file" |
517 |
||
518 |
WarnUnderscoreInIdentifier := aBoolean |
|
608 | 519 |
|
520 |
"Modified: 7.9.1997 / 01:37:13 / cg" |
|
141 | 521 |
! |
522 |
||
523 |
warnings |
|
524 |
"return true, if any warnings are to be shown" |
|
525 |
||
526 |
^ Warnings |
|
527 |
! |
|
528 |
||
529 |
warnings:aBoolean |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
530 |
"this allows turning on/off all warnings; the default is on. |
141 | 531 |
You can turn off warnings in your 'private.rc' file with |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
532 |
Compiler warnings:false |
141 | 533 |
" |
534 |
||
535 |
Warnings := aBoolean |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
536 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
537 |
"Modified: 23.5.1997 / 12:03:05 / cg" |
141 | 538 |
! ! |
539 |
||
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
540 |
!Scanner class methodsFor:'utility scanning'! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
541 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
542 |
scanNumberFrom:aStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
543 |
"utility - helper for Number>>readSmalltalkSyntaxFrom:" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
544 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
545 |
^ self basicNew scanNumberFrom:aStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
546 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
547 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
548 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
549 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
550 |
s := '12345abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
551 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
552 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
553 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
554 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
555 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
556 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
557 |
s := '16rffffxabcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
558 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
559 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
560 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
561 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
562 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
563 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
564 |
s := '1.2345abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
565 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
566 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
567 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
568 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
569 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
570 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
571 |
s := '1.abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
572 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
573 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
574 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
575 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
576 |
"Modified: / 18.6.1998 / 23:10:39 / cg" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
577 |
! ! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
578 |
|
1417 | 579 |
!Scanner methodsFor:'Compatibility-ST80'! |
98 | 580 |
|
581 |
endOfLastToken |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
582 |
"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
|
583 |
This method was required by some PD program. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
584 |
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
|
585 |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
586 |
^ source position1Based |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
587 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
588 |
"Modified: 23.5.1997 / 12:14:27 / cg" |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
589 |
! |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
590 |
|
630 | 591 |
scan:aStringOrStream |
592 |
"initialize the scanner: set the source-stream and |
|
593 |
preread the first token" |
|
594 |
||
595 |
self initializeFor:aStringOrStream. |
|
596 |
self nextToken |
|
597 |
||
598 |
"Created: / 30.10.1997 / 16:59:39 / cg" |
|
599 |
! |
|
600 |
||
601 |
scanToken |
|
602 |
"read the next token from my input stream" |
|
603 |
||
604 |
^ self nextToken |
|
605 |
||
606 |
"Created: / 30.10.1997 / 17:00:16 / cg" |
|
607 |
! |
|
608 |
||
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
609 |
scanTokens:aStringOrStream |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
610 |
"return a collection of symbolic tokens from the passed input" |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
611 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
612 |
|tokens| |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
613 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
614 |
self initializeFor:aStringOrStream. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
615 |
tokens := OrderedCollection new. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
616 |
self nextToken. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
617 |
[token notNil] whileTrue:[ |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
618 |
tokens add:token. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
619 |
self nextToken |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
620 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
621 |
^ tokens |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
622 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
623 |
" |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
624 |
Scanner new |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
625 |
scanTokens:'Boolean subclass:#True |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
626 |
instanceVariableNames:'''' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
627 |
classVariableNames:'''' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
628 |
poolDictionaries:'''' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
629 |
category:''Kernel-Objects'' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
630 |
' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
631 |
" |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
632 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
633 |
"Modified: 20.6.1997 / 18:22:58 / cg" |
98 | 634 |
! ! |
635 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
636 |
!Scanner methodsFor:'accessing'! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
637 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
638 |
comments |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
639 |
^ currentComments |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
640 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
641 |
|
1509 | 642 |
exitBlock:aBlock |
643 |
exitBlock := aBlock |
|
644 |
! |
|
645 |
||
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
646 |
inArrayLiteral:aBoolean |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
647 |
inArrayLiteral := aBoolean |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
648 |
! |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
649 |
|
859 | 650 |
lineNumber |
651 |
^ lineNr |
|
652 |
! |
|
653 |
||
795 | 654 |
newSourceStream:aStream |
655 |
source := aStream. |
|
656 |
self nextToken. |
|
657 |
||
658 |
"Created: / 29.10.1998 / 21:59:33 / cg" |
|
659 |
! |
|
660 |
||
1497 | 661 |
outStream:aStream |
662 |
outStream := aStream. |
|
663 |
outCol := outCol ? 1. |
|
664 |
! |
|
665 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
666 |
saveComments:aBoolean |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
667 |
"not yet implemented" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
668 |
|
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
669 |
saveComments := aBoolean |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
670 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
671 |
"Created: 20.4.1996 / 20:03:56 / cg" |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
672 |
"Modified: 23.5.1997 / 12:14:49 / cg" |
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
673 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
674 |
|
1242 | 675 |
sourcePosition |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
676 |
^ source position1Based |
1242 | 677 |
! |
678 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
679 |
sourceStream |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
680 |
^ source |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
681 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
682 |
"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
|
683 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
684 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
685 |
tokenLineNr |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
686 |
^ tokenLineNr |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
687 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
688 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
689 |
tokenName |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
690 |
^ tokenName |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
691 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
692 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
693 |
tokenPosition |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
694 |
^ tokenPosition |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
695 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
696 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
697 |
tokenType |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
698 |
^ tokenType |
1238 | 699 |
! |
700 |
||
701 |
tokenValue |
|
702 |
^ tokenValue |
|
703 |
||
704 |
"Created: / 21.12.2001 / 22:38:08 / cg" |
|
1362 | 705 |
! |
706 |
||
707 |
warnDollarInIdentifier |
|
708 |
"return the value of the instance variable 'warnDollarInIdentifier' (automatically generated)" |
|
709 |
||
710 |
^ warnDollarInIdentifier |
|
711 |
! |
|
712 |
||
713 |
warnPossibleIncompatibilities |
|
714 |
"return the value of the instance variable 'warnPossibleIncompatibilities' (automatically generated)" |
|
715 |
||
716 |
^ warnPossibleIncompatibilities |
|
717 |
! |
|
718 |
||
719 |
warnSTXNameSpaceUse |
|
720 |
"return the value of the instance variable 'warnSTXNameSpaceUse' (automatically generated)" |
|
721 |
||
722 |
^ warnSTXNameSpaceUse |
|
723 |
! ! |
|
724 |
||
725 |
!Scanner methodsFor:'accessing-flags'! |
|
726 |
||
727 |
allowDollarInIdentifier |
|
728 |
^ allowDollarInIdentifier |
|
729 |
! |
|
730 |
||
1511 | 731 |
allowDollarInIdentifier:something |
732 |
allowDollarInIdentifier := something. |
|
733 |
! |
|
734 |
||
1572 | 735 |
allowLiteralNameSpaceSymbols |
736 |
^ allowLiteralNameSpaceSymbols |
|
737 |
! |
|
738 |
||
739 |
allowLiteralNameSpaceSymbols:aBoolean |
|
740 |
allowLiteralNameSpaceSymbols := aBoolean |
|
741 |
! |
|
742 |
||
1362 | 743 |
allowOldStyleAssignment |
744 |
^ allowOldStyleAssignment |
|
745 |
! |
|
746 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
747 |
allowOldStyleAssignment:aBoolean |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
748 |
allowOldStyleAssignment := aBoolean |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
749 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
750 |
|
1362 | 751 |
allowSqueakExtensions |
1530 | 752 |
"return true, if support for squeak extensions |
753 |
computed arrays { .., } |
|
754 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
755 |
is enabled." |
|
756 |
||
1362 | 757 |
^ allowSqueakExtensions |
758 |
! |
|
759 |
||
760 |
allowSqueakExtensions:aBoolean |
|
1530 | 761 |
"this allows turning on/off support for squeak extensions: |
762 |
computed arrays { .., } |
|
763 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
764 |
" |
|
765 |
||
1362 | 766 |
allowSqueakExtensions := aBoolean |
767 |
! |
|
768 |
||
769 |
allowUnderscoreInIdentifier |
|
770 |
^ allowUnderscoreInIdentifier |
|
771 |
! |
|
772 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
773 |
allowUnderscoreInIdentifier:aBoolean |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
774 |
allowUnderscoreInIdentifier := aBoolean |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
775 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
776 |
|
1362 | 777 |
scanColonAsKeyword |
778 |
^ scanColonAsKeyword |
|
779 |
! |
|
780 |
||
781 |
warnCommonMistakes |
|
782 |
^ warnCommonMistakes |
|
783 |
! |
|
784 |
||
785 |
warnOldStyleAssignment |
|
786 |
^ warnOldStyleAssignment |
|
787 |
! |
|
788 |
||
789 |
warnSTXSpecialComment |
|
790 |
^ warnSTXSpecialComment |
|
791 |
! |
|
792 |
||
793 |
warnUnderscoreInIdentifier |
|
794 |
^ warnUnderscoreInIdentifier |
|
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
795 |
! ! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
796 |
|
81 | 797 |
!Scanner methodsFor:'directives'! |
798 |
||
74 | 799 |
parseDirective |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
800 |
"parse a directive - this is an ST/X special" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
801 |
|
1572 | 802 |
|directive packageName namespace list syntax| |
74 | 803 |
|
804 |
source next. |
|
805 |
source skipSeparatorsExceptCR. |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
806 |
hereChar := source peekOrNil. |
74 | 807 |
hereChar isLetter ifTrue:[ |
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
808 |
directive := source nextWord asLowercase. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
809 |
source peekOrNil == $: ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
810 |
source next. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
811 |
source skipSeparatorsExceptCR. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
812 |
hereChar := source peekOrNil. |
74 | 813 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
814 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
815 |
package: 'name-of-package' |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
816 |
package: packageId |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
817 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
818 |
directive = 'package' ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
819 |
packageName := self parseDirectiveStringArg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
820 |
packageName notNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
821 |
packageName := packageName asSymbol. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
822 |
(requestor notNil |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
823 |
and:[requestor respondsTo:#setPackage:]) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
824 |
requestor setPackage:packageName |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
825 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
826 |
self setPackage:packageName |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
827 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
828 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
829 |
Transcript showCR:'unrecognized ''package'' directive'. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
830 |
^ false |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
831 |
] |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
832 |
]. |
74 | 833 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
834 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
835 |
Namespace: 'nameSpaceIdentifier' |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
836 |
Namespace: nameSpaceIdentifier |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
837 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
838 |
(directive = 'namespace') ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
839 |
namespace := self parseDirectiveStringArg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
840 |
namespace notNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
841 |
(requestor notNil |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
842 |
and:[requestor respondsTo:#setNameSpace:]) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
843 |
requestor setNameSpace:namespace |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
844 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
845 |
self setNameSpace:namespace |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
846 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
847 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
848 |
Transcript showCR:'unrecognized ''namespace'' directive'. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
849 |
^ false |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
850 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
851 |
]. |
81 | 852 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
853 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
854 |
Uses: 'nameSpace1', ... , 'nameSpaceN' |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
855 |
Uses: nameSpaceId1, ... , nameSpaceIdN |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
856 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
857 |
directive = 'uses' ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
858 |
list := self parseDirectiveStringListArg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
859 |
list notNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
860 |
(requestor notNil |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
861 |
and:[requestor respondsTo:#addNameSpaces:]) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
862 |
requestor addNameSpaces:list |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
863 |
] |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
864 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
865 |
Transcript showCR:'unrecognized ''uses'' directive'. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
866 |
^ false |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
867 |
] |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
868 |
]. |
413 | 869 |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
870 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
871 |
Prerequisites: 'name-of-package', ... , 'name-of-package' |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
872 |
" |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
873 |
directive = 'prerequisites' ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
874 |
list := self parseDirectiveStringListArg. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
875 |
list notNil ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
876 |
(requestor notNil |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
877 |
and:[requestor respondsTo:#requirePackages:]) ifTrue:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
878 |
requestor requirePackages:list |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
879 |
]. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
880 |
] ifFalse:[ |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
881 |
Transcript showCR:'unrecognized ''prerequisites'' directive'. |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
882 |
^ false |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
883 |
] |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
884 |
]. |
1572 | 885 |
|
886 |
" |
|
887 |
Syntax: 'name-of-dialect' |
|
888 |
" |
|
889 |
directive = 'syntax' ifTrue:[ |
|
890 |
syntax := self parseDirectiveStringArg. |
|
891 |
syntax notNil ifTrue:[ |
|
892 |
(requestor notNil |
|
893 |
and:[requestor respondsTo:#setSyntax:]) ifTrue:[ |
|
894 |
requestor setSyntax:namespace |
|
895 |
] ifFalse:[ |
|
896 |
self setSyntax:syntax |
|
897 |
]. |
|
898 |
] ifFalse:[ |
|
899 |
Transcript showCR:'unrecognized ''syntax'' directive'. |
|
900 |
^ false |
|
901 |
]. |
|
902 |
]. |
|
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
903 |
] |
74 | 904 |
]. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
905 |
hereChar := source peekOrNil. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
906 |
^ true. |
413 | 907 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
908 |
"Modified: / 5.3.1998 / 02:55:32 / cg" |
141 | 909 |
! |
910 |
||
911 |
parseDirectiveStringArg |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
912 |
"helper for parsing a directive" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
913 |
|
141 | 914 |
hereChar == $' ifTrue:[ |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
915 |
self nextString. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
916 |
tokenType == #String ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
917 |
^ tokenValue |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
918 |
] |
141 | 919 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
920 |
(hereChar isLetter or:[hereChar == $_]) ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
921 |
self nextIdentifier. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
922 |
tokenType == #Identifier ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
923 |
^ tokenName |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
924 |
] |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
925 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
926 |
|
141 | 927 |
^ nil |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
928 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
929 |
"Modified: 23.5.1997 / 12:15:46 / cg" |
141 | 930 |
! |
931 |
||
932 |
parseDirectiveStringListArg |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
933 |
"helper for parsing a directive" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
934 |
|
141 | 935 |
|list| |
936 |
||
937 |
list := OrderedCollection new. |
|
938 |
||
939 |
[hereChar == $'] whileTrue:[ |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
940 |
list addLast:self parseDirectiveStringArg. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
941 |
source skipSeparatorsExceptCR. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
942 |
hereChar := source peekOrNil. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
943 |
(hereChar == $,) ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
944 |
source next. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
945 |
source skipSeparatorsExceptCR. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
946 |
hereChar := source peekOrNil. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
947 |
]. |
141 | 948 |
]. |
949 |
^ list |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
950 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
951 |
"Modified: / 5.3.1998 / 02:55:40 / cg" |
0 | 952 |
! ! |
953 |
||
1418 | 954 |
!Scanner methodsFor:'dummy-syntax highlighting'! |
659
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
955 |
|
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
956 |
markCommentFrom:pos1 to:pos2 |
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
957 |
|
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
958 |
"Created: / 31.3.1998 / 13:34:45 / cg" |
661 | 959 |
! |
960 |
||
671 | 961 |
markConstantFrom:pos1 to:pos2 |
962 |
||
963 |
"Created: / 1.4.1998 / 13:02:56 / cg" |
|
964 |
! |
|
965 |
||
661 | 966 |
markStringFrom:pos1 to:pos2 |
967 |
||
968 |
"Created: / 31.3.1998 / 16:37:18 / cg" |
|
671 | 969 |
! |
970 |
||
971 |
markSymbolFrom:pos1 to:pos2 |
|
972 |
||
973 |
"Created: / 1.4.1998 / 12:58:42 / cg" |
|
659
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
974 |
! ! |
2bbc270156c7
support for syntaxHighlighting
Claus Gittinger <cg@exept.de>
parents:
656
diff
changeset
|
975 |
|
0 | 976 |
!Scanner methodsFor:'error handling'! |
977 |
||
709 | 978 |
correctableError:message position:pos1 to:pos2 |
979 |
"report an error which can be corrected by compiler - |
|
874 | 980 |
return non-false, if correction is wanted (there is more than |
981 |
true/false returned here)" |
|
709 | 982 |
|
983 |
|correctIt| |
|
984 |
||
985 |
requestor isNil ifTrue:[ |
|
828 | 986 |
"/ self showErrorMessage:message position:pos1. |
987 |
correctIt := false |
|
709 | 988 |
] ifFalse:[ |
828 | 989 |
correctIt := requestor correctableError:message position:pos1 to:pos2 from:self |
709 | 990 |
]. |
1492 | 991 |
|
992 |
(correctIt == false or:[correctIt == #Error]) ifTrue:[ |
|
828 | 993 |
exitBlock notNil ifTrue:[exitBlock value] |
709 | 994 |
]. |
995 |
^ correctIt |
|
996 |
||
997 |
"Created: / 13.5.1998 / 16:45:56 / cg" |
|
998 |
! |
|
999 |
||
1023 | 1000 |
correctableSelectorWarning:message position:pos1 to:pos2 |
1001 |
"report a warning which can be corrected by compiler - |
|
1002 |
return non-false, if correction is wanted (there is more than |
|
1003 |
true/false returned here)" |
|
1004 |
||
1005 |
|correctIt| |
|
1006 |
||
1007 |
requestor isNil ifTrue:[ |
|
1008 |
correctIt := false |
|
1009 |
] ifFalse:[ |
|
1010 |
correctIt := requestor correctableSelectorWarning:message position:pos1 to:pos2 from:self |
|
1011 |
]. |
|
1012 |
correctIt == false ifTrue:[ |
|
1013 |
exitBlock notNil ifTrue:[exitBlock value] |
|
1014 |
]. |
|
1015 |
^ correctIt |
|
1016 |
||
1017 |
"Created: / 19.1.2000 / 16:28:03 / cg" |
|
1018 |
! |
|
1019 |
||
1073 | 1020 |
errorMessagePrefix |
1021 |
^ 'Error:' |
|
1022 |
! |
|
1023 |
||
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1024 |
lastTokenLineNumber |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1025 |
"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
|
1026 |
|
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1027 |
^ tokenLineNr |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1028 |
|
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1029 |
"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
|
1030 |
"Modified: 23.5.1997 / 12:16:12 / cg" |
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1031 |
! |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
1032 |
|
0 | 1033 |
notifyError:aMessage position:position to:endPos |
1034 |
"notify requestor of an error - if there is no requestor |
|
53 | 1035 |
put it on the transcript. Requestor is typically the CodeView |
1036 |
in which the accept/doIt was triggered, or the PositionableStream |
|
1037 |
which does the fileIn. The requestor may decide how to highlight the |
|
1038 |
error (and/or to abort the compile). |
|
0 | 1039 |
Return the result passed back by the requestor." |
1040 |
||
1339
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1041 |
|err| |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1042 |
|
53 | 1043 |
ignoreErrors ifFalse:[ |
1339
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1044 |
requestor isNil ifTrue:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1045 |
Parser::ParseError isHandled ifTrue:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1046 |
err := Parser::ParseError new. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1047 |
err errorMessage:aMessage startPosition:position endPosition:endPos. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1048 |
err parameter:self. |
1434
e7d527d493d3
optional lineNumber info added to parseError
Claus Gittinger <cg@exept.de>
parents:
1433
diff
changeset
|
1049 |
err lineNumber:lineNr. |
1423 | 1050 |
^ err raiseRequest. |
1339
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1051 |
] ifFalse:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1052 |
self showErrorMessage:aMessage position:position. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1053 |
]. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1054 |
^ false |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1055 |
]. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
1056 |
^ requestor error:aMessage position:position to:endPos from:self |
0 | 1057 |
]. |
53 | 1058 |
^ false |
0 | 1059 |
! |
1060 |
||
1457 | 1061 |
notifyWarning:aMessage doNotShowAgainAction:doNotShowAgainAction position:position to:endPos |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1062 |
"notify requestor of an warning - if there is no requestor |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1063 |
put it on the transcript. |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1064 |
Return the result passed back by the requestor." |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1065 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1066 |
|answer| |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1067 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1068 |
ignoreWarnings ifTrue:[ ^ false ]. |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1069 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1070 |
requestor isNil ifTrue:[ |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1071 |
"/ self showErrorMessage:aMessage position:position. |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1072 |
^ false |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1073 |
]. |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1074 |
|
1457 | 1075 |
doNotShowAgainAction notNil ifTrue:[ |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1076 |
DoNotShowCompilerWarningAgainActionQuery |
1457 | 1077 |
answer:doNotShowAgainAction |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1078 |
do:[ |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1079 |
answer := requestor warning:aMessage position:position to:endPos from:self |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1080 |
] |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1081 |
] ifFalse:[ |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1082 |
answer := requestor warning:aMessage position:position to:endPos from:self |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1083 |
]. |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1084 |
^ answer |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1085 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1086 |
|
0 | 1087 |
notifyWarning:aMessage position:position to:endPos |
1088 |
"notify requestor of an warning - if there is no requestor |
|
1089 |
put it on the transcript. |
|
1090 |
Return the result passed back by the requestor." |
|
1091 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1092 |
^ self notifyWarning:aMessage doNotShowAgainAction:nil position:position to:endPos. |
0 | 1093 |
! |
1094 |
||
709 | 1095 |
parseError:aMessage |
1096 |
"report an error" |
|
1097 |
||
1098 |
^ self parseError:aMessage position:tokenPosition to:nil |
|
1099 |
||
1100 |
"Created: / 13.5.1998 / 16:45:13 / cg" |
|
1101 |
! |
|
1102 |
||
1103 |
parseError:aMessage position:position |
|
1104 |
"report an error" |
|
1105 |
||
1106 |
^ self parseError:aMessage position:position to:nil |
|
1107 |
||
1108 |
"Created: / 13.5.1998 / 16:45:05 / cg" |
|
1109 |
! |
|
1110 |
||
1111 |
parseError:aMessage position:position to:endPos |
|
1112 |
"report an error" |
|
1113 |
||
1114 |
|m| |
|
1115 |
||
1563 | 1116 |
self errorFlag:true. |
1073 | 1117 |
m := (self errorMessagePrefix) , ' ' , (aMessage ? '???'). |
709 | 1118 |
self notifyError:m position:position to:endPos. |
1119 |
exitBlock notNil ifTrue:[exitBlock value]. |
|
1120 |
^ false |
|
1121 |
||
1122 |
"Created: / 13.5.1998 / 16:44:55 / cg" |
|
783
611d7b234115
care for nil error message (can happen when lastError is nil
Claus Gittinger <cg@exept.de>
parents:
737
diff
changeset
|
1123 |
"Modified: / 28.9.1998 / 19:29:27 / cg" |
709 | 1124 |
! |
1125 |
||
141 | 1126 |
showErrorMessage:aMessage position:pos |
1127 |
"show an errormessage on the Transcript" |
|
0 | 1128 |
|
141 | 1129 |
ignoreErrors ifFalse:[ |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1130 |
Smalltalk silentLoading == true ifFalse:[ |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1131 |
Transcript showCR:(pos printString , ' [line: ' , tokenLineNr printString , '] ' , aMessage) |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1132 |
] |
141 | 1133 |
] |
274 | 1134 |
|
1135 |
"Modified: 18.5.1996 / 15:44:35 / cg" |
|
141 | 1136 |
! |
1137 |
||
1138 |
syntaxError:aMessage |
|
1139 |
"a syntax error happened - position is not known" |
|
1140 |
||
1141 |
^ self syntaxError:aMessage position:tokenPosition |
|
0 | 1142 |
! |
1143 |
||
1144 |
syntaxError:aMessage position:position |
|
1145 |
"a syntax error happened - only start position is known" |
|
1146 |
||
1147 |
^ self syntaxError:aMessage position:position to:nil |
|
1148 |
! |
|
1149 |
||
141 | 1150 |
syntaxError:aMessage position:position to:endPos |
1151 |
"a syntax error happened" |
|
0 | 1152 |
|
1073 | 1153 |
self notifyError:((self errorMessagePrefix) , ' ' , aMessage) position:position to:endPos. |
141 | 1154 |
exitBlock notNil ifTrue:[exitBlock value]. |
1155 |
^ false |
|
87 | 1156 |
! |
1157 |
||
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1158 |
warnCommonMistake:msg at:position |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1159 |
"warn about a common beginners mistake" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1160 |
|
311 | 1161 |
self warnCommonMistake:msg position:position to:position |
1162 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1163 |
"Modified: 23.5.1997 / 12:16:34 / cg" |
311 | 1164 |
! |
1165 |
||
1166 |
warnCommonMistake:msg position:pos1 to:pos2 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1167 |
"warn about a common beginners mistake" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1168 |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1169 |
ignoreWarnings ifFalse:[ |
311 | 1170 |
warnCommonMistakes ifTrue:[ |
1171 |
self |
|
1172 |
warning:msg |
|
1173 |
position:pos1 to:pos2. |
|
1174 |
] |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1175 |
] |
311 | 1176 |
|
1177 |
"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
|
1178 |
"Modified: 23.5.1997 / 12:16:39 / cg" |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1179 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1180 |
|
608 | 1181 |
warnDollarAt:position |
1182 |
"warn about $-character in an identifier" |
|
1183 |
||
1184 |
ignoreWarnings ifFalse:[ |
|
1185 |
warnDollarInIdentifier ifTrue:[ |
|
1186 |
self |
|
1187 |
warning:'$-characters in identifiers/symbols are nonportable' |
|
1188 |
position:position to:position. |
|
1189 |
" |
|
1190 |
only warn once (per method) |
|
1191 |
" |
|
1192 |
warnDollarInIdentifier := false |
|
1193 |
] |
|
1194 |
] |
|
1195 |
||
1196 |
"Created: 7.9.1997 / 01:50:24 / cg" |
|
1197 |
"Modified: 7.9.1997 / 01:51:13 / cg" |
|
1198 |
! |
|
1199 |
||
87 | 1200 |
warnOldStyleAssignmentAt:position |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1201 |
"warn about an oldStyle assignment" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1202 |
|
87 | 1203 |
ignoreWarnings ifFalse:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1204 |
warnOldStyleAssignment ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1205 |
self |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1206 |
warning:'Old style assignment - please change to use '':=''' |
1456
0d87596934ca
allow doNotShowThisWarningAgain in oldStyleSettings
Claus Gittinger <cg@exept.de>
parents:
1454
diff
changeset
|
1207 |
doNotShowAgainAction:[ WarnOldStyleAssignment := false ] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1208 |
position:position to:position. |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1209 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1210 |
" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1211 |
only warn once (per method) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1212 |
" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1213 |
warnOldStyleAssignment := false |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1214 |
] |
87 | 1215 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1216 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1217 |
"Modified: 23.5.1997 / 12:16:48 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1218 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1219 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1220 |
warnPossibleIncompatibility:msg position:pos1 to:pos2 |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1221 |
"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
|
1222 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1223 |
ignoreWarnings ifFalse:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1224 |
warnPossibleIncompatibilities ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1225 |
self |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1226 |
warning:('Possible incompatibility.\\' , msg) withCRs |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1227 |
position:pos1 to:pos2. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1228 |
] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1229 |
] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1230 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1231 |
"Created: 23.5.1997 / 12:17:54 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1232 |
"Modified: 23.5.1997 / 12:22:37 / cg" |
87 | 1233 |
! |
1234 |
||
1235 |
warnUnderscoreAt:position |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1236 |
"warn about an underscore in an identifier" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1237 |
|
87 | 1238 |
ignoreWarnings ifFalse:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1239 |
warnUnderscoreInIdentifier ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1240 |
self |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1241 |
warning:'underscores in identifiers/symbols are nonportable' |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1242 |
position:position to:position. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1243 |
" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1244 |
only warn once (per method) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1245 |
" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1246 |
warnUnderscoreInIdentifier := false |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1247 |
] |
87 | 1248 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1249 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1250 |
"Modified: 23.5.1997 / 12:17:06 / cg" |
141 | 1251 |
! |
1252 |
||
1253 |
warning:aMessage |
|
1254 |
"a warning - position is not known" |
|
1255 |
||
1256 |
^ self warning:aMessage position:tokenPosition |
|
1257 |
! |
|
1258 |
||
1457 | 1259 |
warning:aMessage doNotShowAgainAction:doNotShowAgainAction position:position to:endPos |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1260 |
"a warning" |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1261 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1262 |
^ self |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1263 |
notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) |
1457 | 1264 |
doNotShowAgainAction:doNotShowAgainAction |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1265 |
position:position to:endPos |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1266 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1267 |
|
141 | 1268 |
warning:aMessage position:position |
1269 |
"a warning - only start position is known" |
|
1270 |
||
1271 |
^ self warning:aMessage position:position to:nil |
|
1272 |
! |
|
1273 |
||
1274 |
warning:aMessage position:position to:endPos |
|
1275 |
"a warning" |
|
1276 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1277 |
^ self |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1278 |
notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1279 |
doNotShowAgainAction:nil |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1280 |
position:position to:endPos |
1073 | 1281 |
! |
1282 |
||
1283 |
warningMessagePrefix |
|
1284 |
^ 'Warning:' |
|
0 | 1285 |
! ! |
1286 |
||
17 | 1287 |
!Scanner methodsFor:'general scanning'! |
1288 |
||
1577 | 1289 |
scanDoing:aBlock |
1290 |
"scan, evaluating aBlock for every scanned token." |
|
1291 |
||
1292 |
|t| |
|
1293 |
||
1294 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
1295 |
aBlock value:t. |
|
1296 |
]. |
|
1297 |
! |
|
1298 |
||
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1299 |
scanNumberFrom:aStringOrStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1300 |
"scan aSourceString for the next number in smalltalk syntax |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1301 |
Return the number or nil." |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1302 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1303 |
|oldPos| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1304 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1305 |
self initializeFor:aStringOrStream. |
1430 | 1306 |
oldPos := source position. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1307 |
self nextToken. |
1349
ec1b7cc48572
allow any number in #scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
1347
diff
changeset
|
1308 |
tokenValue isNumber ifTrue:[ |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1309 |
"/ must keep stream positioned correctly |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1310 |
"/ (undo lookahead) |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1311 |
peekChar notNil ifTrue:[ |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1312 |
peekChar2 notNil ifTrue:[ |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1313 |
source skip:-1 |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1314 |
]. |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1315 |
source skip:-1 |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1316 |
]. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1317 |
^ tokenValue |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1318 |
]. |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1319 |
"/ backup in case of error; return nil |
1430 | 1320 |
source position:oldPos. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1321 |
^ nil. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1322 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1323 |
"Created: / 18.6.1998 / 23:05:22 / cg" |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1324 |
"Modified: / 19.11.1999 / 18:25:52 / cg" |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1325 |
! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1326 |
|
17 | 1327 |
scanPositionsFor:aTokenString inString:aSourceString |
1328 |
"scan aSourceString for occurrances of aTokenString. |
|
1329 |
Return a collection of start positions. |
|
1577 | 1330 |
Added for VW compatibility (to support simple syntax-highlight)." |
17 | 1331 |
|
1332 |
|searchType searchName searchValue positions t| |
|
1333 |
||
1577 | 1334 |
aTokenString notNil ifTrue:[ |
1335 |
" |
|
1336 |
first, look what kind of token we have to search for |
|
1337 |
" |
|
1338 |
self initializeFor:(ReadStream on:aTokenString). |
|
1339 |
self nextToken. |
|
1340 |
searchType := tokenType. |
|
1341 |
searchName := tokenName. |
|
1342 |
searchValue := tokenValue. |
|
1343 |
]. |
|
17 | 1344 |
|
1345 |
" |
|
1346 |
start the real work ... |
|
1347 |
" |
|
1348 |
self initializeFor:(ReadStream on:aSourceString). |
|
1349 |
positions := OrderedCollection new. |
|
1350 |
||
1351 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
1577 | 1352 |
searchType == t ifTrue:[ |
1353 |
(searchName isNil or:[tokenName = searchName]) ifTrue:[ |
|
1354 |
(searchValue isNil or:[tokenValue = searchValue]) ifTrue:[ |
|
1355 |
positions add:tokenPosition. |
|
1356 |
] |
|
1357 |
] |
|
1358 |
] |
|
17 | 1359 |
]. |
1360 |
||
1361 |
^ positions |
|
1362 |
||
1363 |
" |
|
30 | 1364 |
Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello' |
1365 |
Scanner new scanPositionsFor:'3.14' inString:'foo 3.145 bar hello 3.14 baz hello 3.14' |
|
1366 |
Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000' |
|
17 | 1367 |
" |
1368 |
! ! |
|
1369 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1370 |
!Scanner methodsFor:'initialization'! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1371 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1372 |
initialize |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1373 |
"initialize the scanner" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1374 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1375 |
errorFlag := false. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1376 |
tokenPosition := 1. |
610 | 1377 |
tokenLineNr := lineNr := 1. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1378 |
currentComments := nil. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1379 |
saveComments := false. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1380 |
ignoreErrors := false. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1381 |
ignoreWarnings := Warnings not. |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1382 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1383 |
warnSTXSpecialComment := WarnSTXSpecials. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1384 |
warnSTXNameSpaceUse := WarnSTXSpecials. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1385 |
warnUnderscoreInIdentifier := WarnUnderscoreInIdentifier. |
608 | 1386 |
warnDollarInIdentifier := WarnDollarInIdentifier. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1387 |
warnOldStyleAssignment := WarnOldStyleAssignment. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1388 |
warnCommonMistakes := WarnCommonMistakes. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1389 |
warnPossibleIncompatibilities := WarnPossibleIncompatibilities. |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1390 |
|
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1391 |
allowUnderscoreInIdentifier := AllowUnderscoreInIdentifier. |
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1392 |
allowDollarInIdentifier := AllowDollarInIdentifier. |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
1393 |
allowOldStyleAssignment := AllowOldStyleAssignment. |
1362 | 1394 |
allowSqueakExtensions := AllowSqueakExtensions. |
1572 | 1395 |
allowLiteralNameSpaceSymbols := AllowLiteralNameSpaceSymbols. |
900 | 1396 |
|
1397 |
"/ not used here, but eases subclassing for other languages. |
|
1398 |
scanColonAsKeyword := true. |
|
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1399 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1400 |
ActionArray isNil ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1401 |
self class setupActions |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1402 |
]. |
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1403 |
actionArray := ActionArray. |
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1404 |
typeArray := TypeArray. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1405 |
|
785
14d0ec37a754
added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
1406 |
"Modified: / 17.10.1998 / 15:48:06 / cg" |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1407 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1408 |
|
1362 | 1409 |
initializeFlagsFrom:aScanner |
1410 |
"initialize flags from another scanner" |
|
1411 |
||
1412 |
ignoreErrors := aScanner ignoreErrors. |
|
1413 |
ignoreWarnings := aScanner ignoreWarnings. |
|
1414 |
||
1415 |
warnSTXSpecialComment := aScanner warnSTXSpecialComment. |
|
1416 |
warnSTXNameSpaceUse := aScanner warnSTXNameSpaceUse. |
|
1417 |
warnUnderscoreInIdentifier := aScanner warnUnderscoreInIdentifier. |
|
1418 |
warnDollarInIdentifier := aScanner warnDollarInIdentifier. |
|
1419 |
warnOldStyleAssignment := aScanner warnOldStyleAssignment. |
|
1420 |
warnCommonMistakes := aScanner warnCommonMistakes. |
|
1421 |
warnPossibleIncompatibilities := aScanner warnPossibleIncompatibilities. |
|
1422 |
||
1423 |
allowUnderscoreInIdentifier := aScanner allowUnderscoreInIdentifier. |
|
1424 |
allowDollarInIdentifier := aScanner allowDollarInIdentifier. |
|
1425 |
allowOldStyleAssignment := aScanner allowOldStyleAssignment. |
|
1426 |
allowSqueakExtensions := aScanner allowSqueakExtensions. |
|
1427 |
||
1572 | 1428 |
allowLiteralNameSpaceSymbols := aScanner allowLiteralNameSpaceSymbols. |
1429 |
||
1362 | 1430 |
scanColonAsKeyword := aScanner scanColonAsKeyword. |
1431 |
! |
|
1432 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1433 |
initializeFor:aStringOrStream |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1434 |
"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
|
1435 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1436 |
self initialize. |
847 | 1437 |
self source:aStringOrStream. |
1438 |
! |
|
1439 |
||
1242 | 1440 |
setSource:newSource |
1441 |
source := newSource |
|
1442 |
||
1443 |
! |
|
1444 |
||
847 | 1445 |
source:aStringOrStream |
1446 |
"prepare for reading from aStringOrStream" |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1447 |
|
854 | 1448 |
errorFlag := false. |
1449 |
tokenPosition := 1. |
|
1450 |
tokenLineNr := lineNr := 1. |
|
1451 |
currentComments := nil. |
|
1452 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1453 |
aStringOrStream isStream ifFalse:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1454 |
source := ReadStream on:aStringOrStream |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1455 |
] ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1456 |
source := aStringOrStream. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1457 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1458 |
|
854 | 1459 |
"Modified: / 26.5.1999 / 12:02:16 / stefan" |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1460 |
! ! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1461 |
|
1237
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1462 |
!Scanner methodsFor:'parser interface'! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1463 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1464 |
errorFlag:flagArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1465 |
errorFlag := flagArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1466 |
! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1467 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1468 |
token |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1469 |
^ token |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1470 |
! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1471 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1472 |
tokenLineNr:lineNumberArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1473 |
tokenLineNr := lineNumberArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1474 |
! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1475 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1476 |
tokenPosition:positionArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1477 |
tokenPosition := positionArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1478 |
! ! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
1479 |
|
141 | 1480 |
!Scanner methodsFor:'private'! |
3 | 1481 |
|
141 | 1482 |
backupPosition |
1483 |
"if reading from a stream, at the end we might have read |
|
1484 |
one token too many" |
|
20 | 1485 |
|
141 | 1486 |
(tokenType == #EOF) ifFalse:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1487 |
source position1Based:tokenPosition |
141 | 1488 |
] |
1489 |
! |
|
15 | 1490 |
|
141 | 1491 |
beginComment |
1492 |
^ self |
|
1493 |
! |
|
1494 |
||
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1495 |
checkForKeyword:string |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1496 |
"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
|
1497 |
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
|
1498 |
or 'thisContext'. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1499 |
'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
|
1500 |
identifier, if declared locally." |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1501 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1502 |
|firstChar| |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1503 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1504 |
firstChar := string at:1. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1505 |
(firstChar == $s) ifTrue:[ |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1506 |
(string = 'self') ifTrue:[tokenType := #Self. ^true]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1507 |
(string = 'super') ifTrue:[tokenType := #Super. ^true] |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1508 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1509 |
(firstChar == $n) ifTrue:[ |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1510 |
(string = 'nil') ifTrue:[tokenType := #Nil. ^true] |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1511 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1512 |
(firstChar == $t) ifTrue:[ |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1513 |
(string = 'true') ifTrue:[tokenType := #True. ^true]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1514 |
(string = 'thisContext') ifTrue:[tokenType := #ThisContext. ^true] |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1515 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1516 |
(firstChar == $f) ifTrue:[ |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1517 |
(string = 'false') ifTrue:[tokenType := #False. ^true] |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1518 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1519 |
^ false |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1520 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1521 |
"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
|
1522 |
! |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1523 |
|
141 | 1524 |
collectedSource |
1525 |
^ collectedSource |
|
1526 |
! |
|
74 | 1527 |
|
1236 | 1528 |
eatPeekChar |
1529 |
peekChar isNil ifTrue:[ |
|
1530 |
source next. |
|
1531 |
] ifFalse:[ |
|
1532 |
peekChar := nil. |
|
1533 |
]. |
|
1534 |
||
1535 |
"Created: / 24.10.1998 / 17:25:39 / cg" |
|
1536 |
! |
|
1537 |
||
141 | 1538 |
endComment:comment |
1539 |
saveComments ifTrue:[ |
|
1540 |
currentComments isNil ifTrue:[ |
|
1541 |
currentComments := OrderedCollection with:comment |
|
45 | 1542 |
] ifFalse:[ |
141 | 1543 |
currentComments add:comment |
45 | 1544 |
] |
3 | 1545 |
]. |
1546 |
! |
|
1547 |
||
648 | 1548 |
endComment:commentString type:commentType |
1549 |
|comment| |
|
1550 |
||
1551 |
saveComments ifTrue:[ |
|
1552 |
comment := Comment new. |
|
1553 |
comment commentString:commentString; commentType:commentType. |
|
1554 |
||
1555 |
currentComments isNil ifTrue:[ |
|
1556 |
currentComments := OrderedCollection with:comment |
|
1557 |
] ifFalse:[ |
|
1558 |
currentComments add:comment |
|
1559 |
] |
|
1560 |
]. |
|
1561 |
||
1562 |
"Created: / 17.2.1998 / 14:48:49 / cg" |
|
1563 |
! |
|
1564 |
||
1321 | 1565 |
escapeCharacterFor:aCharacter |
1566 |
"only if AllowExtendedSTXSyntax is true |
|
1567 |
For now: do not use, since stc does not support it. |
|
1568 |
||
1569 |
much like character escapes in C-literals; |
|
1570 |
expands: |
|
1571 |
`n newLine |
|
1572 |
`r return |
|
1573 |
`t tab |
|
1574 |
`b backspace |
|
1575 |
`f formfeed |
|
1576 |
`g bell |
|
1577 |
||
1578 |
`` backTick |
|
1579 |
` ...` ignored |
|
1580 |
`xNN hexCharacter |
|
1581 |
`xNN hexCharacter |
|
1582 |
" |
|
1583 |
||
1584 |
|ascii nextChar| |
|
1585 |
||
1586 |
aCharacter == $n ifTrue:[^ Character nl]. |
|
1587 |
aCharacter == $r ifTrue:[^ Character return]. |
|
1588 |
aCharacter == $t ifTrue:[^ Character tab]. |
|
1589 |
aCharacter == $b ifTrue:[^ Character backspace]. |
|
1590 |
aCharacter == $f ifTrue:[^ Character ff]. |
|
1591 |
aCharacter == $g ifTrue:[^ Character bell]. |
|
1592 |
aCharacter == $` ifTrue:[^ aCharacter]. |
|
1593 |
aCharacter isSeparator ifTrue:[ |
|
1594 |
nextChar := source next. |
|
1595 |
[nextChar notNil and:[nextChar ~~ $`]] whileTrue:[ |
|
1596 |
(nextChar == Character cr) ifTrue:[ |
|
1597 |
lineNr := lineNr + 1 |
|
1598 |
]. |
|
1599 |
nextChar := source next. |
|
1600 |
]. |
|
1601 |
^ nil |
|
1602 |
]. |
|
1603 |
||
1604 |
aCharacter == $x ifTrue:[ |
|
1605 |
ascii := 0. |
|
1606 |
nextChar := source next. |
|
1607 |
(nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[ |
|
1608 |
ascii := nextChar digitValue. |
|
1609 |
nextChar := source next. |
|
1610 |
(nextChar notNil and:[nextChar isDigitRadix:16]) ifTrue:[ |
|
1611 |
ascii := (ascii bitShift:4) bitOr:nextChar digitValue. |
|
1612 |
] |
|
1613 |
]. |
|
1614 |
^ Character value:ascii. |
|
1615 |
]. |
|
1616 |
aCharacter == $0 ifTrue:[ |
|
1617 |
ascii := 0. |
|
1618 |
nextChar := source next. |
|
1619 |
(nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[ |
|
1620 |
ascii := nextChar digitValue. |
|
1621 |
nextChar := source next. |
|
1622 |
(nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[ |
|
1623 |
ascii := (ascii bitShift:3) bitOr:nextChar digitValue. |
|
1624 |
nextChar := source next. |
|
1625 |
(nextChar notNil and:[nextChar isDigitRadix:8]) ifTrue:[ |
|
1626 |
ascii := (ascii bitShift:3) bitOr:nextChar digitValue. |
|
1627 |
] |
|
1628 |
] |
|
1629 |
]. |
|
1630 |
^ Character value:ascii. |
|
1631 |
]. |
|
1632 |
^ aCharacter |
|
1633 |
||
1634 |
" |
|
1635 |
AllowExtendedSTXSyntax := true |
|
1636 |
" |
|
1637 |
" |
|
1638 |
'hello`nworld' |
|
1639 |
'hello`x08world' |
|
1640 |
'hello` |
|
1641 |
`world' |
|
1642 |
" |
|
1643 |
! |
|
1644 |
||
141 | 1645 |
ignoreErrors |
1365 | 1646 |
"return the flag which controls notification of errors" |
1647 |
||
1648 |
^ ignoreErrors |
|
1649 |
! |
|
1650 |
||
1651 |
ignoreErrors:aBoolean |
|
1652 |
"enable/disable notification of errors" |
|
1653 |
||
1654 |
ignoreErrors := aBoolean |
|
141 | 1655 |
! |
0 | 1656 |
|
141 | 1657 |
ignoreWarnings |
1365 | 1658 |
"return the flag which controls notification of warnings" |
1659 |
||
1660 |
^ ignoreWarnings |
|
1661 |
! |
|
1662 |
||
1663 |
ignoreWarnings:aBoolean |
|
1664 |
"enable/disable notification of warnings" |
|
1665 |
||
1666 |
ignoreWarnings := aBoolean |
|
141 | 1667 |
! |
0 | 1668 |
|
714 | 1669 |
isCommentCharacter:ch |
1670 |
"return true, if ch is the comment-start character. |
|
1671 |
Brought into a separate method to allow for easier subclassing" |
|
1672 |
||
1673 |
^ ch == $" |
|
1674 |
||
1675 |
"Created: / 14.5.1998 / 20:51:42 / cg" |
|
1676 |
"Modified: / 14.5.1998 / 20:53:01 / cg" |
|
1677 |
! |
|
1678 |
||
141 | 1679 |
notifying:anObject |
1680 |
"set the requestor to be notified" |
|
1681 |
||
1682 |
requestor := anObject |
|
426
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
1683 |
! |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
1684 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
1685 |
setNameSpace:aNameSpace |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
1686 |
"/ ignored here |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
1687 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
1688 |
"Created: 8.11.1996 / 13:33:10 / cg" |
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
1689 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
1690 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
1691 |
setPackage:aNameSpace |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
1692 |
"/ ignored here |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
1693 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
1694 |
"Created: 8.11.1996 / 13:33:10 / cg" |
1572 | 1695 |
! |
1696 |
||
1697 |
setSyntax:aSyntax |
|
141 | 1698 |
! ! |
1699 |
||
1700 |
!Scanner methodsFor:'reading next token'! |
|
1701 |
||
1702 |
nextCharacter |
|
1703 |
"a $ has been read - return a character token" |
|
1704 |
||
1240 | 1705 |
|nextChar t| |
141 | 1706 |
|
0 | 1707 |
source next. |
141 | 1708 |
nextChar := source next. |
1709 |
nextChar notNil ifTrue:[ |
|
1240 | 1710 |
t := nextChar. |
1711 |
tokenType := #Character. |
|
141 | 1712 |
] ifFalse:[ |
1240 | 1713 |
t := nil. |
1714 |
tokenType := #EOF |
|
141 | 1715 |
]. |
1240 | 1716 |
tokenValue := token := t. |
0 | 1717 |
^ tokenType |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1718 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1719 |
"Modified: / 13.5.1998 / 15:09:50 / cg" |
0 | 1720 |
! |
1721 |
||
1722 |
nextColonOrAssign |
|
1723 |
"colon has been read - look for = to make it an assign" |
|
1724 |
||
120 | 1725 |
"/ special kludge for identifier:= (without spaces inbetween) |
1726 |
"/ here we needed two characters lookahead after the identifier ... |
|
1727 |
||
1728 |
peekChar == $= ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1729 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1730 |
peekChar := nil. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1731 |
tokenType := token := #':='. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1732 |
^ tokenType |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1733 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1734 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1735 |
"/ special kludge for nameSpace:: (without spaces inbetween) |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1736 |
"/ here we needed two characters lookahead after the identifier ... |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1737 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1738 |
peekChar == $: ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1739 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1740 |
peekChar := nil. |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
1741 |
tokenType := token := #'::'. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1742 |
^ tokenType |
120 | 1743 |
]. |
1744 |
||
0 | 1745 |
(source nextPeek == $=) ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1746 |
source next. |
1004
708e1ca35c3b
dont unify := and _ tokens (otherwise, highlighter would not know
Claus Gittinger <cg@exept.de>
parents:
1002
diff
changeset
|
1747 |
tokenType := token := #':=' |
0 | 1748 |
] ifFalse:[ |
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1749 |
tokenType := token := $: |
0 | 1750 |
]. |
1751 |
^ tokenType |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1752 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
1753 |
"Modified: / 13.5.1998 / 15:10:04 / cg" |
0 | 1754 |
! |
1755 |
||
1298 | 1756 |
nextExcla |
1757 |
"a !! has been read - return either |
|
1758 |
the !! binarySelector, |
|
1759 |
ExclaLeftParen (for '!!('), |
|
1760 |
ExclaLeftBrack (for '!!['), |
|
1761 |
ExclaLeftBrace (for '!!{') |
|
1762 |
" |
|
1763 |
||
1764 |
|nextChar| |
|
1765 |
||
1766 |
nextChar := source nextPeek. |
|
1767 |
AllowExtendedSTXSyntax == true ifTrue:[ |
|
1768 |
(nextChar == $( ) ifTrue:[ |
|
1769 |
source next. |
|
1770 |
token := '!!('. |
|
1771 |
tokenType := #ExclaLeftParen. |
|
1772 |
^ tokenType |
|
1773 |
]. |
|
1774 |
||
1775 |
(nextChar == $[ ) ifTrue:[ |
|
1776 |
source next. |
|
1777 |
token := '!!['. |
|
1778 |
tokenType := #ExclaLeftBrack. |
|
1779 |
^ tokenType |
|
1780 |
]. |
|
1781 |
||
1782 |
(nextChar == ${ ) ifTrue:[ |
|
1783 |
source next. |
|
1784 |
token := '!!{'. |
|
1785 |
tokenType := #ExclaLeftBrace. |
|
1786 |
^ tokenType |
|
1787 |
]. |
|
1788 |
]. |
|
1789 |
||
1790 |
"this allows excla to be used as binop - |
|
1791 |
I dont know, if this is correct ..." |
|
1792 |
||
1307
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
1793 |
"/ tokenName := token := '!!'. |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
1794 |
"/ tokenType := #BinaryOperator. |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
1795 |
"/ ^ tokenType |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
1796 |
|
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
1797 |
^ self nextSpecialWith:$!!. |
1298 | 1798 |
! |
1799 |
||
141 | 1800 |
nextHash |
1226 | 1801 |
"a # has been read - return either |
1802 |
a symbol, |
|
1803 |
HashLeftParen (for '#('), |
|
1804 |
HashLeftBrack (for '#['), |
|
1805 |
HashLeftBrace (for '#{' and AllowQualifiedNames) |
|
1806 |
HashHashLeftParen (for '##(' and AllowDolphinExtensions) |
|
1292 | 1807 |
HashHashLeftBrack (for '##[' ) |
1808 |
HashHash (for '##' ) |
|
1226 | 1809 |
" |
1026 | 1810 |
|
1572 | 1811 |
|nextChar string part isNameSpaceSymbol| |
0 | 1812 |
|
141 | 1813 |
nextChar := source nextPeek. |
1814 |
nextChar notNil ifTrue:[ |
|
1572 | 1815 |
isNameSpaceSymbol := false. |
1279
df137a4fe0a7
#<digit> is no longer allowed as symbol
Claus Gittinger <cg@exept.de>
parents:
1261
diff
changeset
|
1816 |
(nextChar isLetter |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1817 |
or:[(allowUnderscoreInIdentifier == true) and:[nextChar == $_]]) ifTrue:[ |
500 | 1818 |
string := ''. |
1819 |
[nextChar notNil |
|
1820 |
and:[nextChar isLetterOrDigit |
|
1191
47011122e30e
correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents:
1181
diff
changeset
|
1821 |
or:[allowUnderscoreInIdentifier == true and:[nextChar == $_]] |
500 | 1822 |
] |
1823 |
] whileTrue:[ |
|
1191
47011122e30e
correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents:
1181
diff
changeset
|
1824 |
nextChar == $_ ifTrue:[ |
47011122e30e
correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents:
1181
diff
changeset
|
1825 |
part := nil. |
47011122e30e
correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents:
1181
diff
changeset
|
1826 |
] ifFalse:[ |
47011122e30e
correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents:
1181
diff
changeset
|
1827 |
part := source nextAlphaNumericWord. |
47011122e30e
correctly scan #_ (i.e. a symbol consisting of a single underscore)
Claus Gittinger <cg@exept.de>
parents:
1181
diff
changeset
|
1828 |
]. |
500 | 1829 |
part notNil ifTrue:[ |
1830 |
string := string , part. |
|
1831 |
]. |
|
1832 |
nextChar := source peek. |
|
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1833 |
allowUnderscoreInIdentifier == true ifTrue:[ |
500 | 1834 |
nextChar == $_ ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1835 |
self warnUnderscoreAt:source position1Based. |
500 | 1836 |
]. |
1837 |
[nextChar == $_] whileTrue:[ |
|
1838 |
string := string copyWith:nextChar. |
|
1839 |
nextChar := source nextPeek. |
|
1429
5d46769a95ef
ansified (isAlphaNumeric -> isLetterOrDigit)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1840 |
(nextChar isLetterOrDigit) ifTrue:[ |
500 | 1841 |
string := string , source nextAlphaNumericWord. |
1842 |
nextChar := source peek. |
|
1843 |
] |
|
1844 |
]. |
|
1845 |
]. |
|
1846 |
(nextChar == $:) ifFalse:[ |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1847 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1848 |
tokenValue := token := string asSymbol. |
500 | 1849 |
tokenType := #Symbol. |
1850 |
^ tokenType |
|
1851 |
]. |
|
1852 |
string := string copyWith:nextChar. |
|
1572 | 1853 |
nextChar := source nextPeek. |
1854 |
allowLiteralNameSpaceSymbols ifTrue:[ |
|
1855 |
(nextChar == $:) ifTrue:[ |
|
1856 |
string := string copyWith:nextChar. |
|
1857 |
nextChar := source nextPeek. |
|
1858 |
isNameSpaceSymbol := true. |
|
1859 |
]. |
|
1860 |
]. |
|
1861 |
]. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1862 |
tokenValue := token := string asSymbol. |
500 | 1863 |
tokenType := #Symbol. |
1864 |
^ tokenType |
|
1865 |
]. |
|
1866 |
(nextChar == $( ) ifTrue:[ |
|
1867 |
source next. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1868 |
token := '#('. |
500 | 1869 |
tokenType := #HashLeftParen. |
1870 |
^ tokenType |
|
1871 |
]. |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
1872 |
|
500 | 1873 |
(nextChar == $[ ) ifTrue:[ |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
1874 |
"ST-80 & ST/X support Constant ByteArrays as #[...]" |
500 | 1875 |
source next. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1876 |
token := '#['. |
500 | 1877 |
tokenType := #HashLeftBrack. |
1878 |
^ tokenType |
|
1879 |
]. |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
1880 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
1881 |
(nextChar == ${ ) ifTrue:[ |
1290 | 1882 |
" #{ ... } is one of: |
1883 |
#{ Foo.Bar.Baz } VW3 and later qualified name |
|
1884 |
#{ xx-xx-xx-xx-...-xx } StAgents UUID |
|
1885 |
#{ URL } url object qualifier |
|
1074 | 1886 |
" |
1290 | 1887 |
source next. |
1888 |
token := '#{'. |
|
1889 |
tokenType := #HashLeftBrace. |
|
1890 |
^ tokenType |
|
1891 |
]. |
|
1892 |
||
500 | 1893 |
(nextChar == $' ) ifTrue:[ |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
1894 |
"ST-80 and ST/X support arbitrary symbols as #'...'" |
500 | 1895 |
self nextString. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1896 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
1385
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
1897 |
tokenType == #EOF ifFalse:[ |
1488
a6b8a7a14f40
error when a 2-byte symbol is encountered
Claus Gittinger <cg@exept.de>
parents:
1485
diff
changeset
|
1898 |
tokenValue bitsPerCharacter > 8 ifTrue:[ |
a6b8a7a14f40
error when a 2-byte symbol is encountered
Claus Gittinger <cg@exept.de>
parents:
1485
diff
changeset
|
1899 |
self syntaxError:'symbols which require 2-byte characters are not (yet) allowed' |
a6b8a7a14f40
error when a 2-byte symbol is encountered
Claus Gittinger <cg@exept.de>
parents:
1485
diff
changeset
|
1900 |
position:tokenPosition to:(source position1Based - 1). |
a6b8a7a14f40
error when a 2-byte symbol is encountered
Claus Gittinger <cg@exept.de>
parents:
1485
diff
changeset
|
1901 |
]. |
1385
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
1902 |
tokenValue := token := tokenValue asSymbol. |
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
1903 |
tokenType := #Symbol. |
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
1904 |
]. |
500 | 1905 |
^ tokenType |
1906 |
]. |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
1907 |
|
1226 | 1908 |
(nextChar == $#) ifTrue:[ |
1294 | 1909 |
nextChar := source nextPeek. |
1293 | 1910 |
AllowDolphinExtensions == true ifTrue:[ |
1226 | 1911 |
"dolphin does computed literals as ##( ... )" |
1912 |
nextChar == $( ifTrue:[ |
|
1913 |
source next. |
|
1914 |
token := '##('. |
|
1915 |
tokenType := #HashHashLeftParen. |
|
1916 |
^ tokenType |
|
1917 |
]. |
|
1293 | 1918 |
]. |
1919 |
nextChar == $[ ifTrue:[ |
|
1920 |
source next. |
|
1921 |
token := '##('. |
|
1922 |
tokenType := #HashHashLeftBrack. |
|
1291
917f975e3e7e
oops - HashLeftAngle was wrong.
Claus Gittinger <cg@exept.de>
parents:
1290
diff
changeset
|
1923 |
^ tokenType |
917f975e3e7e
oops - HashLeftAngle was wrong.
Claus Gittinger <cg@exept.de>
parents:
1290
diff
changeset
|
1924 |
]. |
1294 | 1925 |
|
1293 | 1926 |
token := '##'. |
1927 |
tokenType := #HashHash. |
|
1928 |
^ tokenType |
|
1226 | 1929 |
]. |
1930 |
||
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
1931 |
((typeArray at:(nextChar codePoint)) == #special) ifTrue:[ |
500 | 1932 |
string := source next asString. |
1933 |
nextChar := source peek. |
|
1934 |
nextChar notNil ifTrue:[ |
|
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
1935 |
((typeArray at:(nextChar codePoint)) == #special) ifTrue:[ |
500 | 1936 |
source next. |
1937 |
string := string copyWith:nextChar |
|
1938 |
] |
|
1939 |
]. |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
1940 |
self markSymbolFrom:tokenPosition to:(source position1Based-1). |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1941 |
tokenValue := token := string asSymbol. |
500 | 1942 |
tokenType := #Symbol. |
1943 |
^ tokenType |
|
1944 |
] |
|
0 | 1945 |
]. |
1298 | 1946 |
|
141 | 1947 |
"this allows hash to be used as binop - |
1948 |
I dont know, if this is correct ..." |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
1949 |
tokenName := token := '#'. |
0 | 1950 |
tokenType := #BinaryOperator. |
1951 |
^ tokenType |
|
500 | 1952 |
|
671 | 1953 |
"Modified: / 1.4.1998 / 13:02:45 / cg" |
0 | 1954 |
! |
1955 |
||
1956 |
nextId |
|
1026 | 1957 |
"no longer used here - remains for backwardCompatibility for |
1958 |
subclass users ... (sigh)" |
|
1959 |
||
0 | 1960 |
|nextChar string oldString |
1961 |
index "{ Class: SmallInteger }" |
|
1962 |
max "{ Class: SmallInteger }" | |
|
1963 |
||
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1964 |
nextChar := source peekOrNil. |
1470
62844fc53a87
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
1965 |
string := String uninitializedNew:20. |
0 | 1966 |
index := 0. |
1967 |
max := 10. |
|
1968 |
[true] whileTrue:[ |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1969 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[ |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1970 |
^ string copyTo:index |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1971 |
]. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1972 |
(index == max) ifTrue:[ |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1973 |
oldString := string. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1974 |
string := String basicNew:(max * 2). |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1975 |
string replaceFrom:1 to:max with:oldString. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1976 |
max := max * 2 |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1977 |
]. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1978 |
index := index + 1. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1979 |
string at:index put:nextChar. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1980 |
nextChar := source nextPeek |
0 | 1981 |
] |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1982 |
|
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
1983 |
"Modified: / 5.3.1998 / 02:53:57 / cg" |
0 | 1984 |
! |
1985 |
||
1986 |
nextIdentifier |
|
1510
875c90576897
Fix duplicate assignment to ActionArray for sh
Stefan Vogel <sv@exept.de>
parents:
1509
diff
changeset
|
1987 |
"an alpha character (or underscore if AllowUnderscore) has been read. |
1026 | 1988 |
Return the next identifier." |
1989 |
||
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
1990 |
|nextChar string ok pos ch2| |
0 | 1991 |
|
87 | 1992 |
hereChar == $_ ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1993 |
"/ |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
1994 |
"/ no need to check for allowUnderscoreInIdentifier here; |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1995 |
"/ could not arrive here if it was off |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1996 |
"/ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1997 |
nextChar := source nextPeek. |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
1998 |
allowOldStyleAssignment ifTrue:[ |
1429
5d46769a95ef
ansified (isAlphaNumeric -> isLetterOrDigit)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1999 |
(nextChar isLetterOrDigit or:[nextChar == $_]) ifFalse:[ |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2000 |
"oops: a single underscore is an old-style assignement" |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2001 |
nextChar ~~ $: ifTrue:[ |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2002 |
self warnOldStyleAssignmentAt:tokenPosition. |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2003 |
tokenType := token := $_. |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2004 |
^ tokenType |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2005 |
] |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2006 |
]. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2007 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2008 |
string := '_'. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2009 |
self warnUnderscoreAt:tokenPosition. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2010 |
[nextChar == $_] whileTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2011 |
string := string copyWith:$_. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2012 |
nextChar := source nextPeek. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2013 |
]. |
1429
5d46769a95ef
ansified (isAlphaNumeric -> isLetterOrDigit)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
2014 |
nextChar isLetterOrDigit ifTrue:[ |
467
feaacb47b0b5
allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
2015 |
string := string , source nextAlphaNumericWord. |
feaacb47b0b5
allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
2016 |
] |
87 | 2017 |
] ifFalse:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2018 |
string := source nextAlphaNumericWord "self nextId". |
87 | 2019 |
]. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2020 |
nextChar := source peekOrNil. |
87 | 2021 |
|
608 | 2022 |
(nextChar == $_ |
2023 |
or:[nextChar == $$]) ifTrue:[ |
|
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2024 |
ok := (nextChar == $_) ifTrue:[allowUnderscoreInIdentifier] ifFalse:[allowDollarInIdentifier]. |
608 | 2025 |
ok ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2026 |
pos := source position1Based. |
608 | 2027 |
nextChar == $_ ifTrue:[ |
610 | 2028 |
self warnUnderscoreAt:pos. |
608 | 2029 |
] ifFalse:[ |
610 | 2030 |
self warnDollarAt:pos. |
608 | 2031 |
]. |
2032 |
[ok] whileTrue:[ |
|
2033 |
string := string copyWith:nextChar. |
|
2034 |
nextChar := source nextPeek. |
|
802
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2035 |
nextChar isNil ifTrue:[ |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2036 |
ok := false |
608 | 2037 |
] ifFalse:[ |
1429
5d46769a95ef
ansified (isAlphaNumeric -> isLetterOrDigit)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
2038 |
(nextChar isLetterOrDigit) ifTrue:[ |
802
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2039 |
string := string , source nextAlphaNumericWord. |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2040 |
nextChar := source peekOrNil. |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2041 |
]. |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2042 |
(nextChar == $_) ifTrue:[ |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2043 |
ok := allowUnderscoreInIdentifier |
608 | 2044 |
] ifFalse:[ |
802
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2045 |
(nextChar == $$) ifTrue:[ |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2046 |
ok := allowDollarInIdentifier |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2047 |
] ifFalse:[ |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2048 |
ok := false |
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2049 |
] |
608 | 2050 |
] |
2051 |
] |
|
2052 |
]. |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2053 |
]. |
60 | 2054 |
]. |
2055 |
||
785
14d0ec37a754
added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
2056 |
(nextChar == $: and:[scanColonAsKeyword]) ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2057 |
source next. |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2058 |
ch2 := source peekOrNil. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2059 |
"/ colon follows - care for '::' (nameSpace separator) or ':=' (assignment) |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2060 |
(ch2 == $=) ifFalse:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2061 |
(ch2 == $:) ifFalse:[ |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2062 |
tokenName := token := string copyWith:nextChar. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2063 |
tokenType := #Keyword. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2064 |
inArrayLiteral == true ifTrue:[ |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2065 |
(ch2 isLetter |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2066 |
or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]) ifTrue:[ |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2067 |
"/ kludge: recurse to read the rest. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2068 |
self nextIdentifier. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2069 |
tokenName := token := (string copyWith:nextChar) , token. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2070 |
tokenType ~~ #Keyword ifTrue:[ |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2071 |
self syntaxError:'invalid keyword symbol in array constant' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2072 |
position:tokenPosition to:(source position1Based - 1). |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2073 |
]. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2074 |
tokenType := #Keyword. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2075 |
]. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2076 |
]. |
1104
0ffcaab55dbc
oops - nextIdentifier must return a tokenType
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
2077 |
^ tokenType |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2078 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2079 |
peekChar := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2080 |
peekChar2 := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2081 |
] ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2082 |
peekChar := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2083 |
peekChar2 := $=. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2084 |
] |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2085 |
] ifFalse:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2086 |
(nextChar == $. and:[AllowQualifiedNames]) ifTrue:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2087 |
"/ period follows - if next-after character is an identifier character, |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2088 |
"/ make peekSym a #NameSpaceSeparator; otherwise a $. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2089 |
source next. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2090 |
ch2 := source peekOrNil. |
1029 | 2091 |
(ch2 notNil |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2092 |
and:[ch2 isLetter or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]]) ifTrue:[ |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2093 |
peekChar := #'::'. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2094 |
] ifFalse:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2095 |
peekChar := $. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2096 |
]. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2097 |
]. |
0 | 2098 |
]. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2099 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2100 |
nextChar == $- ifTrue:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2101 |
pos := source position1Based. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2102 |
self |
1395 | 2103 |
warnPossibleIncompatibility:'add spaces around ''-'' for compatibility with other systems' |
610 | 2104 |
position:pos to:pos. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2105 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2106 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2107 |
tokenName := token := string. |
1026 | 2108 |
(self checkForKeyword:string) ifFalse:[ |
2109 |
tokenType := #Identifier. |
|
2110 |
]. |
|
0 | 2111 |
^ tokenType |
120 | 2112 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2113 |
"Created: / 13.9.1995 / 12:56:42 / claus" |
802
5c6e7db91d5f
bug fix if source ends with underline(-identifier)
Claus Gittinger <cg@exept.de>
parents:
795
diff
changeset
|
2114 |
"Modified: / 2.2.1999 / 22:29:57 / cg" |
0 | 2115 |
! |
2116 |
||
141 | 2117 |
nextMantissa:radix |
1026 | 2118 |
"read the mantissa of a radix number" |
2119 |
||
1351 | 2120 |
<resource: #obsolete> |
2121 |
||
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2122 |
^ (self nextMantissaAndScaledPartWithRadix:radix) first |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2123 |
! |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2124 |
|
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2125 |
nextMantissaAndScaledPartWithRadix:radix |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2126 |
"read the mantissa of a radix number. |
1430 | 2127 |
Since we dont know yet if this is for a Float, LongFloat or a FixedPoint, |
2128 |
return info which is useful for all: an array consisting of |
|
2129 |
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
|
2130 |
|
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2131 |
|nextChar value fixedPointNumerator fixedPointScale factor| |
141 | 2132 |
|
1433 | 2133 |
value := 0.0. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2134 |
fixedPointNumerator := 0. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2135 |
fixedPointScale := 0. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2136 |
|
1431
5ba79dc4c93b
avoid loosing precision when reading float literals
Claus Gittinger <cg@exept.de>
parents:
1430
diff
changeset
|
2137 |
factor := 1.0 asLongFloat / radix. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2138 |
nextChar := source peekOrNil. |
141 | 2139 |
[(nextChar notNil and:[nextChar isDigitRadix:radix])] whileTrue:[ |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2140 |
fixedPointNumerator := (fixedPointNumerator * 10) + nextChar digitValue. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2141 |
fixedPointScale := fixedPointScale + 1. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2142 |
value := value + (nextChar digitValue * factor). |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2143 |
factor := factor / radix. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2144 |
nextChar := source nextPeek |
141 | 2145 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2146 |
^ (Array with:value with:fixedPointNumerator with:fixedPointScale) |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2147 |
|
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2148 |
"Modified: / 5.3.1998 / 02:54:11 / cg" |
141 | 2149 |
! |
2150 |
||
2151 |
nextNumber |
|
1026 | 2152 |
"scan a number; handles radix prefix, mantissa and exponent. |
2153 |
Does not yet handle fixNums. Allows for e, d or q to be used as exponent |
|
2154 |
limiter." |
|
2155 |
||
1430 | 2156 |
|pos1 nextChar value integerPart s tokenRadix mantissaAndScaledPart d type exp| |
141 | 2157 |
|
2158 |
tokenRadix := 10. |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2159 |
type := #Integer. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2160 |
pos1 := source position1Based. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2161 |
|
141 | 2162 |
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
|
2163 |
nextChar := source peekOrNil. |
141 | 2164 |
(nextChar == $r) ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2165 |
tokenRadix := value. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2166 |
source next. |
820
5db3668f751d
syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents:
802
diff
changeset
|
2167 |
|
5db3668f751d
syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents:
802
diff
changeset
|
2168 |
(tokenRadix between:2 and:36) ifFalse:[ |
5db3668f751d
syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents:
802
diff
changeset
|
2169 |
self syntaxError:'bad radix (must be 2 .. 36)' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2170 |
position:tokenPosition to:(source position1Based - 1). |
820
5db3668f751d
syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents:
802
diff
changeset
|
2171 |
]. |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2172 |
s := 1. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2173 |
source peekOrNil == $- ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2174 |
source next. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2175 |
s := -1 |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2176 |
]. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2177 |
value := Integer readFrom:source radix:tokenRadix. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2178 |
value := value * s. |
982
f0cc45f113b3
exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents:
947
diff
changeset
|
2179 |
nextChar := source peekOrNil. |
141 | 2180 |
]. |
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
|
2181 |
|
141 | 2182 |
(nextChar == $.) ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2183 |
nextChar := source nextPeek. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2184 |
(nextChar notNil and:[nextChar isDigitRadix:tokenRadix]) ifTrue:[ |
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
|
2185 |
(tokenRadix > 14 and:[nextChar == $e or:[nextChar == $E]]) ifTrue:[ |
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
|
2186 |
self warning:'float with radix > 14 - (e/E are valid digits; not exponent-leaders)' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2187 |
position:tokenPosition to:(source position1Based - 1). |
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
|
2188 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2189 |
mantissaAndScaledPart := self nextMantissaAndScaledPartWithRadix:tokenRadix. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2190 |
integerPart := value. |
1433 | 2191 |
value := integerPart + (mantissaAndScaledPart first). "could be a longFloat now" |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2192 |
type := #Float. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2193 |
nextChar := source peekOrNil |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2194 |
] ifFalse:[ |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2195 |
('eEdDqQ' includes:nextChar) ifTrue:[ |
1339
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2196 |
"/ allow 5.e-3 - is this standard ? |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2197 |
|
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2198 |
] ifFalse:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2199 |
"/ nextChar == (Character cr) ifTrue:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2200 |
"/ lineNr := lineNr + 1. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2201 |
"/ ]. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2202 |
nextChar := peekChar := $.. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2203 |
] |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2204 |
] |
141 | 2205 |
]. |
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
|
2206 |
|
1026 | 2207 |
('eEdDqQ' includes:nextChar) ifTrue:[ |
1430 | 2208 |
(nextChar == $q or:[nextChar == $Q]) ifTrue:[ |
2209 |
value := value asLongFloat |
|
2210 |
] ifFalse:[ |
|
2211 |
value := value asFloat. |
|
2212 |
]. |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2213 |
type := #Float. |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2214 |
nextChar := source nextPeek. |
982
f0cc45f113b3
exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents:
947
diff
changeset
|
2215 |
(nextChar notNil and:[(nextChar isDigit"Radix:tokenRadix") or:['+-' includes:nextChar]]) ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2216 |
s := 1. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2217 |
(nextChar == $+) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2218 |
nextChar := source nextPeek |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2219 |
] ifFalse:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2220 |
(nextChar == $-) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2221 |
nextChar := source nextPeek. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2222 |
s := s negated |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2223 |
] |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2224 |
]. |
1430 | 2225 |
exp := (Integer readFrom:source) * s. |
2226 |
value := value * ((value class unity * tokenRadix) raisedToInteger:exp). |
|
983 | 2227 |
nextChar := source peek. |
982
f0cc45f113b3
exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents:
947
diff
changeset
|
2228 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2229 |
] ifFalse:[ |
1430 | 2230 |
value isLimitedPrecisionReal ifTrue:[ |
2231 |
"/ no type specified - makes it a float |
|
2232 |
value := value asFloat. |
|
2233 |
]. |
|
2234 |
||
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2235 |
AllowFixedPointLiterals == true ifTrue:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2236 |
"/ Dolphin scaledDecimal numbers |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2237 |
('s' includes:nextChar) ifTrue:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2238 |
nextChar := source nextPeek. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2239 |
mantissaAndScaledPart isNil ifTrue:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2240 |
value := value asFixedPoint:1 |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2241 |
] ifFalse:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2242 |
d := 10 raisedTo:(mantissaAndScaledPart last). |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2243 |
value := FixedPoint |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2244 |
numerator:((integerPart * d) + mantissaAndScaledPart second) |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2245 |
denominator:d |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2246 |
scale:(mantissaAndScaledPart last). |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2247 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2248 |
type := #FixedPoint. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2249 |
self |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2250 |
warnPossibleIncompatibility:'fixedPoint literal might be incompatibile with other systems' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2251 |
position:pos1 to:source position1Based. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2252 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2253 |
]. |
141 | 2254 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2255 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2256 |
nextChar == $- ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2257 |
self |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2258 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2259 |
position:(source position1Based) to:(source position1Based). |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2260 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2261 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2262 |
tokenValue := token := value. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2263 |
tokenType := type. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2264 |
(tokenValue isLimitedPrecisionReal) ~~ (tokenType == #Float) ifTrue:[self halt]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2265 |
|
671 | 2266 |
"/ self markConstantFrom:tokenPosition to:(source position - 1). |
141 | 2267 |
^ tokenType |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2268 |
|
671 | 2269 |
"Modified: / 1.4.1998 / 13:06:28 / cg" |
141 | 2270 |
! |
2271 |
||
0 | 2272 |
nextPrimitive |
1026 | 2273 |
"scan an inline C-primitive." |
2274 |
||
0 | 2275 |
|nextChar inPrimitive string |
2276 |
index "{ Class: SmallInteger }" |
|
2277 |
len "{ Class: SmallInteger }" | |
|
2278 |
||
2279 |
nextChar := source nextPeek. |
|
1302 | 2280 |
(nextChar == ${) ifFalse:[ |
2281 |
^ self nextSpecialWith:$% |
|
2282 |
]. |
|
2283 |
||
0 | 2284 |
string := String new:500. |
2285 |
len := 500. |
|
2286 |
index := 1. |
|
1302 | 2287 |
nextChar := source nextPeek. |
2288 |
inPrimitive := true. |
|
2289 |
[inPrimitive] whileTrue:[ |
|
2290 |
[nextChar == $%] whileFalse:[ |
|
2291 |
nextChar isNil ifTrue:[ |
|
2292 |
self syntaxError:'unterminated primitive' |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2293 |
position:tokenPosition to:source position1Based. |
1302 | 2294 |
^ #Error |
2295 |
]. |
|
2296 |
string at:index put:nextChar. |
|
2297 |
(index == len) ifTrue:[ |
|
2298 |
string := string , (String new:len). |
|
2299 |
len := len * 2 |
|
505
793f88ee6269
handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
2300 |
]. |
1302 | 2301 |
index := index + 1. |
2302 |
nextChar := source next |
|
505
793f88ee6269
handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
2303 |
]. |
1302 | 2304 |
(source peekOrNil == $}) ifTrue:[ |
2305 |
inPrimitive := false |
|
2306 |
] ifFalse:[ |
|
2307 |
string at:index put:nextChar. |
|
2308 |
(index == len) ifTrue:[ |
|
2309 |
string := string , (String new:len). |
|
2310 |
len := len * 2 |
|
2311 |
]. |
|
2312 |
index := index + 1. |
|
2313 |
nextChar := source next |
|
2314 |
] |
|
0 | 2315 |
]. |
1302 | 2316 |
source next. |
2317 |
tokenValue := token := string copyTo:(index - 1). |
|
2318 |
tokenType := #Primitive. |
|
2319 |
lineNr := lineNr + (tokenValue occurrencesOf:(Character cr)). |
|
2320 |
^ tokenType |
|
0 | 2321 |
! |
2322 |
||
141 | 2323 |
nextSpecial |
2324 |
"a special character has been read, look for another one. |
|
2325 |
also -number is handled here" |
|
2326 |
||
1302 | 2327 |
|firstChar| |
0 | 2328 |
|
141 | 2329 |
firstChar := source next. |
1302 | 2330 |
^ self nextSpecialWith:firstChar |
2331 |
! |
|
2332 |
||
2333 |
nextSpecialWith:firstChar |
|
2334 |
"a special character has been read, look for another one. |
|
2335 |
also -number is handled here" |
|
2336 |
||
2337 |
|secondChar thirdChar fourthChar string p| |
|
2338 |
||
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2339 |
secondChar := source peekOrNil. |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
2340 |
((firstChar == $-) and:[secondChar notNil]) ifTrue:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2341 |
secondChar isDigit ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2342 |
self nextNumber. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2343 |
tokenValue := token := tokenValue negated. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2344 |
^ tokenType |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2345 |
] |
0 | 2346 |
]. |
141 | 2347 |
string := firstChar asString. |
2348 |
secondChar notNil ifTrue:[ |
|
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
2349 |
((typeArray at:(secondChar codePoint)) == #special) ifTrue:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2350 |
(secondChar == $-) ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2351 |
"special- look if minus belongs to number following" |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2352 |
p := source position1Based. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2353 |
source next. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2354 |
thirdChar := source peekOrNil. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2355 |
source position1Based:p. |
1356
e2877130760c
oops care for nil peek-character
Claus Gittinger <cg@exept.de>
parents:
1355
diff
changeset
|
2356 |
(thirdChar notNil and:[thirdChar isDigit]) ifTrue:[ |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2357 |
tokenName := token := string. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2358 |
tokenType := #BinaryOperator. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2359 |
self |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2360 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other ST systems' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2361 |
position:p |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2362 |
to:p. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2363 |
^ tokenType |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2364 |
] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2365 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2366 |
source next. |
1302 | 2367 |
string := string copyWith:secondChar. |
2368 |
||
2369 |
thirdChar := source peekOrNil. |
|
2370 |
thirdChar notNil ifTrue:[ |
|
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
2371 |
((typeArray at:(thirdChar codePoint)) == #special) ifTrue:[ |
1302 | 2372 |
(thirdChar == $-) ifTrue:[ |
2373 |
"special- look if minus belongs to number following" |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2374 |
p := source position1Based. |
1302 | 2375 |
source next. |
2376 |
fourthChar := source peekOrNil. |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2377 |
source position1Based:p. |
1302 | 2378 |
fourthChar isDigit ifTrue:[ |
2379 |
tokenName := token := string. |
|
2380 |
tokenType := #BinaryOperator. |
|
2381 |
self |
|
2382 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other ST systems' |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2383 |
position:p |
1302 | 2384 |
to:p. |
2385 |
^ tokenType |
|
2386 |
] |
|
2387 |
]. |
|
2388 |
source next. |
|
2389 |
string := string copyWith:thirdChar. |
|
2390 |
]. |
|
2391 |
]. |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2392 |
]. |
141 | 2393 |
]. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2394 |
tokenName := token := string. |
45 | 2395 |
tokenType := #BinaryOperator. |
3 | 2396 |
^ tokenType |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
2397 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2398 |
"Modified: / 5.3.1998 / 02:54:54 / cg" |
0 | 2399 |
! |
2400 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2401 |
nextString |
1026 | 2402 |
"a single quote has been scanned; scan the string (caring for doubled quotes" |
2403 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2404 |
|nextChar string pos |
0 | 2405 |
index "{ Class: SmallInteger }" |
2406 |
len "{ Class: SmallInteger }" |
|
1321 | 2407 |
inString peekChar| |
0 | 2408 |
|
1470
62844fc53a87
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
2409 |
string := String uninitializedNew:20. |
0 | 2410 |
len := 20. |
2411 |
index := 1. |
|
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2412 |
pos := source position1Based. |
0 | 2413 |
source next. |
2414 |
nextChar := source next. |
|
2415 |
inString := true. |
|
2416 |
||
2417 |
[inString] whileTrue:[ |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2418 |
nextChar isNil ifTrue:[ |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2419 |
self syntaxError:'unexpected end-of-input in String' |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2420 |
position:pos to:(source position1Based - 1). |
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2421 |
self markStringFrom:pos to:source position1Based-1. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2422 |
token := nil. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2423 |
tokenType := #EOF. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2424 |
^ tokenType |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2425 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2426 |
(nextChar == Character cr) ifTrue:[ |
610 | 2427 |
lineNr := lineNr + 1 |
1321 | 2428 |
] ifFalse:[ |
2429 |
(nextChar == Character quote) ifTrue:[ |
|
2430 |
(source peekOrNil == Character quote) ifTrue:[ |
|
2431 |
source next |
|
2432 |
] ifFalse:[ |
|
2433 |
inString := false |
|
2434 |
] |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2435 |
] ifFalse:[ |
1321 | 2436 |
AllowExtendedSTXSyntax == true ifTrue:[ |
2437 |
(nextChar == $`) ifTrue:[ |
|
2438 |
peekChar := source peekOrNil. |
|
2439 |
peekChar notNil ifTrue:[ |
|
2440 |
source next. |
|
2441 |
nextChar := self escapeCharacterFor:peekChar. |
|
2442 |
] |
|
2443 |
] |
|
2444 |
] |
|
2445 |
]. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2446 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2447 |
inString ifTrue:[ |
1321 | 2448 |
nextChar notNil ifTrue:[ |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
2449 |
nextChar codePoint > 255 ifTrue:[ |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
2450 |
string bitsPerCharacter < nextChar bitsPerCharacter ifTrue:[ |
1485 | 2451 |
string := string asUnicodeString. |
2452 |
]. |
|
2453 |
]. |
|
1321 | 2454 |
string at:index put:nextChar. |
2455 |
(index == len) ifTrue:[ |
|
1485 | 2456 |
string := string , (string species new:len). |
1321 | 2457 |
len := len * 2 |
2458 |
]. |
|
2459 |
index := index + 1. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2460 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2461 |
nextChar := source next |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2462 |
] |
0 | 2463 |
]. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2464 |
self markStringFrom:pos to:source position1Based-1. |
661 | 2465 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2466 |
tokenValue := token := string copyTo:(index - 1). |
0 | 2467 |
tokenType := #String. |
2468 |
^ tokenType |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2469 |
|
661 | 2470 |
"Modified: / 31.3.1998 / 17:33:14 / cg" |
141 | 2471 |
! |
2472 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2473 |
nextToken |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2474 |
"return the next token from the source-stream" |
141 | 2475 |
|
1483 | 2476 |
|skipping actionBlock v ch tok errMsg| |
141 | 2477 |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2478 |
[true] whileTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2479 |
peekChar notNil ifTrue:[ |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2480 |
"/ kludge - should be called peekSym. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2481 |
"/ used when xlating Foo.Bar into Foo::Bar |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2482 |
peekChar isSymbol ifTrue:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2483 |
token := nil. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2484 |
tokenType := peekChar. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2485 |
peekChar := nil. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2486 |
^ tokenType |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2487 |
]. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2488 |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2489 |
peekChar isSeparator ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2490 |
peekChar == (Character cr) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2491 |
lineNr := lineNr + 1. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2492 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2493 |
peekChar := peekChar2. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2494 |
peekChar2 := nil. |
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
|
2495 |
]. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2496 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2497 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2498 |
peekChar notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2499 |
ch := peekChar. |
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
|
2500 |
peekChar := peekChar2. |
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
|
2501 |
peekChar2 := nil. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2502 |
hereChar := nil. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2503 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2504 |
skipping := true. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2505 |
[skipping] whileTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2506 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2507 |
outStream notNil ifTrue:[ |
1497 | 2508 |
[ |
2509 |
hereChar := source peekOrNil. |
|
2510 |
(hereChar == Character space) |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2511 |
or:[hereChar isSeparator] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2512 |
] whileTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2513 |
source next. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2514 |
outStream space. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2515 |
outCol := outCol + 1. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2516 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2517 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2518 |
hereChar := source skipSeparatorsExceptCR. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2519 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2520 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2521 |
hereChar == (Character cr) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2522 |
lineNr := lineNr + 1. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2523 |
source next. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2524 |
outStream notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2525 |
outStream cr. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2526 |
outCol := 1 |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2527 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2528 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2529 |
hereChar == (Character return) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2530 |
outStream notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2531 |
outStream nextPut:hereChar. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2532 |
outCol := 1 |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2533 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2534 |
source next. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2535 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2536 |
(self isCommentCharacter:hereChar) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2537 |
"start of a comment" |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2538 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2539 |
self skipComment. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2540 |
hereChar := source peekOrNil. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2541 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2542 |
skipping := false |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2543 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2544 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2545 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2546 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2547 |
hereChar isNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2548 |
token := nil. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2549 |
tokenType := #EOF. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2550 |
^ tokenType |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2551 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2552 |
ch := hereChar |
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
|
2553 |
]. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2554 |
tokenPosition := source position1Based. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2555 |
tokenLineNr := lineNr. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2556 |
|
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
2557 |
(v := ch codePoint) == 0 ifTrue:[ |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
2558 |
v := Character space codePoint |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2559 |
]. |
1483 | 2560 |
v <= 16rFF ifTrue:[ |
2561 |
actionBlock := actionArray at:v. |
|
2562 |
]. |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2563 |
actionBlock notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2564 |
tok := actionBlock value:self value:ch. |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2565 |
tok notNil ifTrue:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2566 |
^ tok |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2567 |
]. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2568 |
] ifFalse:[ |
1483 | 2569 |
ch isPrintable ifTrue:[ |
2570 |
errMsg := 'Scanner - invalid character: ''' , ch asString , ''' ', '(' , (v radixPrintStringRadix:16) , ').'. |
|
2571 |
] ifFalse:[ |
|
2572 |
errMsg := 'Scanner - invalid character: ' , (v radixPrintStringRadix:16) , '.'. |
|
2573 |
]. |
|
1484 | 2574 |
v > 16r7F ifTrue:[ |
1483 | 2575 |
errMsg := errMsg , '\\Notice: only 7-bit ascii allowed (for compatibility).' withCRs. |
2576 |
]. |
|
2577 |
self syntaxError:errMsg position:tokenPosition to:tokenPosition. |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2578 |
source next. |
1103
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1102
diff
changeset
|
2579 |
tokenName := token := nil. |
b75a71996388
ensure that token follows tomeName & tokenValue
Claus Gittinger <cg@exept.de>
parents:
1102
diff
changeset
|
2580 |
tokenType := #Error. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2581 |
^ #Error |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2582 |
] |
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
|
2583 |
]. |
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
|
2584 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2585 |
"Modified: / 13.9.1995 / 12:56:14 / claus" |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
2586 |
"Modified: / 22.10.1998 / 22:15:27 / cg" |
141 | 2587 |
! |
2588 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2589 |
nextToken:aCharacter |
1026 | 2590 |
"return a character token" |
2591 |
||
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2592 |
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
|
2593 |
hereChar notNil ifTrue:[source next]. |
141 | 2594 |
^ 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
|
2595 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2596 |
"Modified: / 13.5.1998 / 15:10:23 / cg" |
141 | 2597 |
! |
2598 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2599 |
nextUnderline |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2600 |
"return a character token" |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2601 |
|
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2602 |
allowUnderscoreInIdentifier ifTrue:[ |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2603 |
^ self nextIdentifier |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2604 |
] ifFalse:[ |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2605 |
^ self nextToken:$_ |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2606 |
] |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2607 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2608 |
|
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2609 |
skipComment |
1026 | 2610 |
"skip over a comment; handles ST/X eol comments." |
2611 |
||
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2612 |
|commentStream commentType startPos stillInComment| |
141 | 2613 |
|
2614 |
saveComments ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2615 |
commentStream := WriteStream on:''. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2616 |
self beginComment. |
141 | 2617 |
]. |
2618 |
||
2619 |
outStream notNil ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2620 |
outStream nextPut:Character doubleQuote. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2621 |
outCol := outCol + 1 |
141 | 2622 |
]. |
2623 |
||
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2624 |
startPos := source position1Based. |
141 | 2625 |
source next. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2626 |
hereChar := source peekOrNil. |
141 | 2627 |
|
2628 |
" |
|
2629 |
special ST/X addition: |
|
2630 |
a $/ right after the initial double quote makes it an up-to-end-of-line comment, |
|
2631 |
which is very useful to comment out parts of filed-in source code. |
|
2632 |
Since this is non-standard, use it in very rare cases only. |
|
2633 |
(maybe the upcoming ansi-standard adds something similar - in this case, I will |
|
2634 |
change it without notice)" |
|
2635 |
||
2636 |
hereChar == $/ ifTrue:[ |
|
648 | 2637 |
commentType := #eolComment. |
2638 |
||
2639 |
hereChar := source nextPeek. |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2640 |
[hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[ |
648 | 2641 |
commentStream notNil ifTrue:[ |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2642 |
commentStream nextPut:hereChar |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2643 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2644 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2645 |
outStream nextPut:hereChar. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2646 |
outCol := outCol + 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2647 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2648 |
hereChar := source nextPeek. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2649 |
]. |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2650 |
self markCommentFrom:startPos to:(source position1Based). |
610 | 2651 |
lineNr := lineNr + 1. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2652 |
ignoreWarnings ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2653 |
warnSTXSpecialComment ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2654 |
self warning:'end-of-line comments are a nonstandard feature of ST/X' |
1458 | 2655 |
doNotShowAgainAction:[ WarnSTXSpecials := false ] |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2656 |
position:startPos to:(source position1Based). |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2657 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2658 |
only warn once |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2659 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2660 |
warnSTXSpecialComment := false |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2661 |
] |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2662 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2663 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2664 |
outStream cr. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2665 |
outCol := 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2666 |
]. |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2667 |
"skip cr" |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2668 |
source next. |
141 | 2669 |
] ifFalse:[ |
648 | 2670 |
commentType := #regularComment. |
2671 |
||
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2672 |
hereChar == ${ ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2673 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2674 |
special ST/X addition: |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2675 |
a ${ right after the initial double quote starts a directive |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2676 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2677 |
self parseDirective |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2678 |
]. |
141 | 2679 |
|
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2680 |
stillInComment := true. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2681 |
[stillInComment] whileTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2682 |
stillInComment := false. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2683 |
|
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2684 |
[hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2685 |
hereChar == (Character cr) ifTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2686 |
lineNr := lineNr + 1. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2687 |
]. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2688 |
commentStream notNil ifTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2689 |
commentStream nextPut:hereChar |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2690 |
]. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2691 |
outStream notNil ifTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2692 |
outStream nextPut:hereChar. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2693 |
outCol := outCol + 1 |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2694 |
]. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2695 |
hereChar := source nextPeek |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2696 |
]. |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2697 |
|
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2698 |
hereChar isNil ifTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2699 |
self markCommentFrom:startPos to:(source size). |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2700 |
self warning:'unclosed comment' position:startPos to:(source position1Based) |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2701 |
] ifFalse:[ |
1371
de4c37ac12fc
code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents:
1370
diff
changeset
|
2702 |
self markCommentFrom:startPos to:(source position1Based). |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2703 |
outStream notNil ifTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2704 |
outStream nextPut:(Character doubleQuote). |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2705 |
outCol := outCol + 1 |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2706 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2707 |
]. |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2708 |
"skip final dQuote" |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2709 |
source next. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2710 |
|
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2711 |
(source peek == Character doubleQuote) ifTrue:[ |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2712 |
stillInComment := true. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
2713 |
hereChar := source nextPeek. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2714 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2715 |
]. |
141 | 2716 |
]. |
2717 |
||
2718 |
saveComments ifTrue:[ |
|
648 | 2719 |
self endComment:(commentStream contents) type:commentType. |
141 | 2720 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
2721 |
|
666 | 2722 |
"Modified: / 31.3.1998 / 23:45:26 / cg" |
648 | 2723 |
! ! |
2724 |
||
2725 |
!Scanner::Comment methodsFor:'accessing'! |
|
2726 |
||
2727 |
commentString |
|
2728 |
"return the value of the instance variable 'commentString' (automatically generated)" |
|
2729 |
||
2730 |
^ commentString |
|
2731 |
||
2732 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
2733 |
! |
|
2734 |
||
2735 |
commentString:something |
|
2736 |
"set the value of the instance variable 'commentString' (automatically generated)" |
|
2737 |
||
2738 |
commentString := something. |
|
2739 |
||
2740 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
2741 |
! |
|
2742 |
||
2743 |
commentType |
|
2744 |
"return the value of the instance variable 'commentType' (automatically generated)" |
|
2745 |
||
2746 |
^ commentType |
|
2747 |
||
2748 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
2749 |
! |
|
2750 |
||
2751 |
commentType:something |
|
2752 |
"set the value of the instance variable 'commentType' (automatically generated)" |
|
2753 |
||
2754 |
commentType := something. |
|
2755 |
||
2756 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
2757 |
! |
|
2758 |
||
2759 |
string |
|
2760 |
^ commentString |
|
2761 |
||
2762 |
"Created: / 17.2.1998 / 14:49:52 / cg" |
|
0 | 2763 |
! ! |
141 | 2764 |
|
1580 | 2765 |
!Scanner::Comment methodsFor:'converting'! |
2766 |
||
2767 |
asString |
|
2768 |
^ commentString. |
|
2769 |
! ! |
|
2770 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
2771 |
!Scanner::DoNotShowCompilerWarningAgainActionQuery class methodsFor:'queries'! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
2772 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
2773 |
actionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
2774 |
^ self query |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
2775 |
! ! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
2776 |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2777 |
!Scanner class methodsFor:'documentation'! |
148 | 2778 |
|
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
2779 |
version |
1580 | 2780 |
^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.195 2005-04-19 09:06:22 cg Exp $' |
148 | 2781 |
! ! |
1321 | 2782 |
|
141 | 2783 |
Scanner initialize! |