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