author | Claus Gittinger <cg@exept.de> |
Sat, 04 Jan 1997 14:16:39 +0100 | |
changeset 462 | 6a29b0b356fc |
parent 460 | c023e3713433 |
child 467 | feaacb47b0b5 |
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 |
||
13 |
Object subclass:#Scanner |
|
311 | 14 |
instanceVariableNames:'source lineNr collectedSource token tokenType tokenPosition |
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
15 |
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
|
16 |
requestor exitBlock errorFlag ignoreErrors ignoreWarnings |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
17 |
saveComments currentComments warnSTXSpecialComment |
311 | 18 |
warnUnderscoreInIdentifier warnOldStyleAssignment |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
19 |
warnCommonMistakes outStream outCol warnSTXNameSpaceUse' |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
20 |
classVariableNames:'TypeArray ActionArray AllowUnderscoreInIdentifier Warnings |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
21 |
WarnSTXSpecials WarnOldStyleAssignment WarnUnderscoreInIdentifier |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
22 |
WarnCommonMistakes' |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
23 |
poolDictionaries:'' |
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
24 |
category:'System-Compiler' |
0 | 25 |
! |
26 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
27 |
!Scanner class methodsFor:'documentation'! |
20 | 28 |
|
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
45 | 32 |
All Rights Reserved |
20 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
Scanner reads from a stream and returns individual smalltalk tokens |
|
75 | 46 |
|
47 |
TODO: some testers noticed, that ST-80's scanner methods are called |
|
48 |
xLetter, xDigit etc. For code using these (internals), the nextNumber, |
|
49 |
nextIdentifier etc. methods should be renamed. |
|
120 | 50 |
(to me, these seem to be internal private methods; their public use |
51 |
is not a good idea ..) |
|
20 | 52 |
" |
41 | 53 |
! ! |
54 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
55 |
!Scanner class methodsFor:'initialization'! |
33 | 56 |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
57 |
binarySelectorCharacters |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
58 |
"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
|
59 |
binary selectors" |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
60 |
|
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
61 |
^ #( $& $- $+ $= $* $/ $\ $< $> $~ $@ $, $? $!! $|) |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
62 |
|
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
63 |
"Created: 4.1.1997 / 14:13:24 / cg" |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
64 |
! |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
65 |
|
60 | 66 |
initialize |
67 |
Warnings := true. |
|
68 |
WarnSTXSpecials := true. |
|
69 |
WarnUnderscoreInIdentifier := true. |
|
87 | 70 |
WarnOldStyleAssignment := true. |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
71 |
WarnCommonMistakes := true. |
60 | 72 |
AllowUnderscoreInIdentifier := false. |
73 |
! |
|
74 |
||
33 | 75 |
setupActions |
76 |
|block| |
|
77 |
||
78 |
ActionArray := Array new:256. |
|
79 |
TypeArray := Array new:256. |
|
80 |
||
81 |
block := [:s :char | s nextNumber]. |
|
82 |
($0 asciiValue) to:($9 asciiValue) do:[:index | |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
83 |
ActionArray at:index put:block |
33 | 84 |
]. |
85 |
||
87 | 86 |
block := [:s :char | s nextSpecial]. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
87 |
self binarySelectorCharacters do:[:binop | |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
88 |
TypeArray at:(binop asciiValue) put:#special. |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
89 |
ActionArray at:(binop asciiValue) put:block |
87 | 90 |
]. |
91 |
||
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
92 |
"/ that one is a special case (both binarySelector AND syntax). |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
93 |
TypeArray at:($| asciiValue) put:nil. |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
94 |
|
87 | 95 |
block := [:s :char | s nextToken:char]. |
89 | 96 |
#( $; $. $( $) $[ $] "$!!" $^ $| $_ ) do:[:ch | |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
97 |
ActionArray at:(ch asciiValue) put:block |
87 | 98 |
]. |
99 |
||
33 | 100 |
block := [:s :char | s nextIdentifier]. |
101 |
($a asciiValue) to:($z asciiValue) do:[:index | |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
102 |
ActionArray at:index put:block |
33 | 103 |
]. |
104 |
($A asciiValue) to:($Z asciiValue) do:[:index | |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
105 |
ActionArray at:index put:block |
33 | 106 |
]. |
71 | 107 |
AllowUnderscoreInIdentifier ifTrue:[ |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
108 |
ActionArray at:$_ asciiValue put:block |
71 | 109 |
]. |
33 | 110 |
|
111 |
"kludge: action is characterToken, but type is special" |
|
112 |
TypeArray at:($| asciiValue) put:#special. |
|
113 |
||
80 | 114 |
"kludge: action is nextColonOrAssign, but type is special" |
115 |
TypeArray at:($: asciiValue) put:#special. |
|
116 |
||
33 | 117 |
ActionArray at:($' asciiValue) put:[:s :char | s nextString]. |
118 |
ActionArray at:($$ asciiValue) put:[:s :char | s nextCharacter]. |
|
119 |
ActionArray at:($# asciiValue) put:[:s :char | s nextHash]. |
|
120 |
ActionArray at:($% asciiValue) put:[:s :char | s nextPrimitive]. |
|
121 |
ActionArray at:($: asciiValue) put:[:s :char | s nextColonOrAssign] |
|
122 |
||
123 |
" |
|
124 |
Scanner setupActions |
|
125 |
" |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
126 |
|
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
127 |
"Modified: 4.1.1997 / 14:14:51 / cg" |
33 | 128 |
! ! |
129 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
130 |
!Scanner class methodsFor:'instance creation'! |
141 | 131 |
|
132 |
for:aStringOrStream |
|
133 |
"return a new scanner reading from aStringOrStream" |
|
134 |
||
135 |
^ (super new) initializeFor:aStringOrStream |
|
136 |
! ! |
|
137 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
138 |
!Scanner class methodsFor:'defaults'! |
141 | 139 |
|
140 |
allowUnderscoreInIdentifier |
|
141 |
"return true, if underscores are allowed in identifiers" |
|
142 |
||
143 |
^ AllowUnderscoreInIdentifier |
|
144 |
! |
|
145 |
||
146 |
allowUnderscoreInIdentifier:aBoolean |
|
147 |
"this allows turning on/off underscores in identifiers. |
|
148 |
If turned off (the default), underscores are not allowed in identifiers, |
|
149 |
but instead scanned as assignment character (old ST/80 syntax). |
|
150 |
If turned on, underscores are in identifiers are allowed, while extra |
|
151 |
underscores are still scanned as assignment. |
|
152 |
If you have to fileIn VV-Vsn2 classes, |
|
153 |
add a line such as: |
|
154 |
Compiler allowUnderscoreInIdentifiers:false |
|
155 |
in your 'private.rc'/'smalltalk.rc' file" |
|
156 |
||
157 |
AllowUnderscoreInIdentifier := aBoolean. |
|
158 |
self setupActions |
|
159 |
! |
|
160 |
||
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
161 |
warnCommonMistakes |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
162 |
"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
|
163 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
164 |
^ WarnCommonMistakes |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
165 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
166 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
167 |
warnCommonMistakes:aBoolean |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
168 |
"this allows turning on/off warnings about common beginners mistakes. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
169 |
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
|
170 |
run time errors later. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
a line as: |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
174 |
Compiler warnCommonMistakes:false |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
175 |
in your 'private.rc' file" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
176 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
177 |
WarnCommonMistakes := aBoolean |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
178 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
179 |
|
141 | 180 |
warnOldStyleAssignment |
181 |
"return true, if underscore-assignment (pre ST-80v4 syntax) are to be warned about" |
|
182 |
||
183 |
^ WarnOldStyleAssignment |
|
184 |
! |
|
185 |
||
186 |
warnOldStyleAssignment:aBoolean |
|
187 |
"this allows turning on/off warnings about underscore-assignment (pre ST-80v4 syntax). |
|
188 |
If you get bored by those warnings, turn them off by adding |
|
189 |
a line as: |
|
190 |
Compiler warnOldStyleAssignment:false |
|
191 |
in your 'private.rc' file" |
|
192 |
||
193 |
WarnOldStyleAssignment := aBoolean |
|
194 |
! |
|
195 |
||
196 |
warnSTXSpecials |
|
197 |
"return true, if ST/X specials are to be warned about" |
|
198 |
||
199 |
^ WarnSTXSpecials |
|
200 |
! |
|
201 |
||
202 |
warnSTXSpecials:aBoolean |
|
203 |
"this allows turning on/off warnings about stx specials. |
|
204 |
If you get bored by those warnings, turn them off by adding |
|
205 |
a line as: |
|
206 |
Compiler warnSTXSpecials:false |
|
207 |
in your 'private.rc' file" |
|
208 |
||
209 |
WarnSTXSpecials := aBoolean |
|
210 |
! |
|
211 |
||
212 |
warnUnderscoreInIdentifier |
|
213 |
"return true, if underscores in identifiers are to be warned about" |
|
214 |
||
215 |
^ WarnUnderscoreInIdentifier |
|
216 |
! |
|
217 |
||
218 |
warnUnderscoreInIdentifier:aBoolean |
|
219 |
"this allows turning on/off warnings about underscores in identifiers. |
|
220 |
If you get bored by those warnings, turn them off by adding |
|
221 |
a line as: |
|
222 |
Compiler warnUnderscoreInIdentifier:false |
|
223 |
in your 'private.rc' file" |
|
224 |
||
225 |
WarnUnderscoreInIdentifier := aBoolean |
|
226 |
! |
|
227 |
||
228 |
warnings |
|
229 |
"return true, if any warnings are to be shown" |
|
230 |
||
231 |
^ Warnings |
|
232 |
! |
|
233 |
||
234 |
warnings:aBoolean |
|
235 |
"this allows turning on/off warnings; the default is on. |
|
236 |
You can turn off warnings in your 'private.rc' file with |
|
237 |
Compiler warnings:false |
|
238 |
" |
|
239 |
||
240 |
Warnings := aBoolean |
|
241 |
! ! |
|
242 |
||
98 | 243 |
!Scanner methodsFor:'ST-80 compatibility'! |
244 |
||
245 |
endOfLastToken |
|
246 |
^ source position |
|
247 |
! ! |
|
248 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
249 |
!Scanner methodsFor:'accessing'! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
250 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
251 |
comments |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
252 |
^ currentComments |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
253 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
254 |
"Created: 20.4.1996 / 20:07:01 / cg" |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
255 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
256 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
257 |
saveComments:aBoolean |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
258 |
saveComments := aBoolean |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
259 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
260 |
"Created: 20.4.1996 / 20:03:56 / cg" |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
261 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
262 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
263 |
sourceStream |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
264 |
^ source |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
265 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
266 |
"Created: 20.4.1996 / 19:59:58 / cg" |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
267 |
! ! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
268 |
|
81 | 269 |
!Scanner methodsFor:'directives'! |
270 |
||
74 | 271 |
parseDirective |
81 | 272 |
|directive packageName namespace list| |
74 | 273 |
|
274 |
source next. |
|
275 |
source skipSeparatorsExceptCR. |
|
276 |
hereChar := source peek. |
|
277 |
hereChar isLetter ifTrue:[ |
|
413 | 278 |
directive := source nextWord. |
279 |
source peek == $: ifTrue:[ |
|
280 |
source next. |
|
281 |
source skipSeparatorsExceptCR. |
|
282 |
hereChar := source peek. |
|
74 | 283 |
|
413 | 284 |
" |
285 |
Package: 'name-of-package' |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
286 |
Package: packageId |
413 | 287 |
" |
288 |
directive = 'Package' ifTrue:[ |
|
289 |
packageName := self parseDirectiveStringArg. |
|
290 |
packageName notNil ifTrue:[ |
|
291 |
(requestor respondsTo:#setPackage:) ifTrue:[ |
|
292 |
requestor setPackage:packageName |
|
293 |
]. |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
294 |
] ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
295 |
Transcript showCR:'unrecognized ''Package'' directive'. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
296 |
^ false |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
297 |
] |
413 | 298 |
]. |
74 | 299 |
|
413 | 300 |
" |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
301 |
Namespace: 'nameSpaceIdentifier' |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
302 |
Namespace: nameSpaceIdentifier |
413 | 303 |
" |
417 | 304 |
(directive = 'Namespace' |
305 |
or:[directive = 'NameSpace']) ifTrue:[ |
|
413 | 306 |
namespace := self parseDirectiveStringArg. |
307 |
namespace notNil ifTrue:[ |
|
308 |
(requestor respondsTo:#setNameSpace:) ifTrue:[ |
|
309 |
requestor setNameSpace:namespace |
|
426
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
310 |
] ifFalse:[ |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
311 |
self setNameSpace:namespace |
413 | 312 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
313 |
] ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
314 |
Transcript showCR:'unrecognized ''NameSpace'' directive'. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
315 |
^ false |
413 | 316 |
]. |
317 |
]. |
|
81 | 318 |
|
413 | 319 |
" |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
320 |
Uses: 'nameSpace1', ... , 'nameSpaceN' |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
321 |
Uses: nameSpaceId1, ... , nameSpaceIdN |
413 | 322 |
" |
323 |
directive = 'Uses' ifTrue:[ |
|
324 |
list := self parseDirectiveStringListArg. |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
325 |
list notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
326 |
(requestor respondsTo:#addNameSpaces:) ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
327 |
requestor addNameSpaces:list |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
328 |
] |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
329 |
] ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
330 |
Transcript showCR:'unrecognized ''Uses'' directive'. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
331 |
^ false |
426
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
332 |
] |
413 | 333 |
]. |
334 |
||
335 |
" |
|
336 |
Prerequisites: 'name-of-package', ... , 'name-of-package' |
|
337 |
" |
|
338 |
directive = 'Prerequisites' ifTrue:[ |
|
339 |
list := self parseDirectiveStringListArg. |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
340 |
list notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
341 |
(requestor respondsTo:#requirePackages:) ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
342 |
requestor requirePackages:list |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
343 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
344 |
] ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
345 |
Transcript showCR:'unrecognized ''Prerequisites'' directive'. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
346 |
^ false |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
347 |
] |
413 | 348 |
]. |
349 |
] |
|
74 | 350 |
]. |
351 |
hereChar := source peek. |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
352 |
^ true. |
413 | 353 |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
354 |
"Modified: 3.1.1997 / 13:43:44 / cg" |
141 | 355 |
! |
356 |
||
357 |
parseDirectiveStringArg |
|
358 |
hereChar == $' ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
359 |
self nextString. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
360 |
tokenType == #String ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
361 |
^ tokenValue |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
362 |
] |
141 | 363 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
364 |
(hereChar isLetter or:[hereChar == $_]) ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
365 |
self nextIdentifier. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
366 |
tokenType == #Identifier ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
367 |
^ tokenName |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
368 |
] |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
369 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
370 |
|
141 | 371 |
^ nil |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
372 |
|
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
373 |
"Modified: 3.1.1997 / 13:35:51 / cg" |
141 | 374 |
! |
375 |
||
376 |
parseDirectiveStringListArg |
|
377 |
|list| |
|
378 |
||
379 |
list := OrderedCollection new. |
|
380 |
||
381 |
[hereChar == $'] whileTrue:[ |
|
382 |
list addLast:self parseDirectiveStringArg. |
|
383 |
source skipSeparatorsExceptCR. |
|
384 |
hereChar := source peek. |
|
385 |
(hereChar == $,) ifTrue:[ |
|
386 |
source next. |
|
387 |
source skipSeparatorsExceptCR. |
|
388 |
hereChar := source peek. |
|
389 |
]. |
|
390 |
]. |
|
391 |
^ list |
|
0 | 392 |
! ! |
393 |
||
394 |
!Scanner methodsFor:'error handling'! |
|
395 |
||
431
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
396 |
lastTokenLineNumber |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
397 |
^ tokenLineNr |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
398 |
|
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
399 |
"Created: 8.11.1996 / 18:46:36 / cg" |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
400 |
! |
058e1ce760ea
added access to lastTokenLineNr
Claus Gittinger <cg@exept.de>
parents:
426
diff
changeset
|
401 |
|
0 | 402 |
notifyError:aMessage position:position to:endPos |
403 |
"notify requestor of an error - if there is no requestor |
|
53 | 404 |
put it on the transcript. Requestor is typically the CodeView |
405 |
in which the accept/doIt was triggered, or the PositionableStream |
|
406 |
which does the fileIn. The requestor may decide how to highlight the |
|
407 |
error (and/or to abort the compile). |
|
0 | 408 |
Return the result passed back by the requestor." |
409 |
||
53 | 410 |
ignoreErrors ifFalse:[ |
411 |
requestor isNil ifTrue:[ |
|
412 |
self showErrorMessage:aMessage position:position. |
|
413 |
^ false |
|
414 |
]. |
|
83 | 415 |
^ requestor error:aMessage position:position to:endPos from:self |
0 | 416 |
]. |
53 | 417 |
^ false |
0 | 418 |
! |
419 |
||
420 |
notifyWarning:aMessage position:position to:endPos |
|
421 |
"notify requestor of an warning - if there is no requestor |
|
422 |
put it on the transcript. |
|
423 |
Return the result passed back by the requestor." |
|
424 |
||
53 | 425 |
ignoreWarnings ifFalse:[ |
426 |
requestor isNil ifTrue:[ |
|
45 | 427 |
self showErrorMessage:aMessage position:position. |
53 | 428 |
^ false |
45 | 429 |
]. |
83 | 430 |
^ requestor warning:aMessage position:position to:endPos from:self |
0 | 431 |
]. |
53 | 432 |
^ false |
0 | 433 |
! |
434 |
||
141 | 435 |
showErrorMessage:aMessage position:pos |
436 |
"show an errormessage on the Transcript" |
|
0 | 437 |
|
141 | 438 |
ignoreErrors ifFalse:[ |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
439 |
Smalltalk silentLoading == true ifFalse:[ |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
440 |
Transcript showCR:(pos printString , ' [line: ' , tokenLineNr printString , '] ' , aMessage) |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
441 |
] |
141 | 442 |
] |
274 | 443 |
|
444 |
"Modified: 18.5.1996 / 15:44:35 / cg" |
|
141 | 445 |
! |
446 |
||
447 |
syntaxError:aMessage |
|
448 |
"a syntax error happened - position is not known" |
|
449 |
||
450 |
^ self syntaxError:aMessage position:tokenPosition |
|
0 | 451 |
! |
452 |
||
453 |
syntaxError:aMessage position:position |
|
454 |
"a syntax error happened - only start position is known" |
|
455 |
||
456 |
^ self syntaxError:aMessage position:position to:nil |
|
457 |
! |
|
458 |
||
141 | 459 |
syntaxError:aMessage position:position to:endPos |
460 |
"a syntax error happened" |
|
0 | 461 |
|
141 | 462 |
self notifyError:('Error:' , aMessage) position:position to:endPos. |
463 |
exitBlock notNil ifTrue:[exitBlock value]. |
|
464 |
^ false |
|
87 | 465 |
! |
466 |
||
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
467 |
warnCommonMistake:msg at:position |
311 | 468 |
self warnCommonMistake:msg position:position to:position |
469 |
||
470 |
"Modified: 18.7.1996 / 10:28:53 / cg" |
|
471 |
! |
|
472 |
||
473 |
warnCommonMistake:msg position:pos1 to:pos2 |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
474 |
ignoreWarnings ifFalse:[ |
311 | 475 |
warnCommonMistakes ifTrue:[ |
476 |
self |
|
477 |
warning:msg |
|
478 |
position:pos1 to:pos2. |
|
479 |
] |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
480 |
] |
311 | 481 |
|
482 |
"Created: 18.7.1996 / 10:28:38 / cg" |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
483 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
484 |
|
87 | 485 |
warnOldStyleAssignmentAt:position |
486 |
ignoreWarnings ifFalse:[ |
|
487 |
warnOldStyleAssignment ifTrue:[ |
|
488 |
self |
|
489 |
warning:'old style assignment - please change to use '':=''' |
|
490 |
position:position to:position. |
|
491 |
" |
|
492 |
only warn once (per method) |
|
493 |
" |
|
494 |
warnOldStyleAssignment := false |
|
495 |
] |
|
496 |
] |
|
497 |
! |
|
498 |
||
499 |
warnUnderscoreAt:position |
|
500 |
ignoreWarnings ifFalse:[ |
|
501 |
warnUnderscoreInIdentifier ifTrue:[ |
|
502 |
self |
|
503 |
warning:'underscores in identifiers/symbols are nonportable' |
|
504 |
position:position to:position. |
|
505 |
" |
|
506 |
only warn once (per method) |
|
507 |
" |
|
508 |
warnUnderscoreInIdentifier := false |
|
509 |
] |
|
510 |
] |
|
141 | 511 |
! |
512 |
||
513 |
warning:aMessage |
|
514 |
"a warning - position is not known" |
|
515 |
||
516 |
^ self warning:aMessage position:tokenPosition |
|
517 |
! |
|
518 |
||
519 |
warning:aMessage position:position |
|
520 |
"a warning - only start position is known" |
|
521 |
||
522 |
^ self warning:aMessage position:position to:nil |
|
523 |
! |
|
524 |
||
525 |
warning:aMessage position:position to:endPos |
|
526 |
"a warning" |
|
527 |
||
528 |
^ self notifyWarning:('Warning: ' , aMessage) position:position to:endPos |
|
0 | 529 |
! ! |
530 |
||
17 | 531 |
!Scanner methodsFor:'general scanning'! |
532 |
||
533 |
scanPositionsFor:aTokenString inString:aSourceString |
|
534 |
"scan aSourceString for occurrances of aTokenString. |
|
535 |
Return a collection of start positions. |
|
536 |
Added for VW compatibility (to support syntax-highlight)." |
|
537 |
||
538 |
|searchType searchName searchValue positions t| |
|
539 |
||
540 |
" |
|
541 |
first, look what kind of token we have to search for |
|
542 |
" |
|
543 |
self initializeFor:(ReadStream on:aTokenString). |
|
544 |
self nextToken. |
|
545 |
searchType := tokenType. |
|
546 |
searchName := tokenName. |
|
547 |
searchValue := tokenValue. |
|
548 |
||
549 |
" |
|
550 |
start the real work ... |
|
551 |
" |
|
552 |
self initializeFor:(ReadStream on:aSourceString). |
|
553 |
positions := OrderedCollection new. |
|
554 |
||
555 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
45 | 556 |
searchType == t ifTrue:[ |
557 |
(searchName isNil or:[tokenName = searchName]) ifTrue:[ |
|
558 |
(searchValue isNil or:[tokenValue = searchValue]) ifTrue:[ |
|
559 |
positions add:tokenPosition. |
|
560 |
] |
|
561 |
] |
|
562 |
] |
|
17 | 563 |
]. |
564 |
||
565 |
^ positions |
|
566 |
||
567 |
" |
|
30 | 568 |
Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello' |
569 |
Scanner new scanPositionsFor:'3.14' inString:'foo 3.145 bar hello 3.14 baz hello 3.14' |
|
570 |
Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000' |
|
17 | 571 |
" |
572 |
! ! |
|
573 |
||
141 | 574 |
!Scanner methodsFor:'private'! |
3 | 575 |
|
141 | 576 |
backupPosition |
577 |
"if reading from a stream, at the end we might have read |
|
578 |
one token too many" |
|
20 | 579 |
|
141 | 580 |
(tokenType == #EOF) ifFalse:[ |
581 |
source position:tokenPosition |
|
582 |
] |
|
583 |
! |
|
15 | 584 |
|
141 | 585 |
beginComment |
586 |
^ self |
|
587 |
! |
|
588 |
||
589 |
collectedSource |
|
590 |
^ collectedSource |
|
591 |
! |
|
74 | 592 |
|
141 | 593 |
endComment:comment |
594 |
saveComments ifTrue:[ |
|
595 |
currentComments isNil ifTrue:[ |
|
596 |
currentComments := OrderedCollection with:comment |
|
45 | 597 |
] ifFalse:[ |
141 | 598 |
currentComments add:comment |
45 | 599 |
] |
3 | 600 |
]. |
601 |
! |
|
602 |
||
141 | 603 |
ignoreErrors |
604 |
"turn off notification of errors" |
|
605 |
||
606 |
ignoreErrors := true |
|
607 |
! |
|
0 | 608 |
|
141 | 609 |
ignoreWarnings |
610 |
"turn off notification of warnings" |
|
611 |
||
612 |
ignoreWarnings := true |
|
613 |
! |
|
0 | 614 |
|
141 | 615 |
initialize |
616 |
"prepare a scan" |
|
3 | 617 |
|
141 | 618 |
errorFlag := false. |
266
6c6c1d5a3d9d
initialize tokenPosition (error/warning at first token had it nil)
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
619 |
tokenPosition := 1. |
141 | 620 |
tokenLineNr := 1. |
621 |
currentComments := nil. |
|
622 |
saveComments := false. |
|
623 |
ignoreErrors := false. |
|
624 |
ignoreWarnings := Warnings not. |
|
625 |
warnSTXSpecialComment := WarnSTXSpecials. |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
626 |
warnSTXNameSpaceUse := WarnSTXSpecials. |
141 | 627 |
warnUnderscoreInIdentifier := WarnUnderscoreInIdentifier. |
628 |
warnOldStyleAssignment := WarnOldStyleAssignment. |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
629 |
warnCommonMistakes := WarnCommonMistakes. |
141 | 630 |
ActionArray isNil ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
631 |
self class setupActions |
141 | 632 |
] |
266
6c6c1d5a3d9d
initialize tokenPosition (error/warning at first token had it nil)
Claus Gittinger <cg@exept.de>
parents:
265
diff
changeset
|
633 |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
634 |
"Modified: 14.10.1996 / 19:08:22 / cg" |
0 | 635 |
! |
636 |
||
141 | 637 |
initializeFor:aStringOrStream |
638 |
"initialize - |
|
639 |
if this is the first time, setup character- and action tables" |
|
640 |
||
641 |
self initialize. |
|
642 |
||
643 |
aStringOrStream isStream ifFalse:[ |
|
644 |
source := ReadStream on:aStringOrStream |
|
645 |
] ifTrue:[ |
|
646 |
source := aStringOrStream. |
|
647 |
]. |
|
648 |
! |
|
649 |
||
650 |
notifying:anObject |
|
651 |
"set the requestor to be notified" |
|
652 |
||
653 |
requestor := anObject |
|
426
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
654 |
! |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
655 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
656 |
setNameSpace:aNameSpace |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
657 |
"/ ignored here |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
658 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
659 |
"Created: 8.11.1996 / 13:33:10 / cg" |
141 | 660 |
! ! |
661 |
||
662 |
!Scanner methodsFor:'reading next token'! |
|
663 |
||
664 |
nextCharacter |
|
665 |
"a $ has been read - return a character token" |
|
666 |
||
667 |
|nextChar| |
|
668 |
||
0 | 669 |
source next. |
141 | 670 |
nextChar := source next. |
671 |
nextChar notNil ifTrue:[ |
|
672 |
tokenValue := nextChar. |
|
673 |
tokenType := #Character |
|
674 |
] ifFalse:[ |
|
675 |
tokenType := #EOF |
|
676 |
]. |
|
0 | 677 |
^ tokenType |
678 |
! |
|
679 |
||
680 |
nextColonOrAssign |
|
681 |
"colon has been read - look for = to make it an assign" |
|
682 |
||
120 | 683 |
"/ special kludge for identifier:= (without spaces inbetween) |
684 |
"/ here we needed two characters lookahead after the identifier ... |
|
685 |
||
686 |
peekChar == $= ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
687 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
688 |
peekChar := nil. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
689 |
tokenType := #':='. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
690 |
^ tokenType |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
691 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
692 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
693 |
"/ special kludge for nameSpace:: (without spaces inbetween) |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
694 |
"/ here we needed two characters lookahead after the identifier ... |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
695 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
696 |
peekChar == $: ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
697 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
698 |
peekChar := nil. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
699 |
tokenType := #'::'. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
700 |
^ tokenType |
120 | 701 |
]. |
702 |
||
0 | 703 |
(source nextPeek == $=) ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
704 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
705 |
tokenType := $_ |
0 | 706 |
] ifFalse:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
707 |
tokenType := $: |
0 | 708 |
]. |
709 |
^ tokenType |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
710 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
711 |
"Modified: 14.10.1996 / 18:49:29 / cg" |
0 | 712 |
! |
713 |
||
141 | 714 |
nextHash |
715 |
|nextChar string| |
|
0 | 716 |
|
141 | 717 |
nextChar := source nextPeek. |
718 |
nextChar notNil ifTrue:[ |
|
719 |
nextChar isLetterOrDigit ifTrue:[ |
|
720 |
string := ''. |
|
721 |
[nextChar notNil and:[nextChar isLetterOrDigit]] whileTrue:[ |
|
722 |
string := string , (source nextAlphaNumericWord "self nextId"). |
|
723 |
nextChar := source peek. |
|
724 |
AllowUnderscoreInIdentifier == true ifTrue:[ |
|
725 |
nextChar == $_ ifTrue:[ |
|
726 |
self warnUnderscoreAt:source position. |
|
727 |
]. |
|
728 |
[nextChar == $_] whileTrue:[ |
|
729 |
string := string copyWith:nextChar. |
|
730 |
nextChar := source nextPeek. |
|
731 |
(nextChar isAlphaNumeric) ifTrue:[ |
|
732 |
string := string , source nextAlphaNumericWord. |
|
733 |
nextChar := source peek. |
|
734 |
] |
|
735 |
]. |
|
736 |
]. |
|
737 |
(nextChar == $:) ifFalse:[ |
|
738 |
tokenValue := string asSymbol. |
|
739 |
tokenType := #Symbol. |
|
740 |
^ tokenType |
|
741 |
]. |
|
742 |
string := string copyWith:nextChar. |
|
743 |
nextChar := source nextPeek |
|
744 |
]. |
|
745 |
tokenValue := string asSymbol. |
|
746 |
tokenType := #Symbol. |
|
747 |
^ tokenType |
|
748 |
]. |
|
749 |
(nextChar == $( ) ifTrue:[ |
|
750 |
source next. |
|
751 |
tokenType := #HashLeftParen. |
|
752 |
^ tokenType |
|
753 |
]. |
|
754 |
(nextChar == $[ ) ifTrue:[ |
|
755 |
"it seems that ST-80 supports Constant ByteArrays as #[...] |
|
756 |
(seen in a PD program)" |
|
757 |
source next. |
|
758 |
tokenType := #HashLeftBrack. |
|
759 |
^ tokenType |
|
760 |
]. |
|
761 |
(nextChar == $' ) ifTrue:[ |
|
762 |
"it seems that ST-80 supports arbitrary symbols as #'...' |
|
763 |
(seen in a PD program)" |
|
764 |
self nextString. |
|
765 |
tokenValue := tokenValue asSymbol. |
|
766 |
tokenType := #Symbol. |
|
767 |
^ tokenType |
|
768 |
]. |
|
769 |
((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[ |
|
770 |
string := source next asString. |
|
771 |
nextChar := source peek. |
|
772 |
nextChar notNil ifTrue:[ |
|
773 |
((TypeArray at:(nextChar asciiValue)) == #special) ifTrue:[ |
|
774 |
source next. |
|
775 |
string := string copyWith:nextChar |
|
776 |
] |
|
777 |
]. |
|
778 |
tokenValue := string asSymbol. |
|
779 |
tokenType := #Symbol. |
|
45 | 780 |
^ tokenType |
781 |
] |
|
0 | 782 |
]. |
141 | 783 |
"this allows hash to be used as binop - |
784 |
I dont know, if this is correct ..." |
|
785 |
||
786 |
tokenName := '#'. |
|
0 | 787 |
tokenType := #BinaryOperator. |
788 |
^ tokenType |
|
141 | 789 |
" |
790 |
self syntaxError:'unexpected end-of-input in Symbol' |
|
791 |
position:tokenPosition to:(tokenPosition + 1). |
|
792 |
^ #Error |
|
793 |
" |
|
0 | 794 |
! |
795 |
||
796 |
nextId |
|
797 |
|nextChar string oldString |
|
798 |
index "{ Class: SmallInteger }" |
|
799 |
max "{ Class: SmallInteger }" | |
|
800 |
||
801 |
nextChar := source peek. |
|
96 | 802 |
string := String basicNew:20. |
0 | 803 |
index := 0. |
804 |
max := 10. |
|
805 |
[true] whileTrue:[ |
|
45 | 806 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifFalse:[ |
807 |
^ string copyTo:index |
|
808 |
]. |
|
809 |
(index == max) ifTrue:[ |
|
810 |
oldString := string. |
|
96 | 811 |
string := String basicNew:(max * 2). |
45 | 812 |
string replaceFrom:1 to:max with:oldString. |
813 |
max := max * 2 |
|
814 |
]. |
|
815 |
index := index + 1. |
|
816 |
string at:index put:nextChar. |
|
817 |
nextChar := source nextPeek |
|
0 | 818 |
] |
819 |
! |
|
820 |
||
821 |
nextIdentifier |
|
97 | 822 |
|nextChar string firstChar| |
0 | 823 |
|
87 | 824 |
hereChar == $_ ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
825 |
"/ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
826 |
"/ no need to check for AllowUnderscoreInIdentifier here; |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
827 |
"/ could not arrive here if it was off |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
828 |
"/ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
829 |
nextChar := source nextPeek. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
830 |
(nextChar isAlphaNumeric or:[nextChar == $_]) ifFalse:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
831 |
"oops: a single underscore is an old-style assignement" |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
832 |
self warnOldStyleAssignmentAt:tokenPosition. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
833 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
834 |
tokenType := $_. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
835 |
^ tokenType |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
836 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
837 |
string := '_'. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
838 |
self warnUnderscoreAt:tokenPosition. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
839 |
[nextChar == $_] whileTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
840 |
string := string copyWith:$_. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
841 |
nextChar := source nextPeek. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
842 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
843 |
string := string , source nextAlphaNumericWord. |
87 | 844 |
] ifFalse:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
845 |
string := source nextAlphaNumericWord "self nextId". |
87 | 846 |
]. |
0 | 847 |
nextChar := source peek. |
87 | 848 |
|
60 | 849 |
AllowUnderscoreInIdentifier ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
850 |
nextChar == $_ ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
851 |
self warnUnderscoreAt:(source position). |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
852 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
853 |
[nextChar == $_] whileTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
854 |
string := string copyWith:nextChar. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
855 |
nextChar := source nextPeek. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
856 |
(nextChar isAlphaNumeric) ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
857 |
string := string , source nextAlphaNumericWord. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
858 |
nextChar := source peek. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
859 |
] |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
860 |
]. |
60 | 861 |
]. |
862 |
||
0 | 863 |
(nextChar == $:) ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
864 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
865 |
(source peek == $=) ifFalse:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
866 |
(source peek == $:) ifFalse:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
867 |
tokenName := string copyWith:nextChar. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
868 |
tokenType := #Keyword. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
869 |
^ self |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
870 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
871 |
peekChar := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
872 |
peekChar2 := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
873 |
] ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
874 |
peekChar := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
875 |
peekChar2 := $=. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
876 |
] |
0 | 877 |
]. |
20 | 878 |
tokenName := string. |
0 | 879 |
firstChar := string at:1. |
880 |
(firstChar == $s) ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
881 |
(string = 'self') ifTrue:[tokenType := #Self. ^self]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
882 |
(string = 'super') ifTrue:[tokenType := #Super. ^self] |
0 | 883 |
]. |
884 |
(firstChar == $n) ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
885 |
(string = 'nil') ifTrue:[tokenType := #Nil. ^self] |
0 | 886 |
]. |
887 |
(firstChar == $t) ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
888 |
(string = 'true') ifTrue:[tokenType := #True. ^self]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
889 |
(string = 'thisContext') ifTrue:[tokenType := #ThisContext. ^self] |
0 | 890 |
]. |
891 |
(firstChar == $f) ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
892 |
(string = 'false') ifTrue:[tokenType := #False. ^self] |
0 | 893 |
]. |
894 |
tokenType := #Identifier. |
|
895 |
^ tokenType |
|
120 | 896 |
|
897 |
"Created: 13.9.1995 / 12:56:42 / claus" |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
898 |
"Modified: 14.10.1996 / 18:50:45 / cg" |
0 | 899 |
! |
900 |
||
141 | 901 |
nextMantissa:radix |
902 |
|nextChar value factor| |
|
903 |
||
904 |
value := 0. |
|
905 |
factor := 1.0 / radix. |
|
906 |
nextChar := source peek. |
|
907 |
[(nextChar notNil and:[nextChar isDigitRadix:radix])] whileTrue:[ |
|
908 |
value := value + (nextChar digitValue * factor). |
|
909 |
factor := factor / radix. |
|
910 |
nextChar := source nextPeek |
|
911 |
]. |
|
912 |
^ value |
|
913 |
! |
|
914 |
||
915 |
nextNumber |
|
441 | 916 |
|nextChar value s tokenRadix| |
141 | 917 |
|
918 |
tokenRadix := 10. |
|
919 |
value := Integer readFrom:source radix:tokenRadix. |
|
920 |
nextChar := source peek. |
|
921 |
(nextChar == $r) ifTrue:[ |
|
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
922 |
tokenRadix := value. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
923 |
source next. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
924 |
s := 1. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
925 |
source peek == $- ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
926 |
source next. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
927 |
s := -1 |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
928 |
]. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
929 |
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
|
930 |
value := value * s. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
931 |
nextChar := source peek |
141 | 932 |
]. |
933 |
(nextChar == $.) ifTrue:[ |
|
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
934 |
nextChar := source nextPeek. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
935 |
(nextChar notNil and:[nextChar isDigitRadix:tokenRadix]) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
936 |
value := value asFloat + (self nextMantissa:tokenRadix). |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
937 |
nextChar := source peek |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
938 |
] ifFalse:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
939 |
nextChar == (Character cr) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
940 |
tokenLineNr := tokenLineNr + 1. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
941 |
]. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
942 |
peekChar := $. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
943 |
] |
141 | 944 |
]. |
945 |
((nextChar == $e) or:[nextChar == $E]) ifTrue:[ |
|
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
946 |
nextChar := source nextPeek. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
947 |
(nextChar notNil and:[(nextChar isDigitRadix:tokenRadix) or:['+-' includes:nextChar]]) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
948 |
s := 1. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
949 |
(nextChar == $+) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
950 |
nextChar := source nextPeek |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
951 |
] ifFalse:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
952 |
(nextChar == $-) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
953 |
nextChar := source nextPeek. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
954 |
s := s negated |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
955 |
] |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
956 |
]. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
957 |
value := value asFloat |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
958 |
* (10.0 raisedToInteger:((Integer readFrom:source radix:tokenRadix) * s)) |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
959 |
] |
141 | 960 |
]. |
961 |
tokenValue := value. |
|
962 |
(value isMemberOf:Float) ifTrue:[ |
|
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
963 |
(nextChar == $d) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
964 |
source next |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
965 |
]. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
966 |
tokenType := #Float |
141 | 967 |
] ifFalse:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
968 |
tokenType := #Integer |
141 | 969 |
]. |
970 |
^ tokenType |
|
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
971 |
|
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
972 |
"Modified: 19.7.1996 / 12:23:38 / cg" |
141 | 973 |
! |
974 |
||
0 | 975 |
nextPrimitive |
976 |
|nextChar inPrimitive string |
|
977 |
index "{ Class: SmallInteger }" |
|
978 |
len "{ Class: SmallInteger }" | |
|
979 |
||
980 |
nextChar := source nextPeek. |
|
981 |
string := String new:500. |
|
982 |
len := 500. |
|
983 |
index := 1. |
|
984 |
(nextChar == ${) ifTrue:[ |
|
45 | 985 |
nextChar := source nextPeek. |
986 |
inPrimitive := true. |
|
987 |
[inPrimitive] whileTrue:[ |
|
988 |
[nextChar == $%] whileFalse:[ |
|
989 |
string at:index put:nextChar. |
|
990 |
(index == len) ifTrue:[ |
|
991 |
string := string , (String new:len). |
|
992 |
len := len * 2 |
|
993 |
]. |
|
994 |
index := index + 1. |
|
995 |
nextChar := source next |
|
996 |
]. |
|
997 |
(source peek == $}) ifTrue:[ |
|
998 |
inPrimitive := false |
|
999 |
] ifFalse:[ |
|
1000 |
string at:index put:nextChar. |
|
1001 |
(index == len) ifTrue:[ |
|
1002 |
string := string , (String new:len). |
|
1003 |
len := len * 2 |
|
1004 |
]. |
|
1005 |
index := index + 1. |
|
1006 |
nextChar := source next |
|
1007 |
] |
|
1008 |
]. |
|
1009 |
source next. |
|
1010 |
tokenValue := string copyTo:(index - 1). |
|
1011 |
tokenType := #Primitive. |
|
1012 |
tokenLineNr := tokenLineNr + (tokenValue occurrencesOf:(Character cr)). |
|
1013 |
^ tokenType |
|
0 | 1014 |
]. |
1015 |
||
1016 |
"a % alone is a binary operator" |
|
1017 |
tokenName := '%'. |
|
1018 |
tokenType := #BinaryOperator. |
|
1019 |
^ tokenType. |
|
1020 |
" |
|
1021 |
self syntaxError:('invalid character: ''' , nextChar asString , '''') |
|
45 | 1022 |
position:tokenPosition to:(tokenPosition + 1). |
0 | 1023 |
^ #Error |
1024 |
" |
|
1025 |
! |
|
1026 |
||
141 | 1027 |
nextSpecial |
1028 |
"a special character has been read, look for another one. |
|
1029 |
also -number is handled here" |
|
1030 |
||
1031 |
|firstChar secondChar thirdChar string p| |
|
0 | 1032 |
|
141 | 1033 |
firstChar := source next. |
1034 |
secondChar := source peek. |
|
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
1035 |
((firstChar == $-) and:[secondChar notNil]) ifTrue:[ |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1036 |
secondChar isDigit ifTrue:[ |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1037 |
self nextNumber. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1038 |
tokenValue := tokenValue negated. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1039 |
^ tokenType |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1040 |
] |
0 | 1041 |
]. |
141 | 1042 |
string := firstChar asString. |
1043 |
secondChar notNil ifTrue:[ |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1044 |
((TypeArray at:(secondChar asciiValue)) == #special) ifTrue:[ |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1045 |
(secondChar == $-) ifTrue:[ |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1046 |
"special- look if minus belongs to number following" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1047 |
p := source position. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1048 |
source next. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1049 |
thirdChar := source peek. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1050 |
source position:p. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1051 |
thirdChar isDigit ifTrue:[ |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1052 |
tokenName := string. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1053 |
tokenType := #BinaryOperator. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1054 |
^ tokenType |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1055 |
] |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1056 |
]. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1057 |
source next. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1058 |
string := string copyWith:secondChar |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
1059 |
]. |
141 | 1060 |
]. |
1061 |
tokenName := string. |
|
45 | 1062 |
tokenType := #BinaryOperator. |
3 | 1063 |
^ tokenType |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
1064 |
|
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
1065 |
"Modified: 12.4.1996 / 15:05:19 / cg" |
0 | 1066 |
! |
1067 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1068 |
nextString |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1069 |
|nextChar string pos |
0 | 1070 |
index "{ Class: SmallInteger }" |
1071 |
len "{ Class: SmallInteger }" |
|
1072 |
inString| |
|
1073 |
||
96 | 1074 |
string := String basicNew:20. |
0 | 1075 |
len := 20. |
1076 |
index := 1. |
|
1077 |
pos := source position. |
|
1078 |
source next. |
|
1079 |
nextChar := source next. |
|
1080 |
inString := true. |
|
1081 |
||
1082 |
[inString] whileTrue:[ |
|
45 | 1083 |
nextChar isNil ifTrue:[ |
1084 |
self syntaxError:'unexpected end-of-input in String' |
|
1085 |
position:pos to:(source position - 1). |
|
1086 |
tokenType := #EOF. |
|
1087 |
^ tokenType |
|
1088 |
]. |
|
1089 |
(nextChar == Character cr) ifTrue:[ |
|
1090 |
tokenLineNr := tokenLineNr + 1 |
|
1091 |
]. |
|
1092 |
(nextChar == Character quote) ifTrue:[ |
|
1093 |
(source peek == Character quote) ifTrue:[ |
|
1094 |
source next |
|
1095 |
] ifFalse:[ |
|
1096 |
inString := false |
|
1097 |
] |
|
1098 |
]. |
|
1099 |
inString ifTrue:[ |
|
1100 |
string at:index put:nextChar. |
|
1101 |
(index == len) ifTrue:[ |
|
1102 |
string := string , (String new:len). |
|
1103 |
len := len * 2 |
|
1104 |
]. |
|
1105 |
index := index + 1. |
|
1106 |
nextChar := source next |
|
1107 |
] |
|
0 | 1108 |
]. |
15 | 1109 |
tokenValue := string copyTo:(index - 1). |
0 | 1110 |
tokenType := #String. |
1111 |
^ tokenType |
|
141 | 1112 |
! |
1113 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1114 |
nextToken |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1115 |
"return the next token from the source-stream" |
141 | 1116 |
|
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1117 |
|skipping actionBlock v| |
141 | 1118 |
|
1119 |
peekChar notNil ifTrue:[ |
|
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1120 |
hereChar := peekChar. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1121 |
peekChar := peekChar2. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1122 |
peekChar2 := nil |
141 | 1123 |
] ifFalse:[ |
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1124 |
skipping := true. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1125 |
[skipping] whileTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1126 |
outStream notNil ifTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1127 |
[(hereChar := source peek) == Character space] whileTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1128 |
source next. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1129 |
outStream space. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1130 |
outCol := outCol + 1. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1131 |
] |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1132 |
] ifFalse:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1133 |
hereChar := source skipSeparatorsExceptCR. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1134 |
]. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1135 |
hereChar == (Character cr) ifTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1136 |
tokenLineNr := tokenLineNr + 1. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1137 |
source next. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1138 |
outStream notNil ifTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1139 |
outStream cr. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1140 |
outCol := 1 |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1141 |
] |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1142 |
] ifFalse:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1143 |
hereChar == (Character doubleQuote) ifTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1144 |
"start of a comment" |
141 | 1145 |
|
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1146 |
self skipComment. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1147 |
hereChar := source peek. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1148 |
] ifFalse:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1149 |
skipping := false |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1150 |
] |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1151 |
] |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1152 |
]. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1153 |
hereChar isNil ifTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1154 |
tokenType := #EOF. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1155 |
^ tokenType |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1156 |
] |
141 | 1157 |
]. |
1158 |
tokenPosition := source position. |
|
1159 |
||
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1160 |
(v := hereChar asciiValue) == 0 ifTrue:[ |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1161 |
v := Character space asciiValue |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1162 |
]. |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1163 |
actionBlock := ActionArray at:v. |
141 | 1164 |
actionBlock notNil ifTrue:[ |
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1165 |
^ actionBlock value:self value:hereChar |
141 | 1166 |
]. |
1167 |
||
1168 |
self syntaxError:('invalid character: ''' , hereChar asString , ''' ', |
|
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1169 |
'(' , v printString , ')') |
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1170 |
position:tokenPosition to:tokenPosition. |
141 | 1171 |
tokenType := #Error. |
1172 |
^ #Error |
|
1173 |
||
1174 |
"Modified: 13.9.1995 / 12:56:14 / claus" |
|
449
6ad7a414ea5d
just to make certain: handle 0-characters in input
Claus Gittinger <cg@exept.de>
parents:
441
diff
changeset
|
1175 |
"Modified: 10.12.1996 / 18:52:01 / cg" |
141 | 1176 |
! |
1177 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1178 |
nextToken:aCharacter |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1179 |
tokenType := aCharacter. |
141 | 1180 |
source next. |
1181 |
^ tokenType |
|
1182 |
! |
|
1183 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1184 |
skipComment |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1185 |
|commentStream startPos| |
141 | 1186 |
|
1187 |
saveComments ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1188 |
commentStream := WriteStream on:''. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1189 |
self beginComment. |
141 | 1190 |
]. |
1191 |
||
1192 |
outStream notNil ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1193 |
outStream nextPut:Character doubleQuote. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1194 |
outCol := outCol + 1 |
141 | 1195 |
]. |
1196 |
||
1197 |
startPos := source position. |
|
1198 |
source next. |
|
1199 |
hereChar := source peek. |
|
1200 |
||
1201 |
" |
|
1202 |
special ST/X addition: |
|
1203 |
a $/ right after the initial double quote makes it an up-to-end-of-line comment, |
|
1204 |
which is very useful to comment out parts of filed-in source code. |
|
1205 |
Since this is non-standard, use it in very rare cases only. |
|
1206 |
(maybe the upcoming ansi-standard adds something similar - in this case, I will |
|
1207 |
change it without notice)" |
|
1208 |
||
1209 |
hereChar == $/ ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1210 |
[hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1211 |
saveComments ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1212 |
commentStream nextPut:hereChar |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1213 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1214 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1215 |
outStream nextPut:hereChar. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1216 |
outCol := outCol + 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1217 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1218 |
hereChar := source nextPeek. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1219 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1220 |
tokenLineNr := tokenLineNr + 1. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1221 |
ignoreWarnings ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1222 |
warnSTXSpecialComment ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1223 |
self warning:'end-of-line comments are a nonstandard feature of ST/X' |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1224 |
position:startPos to:(source position). |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1225 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1226 |
only warn once |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1227 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1228 |
warnSTXSpecialComment := false |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1229 |
] |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1230 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1231 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1232 |
outStream cr. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1233 |
outCol := 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1234 |
]. |
141 | 1235 |
] ifFalse:[ |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1236 |
hereChar == ${ ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1237 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1238 |
special ST/X addition: |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1239 |
a ${ right after the initial double quote starts a directive |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1240 |
" |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1241 |
self parseDirective |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1242 |
]. |
141 | 1243 |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1244 |
[hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1245 |
hereChar == (Character cr) ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1246 |
tokenLineNr := tokenLineNr + 1. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1247 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1248 |
saveComments ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1249 |
commentStream nextPut:hereChar |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1250 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1251 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1252 |
outStream nextPut:hereChar. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1253 |
outCol := outCol + 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1254 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1255 |
hereChar := source nextPeek |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1256 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1257 |
hereChar isNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1258 |
self warning:'unclosed comment' position:startPos to:(source position) |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1259 |
] ifFalse:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1260 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1261 |
outStream nextPut:(Character doubleQuote). |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1262 |
outCol := outCol + 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1263 |
]. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1264 |
] |
141 | 1265 |
]. |
1266 |
||
1267 |
"skip final dQuote or cr" |
|
1268 |
source next. |
|
1269 |
||
1270 |
saveComments ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1271 |
self endComment:commentStream contents. |
141 | 1272 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1273 |
|
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
1274 |
"Modified: 3.1.1997 / 13:44:43 / cg" |
0 | 1275 |
! ! |
141 | 1276 |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
1277 |
!Scanner class methodsFor:'documentation'! |
148 | 1278 |
|
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
1279 |
version |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
1280 |
^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.59 1997-01-04 13:16:39 cg Exp $' |
148 | 1281 |
! ! |
141 | 1282 |
Scanner initialize! |