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