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