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