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