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