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