author | Claus Gittinger <cg@exept.de> |
Thu, 29 May 2014 14:32:57 +0200 | |
changeset 3454 | ba5ba1fc1153 |
parent 3449 | 3857b52841ba |
child 3456 | a8e3abd9cc74 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
1584 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1073 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
0 | 14 |
Object subclass:#Scanner |
1595 | 15 |
instanceVariableNames:'typeArray actionArray source lineNr token tokenType tokenPosition |
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
|
16 |
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
|
17 |
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
|
18 |
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
|
19 |
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
|
20 |
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
|
21 |
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
|
22 |
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
|
23 |
unicodeActions' |
3181 | 24 |
classVariableNames:'DefaultTypeArray DefaultActionArray EmptySourceNotificationSignal |
25 |
DefaultUnicodeActions' |
|
1595 | 26 |
poolDictionaries:'' |
2485 | 27 |
category:'System-Compiler' |
0 | 28 |
! |
29 |
||
2484 | 30 |
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
|
31 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
32 |
" |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
33 |
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
|
34 |
" |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
35 |
! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
36 |
|
648 | 37 |
Object subclass:#Comment |
1595 | 38 |
instanceVariableNames:'commentType commentString' |
39 |
classVariableNames:'' |
|
40 |
poolDictionaries:'' |
|
41 |
privateIn:Scanner |
|
648 | 42 |
! |
43 |
||
1596 | 44 |
Object subclass:#Directive |
45 |
instanceVariableNames:'' |
|
46 |
classVariableNames:'' |
|
47 |
poolDictionaries:'' |
|
48 |
privateIn:Scanner |
|
49 |
! |
|
50 |
||
51 |
Scanner::Directive subclass:#ClassDirective |
|
52 |
instanceVariableNames:'className' |
|
53 |
classVariableNames:'' |
|
54 |
poolDictionaries:'' |
|
55 |
privateIn:Scanner::Directive |
|
56 |
! |
|
57 |
||
58 |
Scanner::Directive::ClassDirective subclass:#ClassHintDirective |
|
59 |
instanceVariableNames:'' |
|
60 |
classVariableNames:'' |
|
61 |
poolDictionaries:'' |
|
62 |
privateIn:Scanner::Directive |
|
63 |
! |
|
64 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
65 |
!Scanner class methodsFor:'documentation'! |
20 | 66 |
|
901 | 67 |
bugs |
68 |
" |
|
69 |
array constant containing keywords as in: |
|
70 |
#( |
|
71 |
foo:bar: |
|
72 |
fee:baz: |
|
73 |
) |
|
74 |
||
75 |
is scanned as 4-element array containing ( #foo: #bar: #fee: #baz: ) |
|
76 |
this MUST be fixed. |
|
77 |
||
78 |
workaround: |
|
79 |
#( |
|
80 |
#'foo:bar:' |
|
81 |
#'fee:baz:' |
|
82 |
) |
|
83 |
||
84 |
" |
|
85 |
! |
|
86 |
||
20 | 87 |
copyright |
88 |
" |
|
89 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1584 | 90 |
All Rights Reserved |
20 | 91 |
|
92 |
This software is furnished under a license and may be used |
|
93 |
only in accordance with the terms of that license and with the |
|
94 |
inclusion of the above copyright notice. This software may not |
|
95 |
be provided or otherwise made available to, or used by, any |
|
96 |
other person. No title to or ownership of the software is |
|
97 |
hereby transferred. |
|
98 |
" |
|
99 |
! |
|
100 |
||
101 |
documentation |
|
102 |
" |
|
103 |
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
|
104 |
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
|
105 |
Possibly placing additional information (such as tokenValue) into |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
106 |
instance variables as a side effect. |
75 | 107 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
108 |
TODO: |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
nextIdentifier etc. methods should be renamed. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
112 |
(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
|
113 |
their public use is not a good idea ..) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
114 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
115 |
Scanner is typically subclassed for parsing and #nextToken |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
116 |
invoked via #self-sends. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
117 |
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
|
118 |
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
|
119 |
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
|
120 |
|
1302 | 121 |
Extensions: |
122 |
this scanner allows for 3-character binary selectors. |
|
123 |
also, # is a valid selector. (however, ## is currently scanned as a symbol literal). |
|
124 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
125 |
[author:] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
126 |
Claus Gittinger |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
127 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
128 |
[see also:] |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
129 |
Parser |
20 | 130 |
" |
41 | 131 |
! ! |
132 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
133 |
!Scanner class methodsFor:'initialization'! |
33 | 134 |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
135 |
binarySelectorCharacters |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
136 |
"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
|
137 |
|
2487 | 138 |
^ '&-+=*/\<>~@,?!!|%#'. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
139 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
140 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
141 |
extendedBinarySelectorCharacters |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
142 |
"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
|
143 |
|
2487 | 144 |
"/ ^ '±×·÷'. |
145 |
^ String |
|
146 |
with:(Character value:16rB1) "/ plus-minus |
|
147 |
with:(Character value:16rD7) "/ times |
|
148 |
with:(Character value:16rB7) "/ centered dot |
|
149 |
with:(Character value:16rF7). "/ divide |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
150 |
! |
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
151 |
|
33 | 152 |
setupActions |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
153 |
"initialize the scanners actionTables - these are used to dispatch |
2141 | 154 |
into scanner methods as characters are read. |
155 |
Compatibility note: in previous versions, these tables used to be kept |
|
156 |
in classVariables, which made reuse hard as subclasses had no easy way of |
|
157 |
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
|
158 |
|
2484 | 159 |
|block actionArray typeArray unicodeActions| |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
160 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
161 |
actionArray := Array new:256. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
162 |
typeArray := Array new:256. |
2484 | 163 |
unicodeActions := Dictionary new. |
33 | 164 |
|
1303 | 165 |
"/ TODO: later versions should be configurable w.r.t separators. |
166 |
"/ #(9 10 12 13 26 32) do: [:i | TypeArray at:(i+1) put: #separator]. |
|
33 | 167 |
block := [:s :char | s nextNumber]. |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
168 |
($0 codePoint) to:($9 codePoint) do:[:index | |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
169 |
actionArray at:index put:block |
33 | 170 |
]. |
171 |
||
87 | 172 |
block := [:s :char | s nextSpecial]. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
173 |
self binarySelectorCharacters do:[:binop | |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
174 |
typeArray at:(binop codePoint) put:#special. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
175 |
actionArray at:(binop codePoint) put:block |
87 | 176 |
]. |
2146 | 177 |
block := [:s :char | s nextExtendedSpecial:char]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
178 |
self extendedBinarySelectorCharacters do:[:binop | |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
179 |
typeArray at:(binop codePoint) put:#extendedSpecial. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
180 |
actionArray at:(binop codePoint) put:block |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
181 |
]. |
87 | 182 |
|
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
183 |
"/ that one is a special case (both binarySelector AND syntax). |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
184 |
typeArray at:($| codePoint) put:nil. |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
185 |
|
87 | 186 |
block := [:s :char | s nextToken:char]. |
1510
875c90576897
Fix duplicate assignment to ActionArray for sh
Stefan Vogel <sv@exept.de>
parents:
1509
diff
changeset
|
187 |
';.^|()[]{}' do:[:ch | |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
188 |
actionArray at:(ch codePoint) put:block |
87 | 189 |
]. |
190 |
||
33 | 191 |
block := [:s :char | s nextIdentifier]. |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
192 |
($a codePoint) to:($z codePoint) do:[:index | |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
193 |
actionArray at:index put:block |
33 | 194 |
]. |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
195 |
($A codePoint) to:($Z codePoint) do:[:index | |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
196 |
actionArray at:index put:block |
33 | 197 |
]. |
198 |
||
199 |
"kludge: action is characterToken, but type is special" |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
200 |
typeArray at:($| codePoint) put:#special. |
33 | 201 |
|
80 | 202 |
"kludge: action is nextColonOrAssign, but type is special" |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
203 |
typeArray at:($: codePoint) put:#special. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
204 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
205 |
actionArray at:($' codePoint) put:[:s :char | s nextString:char]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
206 |
actionArray at:($$ codePoint) put:[:s :char | s nextCharacter]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
207 |
actionArray at:($# codePoint) put:[:s :char | s nextHash]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
208 |
actionArray at:($!! codePoint) put:[:s :char | s nextExcla]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
209 |
actionArray at:($% codePoint) put:[:s :char | s nextPrimitive]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
210 |
actionArray at:($: codePoint) put:[:s :char | s nextColonOrAssign]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
211 |
actionArray at:($_ codePoint) put:[:s :char | s nextUnderline]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
212 |
|
2486 | 213 |
unicodeActions at:2190 "<- left arrow" put:[:s :char | s nextAssignmentArrow]. |
2484 | 214 |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
215 |
ActionArray := DefaultActionArray := actionArray. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
216 |
TypeArray := DefaultTypeArray := typeArray. |
2484 | 217 |
UnicodeActions := DefaultUnicodeActions := unicodeActions. |
33 | 218 |
|
219 |
" |
|
220 |
Scanner setupActions |
|
2182 | 221 |
Scanner withAllSubclassesDo:[:cls | cls setupActions ] |
33 | 222 |
" |
462
6a29b0b356fc
added query for valid binarySelector characters
Claus Gittinger <cg@exept.de>
parents:
460
diff
changeset
|
223 |
|
2484 | 224 |
"Modified: / 25-03-2011 / 13:58:59 / cg" |
33 | 225 |
! ! |
226 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
227 |
!Scanner class methodsFor:'instance creation'! |
141 | 228 |
|
229 |
for:aStringOrStream |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
230 |
"create & return a new scanner reading from aStringOrStream" |
141 | 231 |
|
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
232 |
^ self basicNew initializeFor:aStringOrStream |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
233 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
234 |
"Modified: 23.5.1997 / 12:08:42 / cg" |
854 | 235 |
! |
236 |
||
237 |
new |
|
238 |
"create & return a new scanner" |
|
239 |
||
859 | 240 |
^ self basicNew initialize. |
854 | 241 |
|
242 |
"Modified: / 23.5.1997 / 12:08:42 / cg" |
|
243 |
"Created: / 26.5.1999 / 12:02:16 / stefan" |
|
141 | 244 |
! ! |
245 |
||
717 | 246 |
!Scanner class methodsFor:'Signal constants'! |
247 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
248 |
doNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
249 |
^ DoNotShowCompilerWarningAgainActionQuery |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
250 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
251 |
|
717 | 252 |
emptySourceNotificationSignal |
253 |
^ EmptySourceNotificationSignal |
|
254 |
||
255 |
"Created: / 16.5.1998 / 15:55:14 / cg" |
|
256 |
! ! |
|
257 |
||
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
258 |
!Scanner class methodsFor:'accessing'! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
259 |
|
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
260 |
actionArray |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
261 |
ActionArray isNil ifTrue:[ |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
262 |
self setupActions |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
263 |
]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
264 |
^ ActionArray ? DefaultActionArray |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
265 |
! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
266 |
|
2146 | 267 |
flushActionArray |
268 |
ActionArray := DefaultActionArray := nil. |
|
269 |
TypeArray := DefaultTypeArray := nil. |
|
270 |
||
271 |
" |
|
272 |
Scanner flushActionArray |
|
273 |
Parser flushActionArray |
|
274 |
ByteCodeCompiler flushActionArray |
|
275 |
Explainer flushActionArray |
|
276 |
" |
|
277 |
! |
|
278 |
||
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
279 |
typeArray |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
280 |
TypeArray isNil ifTrue:[ |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
281 |
self setupActions |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
282 |
]. |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
283 |
^ TypeArray ? DefaultTypeArray |
2484 | 284 |
! |
285 |
||
286 |
unicodeActions |
|
287 |
UnicodeActions isNil ifTrue:[ |
|
288 |
self setupActions |
|
289 |
]. |
|
290 |
^ UnicodeActions ? DefaultUnicodeActions |
|
291 |
||
292 |
"Created: / 25-03-2011 / 13:57:34 / cg" |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
293 |
! ! |
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
294 |
|
717 | 295 |
!Scanner class methodsFor:'class initialization'! |
296 |
||
297 |
initialize |
|
298 |
"initialize the classes defaults. Typically, these are changed |
|
299 |
later in the 'private.rc' file." |
|
300 |
||
301 |
EmptySourceNotificationSignal isNil ifTrue:[ |
|
302 |
EmptySourceNotificationSignal := QuerySignal new mayProceed:true. |
|
303 |
EmptySourceNotificationSignal notifierString:'empty source given to evaluate'. |
|
304 |
EmptySourceNotificationSignal nameClass:self message:#emptySourceNotificationSignal. |
|
305 |
]. |
|
306 |
||
307 |
" |
|
308 |
self initialize |
|
309 |
" |
|
310 |
||
311 |
"Modified: / 16.5.1998 / 15:55:41 / cg" |
|
312 |
! ! |
|
313 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
314 |
!Scanner class methodsFor:'defaults'! |
141 | 315 |
|
608 | 316 |
allowDollarInIdentifier |
317 |
"return true, if $-characters are allowed in identifiers. |
|
318 |
Notice, that dollars are NEVER allowed as the first character in an identifier." |
|
319 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
320 |
^ ParserFlags allowDollarInIdentifier |
608 | 321 |
|
322 |
"Created: 7.9.1997 / 01:32:18 / cg" |
|
323 |
"Modified: 7.9.1997 / 01:39:44 / cg" |
|
324 |
! |
|
325 |
||
326 |
allowDollarInIdentifier:aBoolean |
|
327 |
"this allows turning on/off $-characters in identifiers. |
|
328 |
Notice, that dollars are NEVER allowed as the first character in an identifier. |
|
329 |
If turned off (the default), dollars are not allowed in identifiers, |
|
330 |
but instead are scanned as character-constant prefix. |
|
331 |
If turned on, dollars are in identifiers are allowed, while extra |
|
332 |
dollars are still scanned as constant character prefix. |
|
333 |
If you have to fileIn old VW-Vsn2.x classes, turn this off |
|
334 |
before filing them in; i.e.: |
|
335 |
Compiler allowDollarInIdentifiers:false" |
|
336 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
337 |
ParserFlags allowDollarInIdentifier:aBoolean. |
608 | 338 |
|
339 |
"Created: 7.9.1997 / 01:34:49 / cg" |
|
340 |
"Modified: 7.9.1997 / 01:39:30 / cg" |
|
341 |
! |
|
342 |
||
1226 | 343 |
allowDolphinExtensions |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
344 |
"return true, if ##(..) computed literal Arrays are allowed" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
345 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
346 |
^ ParserFlags allowDolphinExtensions |
1226 | 347 |
! |
348 |
||
349 |
allowDolphinExtensions:aBoolean |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
350 |
"this allows turning on/off support for computed literal Arrays ##(..) as in dolphin. |
1226 | 351 |
If you want to fileIn Dolphin classes, enable this with: |
352 |
Compiler allowDolphinComputedArrays:true" |
|
353 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
354 |
ParserFlags allowDolphinExtensions:aBoolean. |
1226 | 355 |
|
356 |
" |
|
357 |
self allowDolphinExtensions:true |
|
358 |
self allowDolphinExtensions:false |
|
359 |
" |
|
360 |
! |
|
361 |
||
1572 | 362 |
allowLiteralNameSpaceSymbols |
363 |
"return true, if literal nameSpace symbols are allowed (#foo::bar) are allowed" |
|
364 |
||
3327 | 365 |
^ ParserFlags allowLiteralNameSpaceSymbols |
1572 | 366 |
! |
367 |
||
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
368 |
allowOldStyleAssignment |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
369 |
"return true, if underscore-assignment (pre ST-80v4 syntax) are to be allowed" |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
370 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
371 |
^ ParserFlags allowOldStyleAssignment |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
372 |
! |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
373 |
|
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
374 |
allowOldStyleAssignment:aBoolean |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
375 |
"this allows turning on/off recognition of underscore-assignment (pre ST-80v4 syntax). |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
376 |
You must turn this off, if code with variables named '_' is to be filedIn" |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
377 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
378 |
ParserFlags allowOldStyleAssignment:aBoolean |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
379 |
! |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
380 |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
381 |
allowQualifiedNames |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
382 |
"return true, if #{..} qualified names are allowed" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
383 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
384 |
^ ParserFlags allowQualifiedNames |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
385 |
! |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
386 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
387 |
allowQualifiedNames:aBoolean |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
388 |
"this allows turning on/off support for qualifiedNames #{ .., } as in vw3. |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
389 |
If you want to fileIn vw3 or later classes, enable this with: |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
390 |
Compiler allowQualifiedNames:true |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
391 |
Notice, that qualified names are not really supported semantically |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
392 |
(they are parsed, but treated like regular globals) |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
393 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
394 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
395 |
ParserFlags allowQualifiedNames:aBoolean. |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
396 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
397 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
398 |
self allowQualifiedNames:true |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
399 |
self allowQualifiedNames:false |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
400 |
" |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
401 |
! |
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
402 |
|
895 | 403 |
allowSqueakExtensions |
1530 | 404 |
"return true, if support for squeak extensions |
405 |
computed arrays { .., } |
|
406 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
407 |
is enabled." |
|
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
408 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
409 |
^ ParserFlags allowSqueakExtensions |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
410 |
! |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
411 |
|
895 | 412 |
allowSqueakExtensions:aBoolean |
1530 | 413 |
"this allows turning on/off support for squeak extensions: |
414 |
computed arrays { .., } |
|
415 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
416 |
||
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
417 |
If you want to fileIn Squeak classes, enable this with: |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
418 |
Compiler allowSqueakComputedArrays:true" |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
419 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
420 |
ParserFlags allowSqueakExtensions:aBoolean. |
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
421 |
|
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
422 |
" |
895 | 423 |
self allowSqueakExtensions:true |
424 |
self allowSqueakExtensions:false |
|
893
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
425 |
" |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
426 |
! |
9fcb0294a51e
changes to support loading squeak code containing computed
Claus Gittinger <cg@exept.de>
parents:
874
diff
changeset
|
427 |
|
141 | 428 |
allowUnderscoreInIdentifier |
429 |
"return true, if underscores are allowed in identifiers" |
|
430 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
431 |
^ ParserFlags allowUnderscoreInIdentifier |
141 | 432 |
! |
433 |
||
434 |
allowUnderscoreInIdentifier:aBoolean |
|
435 |
"this allows turning on/off underscores in identifiers. |
|
436 |
If turned off (the default), underscores are not allowed in identifiers, |
|
437 |
but instead scanned as assignment character (old ST/80 syntax). |
|
438 |
If turned on, underscores are in identifiers are allowed, while extra |
|
439 |
underscores are still scanned as assignment. |
|
608 | 440 |
If you have to fileIn old VW-Vsn2.x classes, |
441 |
turn them off with: |
|
442 |
Compiler allowUnderscoreInIdentifiers:false" |
|
141 | 443 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
444 |
ParserFlags allowUnderscoreInIdentifier:aBoolean. |
608 | 445 |
|
446 |
"Modified: 7.9.1997 / 01:35:19 / cg" |
|
141 | 447 |
! |
448 |
||
1644
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
449 |
maxBinarySelectorSize |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
450 |
^ 3 |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
451 |
|
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
452 |
" |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
453 |
in ST/X, binops are allowed with up-to 3 characters; |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
454 |
for example: |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
455 |
<-> |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
456 |
<=> |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
457 |
+++ |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
458 |
:=: |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
459 |
etc. are valid binOps here |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
460 |
" |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
461 |
! |
1991a9e37aef
numArgs fixed (binOps can now be longer)
Claus Gittinger <cg@exept.de>
parents:
1636
diff
changeset
|
462 |
|
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
463 |
warnCommonMistakes |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
464 |
"return true, if common beginners mistakes are to be warned about" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
465 |
|
1663 | 466 |
^ ParserFlags warnCommonMistakes |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
467 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
468 |
|
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
469 |
warnCommonMistakes:aBoolean |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
470 |
"this allows turning on/off warnings about common beginners mistakes. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
471 |
Those are not really errors in the strict sense, but often lead to |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
472 |
run time errors later. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
473 |
Examples are: expr or:expr2, where expr2 is not a block. |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
474 |
If you get bored by those warnings, turn them off by adding |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
475 |
a line as: |
1584 | 476 |
Compiler warnCommonMistakes:false |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
477 |
in your 'private.rc' file" |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
478 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
479 |
ParserFlags warnCommonMistakes:aBoolean |
310
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
480 |
! |
27ed956b591e
beginners common error warnings
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
481 |
|
608 | 482 |
warnDollarInIdentifier |
483 |
"return true, if $-characters in identifiers are to be warned about" |
|
484 |
||
1663 | 485 |
^ ParserFlags warnDollarInIdentifier |
608 | 486 |
|
487 |
"Created: 7.9.1997 / 01:36:17 / cg" |
|
488 |
! |
|
489 |
||
490 |
warnDollarInIdentifier:aBoolean |
|
491 |
"this allows turning on/off warnings about $-characters in identifiers. |
|
492 |
You may find those warnings useful, to make certain that your code |
|
493 |
is portable to other smalltalk versions, which do not allow this |
|
494 |
(i.e. VW releases 2.x and maybe others). |
|
495 |
Notice, that dollars are NEVER allowed as the first character in an identifier. |
|
496 |
If you get bored by those warnings, turn them off by adding |
|
497 |
a line as: |
|
498 |
Compiler warnDollarInIdentifier:false |
|
499 |
in your 'private.rc' file" |
|
500 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
501 |
ParserFlags warnDollarInIdentifier:aBoolean |
608 | 502 |
|
503 |
"Created: 7.9.1997 / 01:37:42 / cg" |
|
504 |
"Modified: 7.9.1997 / 01:40:02 / cg" |
|
505 |
! |
|
506 |
||
141 | 507 |
warnOldStyleAssignment |
508 |
"return true, if underscore-assignment (pre ST-80v4 syntax) are to be warned about" |
|
509 |
||
1663 | 510 |
^ ParserFlags warnOldStyleAssignment |
141 | 511 |
! |
512 |
||
513 |
warnOldStyleAssignment:aBoolean |
|
514 |
"this allows turning on/off warnings about underscore-assignment (pre ST-80v4 syntax). |
|
515 |
If you get bored by those warnings, turn them off by adding |
|
516 |
a line as: |
|
1584 | 517 |
Compiler warnOldStyleAssignment:false |
141 | 518 |
in your 'private.rc' file" |
519 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
520 |
ParserFlags warnOldStyleAssignment:aBoolean |
141 | 521 |
! |
522 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
523 |
warnPossibleIncompatibilities |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
524 |
"return true, if possible incompatibilities (with other ST systems) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
525 |
are to be warned about" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
526 |
|
1663 | 527 |
^ ParserFlags warnPossibleIncompatibilities |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
528 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
529 |
"Modified: 23.5.1997 / 12:02:02 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
530 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
531 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
532 |
warnPossibleIncompatibilities:aBoolean |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
533 |
"this turns warnings about possible incompatibilities (with other ST systems) |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
534 |
on or off. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
535 |
If you get bored by those warnings, turn them off by adding |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
536 |
a line as: |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
537 |
Compiler warnPossibleIncompatibilities:false |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
538 |
in your 'private.rc' file." |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
539 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
540 |
ParserFlags warnPossibleIncompatibilities:aBoolean |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
541 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
542 |
"Created: 23.5.1997 / 12:02:45 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
543 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
544 |
|
141 | 545 |
warnSTXSpecials |
546 |
"return true, if ST/X specials are to be warned about" |
|
547 |
||
1663 | 548 |
^ ParserFlags warnSTXSpecials |
141 | 549 |
! |
550 |
||
551 |
warnSTXSpecials:aBoolean |
|
552 |
"this allows turning on/off warnings about stx specials. |
|
553 |
If you get bored by those warnings, turn them off by adding |
|
554 |
a line as: |
|
1584 | 555 |
Compiler warnSTXSpecials:false |
141 | 556 |
in your 'private.rc' file" |
557 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
558 |
ParserFlags warnSTXSpecials:aBoolean |
141 | 559 |
! |
560 |
||
561 |
warnUnderscoreInIdentifier |
|
562 |
"return true, if underscores in identifiers are to be warned about" |
|
563 |
||
1663 | 564 |
^ ParserFlags warnUnderscoreInIdentifier |
141 | 565 |
! |
566 |
||
567 |
warnUnderscoreInIdentifier:aBoolean |
|
568 |
"this allows turning on/off warnings about underscores in identifiers. |
|
608 | 569 |
You may find those warnings useful, to make certain that your code |
570 |
is portable to other smalltalk versions, which do not allow this |
|
571 |
(i.e. VW releases 2.x). |
|
141 | 572 |
If you get bored by those warnings, turn them off by adding |
573 |
a line as: |
|
608 | 574 |
Compiler warnUnderscoreInIdentifier:false |
141 | 575 |
in your 'private.rc' file" |
576 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
577 |
ParserFlags warnUnderscoreInIdentifier:aBoolean |
608 | 578 |
|
579 |
"Modified: 7.9.1997 / 01:37:13 / cg" |
|
141 | 580 |
! |
581 |
||
582 |
warnings |
|
583 |
"return true, if any warnings are to be shown" |
|
584 |
||
1663 | 585 |
^ ParserFlags warnings |
141 | 586 |
! |
587 |
||
588 |
warnings:aBoolean |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
589 |
"this allows turning on/off all warnings; the default is on. |
141 | 590 |
You can turn off warnings in your 'private.rc' file with |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
591 |
Compiler warnings:false |
141 | 592 |
" |
593 |
||
1663 | 594 |
ParserFlags warnings:aBoolean |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
595 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
596 |
"Modified: 23.5.1997 / 12:03:05 / cg" |
141 | 597 |
! ! |
598 |
||
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
599 |
!Scanner class methodsFor:'utility scanning'! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
600 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
601 |
scanNumberFrom:aStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
602 |
"utility - helper for Number>>readSmalltalkSyntaxFrom:" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
603 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
604 |
^ self basicNew scanNumberFrom:aStream |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
605 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
606 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
607 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
608 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
609 |
s := '12345abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
610 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
611 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
612 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
613 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
614 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
615 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
616 |
s := '16rffffxabcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
617 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
618 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
619 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
620 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
621 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
622 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
623 |
s := '1.2345abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
624 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
625 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
626 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
627 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
628 |
|s| |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
629 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
630 |
s := '1.abcd' readStream. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
631 |
Transcript showCR:(self scanNumberFrom:s). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
632 |
Transcript showCR:(s upToEnd). |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
633 |
" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
634 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
635 |
"Modified: / 18.6.1998 / 23:10:39 / cg" |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
636 |
! ! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
637 |
|
1417 | 638 |
!Scanner methodsFor:'Compatibility-ST80'! |
98 | 639 |
|
640 |
endOfLastToken |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
641 |
"return the position of the token which was just read. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
642 |
This method was required by some PD program. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
643 |
It is not maintained and may be removed without notice." |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
644 |
|
3268 | 645 |
^ source position + 1 |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
646 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
647 |
"Modified: 23.5.1997 / 12:14:27 / cg" |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
648 |
! |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
649 |
|
630 | 650 |
scan:aStringOrStream |
651 |
"initialize the scanner: set the source-stream and |
|
652 |
preread the first token" |
|
653 |
||
654 |
self initializeFor:aStringOrStream. |
|
655 |
self nextToken |
|
656 |
||
657 |
"Created: / 30.10.1997 / 16:59:39 / cg" |
|
658 |
! |
|
659 |
||
2139 | 660 |
scanDoing:aBlock |
661 |
"scan, evaluating aBlock for every scanned token." |
|
662 |
||
663 |
|t| |
|
664 |
||
665 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
666 |
aBlock value:t. |
|
667 |
]. |
|
668 |
! |
|
669 |
||
630 | 670 |
scanToken |
671 |
"read the next token from my input stream" |
|
672 |
||
673 |
^ self nextToken |
|
674 |
||
675 |
"Created: / 30.10.1997 / 17:00:16 / cg" |
|
676 |
! |
|
677 |
||
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
678 |
scanTokens:aStringOrStream |
3056 | 679 |
"return a collection of symbolic tokens from the passed input, |
680 |
similar to what would be read when reading '#( <string> )'" |
|
681 |
||
682 |
|tokens readArray| |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
683 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
684 |
self initializeFor:aStringOrStream. |
3056 | 685 |
|
686 |
readArray := |
|
687 |
[ |
|
688 |
|elements| |
|
689 |
||
690 |
elements := OrderedCollection new. |
|
691 |
[ token ~~ $) ] whileTrue:[ |
|
692 |
token == $( ifTrue:[ |
|
693 |
self nextToken. |
|
694 |
elements add:(readArray value) |
|
695 |
] ifFalse:[ |
|
696 |
elements add:token. |
|
697 |
]. |
|
698 |
self nextToken. |
|
699 |
]. |
|
700 |
elements asArray |
|
701 |
]. |
|
702 |
||
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
703 |
tokens := OrderedCollection new. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
704 |
self nextToken. |
3056 | 705 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
706 |
[token notNil] whileTrue:[ |
3056 | 707 |
token == $( ifTrue:[ |
708 |
self nextToken. |
|
709 |
tokens add:(readArray value) |
|
710 |
] ifFalse:[ |
|
711 |
tokens add:token |
|
712 |
]. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
713 |
self nextToken |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
714 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
715 |
^ tokens |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
716 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
717 |
" |
3056 | 718 |
Scanner new scanTokens:'name ident #sym ''string'' 8r12' |
719 |
||
720 |
Scanner new scanTokens:'translate (200px 100px)' |
|
721 |
||
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
722 |
Scanner new |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
723 |
scanTokens:'Boolean subclass:#True |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
724 |
instanceVariableNames:'''' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
725 |
classVariableNames:'''' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
726 |
poolDictionaries:'''' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
727 |
category:''Kernel-Objects'' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
728 |
' |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
729 |
" |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
730 |
|
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
731 |
"Modified: 20.6.1997 / 18:22:58 / cg" |
98 | 732 |
! ! |
733 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
734 |
!Scanner methodsFor:'accessing'! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
735 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
736 |
comments |
1584 | 737 |
^ currentComments ? #() |
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
738 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
739 |
|
1509 | 740 |
exitBlock:aBlock |
741 |
exitBlock := aBlock |
|
742 |
! |
|
743 |
||
2742
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
744 |
getCollectedComments |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
745 |
"retrieve the so far collected comments, reset comment collection" |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
746 |
|
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 |
(comments := currentComments) isEmptyOrNil ifTrue:[^ nil]. |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
750 |
currentComments := nil. |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
751 |
^ comments |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
752 |
|
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
753 |
"Created: / 05-10-2011 / 10:09:01 / cg" |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
754 |
! |
1da09935db64
added: #getCollectedComments
Claus Gittinger <cg@exept.de>
parents:
2741
diff
changeset
|
755 |
|
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
756 |
inArrayLiteral:aBoolean |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
757 |
inArrayLiteral := aBoolean |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
758 |
! |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
759 |
|
859 | 760 |
lineNumber |
761 |
^ lineNr |
|
762 |
! |
|
763 |
||
795 | 764 |
newSourceStream:aStream |
765 |
source := aStream. |
|
766 |
self nextToken. |
|
767 |
||
768 |
"Created: / 29.10.1998 / 21:59:33 / cg" |
|
769 |
! |
|
770 |
||
1497 | 771 |
outStream:aStream |
772 |
outStream := aStream. |
|
773 |
outCol := outCol ? 1. |
|
774 |
! |
|
775 |
||
3283 | 776 |
requestor |
777 |
^ requestor |
|
778 |
! |
|
779 |
||
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
780 |
saveComments:aBoolean |
1582
701f40070c8a
comments returns a collection
Claus Gittinger <cg@exept.de>
parents:
1580
diff
changeset
|
781 |
saveComments := aBoolean. |
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
782 |
|
2737 | 783 |
"Created: / 20-04-1996 / 20:03:56 / cg" |
784 |
"Modified: / 23-05-1997 / 12:14:49 / cg" |
|
785 |
"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
|
786 |
! |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
787 |
|
1242 | 788 |
sourcePosition |
3268 | 789 |
^ source position + 1 |
1242 | 790 |
! |
791 |
||
2678
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
792 |
sourcePositionWithoutPeeks |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
793 |
|
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 |
pos := self sourcePosition. |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
796 |
peekChar2 notNil ifTrue:[^ pos - 2]. |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
797 |
peekChar notNil ifTrue:[^ pos - 1]. |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
798 |
^pos |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
799 |
|
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
800 |
"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
|
801 |
! |
fc0df237f01e
Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2612
diff
changeset
|
802 |
|
254
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
803 |
sourceStream |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
804 |
^ source |
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
805 |
|
edfcf93d821f
changes to allow parsing for comments
Claus Gittinger <cg@exept.de>
parents:
241
diff
changeset
|
806 |
"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
|
807 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
808 |
|
3334 | 809 |
tokenEndPosition |
3335 | 810 |
^ tokenPosition + tokenName size - 1. |
3334 | 811 |
|
812 |
"Created: / 22-10-2013 / 00:30:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3335 | 813 |
"Modified: / 22-10-2013 / 03:11:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3334 | 814 |
! |
815 |
||
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
816 |
tokenLineNr |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
817 |
^ tokenLineNr |
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 |
tokenName |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
821 |
^ tokenName |
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 |
|
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
824 |
tokenPosition |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
825 |
^ tokenPosition |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
826 |
! |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
827 |
|
3334 | 828 |
tokenStartPosition |
829 |
^ tokenPosition |
|
830 |
||
831 |
"Created: / 22-10-2013 / 00:29:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
832 |
! |
|
833 |
||
1235
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
834 |
tokenType |
fc0ccb509f4e
accessors (to allow using scanner as instVar in parser)
Claus Gittinger <cg@exept.de>
parents:
1226
diff
changeset
|
835 |
^ tokenType |
1238 | 836 |
! |
837 |
||
838 |
tokenValue |
|
839 |
^ tokenValue |
|
840 |
||
841 |
"Created: / 21.12.2001 / 22:38:08 / cg" |
|
1362 | 842 |
! ! |
843 |
||
844 |
!Scanner methodsFor:'accessing-flags'! |
|
845 |
||
846 |
allowDollarInIdentifier |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
847 |
^ parserFlags allowDollarInIdentifier |
1362 | 848 |
! |
849 |
||
1511 | 850 |
allowDollarInIdentifier:something |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
851 |
parserFlags allowDollarInIdentifier:something |
1511 | 852 |
! |
853 |
||
1572 | 854 |
allowLiteralNameSpaceSymbols |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
855 |
^ parserFlags allowLiteralNameSpaceSymbols |
1572 | 856 |
! |
857 |
||
858 |
allowLiteralNameSpaceSymbols:aBoolean |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
859 |
parserFlags allowLiteralNameSpaceSymbols:aBoolean |
1572 | 860 |
! |
861 |
||
1362 | 862 |
allowOldStyleAssignment |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
863 |
^ parserFlags allowOldStyleAssignment |
1362 | 864 |
! |
865 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
866 |
allowOldStyleAssignment:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
867 |
parserFlags allowOldStyleAssignment:aBoolean |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
868 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
869 |
|
1362 | 870 |
allowSqueakExtensions |
1530 | 871 |
"return true, if support for squeak extensions |
872 |
computed arrays { .., } |
|
873 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
874 |
is enabled." |
|
875 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
876 |
^ parserFlags allowSqueakExtensions |
1362 | 877 |
! |
878 |
||
879 |
allowSqueakExtensions:aBoolean |
|
1530 | 880 |
"this allows turning on/off support for squeak extensions: |
881 |
computed arrays { .., } |
|
882 |
c/java style arguments in message sends rec foo(arg1, ... argN) |
|
883 |
" |
|
884 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
885 |
parserFlags allowSqueakExtensions:aBoolean |
1362 | 886 |
! |
887 |
||
888 |
allowUnderscoreInIdentifier |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
889 |
^ parserFlags allowUnderscoreInIdentifier |
1362 | 890 |
! |
891 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
892 |
allowUnderscoreInIdentifier:aBoolean |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
893 |
parserFlags allowUnderscoreInIdentifier:aBoolean |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
894 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
895 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
896 |
parserFlags |
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) |
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
|
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. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1735 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1736 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1737 |
only warn once (per method) |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1738 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1739 |
didWarnAboutOldStyleAssignment := true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1740 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1741 |
] |
87 | 1742 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1743 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1744 |
"Modified: 23.5.1997 / 12:16:48 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1745 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1746 |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1747 |
warnPeriodAt:position |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1748 |
"warn about a period in an identifier" |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1749 |
|
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1750 |
ignoreWarnings ifFalse:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1751 |
didWarnAboutPeriodInSymbol ifFalse:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1752 |
parserFlags warnAboutPeriodInSymbol ifTrue:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1753 |
self |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1754 |
warning:'Period in symbols are nonportable' |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1755 |
doNotShowAgainAction:[ ParserFlags warnAboutPeriodInSymbol:false ] |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1756 |
position:position to:position. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1757 |
" |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1758 |
only warn once (per method) |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1759 |
" |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1760 |
didWarnAboutPeriodInSymbol := true |
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 |
! |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1765 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1766 |
warnPossibleIncompatibility:msg position:pos1 to:pos2 |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1767 |
"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
|
1768 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1769 |
ignoreWarnings ifFalse:[ |
1681 | 1770 |
parserFlags warnPossibleIncompatibilities ifTrue:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1771 |
self |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1772 |
warning:('Possible incompatibility.\\' , msg) withCRs |
3424 | 1773 |
doNotShowAgainAction:[ ParserFlags warnPossibleIncompatibilities:false. |
1774 |
parserFlags warnPossibleIncompatibilities:false ] |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1775 |
position:pos1 to:pos2. |
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 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1779 |
"Created: 23.5.1997 / 12:17:54 / cg" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1780 |
"Modified: 23.5.1997 / 12:22:37 / cg" |
87 | 1781 |
! |
1782 |
||
1653 | 1783 |
warnSTXSpecialCommentAt:position to:endPosition |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1784 |
ignoreWarnings ifFalse:[ |
2831 | 1785 |
"/ dfo |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1786 |
didWarnAboutSTXSpecialComment ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1787 |
parserFlags warnSTXSpecialComment ifTrue:[ |
2831 | 1788 |
self |
1789 |
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
|
1790 |
doNotShowAgainAction:[ parserFlags warnSTXSpecialComment:false. ParserFlags warnSTXSpecials:false. ] |
2831 | 1791 |
doNotShowAgainForThisMethodAction: [ self disableWarningsOnCurrentMethodFor: #warnSTXSpecials ] |
1792 |
position:position to:endPosition. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1793 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1794 |
only warn once |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1795 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1796 |
didWarnAboutSTXSpecialComment := true |
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 |
] |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1799 |
]. |
2831 | 1800 |
|
2854
64b0decefcec
changed: #warnSTXSpecialCommentAt:to:
Claus Gittinger <cg@exept.de>
parents:
2846
diff
changeset
|
1801 |
"Modified: / 16-03-2012 / 18:37:11 / cg" |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1802 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1803 |
|
87 | 1804 |
warnUnderscoreAt:position |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1805 |
"warn about an underscore in an identifier" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1806 |
|
87 | 1807 |
ignoreWarnings ifFalse:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1808 |
didWarnAboutUnderscoreInIdentifier ifFalse:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1809 |
parserFlags warnUnderscoreInIdentifier ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1810 |
self |
1663 | 1811 |
warning:'Underscores in identifiers/symbols are nonportable' |
1812 |
doNotShowAgainAction:[ ParserFlags warnUnderscoreInIdentifier:false ] |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1813 |
position:position to:position. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1814 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1815 |
only warn once (per method) |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1816 |
" |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1817 |
didWarnAboutUnderscoreInIdentifier := true |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
1818 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1819 |
] |
87 | 1820 |
] |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1821 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
1822 |
"Modified: 23.5.1997 / 12:17:06 / cg" |
141 | 1823 |
! |
1824 |
||
1825 |
warning:aMessage |
|
1826 |
"a warning - position is not known" |
|
1827 |
||
1828 |
^ self warning:aMessage position:tokenPosition |
|
1829 |
! |
|
1830 |
||
2831 | 1831 |
warning:aMessage doNotShowAgainAction:doNotShowAgainAction doNotShowAgainForThisMethodAction:doNotShowAgainForThisMethodAction position:position to:endPos |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1832 |
"a warning" |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1833 |
|
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1834 |
^ self |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1835 |
notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) |
1457 | 1836 |
doNotShowAgainAction:doNotShowAgainAction |
2831 | 1837 |
doNotShowAgainForThisMethodAction:doNotShowAgainForThisMethodAction |
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1838 |
position:position to:endPos |
2831 | 1839 |
|
1840 |
"Created: / 28-02-2012 / 08:38:16 / cg" |
|
1841 |
! |
|
1842 |
||
1843 |
warning:aMessage doNotShowAgainAction:doNotShowAgainAction position:position to:endPos |
|
1844 |
"a warning" |
|
1845 |
||
1846 |
^ self |
|
1847 |
warning:aMessage |
|
1848 |
doNotShowAgainAction:doNotShowAgainAction |
|
1849 |
doNotShowAgainForThisMethodAction:nil |
|
1850 |
position:position to:endPos |
|
1851 |
||
1852 |
"Modified: / 28-02-2012 / 08:43:00 / cg" |
|
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1853 |
! |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1854 |
|
1948 | 1855 |
warning:aMessage line:lNr |
1856 |
"a warning - only start position is known" |
|
1857 |
||
1858 |
|position| |
|
1859 |
||
1860 |
position := self positionFromLineNumber:lNr. |
|
1861 |
^ self warning:aMessage position:position to:nil |
|
1862 |
||
1863 |
"Created: / 16-11-2006 / 14:29:30 / cg" |
|
1864 |
! |
|
1865 |
||
141 | 1866 |
warning:aMessage position:position |
1867 |
"a warning - only start position is known" |
|
1868 |
||
1869 |
^ self warning:aMessage position:position to:nil |
|
1870 |
! |
|
1871 |
||
1872 |
warning:aMessage position:position to:endPos |
|
1873 |
"a warning" |
|
1874 |
||
1454
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1875 |
^ self |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1876 |
notifyWarning:((self warningMessagePrefix) , ' ' , aMessage) |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1877 |
doNotShowAgainAction:nil |
d3c4be472930
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
1434
diff
changeset
|
1878 |
position:position to:endPos |
1073 | 1879 |
! |
1880 |
||
1881 |
warningMessagePrefix |
|
1882 |
^ 'Warning:' |
|
0 | 1883 |
! ! |
1884 |
||
17 | 1885 |
!Scanner methodsFor:'general scanning'! |
1886 |
||
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1887 |
scanNumberFrom:aStringOrStream |
3143 | 1888 |
"scan aSourceString for the next number in smalltalk syntax. |
3144 | 1889 |
Return the number or nil. Leave the position of the stream after the number |
3143 | 1890 |
or unchanged (if no number is coming) |
1891 |
Extension: |
|
1892 |
since contant fractions (int/int) are treated like lexical tokens (not messages) |
|
1893 |
in Smalltalk/X, this also reads fractions." |
|
1894 |
||
3144 | 1895 |
|oldPos posAfter denominator numerator parentized sign| |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1896 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1897 |
self initializeFor:aStringOrStream. |
1430 | 1898 |
oldPos := source position. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1899 |
self nextToken. |
3144 | 1900 |
|
1901 |
sign := 1. |
|
1902 |
tokenType == #BinaryOperator ifTrue:[ |
|
1903 |
tokenName = '+' ifTrue:[ |
|
1904 |
self nextToken. |
|
1905 |
] ifFalse:[ |
|
1906 |
tokenName = '-' ifTrue:[ |
|
1907 |
sign := -1. |
|
1908 |
self nextToken. |
|
1909 |
]. |
|
1910 |
]. |
|
1911 |
]. |
|
1912 |
(parentized := tokenType == $( ) ifTrue:[ |
|
1913 |
self nextToken. |
|
1914 |
tokenType == #BinaryOperator ifTrue:[ |
|
1915 |
tokenName = '+' ifTrue:[ |
|
1916 |
self nextToken. |
|
1917 |
] ifFalse:[ |
|
1918 |
tokenName = '-' ifTrue:[ |
|
1919 |
sign := sign negated. |
|
1920 |
self nextToken. |
|
1921 |
]. |
|
1922 |
]. |
|
1923 |
]. |
|
1924 |
]. |
|
1925 |
||
3143 | 1926 |
(tokenValue isNumber) ifTrue:[ |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1927 |
"/ must keep stream positioned correctly |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1928 |
"/ (undo lookahead) |
3143 | 1929 |
posAfter := source position. |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1930 |
peekChar notNil ifTrue:[ |
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1931 |
peekChar2 notNil ifTrue:[ |
3143 | 1932 |
posAfter := posAfter - 1 |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1933 |
]. |
3143 | 1934 |
posAfter := posAfter - 1 |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1935 |
]. |
3143 | 1936 |
tokenValue isInteger ifTrue:[ |
1937 |
source skipSeparators. |
|
1938 |
source peekOrNil == $/ ifTrue:[ |
|
1939 |
numerator := tokenValue. |
|
1940 |
self nextToken. "/ skip / |
|
3175 | 1941 |
"/ oops - must check for // |
1942 |
tokenName = '/' ifFalse:[ |
|
1943 |
parentized ifTrue:[ |
|
1944 |
"/ nothing at all |
|
1945 |
source position:oldPos. |
|
1946 |
^ nil. |
|
1947 |
]. |
|
1948 |
"/ only an integer |
|
1949 |
source position:posAfter. |
|
1950 |
^ tokenValue |
|
1951 |
]. |
|
1952 |
||
3143 | 1953 |
self nextToken. "/ get denominator |
3144 | 1954 |
tokenType == #BinaryOperator ifTrue:[ |
1955 |
tokenName = '+' ifTrue:[ |
|
1956 |
self nextToken. |
|
1957 |
] ifFalse:[ |
|
1958 |
tokenName = '-' ifTrue:[ |
|
1959 |
sign := sign negated. |
|
1960 |
self nextToken. |
|
1961 |
]. |
|
1962 |
]. |
|
1963 |
]. |
|
3143 | 1964 |
(tokenType == #Integer and:[tokenValue isInteger]) ifTrue:[ |
1965 |
denominator := tokenValue. |
|
1966 |
tokenValue := Fraction numerator:numerator denominator:denominator. |
|
1967 |
posAfter := source position. |
|
1968 |
peekChar notNil ifTrue:[ |
|
1969 |
peekChar2 notNil ifTrue:[ |
|
1970 |
posAfter := posAfter - 1 |
|
1971 |
]. |
|
1972 |
posAfter := posAfter - 1 |
|
1973 |
]. |
|
1974 |
]. |
|
1975 |
]. |
|
1976 |
]. |
|
3144 | 1977 |
parentized ifTrue:[ |
1978 |
tokenType == $) ifTrue:[ |
|
1979 |
self nextToken |
|
1980 |
] |
|
1981 |
] ifFalse:[ |
|
1982 |
source position:posAfter. |
|
1983 |
]. |
|
1984 |
sign == -1 ifTrue:[^ tokenValue negated]. |
|
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1985 |
^ tokenValue |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1986 |
]. |
996
53dbf13d1aa0
keep stream positioned correctly after scanNumberFrom:
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
1987 |
"/ backup in case of error; return nil |
1430 | 1988 |
source position:oldPos. |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1989 |
^ nil. |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1990 |
|
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1991 |
"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
|
1992 |
"Modified: / 19.11.1999 / 18:25:52 / cg" |
737
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1993 |
! |
4062aa740959
support for readSmalltalkSyntax
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1994 |
|
17 | 1995 |
scanPositionsFor:aTokenString inString:aSourceString |
1996 |
"scan aSourceString for occurrances of aTokenString. |
|
1997 |
Return a collection of start positions. |
|
1577 | 1998 |
Added for VW compatibility (to support simple syntax-highlight)." |
17 | 1999 |
|
2000 |
|searchType searchName searchValue positions t| |
|
2001 |
||
1577 | 2002 |
aTokenString notNil ifTrue:[ |
2003 |
" |
|
2004 |
first, look what kind of token we have to search for |
|
2005 |
" |
|
2006 |
self initializeFor:(ReadStream on:aTokenString). |
|
2007 |
self nextToken. |
|
2008 |
searchType := tokenType. |
|
2009 |
searchName := tokenName. |
|
2010 |
searchValue := tokenValue. |
|
2011 |
]. |
|
17 | 2012 |
|
2013 |
" |
|
2014 |
start the real work ... |
|
2015 |
" |
|
2016 |
self initializeFor:(ReadStream on:aSourceString). |
|
2017 |
positions := OrderedCollection new. |
|
2018 |
||
2019 |
[(t := self nextToken) ~~ #EOF] whileTrue:[ |
|
1577 | 2020 |
searchType == t ifTrue:[ |
2021 |
(searchName isNil or:[tokenName = searchName]) ifTrue:[ |
|
2022 |
(searchValue isNil or:[tokenValue = searchValue]) ifTrue:[ |
|
2023 |
positions add:tokenPosition. |
|
2024 |
] |
|
2025 |
] |
|
2026 |
] |
|
17 | 2027 |
]. |
2028 |
||
2029 |
^ positions |
|
2030 |
||
2031 |
" |
|
30 | 2032 |
Scanner new scanPositionsFor:'hello' inString:'foo bar hello baz hello' |
2033 |
Scanner new scanPositionsFor:'3.14' inString:'foo 3.145 bar hello 3.14 baz hello 3.14' |
|
2034 |
Scanner new scanPositionsFor:'16' inString:'foo 16 bar hello 16r10 baz hello 2r10000' |
|
17 | 2035 |
" |
2036 |
! ! |
|
2037 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2038 |
!Scanner methodsFor:'initialization'! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2039 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2040 |
initialize |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2041 |
"initialize the scanner" |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2042 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2043 |
errorFlag := false. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2044 |
tokenPosition := 1. |
610 | 2045 |
tokenLineNr := lineNr := 1. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2046 |
currentComments := nil. |
2740 | 2047 |
"/ allow for these to be already set (kludge) |
2048 |
saveComments isNil ifTrue:[ saveComments := false ]. |
|
2049 |
parserFlags isNil ifTrue:[ parserFlags := ParserFlags new ]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2050 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2051 |
ignoreErrors := false. |
1930 | 2052 |
ignoreWarnings := parserFlags warnings not. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2053 |
didWarnAboutSTXSpecialComment := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2054 |
didWarnAboutUnderscoreInIdentifier := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2055 |
didWarnAboutDollarInIdentifier := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2056 |
didWarnAboutOldStyleAssignment := false. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2057 |
|
900 | 2058 |
"/ not used here, but eases subclassing for other languages. |
2740 | 2059 |
scanColonAsKeyword isNil ifTrue:[ scanColonAsKeyword := true ]. |
1930 | 2060 |
self initializeActionTable. |
2061 |
||
2740 | 2062 |
"Modified (comment): / 05-10-2011 / 09:22:46 / cg" |
1930 | 2063 |
! |
2064 |
||
2065 |
initializeActionTable |
|
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
2066 |
actionArray := self class actionArray. |
2484 | 2067 |
unicodeActions := self class unicodeActions. |
2140
f9b4ef3e9368
type- and actionArray are now class-instance variables
Claus Gittinger <cg@exept.de>
parents:
2139
diff
changeset
|
2068 |
typeArray := self class typeArray. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2069 |
|
1930 | 2070 |
"Created: / 18-10-2006 / 23:10:55 / cg" |
2484 | 2071 |
"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
|
2072 |
! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2073 |
|
1362 | 2074 |
initializeFlagsFrom:aScanner |
2075 |
"initialize flags from another scanner" |
|
2076 |
||
2077 |
ignoreErrors := aScanner ignoreErrors. |
|
2078 |
ignoreWarnings := aScanner ignoreWarnings. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2079 |
parserFlags := aScanner parserFlags copy. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2080 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2081 |
"/ not used here, but eases subclassing for other languages. |
1362 | 2082 |
scanColonAsKeyword := aScanner scanColonAsKeyword. |
2083 |
! |
|
2084 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2085 |
initializeFor:aStringOrStream |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2086 |
"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
|
2087 |
|
2741 | 2088 |
actionArray isNil ifTrue:[ |
2089 |
"/ if not already initialized... |
|
2090 |
self initialize. |
|
2091 |
]. |
|
847 | 2092 |
self source:aStringOrStream. |
2741 | 2093 |
|
2094 |
"Modified: / 05-10-2011 / 09:24:00 / cg" |
|
847 | 2095 |
! |
2096 |
||
1962 | 2097 |
requestor:anObject |
2098 |
"set the requestor to be notified" |
|
2099 |
||
2100 |
requestor := anObject |
|
2101 |
||
2102 |
"Created: / 07-12-2006 / 18:13:13 / cg" |
|
2103 |
! |
|
2104 |
||
1242 | 2105 |
setSource:newSource |
2106 |
source := newSource |
|
2107 |
||
2108 |
! |
|
2109 |
||
847 | 2110 |
source:aStringOrStream |
2766 | 2111 |
"prepare for reading from aStringOrStream; |
2112 |
notice: if token is nonNil, it is preserved. This allows for scanning |
|
2113 |
across streams." |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2114 |
|
854 | 2115 |
errorFlag := false. |
2116 |
tokenPosition := 1. |
|
2117 |
tokenLineNr := lineNr := 1. |
|
2118 |
currentComments := nil. |
|
2119 |
||
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2120 |
aStringOrStream isStream ifFalse:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2121 |
source := ReadStream on:aStringOrStream |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2122 |
] ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2123 |
source := aStringOrStream. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2124 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2125 |
|
2762 | 2126 |
"Modified: / 26-05-1999 / 12:02:16 / stefan" |
2766 | 2127 |
"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
|
2128 |
! ! |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2129 |
|
1237
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2130 |
!Scanner methodsFor:'parser interface'! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2131 |
|
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2132 |
token |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2133 |
^ token |
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 |
|
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 |
tokenLineNr := lineNumberArg |
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 |
|
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 |
tokenPosition := positionArg |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2142 |
! ! |
4c8cd98c5778
more refactorings for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1236
diff
changeset
|
2143 |
|
141 | 2144 |
!Scanner methodsFor:'private'! |
3 | 2145 |
|
141 | 2146 |
backupPosition |
2147 |
"if reading from a stream, at the end we might have read |
|
2148 |
one token too many" |
|
20 | 2149 |
|
141 | 2150 |
(tokenType == #EOF) ifFalse:[ |
3268 | 2151 |
source position:tokenPosition-1 |
141 | 2152 |
] |
2153 |
! |
|
15 | 2154 |
|
141 | 2155 |
beginComment |
2156 |
^ self |
|
2157 |
! |
|
2158 |
||
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2159 |
checkForKeyword:string |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2160 |
"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
|
2161 |
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
|
2162 |
or 'thisContext'. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2163 |
'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
|
2164 |
identifier, if declared locally." |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2165 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2166 |
|firstChar| |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2167 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2168 |
firstChar := string at:1. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2169 |
(firstChar == $s) ifTrue:[ |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2170 |
(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
|
2171 |
(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
|
2172 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2173 |
(firstChar == $n) ifTrue:[ |
1681 | 2174 |
(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
|
2175 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2176 |
(firstChar == $t) ifTrue:[ |
1681 | 2177 |
(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
|
2178 |
(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
|
2179 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2180 |
(firstChar == $f) ifTrue:[ |
1681 | 2181 |
(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
|
2182 |
]. |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2183 |
^ false |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2184 |
|
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2185 |
"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
|
2186 |
! |
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2187 |
|
141 | 2188 |
collectedSource |
2189 |
^ collectedSource |
|
2190 |
! |
|
74 | 2191 |
|
1236 | 2192 |
eatPeekChar |
2193 |
peekChar isNil ifTrue:[ |
|
2194 |
source next. |
|
2195 |
] ifFalse:[ |
|
2196 |
peekChar := nil. |
|
2197 |
]. |
|
2198 |
||
2199 |
"Created: / 24.10.1998 / 17:25:39 / cg" |
|
2200 |
! |
|
2201 |
||
141 | 2202 |
endComment:comment |
2203 |
saveComments ifTrue:[ |
|
1584 | 2204 |
currentComments isNil ifTrue:[ |
2205 |
currentComments := OrderedCollection with:comment |
|
2206 |
] ifFalse:[ |
|
2207 |
currentComments add:comment |
|
2208 |
] |
|
3 | 2209 |
]. |
2210 |
! |
|
2211 |
||
648 | 2212 |
endComment:commentString type:commentType |
2213 |
|comment| |
|
2214 |
||
2215 |
saveComments ifTrue:[ |
|
1596 | 2216 |
comment := Comment new commentString:commentString commentType:commentType. |
648 | 2217 |
|
2218 |
currentComments isNil ifTrue:[ |
|
2219 |
currentComments := OrderedCollection with:comment |
|
2220 |
] ifFalse:[ |
|
2221 |
currentComments add:comment |
|
2222 |
] |
|
2223 |
]. |
|
2224 |
||
2225 |
"Created: / 17.2.1998 / 14:48:49 / cg" |
|
2226 |
! |
|
2227 |
||
2481 | 2228 |
eolIsWhiteSpace |
2229 |
^ true |
|
2230 |
||
2231 |
"Created: / 14-03-2011 / 14:11:46 / cg" |
|
2232 |
! |
|
2233 |
||
1321 | 2234 |
escapeCharacterFor:aCharacter |
2235 |
"only if AllowExtendedSTXSyntax is true |
|
2236 |
For now: do not use, since stc does not support it. |
|
2237 |
||
2238 |
much like character escapes in C-literals; |
|
2239 |
expands: |
|
1681 | 2240 |
\n newLine |
2241 |
\r return |
|
2242 |
\t tab |
|
2243 |
\b backspace |
|
2244 |
\f formfeed |
|
2245 |
\g bell |
|
2246 |
||
2247 |
\\ backSlash |
|
2248 |
\ ...\ (backslash-separator) ignored up to next backslash |
|
2249 |
\xNN hexCharacter |
|
2250 |
\uNNNN hex UnicodeCharacter |
|
1321 | 2251 |
" |
2252 |
||
1681 | 2253 |
|ascii nextChar fetchNext| |
1321 | 2254 |
|
2255 |
aCharacter == $n ifTrue:[^ Character nl]. |
|
2256 |
aCharacter == $r ifTrue:[^ Character return]. |
|
2257 |
aCharacter == $t ifTrue:[^ Character tab]. |
|
2258 |
aCharacter == $b ifTrue:[^ Character backspace]. |
|
2259 |
aCharacter == $f ifTrue:[^ Character ff]. |
|
2260 |
aCharacter == $g ifTrue:[^ Character bell]. |
|
1681 | 2261 |
aCharacter == $\ ifTrue:[^ aCharacter]. |
1321 | 2262 |
aCharacter isSeparator ifTrue:[ |
2263 |
nextChar := source next. |
|
1681 | 2264 |
[nextChar notNil and:[nextChar ~~ $\]] whileTrue:[ |
1321 | 2265 |
(nextChar == Character cr) ifTrue:[ |
2266 |
lineNr := lineNr + 1 |
|
2267 |
]. |
|
2268 |
nextChar := source next. |
|
2269 |
]. |
|
2270 |
^ nil |
|
2271 |
]. |
|
2272 |
||
1681 | 2273 |
(aCharacter == $x or:[ aCharacter == $u ]) ifTrue:[ |
2274 |
fetchNext := |
|
2275 |
[ |
|
1321 | 2276 |
nextChar := source next. |
1681 | 2277 |
(nextChar notNil and:[nextChar isDigitRadix:16]) ifFalse:[ |
2278 |
self syntaxError:'hex digit expected in string literal' |
|
3268 | 2279 |
position:(source position) to:(source position). |
1681 | 2280 |
]. |
2281 |
nextChar digitValue |
|
2282 |
]. |
|
2283 |
||
2284 |
ascii := fetchNext value. |
|
2285 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2286 |
||
2287 |
(aCharacter == $u ) ifTrue:[ |
|
2288 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
2289 |
ascii := (ascii bitShift:4) bitOr:(fetchNext value). |
|
1321 | 2290 |
]. |
2291 |
^ Character value:ascii. |
|
2292 |
]. |
|
2293 |
^ aCharacter |
|
2294 |
||
2295 |
" |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2296 |
ParserFlags allowExtendedSTXSyntax:true |
1321 | 2297 |
" |
2298 |
" |
|
1681 | 2299 |
'hello\nworld' |
2300 |
'hello\x0Dworld' |
|
2301 |
'hello\x08world' |
|
2302 |
'hello\ |
|
2303 |
\world' |
|
1321 | 2304 |
" |
1681 | 2305 |
" |
2306 |
ParserFlags allowExtendedSTXSyntax:false |
|
2307 |
" |
|
1321 | 2308 |
! |
2309 |
||
141 | 2310 |
ignoreErrors |
1365 | 2311 |
"return the flag which controls notification of errors" |
2312 |
||
2313 |
^ ignoreErrors |
|
2314 |
! |
|
2315 |
||
2316 |
ignoreErrors:aBoolean |
|
2317 |
"enable/disable notification of errors" |
|
2318 |
||
2319 |
ignoreErrors := aBoolean |
|
141 | 2320 |
! |
0 | 2321 |
|
141 | 2322 |
ignoreWarnings |
1365 | 2323 |
"return the flag which controls notification of warnings" |
2324 |
||
2325 |
^ ignoreWarnings |
|
2326 |
! |
|
2327 |
||
2328 |
ignoreWarnings:aBoolean |
|
2329 |
"enable/disable notification of warnings" |
|
2330 |
||
2331 |
ignoreWarnings := aBoolean |
|
141 | 2332 |
! |
0 | 2333 |
|
714 | 2334 |
isCommentCharacter:ch |
2335 |
"return true, if ch is the comment-start character. |
|
2336 |
Brought into a separate method to allow for easier subclassing" |
|
2337 |
||
2338 |
^ ch == $" |
|
2339 |
||
2340 |
"Created: / 14.5.1998 / 20:51:42 / cg" |
|
2341 |
"Modified: / 14.5.1998 / 20:53:01 / cg" |
|
2342 |
! |
|
2343 |
||
2983 | 2344 |
isDoIt |
2345 |
^ false |
|
2346 |
! |
|
2347 |
||
1722 | 2348 |
isSpecialOrExtendedSpecialCharacter:ch |
2027 | 2349 |
|code charType| |
2350 |
||
2351 |
code := ch codePoint. |
|
2352 |
code > typeArray size ifTrue:[^ false]. |
|
2353 |
||
2354 |
charType := typeArray at:code. |
|
1722 | 2355 |
^ (charType == #special) |
2356 |
or:[ (charType == #extendedSpecial) and:[parserFlags allowExtendedBinarySelectors] ] |
|
2290 | 2357 |
|
2358 |
" |
|
2359 |
self basicNew isSpecialOrExtendedSpecialCharacter:$- |
|
2360 |
" |
|
1722 | 2361 |
! |
2362 |
||
141 | 2363 |
notifying:anObject |
2364 |
"set the requestor to be notified" |
|
2365 |
||
2366 |
requestor := anObject |
|
426
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2367 |
! |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2368 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2369 |
setNameSpace:aNameSpace |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2370 |
"/ ignored here |
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2371 |
|
871231a532fc
remember nameSpace as scanned from directive
Claus Gittinger <cg@exept.de>
parents:
417
diff
changeset
|
2372 |
"Created: 8.11.1996 / 13:33:10 / cg" |
1247
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2373 |
! |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2374 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2375 |
setPackage:aNameSpace |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2376 |
"/ ignored here |
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2377 |
|
ce0d19140248
care for package directive (remember)
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
2378 |
"Created: 8.11.1996 / 13:33:10 / cg" |
1572 | 2379 |
! |
2380 |
||
2381 |
setSyntax:aSyntax |
|
141 | 2382 |
! ! |
2383 |
||
2384 |
!Scanner methodsFor:'reading next token'! |
|
2385 |
||
2484 | 2386 |
nextAssignmentArrow |
2387 |
"return a left-arrow" |
|
2388 |
||
2389 |
^ self nextToken:$_ |
|
2390 |
||
2391 |
"Created: / 25-03-2011 / 13:58:50 / cg" |
|
2392 |
! |
|
2393 |
||
141 | 2394 |
nextCharacter |
2395 |
"a $ has been read - return a character token" |
|
2396 |
||
1240 | 2397 |
|nextChar t| |
141 | 2398 |
|
0 | 2399 |
source next. |
141 | 2400 |
nextChar := source next. |
2401 |
nextChar notNil ifTrue:[ |
|
1240 | 2402 |
t := nextChar. |
2403 |
tokenType := #Character. |
|
141 | 2404 |
] ifFalse:[ |
1240 | 2405 |
t := nil. |
2406 |
tokenType := #EOF |
|
141 | 2407 |
]. |
1240 | 2408 |
tokenValue := token := t. |
0 | 2409 |
^ tokenType |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2410 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2411 |
"Modified: / 13.5.1998 / 15:09:50 / cg" |
0 | 2412 |
! |
2413 |
||
2414 |
nextColonOrAssign |
|
2415 |
"colon has been read - look for = to make it an assign" |
|
2416 |
||
3181 | 2417 |
|thirdChar| |
1722 | 2418 |
|
120 | 2419 |
"/ special kludge for identifier:= (without spaces inbetween) |
2420 |
"/ here we needed two characters lookahead after the identifier ... |
|
2421 |
||
2422 |
peekChar == $= ifTrue:[ |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2423 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2424 |
peekChar := nil. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2425 |
tokenType := token := #':='. |
1722 | 2426 |
|
2427 |
thirdChar := source peek. |
|
2428 |
thirdChar notNil ifTrue:[ |
|
2429 |
(self isSpecialOrExtendedSpecialCharacter:thirdChar) ifTrue:[ |
|
2430 |
||
2431 |
] |
|
2432 |
]. |
|
2433 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2434 |
^ tokenType |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2435 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2436 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2437 |
"/ special kludge for nameSpace:: (without spaces inbetween) |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2438 |
"/ here we needed two characters lookahead after the identifier ... |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2439 |
|
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2440 |
peekChar == $: ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2441 |
source next. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2442 |
peekChar := nil. |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2443 |
tokenType := token := #'::'. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2444 |
^ tokenType |
120 | 2445 |
]. |
2446 |
||
0 | 2447 |
(source nextPeek == $=) ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2448 |
source next. |
1004
708e1ca35c3b
dont unify := and _ tokens (otherwise, highlighter would not know
Claus Gittinger <cg@exept.de>
parents:
1002
diff
changeset
|
2449 |
tokenType := token := #':=' |
0 | 2450 |
] ifFalse:[ |
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2451 |
tokenType := token := $: |
0 | 2452 |
]. |
2453 |
^ tokenType |
|
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2454 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
2455 |
"Modified: / 13.5.1998 / 15:10:04 / cg" |
0 | 2456 |
! |
2457 |
||
1298 | 2458 |
nextExcla |
2459 |
"a !! has been read - return either |
|
2460 |
the !! binarySelector, |
|
2461 |
ExclaLeftParen (for '!!('), |
|
2462 |
ExclaLeftBrack (for '!!['), |
|
2463 |
ExclaLeftBrace (for '!!{') |
|
2464 |
" |
|
2465 |
||
2466 |
|nextChar| |
|
2467 |
||
2468 |
nextChar := source nextPeek. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2469 |
parserFlags allowExtendedSTXSyntax == true ifTrue:[ |
1298 | 2470 |
(nextChar == $( ) ifTrue:[ |
2471 |
source next. |
|
2472 |
token := '!!('. |
|
2473 |
tokenType := #ExclaLeftParen. |
|
2474 |
^ tokenType |
|
2475 |
]. |
|
2476 |
||
2477 |
(nextChar == $[ ) ifTrue:[ |
|
2478 |
source next. |
|
2479 |
token := '!!['. |
|
2480 |
tokenType := #ExclaLeftBrack. |
|
2481 |
^ tokenType |
|
2482 |
]. |
|
2483 |
||
2484 |
(nextChar == ${ ) ifTrue:[ |
|
2485 |
source next. |
|
2486 |
token := '!!{'. |
|
2487 |
tokenType := #ExclaLeftBrace. |
|
2488 |
^ tokenType |
|
2489 |
]. |
|
2490 |
]. |
|
2491 |
||
2492 |
"this allows excla to be used as binop - |
|
2493 |
I dont know, if this is correct ..." |
|
2494 |
||
1307
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2495 |
"/ tokenName := token := '!!'. |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2496 |
"/ tokenType := #BinaryOperator. |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2497 |
"/ ^ tokenType |
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2498 |
|
a91664d148ad
also allow multi-character binary selectors starting with excla
Claus Gittinger <cg@exept.de>
parents:
1303
diff
changeset
|
2499 |
^ self nextSpecialWith:$!!. |
1298 | 2500 |
! |
2501 |
||
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2502 |
nextExtendedSpecial:ch |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2503 |
parserFlags allowExtendedBinarySelectors ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2504 |
^ self nextSpecial |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2505 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2506 |
^ self invalidCharacter:source peek. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2507 |
! |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2508 |
|
141 | 2509 |
nextHash |
1226 | 2510 |
"a # has been read - return either |
2511 |
a symbol, |
|
2512 |
HashLeftParen (for '#('), |
|
2513 |
HashLeftBrack (for '#['), |
|
2514 |
HashLeftBrace (for '#{' and AllowQualifiedNames) |
|
2515 |
HashHashLeftParen (for '##(' and AllowDolphinExtensions) |
|
1292 | 2516 |
HashHashLeftBrack (for '##[' ) |
2517 |
HashHash (for '##' ) |
|
1226 | 2518 |
" |
1026 | 2519 |
|
1656 | 2520 |
|nextChar string allowUnderscoreInIdentifier| |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2521 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2522 |
allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier. |
0 | 2523 |
|
141 | 2524 |
nextChar := source nextPeek. |
2525 |
nextChar notNil ifTrue:[ |
|
500 | 2526 |
(nextChar == $( ) ifTrue:[ |
2527 |
source next. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2528 |
token := '#('. |
500 | 2529 |
tokenType := #HashLeftParen. |
2530 |
^ tokenType |
|
2531 |
]. |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
2532 |
|
500 | 2533 |
(nextChar == $[ ) ifTrue:[ |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
2534 |
"ST-80 & ST/X support Constant ByteArrays as #[...]" |
500 | 2535 |
source next. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2536 |
token := '#['. |
500 | 2537 |
tokenType := #HashLeftBrack. |
2538 |
^ tokenType |
|
2539 |
]. |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
2540 |
|
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
2541 |
(nextChar == ${ ) ifTrue:[ |
1290 | 2542 |
" #{ ... } is one of: |
2543 |
#{ Foo.Bar.Baz } VW3 and later qualified name |
|
2544 |
#{ xx-xx-xx-xx-...-xx } StAgents UUID |
|
2545 |
#{ URL } url object qualifier |
|
1074 | 2546 |
" |
1290 | 2547 |
source next. |
2548 |
token := '#{'. |
|
2549 |
tokenType := #HashLeftBrace. |
|
2550 |
^ tokenType |
|
2551 |
]. |
|
2552 |
||
500 | 2553 |
(nextChar == $' ) ifTrue:[ |
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
2554 |
"ST-80 and ST/X support arbitrary symbols as #'...'" |
1781 | 2555 |
self nextString:nextChar. |
3268 | 2556 |
self markSymbolFrom:tokenPosition to:(source position). |
1385
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
2557 |
tokenType == #EOF ifFalse:[ |
2987 | 2558 |
tokenValue isWideString ifTrue:[ |
1488
a6b8a7a14f40
error when a 2-byte symbol is encountered
Claus Gittinger <cg@exept.de>
parents:
1485
diff
changeset
|
2559 |
self syntaxError:'symbols which require 2-byte characters are not (yet) allowed' |
3268 | 2560 |
position:tokenPosition to:(source position). |
1488
a6b8a7a14f40
error when a 2-byte symbol is encountered
Claus Gittinger <cg@exept.de>
parents:
1485
diff
changeset
|
2561 |
]. |
1385
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
2562 |
tokenValue := token := tokenValue asSymbol. |
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
2563 |
tokenType := #Symbol. |
7cdbe857e075
handle missing closing quote in #'...'
Claus Gittinger <cg@exept.de>
parents:
1371
diff
changeset
|
2564 |
]. |
500 | 2565 |
^ tokenType |
2566 |
]. |
|
922
77c58cc5bebc
support for vw3 qualifiedNames
Claus Gittinger <cg@exept.de>
parents:
921
diff
changeset
|
2567 |
|
1226 | 2568 |
(nextChar == $#) ifTrue:[ |
1294 | 2569 |
nextChar := source nextPeek. |
1722 | 2570 |
nextChar == $( ifTrue:[ |
2571 |
parserFlags allowDolphinExtensions == true ifTrue:[ |
|
2712
eddb351cf9c2
comment/format in: #nextHash
Claus Gittinger <cg@exept.de>
parents:
2678
diff
changeset
|
2572 |
"dolphin does computed literals as ##( ... )" |
1226 | 2573 |
source next. |
2574 |
token := '##('. |
|
2575 |
tokenType := #HashHashLeftParen. |
|
2576 |
^ tokenType |
|
2577 |
]. |
|
1293 | 2578 |
]. |
1656 | 2579 |
|
1293 | 2580 |
nextChar == $[ ifTrue:[ |
2581 |
source next. |
|
1722 | 2582 |
token := '##['. |
1293 | 2583 |
tokenType := #HashHashLeftBrack. |
1291
917f975e3e7e
oops - HashLeftAngle was wrong.
Claus Gittinger <cg@exept.de>
parents:
1290
diff
changeset
|
2584 |
^ tokenType |
917f975e3e7e
oops - HashLeftAngle was wrong.
Claus Gittinger <cg@exept.de>
parents:
1290
diff
changeset
|
2585 |
]. |
1294 | 2586 |
|
1656 | 2587 |
parserFlags allowVisualAgeESSymbolLiterals == true ifTrue:[ |
2588 |
(self nextSymbolAfterHash) notNil ifTrue:[ |
|
2589 |
tokenType := #ESSymbol. |
|
2590 |
^ #ESSymbol |
|
2591 |
]. |
|
2592 |
(nextChar == $') ifTrue:[ |
|
2593 |
source next. |
|
1781 | 2594 |
self nextString:nextChar. |
1656 | 2595 |
tokenType := #ESSymbol. |
2596 |
^ #ESSymbol |
|
2597 |
]. |
|
2598 |
]. |
|
2599 |
||
1293 | 2600 |
token := '##'. |
2601 |
tokenType := #HashHash. |
|
2602 |
^ tokenType |
|
1226 | 2603 |
]. |
2604 |
||
1656 | 2605 |
(self nextSymbolAfterHash) notNil ifTrue:[ |
2606 |
^ #Symbol |
|
2607 |
]. |
|
2608 |
||
1722 | 2609 |
(self isSpecialOrExtendedSpecialCharacter:nextChar) ifTrue:[ |
500 | 2610 |
string := source next asString. |
2611 |
nextChar := source peek. |
|
2612 |
nextChar notNil ifTrue:[ |
|
1722 | 2613 |
(self isSpecialOrExtendedSpecialCharacter:nextChar) ifTrue:[ |
500 | 2614 |
source next. |
2615 |
string := string copyWith:nextChar |
|
2616 |
] |
|
2617 |
]. |
|
3268 | 2618 |
self markSymbolFrom:tokenPosition to:(source position). |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2619 |
tokenValue := token := string asSymbol. |
500 | 2620 |
tokenType := #Symbol. |
2621 |
^ tokenType |
|
2622 |
] |
|
0 | 2623 |
]. |
1298 | 2624 |
|
141 | 2625 |
"this allows hash to be used as binop - |
2626 |
I dont know, if this is correct ..." |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2627 |
tokenName := token := '#'. |
0 | 2628 |
tokenType := #BinaryOperator. |
2629 |
^ tokenType |
|
500 | 2630 |
|
1781 | 2631 |
"Modified: / 01-08-2006 / 14:57:19 / cg" |
2712
eddb351cf9c2
comment/format in: #nextHash
Claus Gittinger <cg@exept.de>
parents:
2678
diff
changeset
|
2632 |
"Modified (format): / 30-09-2011 / 12:23:04 / cg" |
0 | 2633 |
! |
2634 |
||
2635 |
nextId |
|
1026 | 2636 |
"no longer used here - remains for backwardCompatibility for |
2637 |
subclass users ... (sigh)" |
|
2638 |
||
0 | 2639 |
|nextChar string oldString |
2640 |
index "{ Class: SmallInteger }" |
|
2641 |
max "{ Class: SmallInteger }" | |
|
2642 |
||
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2643 |
nextChar := source peekOrNil. |
1470
62844fc53a87
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
2644 |
string := String uninitializedNew:20. |
0 | 2645 |
index := 0. |
2646 |
max := 10. |
|
3405 | 2647 |
[ |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2648 |
(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
|
2649 |
^ string copyTo:index |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2650 |
]. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2651 |
(index == max) ifTrue:[ |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2652 |
oldString := string. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2653 |
string := String basicNew:(max * 2). |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2654 |
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
|
2655 |
max := max * 2 |
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 := index + 1. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2658 |
string at:index put:nextChar. |
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2659 |
nextChar := source nextPeek |
3405 | 2660 |
] loop. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2661 |
|
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2662 |
"Modified: / 5.3.1998 / 02:53:57 / cg" |
0 | 2663 |
! |
2664 |
||
2665 |
nextIdentifier |
|
1510
875c90576897
Fix duplicate assignment to ActionArray for sh
Stefan Vogel <sv@exept.de>
parents:
1509
diff
changeset
|
2666 |
"an alpha character (or underscore if AllowUnderscore) has been read. |
1026 | 2667 |
Return the next identifier." |
2668 |
||
3449 | 2669 |
|nextChar string ok pos ch2 |
2670 |
allowUnderscoreInIdentifier allowDollarInIdentifier |
|
2671 |
allowNationalCharactersInIdentifier| |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2672 |
|
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2673 |
allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier. |
3449 | 2674 |
allowDollarInIdentifier := parserFlags allowDollarInIdentifier. |
2675 |
allowNationalCharactersInIdentifier := parserFlags allowNationalCharactersInIdentifier. |
|
0 | 2676 |
|
87 | 2677 |
hereChar == $_ ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2678 |
"/ |
708
11837544357d
made scanner tables instVars - for easier subclassability
Claus Gittinger <cg@exept.de>
parents:
707
diff
changeset
|
2679 |
"/ no need to check for allowUnderscoreInIdentifier here; |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2680 |
"/ could not arrive here if it was off |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2681 |
"/ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2682 |
nextChar := source nextPeek. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2683 |
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
|
2684 |
(nextChar notNil and:[ nextChar isLetterOrDigit or:[nextChar == $_]]) ifFalse:[ |
1261
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2685 |
"oops: a single underscore is an old-style assignement" |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2686 |
nextChar ~~ $: ifTrue:[ |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2687 |
self warnOldStyleAssignmentAt:tokenPosition. |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2688 |
tokenType := token := $_. |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2689 |
^ tokenType |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2690 |
] |
3de89ad9de69
allow oldStyleAssignment setting added
Claus Gittinger <cg@exept.de>
parents:
1247
diff
changeset
|
2691 |
]. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2692 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2693 |
string := '_'. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2694 |
self warnUnderscoreAt:tokenPosition. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2695 |
[nextChar == $_] whileTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2696 |
string := string copyWith:$_. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2697 |
nextChar := source nextPeek. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2698 |
]. |
1954
3c20721e963c
care for end-of-text when parsing a single underline identifier.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2699 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[ |
467
feaacb47b0b5
allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
2700 |
string := string , source nextAlphaNumericWord. |
feaacb47b0b5
allow degenerated keyword '_:'
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
2701 |
] |
87 | 2702 |
] ifFalse:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2703 |
string := source nextAlphaNumericWord "self nextId". |
87 | 2704 |
]. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2705 |
nextChar := source peekOrNil. |
87 | 2706 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2707 |
(((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
3449 | 2708 |
or:[((nextChar == $$ ) and:[allowDollarInIdentifier]) |
2709 |
or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]) ifTrue:[ |
|
3268 | 2710 |
pos := source position + 1. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2711 |
nextChar == $_ ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2712 |
self warnUnderscoreAt:pos. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2713 |
] ifFalse:[ |
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
2714 |
nextChar == $$ ifTrue:[ |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
2715 |
self warnDollarAt:pos. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
2716 |
] ifFalse:[ |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
2717 |
"/ self warnNationalCharacterAt:pos. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
2718 |
] |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2719 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2720 |
ok := true. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2721 |
[ok] whileTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2722 |
string := string copyWith:nextChar. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2723 |
nextChar := source nextPeek. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2724 |
nextChar isNil ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2725 |
ok := false |
608 | 2726 |
] ifFalse:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2727 |
(nextChar isLetterOrDigit) ifTrue:[ |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2728 |
string := string , source nextAlphaNumericWord. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2729 |
nextChar := source peekOrNil. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2730 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2731 |
ok := ((nextChar == $_) and:[allowUnderscoreInIdentifier]) |
3449 | 2732 |
or:[((nextChar == $$ ) and:[allowDollarInIdentifier]) |
2733 |
or:[(nextChar notNil and:[nextChar isNationalLetter]) and:[allowNationalCharactersInIdentifier]]]. |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2734 |
] |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2735 |
]. |
60 | 2736 |
]. |
2737 |
||
785
14d0ec37a754
added hook for subclasses which do not want to scan
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
2738 |
(nextChar == $: and:[scanColonAsKeyword]) ifTrue:[ |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2739 |
source next. |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2740 |
ch2 := source peekOrNil. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2741 |
"/ 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
|
2742 |
(ch2 == $=) ifFalse:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2743 |
(ch2 == $:) ifFalse:[ |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2744 |
tokenName := token := string copyWith:nextChar. |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2745 |
tokenType := #Keyword. |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2746 |
inArrayLiteral == true ifTrue:[ |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2747 |
(ch2 isLetter |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2748 |
or:[ch2 == $_ and:[allowUnderscoreInIdentifier]]) ifTrue:[ |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2749 |
"/ kludge: recurse to read the rest. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2750 |
self nextIdentifier. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2751 |
tokenName := token := (string copyWith:nextChar) , token. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2752 |
tokenType ~~ #Keyword ifTrue:[ |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2753 |
self syntaxError:'invalid keyword symbol in array constant' |
3268 | 2754 |
position:tokenPosition to:(source position). |
1202
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2755 |
]. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2756 |
tokenType := #Keyword. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2757 |
]. |
95abdd4272cd
scanning of keyword symbols in array consts fixed
Claus Gittinger <cg@exept.de>
parents:
1195
diff
changeset
|
2758 |
]. |
1104
0ffcaab55dbc
oops - nextIdentifier must return a tokenType
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
2759 |
^ tokenType |
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2760 |
]. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2761 |
peekChar := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2762 |
peekChar2 := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2763 |
] ifTrue:[ |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2764 |
peekChar := $:. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2765 |
peekChar2 := $=. |
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
2766 |
] |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2767 |
] ifFalse:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2768 |
(nextChar == $. and:[parserFlags allowQualifiedNames]) ifTrue:[ |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2769 |
"/ 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
|
2770 |
"/ make peekSym a #NameSpaceSeparator; otherwise a $. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2771 |
source next. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2772 |
ch2 := source peekOrNil. |
1029 | 2773 |
(ch2 notNil |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
2774 |
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
|
2775 |
peekChar := #'::'. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2776 |
] ifFalse:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2777 |
peekChar := $. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2778 |
]. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
2779 |
]. |
0 | 2780 |
]. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2781 |
|
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2782 |
nextChar == $- ifTrue:[ |
3268 | 2783 |
pos := source position + 1. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2784 |
self |
1395 | 2785 |
warnPossibleIncompatibility:'add spaces around ''-'' for compatibility with other systems' |
610 | 2786 |
position:pos to:pos. |
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 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
2789 |
tokenName := token := string. |
1026 | 2790 |
(self checkForKeyword:string) ifFalse:[ |
2791 |
tokenType := #Identifier. |
|
2792 |
]. |
|
0 | 2793 |
^ tokenType |
120 | 2794 |
|
1954
3c20721e963c
care for end-of-text when parsing a single underline identifier.
Claus Gittinger <cg@exept.de>
parents:
1949
diff
changeset
|
2795 |
"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
|
2796 |
"Modified: / 24-11-2006 / 10:38:47 / cg" |
0 | 2797 |
! |
2798 |
||
141 | 2799 |
nextMantissa:radix |
1026 | 2800 |
"read the mantissa of a radix number" |
2801 |
||
1351 | 2802 |
<resource: #obsolete> |
2803 |
||
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2804 |
^ (self nextMantissaAndScaledPartWithRadix:radix) first |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2805 |
! |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2806 |
|
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2807 |
nextMantissaAndScaledPartWithRadix:radix |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2808 |
"read the mantissa of a radix number. |
1430 | 2809 |
Since we dont know yet if this is for a Float, LongFloat or a FixedPoint, |
2810 |
return info which is useful for all: an array consisting of |
|
2811 |
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
|
2812 |
|
1972
f52b7e609f1f
common code with Number-reading
Claus Gittinger <cg@exept.de>
parents:
1971
diff
changeset
|
2813 |
^ Number readMantissaAndScaleFrom:source radix:radix |
141 | 2814 |
! |
2815 |
||
2816 |
nextNumber |
|
1026 | 2817 |
"scan a number; handles radix prefix, mantissa and exponent. |
1673 | 2818 |
Allows for e, d or q to be used as exponent limiter." |
1026 | 2819 |
|
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
2820 |
|pos1 nextChar value integerPart sign |
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
2821 |
expSign tokenRadix mantissaAndScaledPart d type exp scale| |
141 | 2822 |
|
2823 |
tokenRadix := 10. |
|
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
2824 |
sign := 1. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2825 |
type := #Integer. |
3268 | 2826 |
pos1 := source position + 1. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2827 |
|
141 | 2828 |
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
|
2829 |
nextChar := source peekOrNil. |
141 | 2830 |
(nextChar == $r) ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2831 |
tokenRadix := value. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2832 |
source next. |
820
5db3668f751d
syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents:
802
diff
changeset
|
2833 |
|
5db3668f751d
syntax error if radix is not in 2..36
Claus Gittinger <cg@exept.de>
parents:
802
diff
changeset
|
2834 |
(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
|
2835 |
self syntaxError:'bad radix (must be 2 .. 36)' |
3268 | 2836 |
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
|
2837 |
]. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2838 |
source peekOrNil == $- ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2839 |
source next. |
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
2840 |
sign := -1 |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2841 |
]. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2842 |
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
|
2843 |
nextChar := source peekOrNil. |
141 | 2844 |
]. |
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
|
2845 |
|
141 | 2846 |
(nextChar == $.) ifTrue:[ |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2847 |
nextChar := source nextPeek. |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2848 |
(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
|
2849 |
(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
|
2850 |
self warning:'float with radix > 14 - (e/E are valid digits; not exponent-leaders)' |
3268 | 2851 |
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
|
2852 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2853 |
mantissaAndScaledPart := self nextMantissaAndScaledPartWithRadix:tokenRadix. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2854 |
integerPart := value. |
1433 | 2855 |
value := integerPart + (mantissaAndScaledPart first). "could be a longFloat now" |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2856 |
type := #Float. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
2857 |
nextChar := source peekOrNil |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2858 |
] ifFalse:[ |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2859 |
('eEdDqQ' includes:nextChar) ifTrue:[ |
1339
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2860 |
"/ allow 5.e-3 - is this standard ? |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2861 |
|
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2862 |
] ifFalse:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2863 |
"/ nextChar == (Character cr) ifTrue:[ |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2864 |
"/ lineNr := lineNr + 1. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2865 |
"/ ]. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2866 |
nextChar := peekChar := $.. |
7dd363978456
start to migrate towards raising ParseError.
Claus Gittinger <cg@exept.de>
parents:
1321
diff
changeset
|
2867 |
] |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2868 |
] |
141 | 2869 |
]. |
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
|
2870 |
|
1026 | 2871 |
('eEdDqQ' includes:nextChar) ifTrue:[ |
1430 | 2872 |
(nextChar == $q or:[nextChar == $Q]) ifTrue:[ |
2873 |
value := value asLongFloat |
|
2874 |
] ifFalse:[ |
|
2875 |
value := value asFloat. |
|
2876 |
]. |
|
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2877 |
type := #Float. |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2878 |
nextChar := source nextPeek. |
982
f0cc45f113b3
exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents:
947
diff
changeset
|
2879 |
(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
|
2880 |
expSign := 1. |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2881 |
(nextChar == $+) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2882 |
nextChar := source nextPeek |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2883 |
] ifFalse:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2884 |
(nextChar == $-) ifTrue:[ |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2885 |
nextChar := source nextPeek. |
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 |
] |
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2888 |
]. |
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
2889 |
exp := (Integer readFrom:source) * expSign. |
1430 | 2890 |
value := value * ((value class unity * tokenRadix) raisedToInteger:exp). |
983 | 2891 |
nextChar := source peek. |
982
f0cc45f113b3
exponent after [eE] is always taken base 10.
Claus Gittinger <cg@exept.de>
parents:
947
diff
changeset
|
2892 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2893 |
] ifFalse:[ |
1430 | 2894 |
value isLimitedPrecisionReal ifTrue:[ |
2895 |
"/ no type specified - makes it a float |
|
2896 |
value := value asFloat. |
|
2897 |
]. |
|
2898 |
||
1673 | 2899 |
parserFlags allowFixedPointLiterals == true ifTrue:[ |
1676 | 2900 |
"/ ScaledDecimal numbers |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2901 |
('s' includes:nextChar) ifTrue:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2902 |
nextChar := source nextPeek. |
1678 | 2903 |
|
2904 |
(nextChar notNil and:[(nextChar isDigit)]) ifTrue:[ |
|
2905 |
scale := (Integer readFrom:source). |
|
2906 |
]. |
|
2907 |
||
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2908 |
mantissaAndScaledPart isNil ifTrue:[ |
1678 | 2909 |
value := value asFixedPoint:(scale ? 0) |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2910 |
] ifFalse:[ |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2911 |
d := 10 raisedTo:(mantissaAndScaledPart last). |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2912 |
value := FixedPoint |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2913 |
numerator:((integerPart * d) + mantissaAndScaledPart second) |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2914 |
denominator:d |
1678 | 2915 |
scale:(scale ? mantissaAndScaledPart last). |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2916 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2917 |
type := #FixedPoint. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2918 |
self |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2919 |
warnPossibleIncompatibility:'fixedPoint literal might be incompatibile with other systems' |
3268 | 2920 |
position:pos1 to:source position + 1. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2921 |
]. |
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2922 |
]. |
141 | 2923 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2924 |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2925 |
nextChar == $- ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2926 |
self |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2927 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with other systems' |
3268 | 2928 |
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
|
2929 |
]. |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
2930 |
|
1679
c568383eb5ec
reading signed radix numbers
Claus Gittinger <cg@exept.de>
parents:
1678
diff
changeset
|
2931 |
tokenValue := token := value * sign. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2932 |
tokenType := type. |
1596 | 2933 |
(tokenValue isLimitedPrecisionReal) ~~ (tokenType == #Float) ifTrue:[ |
2127
2e29f839edff
Change #halt: to #shouldImplement or #assert:
Stefan Vogel <sv@exept.de>
parents:
2122
diff
changeset
|
2934 |
self shouldImplement. |
1596 | 2935 |
]. |
1347
6168b045f2ef
preps for fixedPoint literals
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
2936 |
|
671 | 2937 |
"/ self markConstantFrom:tokenPosition to:(source position - 1). |
141 | 2938 |
^ tokenType |
313
ee72a11af9a2
handle trailing 'd' after a float (ST-80 compatible Doubles)
Claus Gittinger <cg@exept.de>
parents:
311
diff
changeset
|
2939 |
|
671 | 2940 |
"Modified: / 1.4.1998 / 13:06:28 / cg" |
141 | 2941 |
! |
2942 |
||
0 | 2943 |
nextPrimitive |
1026 | 2944 |
"scan an inline C-primitive." |
2945 |
||
0 | 2946 |
|nextChar inPrimitive string |
2947 |
index "{ Class: SmallInteger }" |
|
2948 |
len "{ Class: SmallInteger }" | |
|
2949 |
||
2950 |
nextChar := source nextPeek. |
|
1302 | 2951 |
(nextChar == ${) ifFalse:[ |
2952 |
^ self nextSpecialWith:$% |
|
2953 |
]. |
|
2954 |
||
0 | 2955 |
string := String new:500. |
2956 |
len := 500. |
|
2957 |
index := 1. |
|
1302 | 2958 |
nextChar := source nextPeek. |
2959 |
inPrimitive := true. |
|
2960 |
[inPrimitive] whileTrue:[ |
|
2961 |
[nextChar == $%] whileFalse:[ |
|
2962 |
nextChar isNil ifTrue:[ |
|
2963 |
self syntaxError:'unterminated primitive' |
|
3268 | 2964 |
position:tokenPosition to:source position + 1. |
1302 | 2965 |
^ #Error |
2966 |
]. |
|
2967 |
string at:index put:nextChar. |
|
2968 |
(index == len) ifTrue:[ |
|
2969 |
string := string , (String new:len). |
|
2970 |
len := len * 2 |
|
505
793f88ee6269
handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
2971 |
]. |
1302 | 2972 |
index := index + 1. |
2973 |
nextChar := source next |
|
505
793f88ee6269
handle end of input while scanning a primitive
Claus Gittinger <cg@exept.de>
parents:
500
diff
changeset
|
2974 |
]. |
1302 | 2975 |
(source peekOrNil == $}) ifTrue:[ |
2976 |
inPrimitive := false |
|
2977 |
] ifFalse:[ |
|
2978 |
string at:index put:nextChar. |
|
2979 |
(index == len) ifTrue:[ |
|
2980 |
string := string , (String new:len). |
|
2981 |
len := len * 2 |
|
2982 |
]. |
|
2983 |
index := index + 1. |
|
2984 |
nextChar := source next |
|
2985 |
] |
|
0 | 2986 |
]. |
1302 | 2987 |
source next. |
2988 |
tokenValue := token := string copyTo:(index - 1). |
|
2989 |
tokenType := #Primitive. |
|
2990 |
lineNr := lineNr + (tokenValue occurrencesOf:(Character cr)). |
|
2991 |
^ tokenType |
|
0 | 2992 |
! |
2993 |
||
141 | 2994 |
nextSpecial |
2995 |
"a special character has been read, look for another one. |
|
2996 |
also -number is handled here" |
|
2997 |
||
1302 | 2998 |
|firstChar| |
0 | 2999 |
|
141 | 3000 |
firstChar := source next. |
1302 | 3001 |
^ self nextSpecialWith:firstChar |
3002 |
! |
|
3003 |
||
3004 |
nextSpecialWith:firstChar |
|
3005 |
"a special character has been read, look for another one. |
|
3006 |
also -number is handled here" |
|
3007 |
||
2155 | 3008 |
|secondChar thirdChar fourthChar string p| |
1302 | 3009 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
3010 |
secondChar := source peekOrNil. |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
3011 |
((firstChar == $-) and:[secondChar notNil]) ifTrue:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3012 |
secondChar isDigit ifTrue:[ |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3013 |
self nextNumber. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3014 |
tokenValue := token := tokenValue negated. |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3015 |
^ tokenType |
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3016 |
] |
0 | 3017 |
]. |
141 | 3018 |
string := firstChar asString. |
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3019 |
|
2155 | 3020 |
"/ changed: do not allow second char to be a hash |
3021 |
"/ unless the first is also. |
|
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3022 |
secondChar == $# ifTrue:[ |
2155 | 3023 |
(parserFlags allowHashAsBinarySelector |
3024 |
and:[firstChar == $#]) ifFalse:[ |
|
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3025 |
tokenName := token := string. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3026 |
tokenType := #BinaryOperator. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3027 |
^ tokenType |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3028 |
]. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3029 |
]. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3030 |
|
141 | 3031 |
secondChar notNil ifTrue:[ |
2290 | 3032 |
(secondChar == $-) ifTrue:[ |
3033 |
"special- look if minus belongs to number following" |
|
3268 | 3034 |
p := source position. |
2290 | 3035 |
source next. |
3036 |
thirdChar := source peekOrNil. |
|
3268 | 3037 |
source position:p. |
2290 | 3038 |
(thirdChar notNil and:[thirdChar isDigit]) ifTrue:[ |
3039 |
tokenName := token := string. |
|
3040 |
tokenType := #BinaryOperator. |
|
3041 |
self |
|
2291 | 3042 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with stc and other ST systems' |
3268 | 3043 |
position:p+1 |
3044 |
to:p+1. |
|
2290 | 3045 |
^ tokenType |
3046 |
] |
|
3047 |
]. |
|
1722 | 3048 |
(self isSpecialOrExtendedSpecialCharacter:secondChar) ifTrue:[ |
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3049 |
source next. |
1302 | 3050 |
string := string copyWith:secondChar. |
3051 |
||
3052 |
thirdChar := source peekOrNil. |
|
3053 |
thirdChar notNil ifTrue:[ |
|
1722 | 3054 |
(self isSpecialOrExtendedSpecialCharacter:thirdChar) ifTrue:[ |
1302 | 3055 |
(thirdChar == $-) ifTrue:[ |
3056 |
"special- look if minus belongs to number following" |
|
3268 | 3057 |
p := source position. |
1302 | 3058 |
source next. |
3059 |
fourthChar := source peekOrNil. |
|
3268 | 3060 |
source position:p. |
1302 | 3061 |
fourthChar isDigit ifTrue:[ |
3062 |
tokenName := token := string. |
|
3063 |
tokenType := #BinaryOperator. |
|
3064 |
self |
|
2291 | 3065 |
warnPossibleIncompatibility:'add a space before ''-'' for compatibility with stc and other ST systems' |
3268 | 3066 |
position:p+1 |
3067 |
to:p+1. |
|
1302 | 3068 |
^ tokenType |
3069 |
] |
|
3070 |
]. |
|
3071 |
source next. |
|
3072 |
string := string copyWith:thirdChar. |
|
3073 |
]. |
|
3074 |
]. |
|
526
adb8aed3a691
added compatibility warnings for '-' without whitespace
Claus Gittinger <cg@exept.de>
parents:
505
diff
changeset
|
3075 |
]. |
141 | 3076 |
]. |
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3077 |
tokenName := token := string. |
45 | 3078 |
tokenType := #BinaryOperator. |
3 | 3079 |
^ tokenType |
241
418eb41350d3
no debugger when parsing '-' (which is wrong anyway ...)
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
3080 |
|
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
3081 |
"Modified: / 5.3.1998 / 02:54:54 / cg" |
0 | 3082 |
! |
3083 |
||
1781 | 3084 |
nextString:delimiter |
1026 | 3085 |
"a single quote has been scanned; scan the string (caring for doubled quotes" |
3086 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3087 |
|nextChar string pos |
0 | 3088 |
index "{ Class: SmallInteger }" |
3089 |
len "{ Class: SmallInteger }" |
|
1321 | 3090 |
inString peekChar| |
0 | 3091 |
|
1470
62844fc53a87
String new -> uninitializedNew: / basicNew:
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
3092 |
string := String uninitializedNew:20. |
0 | 3093 |
len := 20. |
3094 |
index := 1. |
|
3268 | 3095 |
pos := source position + 1. |
0 | 3096 |
source next. |
3097 |
nextChar := source next. |
|
3098 |
inString := true. |
|
3099 |
||
3100 |
[inString] whileTrue:[ |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3101 |
nextChar isNil ifTrue:[ |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3102 |
self syntaxError:'unexpected end-of-input in String' |
3268 | 3103 |
position:pos to:(source position). |
3104 |
self markStringFrom:pos to:source position. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3105 |
token := nil. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3106 |
tokenType := #EOF. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3107 |
^ tokenType |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3108 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3109 |
(nextChar == Character cr) ifTrue:[ |
610 | 3110 |
lineNr := lineNr + 1 |
1321 | 3111 |
] ifFalse:[ |
1781 | 3112 |
(nextChar == delimiter) ifTrue:[ |
3113 |
(source peekOrNil == delimiter) ifTrue:[ |
|
1321 | 3114 |
source next |
3115 |
] ifFalse:[ |
|
3116 |
inString := false |
|
3117 |
] |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3118 |
] ifFalse:[ |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3119 |
parserFlags allowExtendedSTXSyntax == true ifTrue:[ |
1681 | 3120 |
(nextChar == $\) ifTrue:[ |
1321 | 3121 |
peekChar := source peekOrNil. |
3122 |
peekChar notNil ifTrue:[ |
|
3123 |
source next. |
|
3124 |
nextChar := self escapeCharacterFor:peekChar. |
|
3125 |
] |
|
3126 |
] |
|
3127 |
] |
|
3128 |
]. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3129 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3130 |
inString ifTrue:[ |
1321 | 3131 |
nextChar notNil ifTrue:[ |
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
3132 |
nextChar codePoint > 255 ifTrue:[ |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
3133 |
string bitsPerCharacter < nextChar bitsPerCharacter ifTrue:[ |
3362 | 3134 |
nextChar codePoint > 16rFFFF ifTrue:[ |
3135 |
string := string asUnicode32String |
|
3136 |
] ifFalse:[ |
|
3137 |
string := string asUnicode16String. |
|
3138 |
]. |
|
1485 | 3139 |
]. |
3140 |
]. |
|
1321 | 3141 |
string at:index put:nextChar. |
3142 |
(index == len) ifTrue:[ |
|
1485 | 3143 |
string := string , (string species new:len). |
1321 | 3144 |
len := len * 2 |
3145 |
]. |
|
3146 |
index := index + 1. |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3147 |
]. |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3148 |
nextChar := source next |
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3149 |
] |
0 | 3150 |
]. |
661 | 3151 |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3152 |
tokenValue := token := string copyTo:(index - 1). |
0 | 3153 |
tokenType := #String. |
3154 |
^ tokenType |
|
546
db5ce842f64f
added #scanTokens for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
526
diff
changeset
|
3155 |
|
1781 | 3156 |
"Created: / 01-08-2006 / 14:56:07 / cg" |
1856
209089a85ed3
error messages shortened and cleanup
Claus Gittinger <cg@exept.de>
parents:
1781
diff
changeset
|
3157 |
"Modified: / 22-08-2006 / 14:10:26 / cg" |
141 | 3158 |
! |
3159 |
||
1656 | 3160 |
nextSymbolAfterHash |
3161 |
"helper: a # has been read - return #Symbol token or nil" |
|
3162 |
||
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3163 |
|nextChar string part isNameSpaceSymbol allowUnderscoreInIdentifier |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3164 |
allowPeriodInSymbol| |
1656 | 3165 |
|
3166 |
nextChar := source peek. |
|
3167 |
nextChar isNil ifTrue:[^ nil]. |
|
3168 |
||
3169 |
allowUnderscoreInIdentifier := parserFlags allowUnderscoreInIdentifier. |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3170 |
allowPeriodInSymbol := parserFlags allowPeriodInSymbol. |
1656 | 3171 |
isNameSpaceSymbol := false. |
3172 |
||
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3173 |
nextChar isLetter ifFalse:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3174 |
((nextChar == $_) and:[allowUnderscoreInIdentifier]) ifFalse:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3175 |
((nextChar == $.) and:[allowPeriodInSymbol]) ifFalse:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3176 |
^ nil |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3177 |
] |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3178 |
] |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3179 |
]. |
1656 | 3180 |
|
3181 |
string := ''. |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3182 |
[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3183 |
nextChar notNil |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3184 |
and:[nextChar isLetterOrDigit |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3185 |
or:[(nextChar == $_ and:[allowUnderscoreInIdentifier]) |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3186 |
or:[nextChar == $. and:[allowPeriodInSymbol and:[source peek isLetter]]]] |
1656 | 3187 |
] |
3188 |
] whileTrue:[ |
|
3189 |
nextChar == $_ ifTrue:[ |
|
3190 |
part := nil. |
|
3191 |
] ifFalse:[ |
|
2181 | 3192 |
(allowPeriodInSymbol and:[nextChar == $.]) ifTrue:[ |
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3193 |
part := nil. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3194 |
] ifFalse:[ |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3195 |
part := source nextAlphaNumericWord. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3196 |
] |
1656 | 3197 |
]. |
3198 |
part notNil ifTrue:[ |
|
3199 |
string := string , part. |
|
3200 |
]. |
|
3201 |
nextChar := source peek. |
|
3202 |
||
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3203 |
((allowUnderscoreInIdentifier and:[nextChar == $_]) |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3204 |
or:[ allowPeriodInSymbol and:[nextChar == $.] ]) ifTrue:[ |
1656 | 3205 |
nextChar == $_ ifTrue:[ |
3268 | 3206 |
self warnUnderscoreAt:source position + 1. |
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3207 |
] ifFalse:[ |
3268 | 3208 |
self warnPeriodAt:source position + 1. |
1656 | 3209 |
]. |
2181 | 3210 |
[(nextChar == $_) or:[(allowPeriodInSymbol and:[nextChar == $.])]] whileTrue:[ |
1656 | 3211 |
string := string copyWith:nextChar. |
3212 |
nextChar := source nextPeek. |
|
3213 |
(nextChar notNil and:[nextChar isLetterOrDigit]) ifTrue:[ |
|
3214 |
string := string , source nextAlphaNumericWord. |
|
3215 |
nextChar := source peek. |
|
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3216 |
] ifFalse:[ |
2181 | 3217 |
(allowPeriodInSymbol and:[string last == $.]) ifTrue:[ |
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3218 |
peekChar := nextChar. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3219 |
nextChar := $.. |
3153
bf5cbbed06d5
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
3144
diff
changeset
|
3220 |
string := string copyButLast:1. |
2180
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3221 |
tokenValue := token := string asSymbol. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3222 |
tokenType := #Symbol. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3223 |
^ tokenType |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3224 |
]. |
891d45ffad68
allowPeriodInSymbol - to read old st80/squeak code
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
3225 |
]. |
1656 | 3226 |
]. |
3227 |
]. |
|
3228 |
(nextChar == $:) ifFalse:[ |
|
3268 | 3229 |
self markSymbolFrom:tokenPosition to:(source position). |
1656 | 3230 |
tokenValue := token := string asSymbol. |
3231 |
tokenType := #Symbol. |
|
3232 |
^ tokenType |
|
3233 |
]. |
|
3234 |
string := string copyWith:nextChar. |
|
3235 |
nextChar := source nextPeek. |
|
3236 |
parserFlags allowLiteralNameSpaceSymbols ifTrue:[ |
|
3237 |
(nextChar == $:) ifTrue:[ |
|
3238 |
string := string copyWith:nextChar. |
|
3239 |
nextChar := source nextPeek. |
|
3240 |
isNameSpaceSymbol := true. |
|
3241 |
]. |
|
3242 |
]. |
|
3243 |
]. |
|
3244 |
tokenValue := token := string asSymbol. |
|
3245 |
tokenType := #Symbol. |
|
3246 |
^ tokenType |
|
3247 |
! |
|
3248 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3249 |
nextToken |
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3250 |
"return the next token from the source-stream" |
141 | 3251 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3252 |
|skipping actionBlock v ch tok| |
141 | 3253 |
|
3268 | 3254 |
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
|
3255 |
|
3405 | 3256 |
[ |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3257 |
peekChar notNil ifTrue:[ |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3258 |
"/ kludge - should be called peekSym. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3259 |
"/ 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
|
3260 |
peekChar isSymbol ifTrue:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3261 |
token := nil. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3262 |
tokenType := peekChar. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3263 |
peekChar := nil. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3264 |
^ tokenType |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3265 |
]. |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3266 |
|
3418 | 3267 |
(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
|
3268 |
peekChar == (Character cr) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3269 |
lineNr := lineNr + 1. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3270 |
]. |
2481 | 3271 |
hereChar := peekChar. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3272 |
peekChar := peekChar2. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3273 |
peekChar2 := nil. |
3204 | 3274 |
(hereChar == Character cr) ifTrue:[ |
3275 |
(self eolIsWhiteSpace) ifFalse:[ |
|
3276 |
token := nil. |
|
3277 |
tokenType := #EOL. |
|
3278 |
^ tokenType |
|
3279 |
]. |
|
2481 | 3280 |
]. |
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
|
3281 |
]. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3282 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3283 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3284 |
peekChar notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3285 |
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
|
3286 |
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
|
3287 |
peekChar2 := nil. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3288 |
hereChar := nil. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3289 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3290 |
skipping := true. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3291 |
[skipping] whileTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3292 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3293 |
outStream notNil ifTrue:[ |
1497 | 3294 |
[ |
2481 | 3295 |
hereChar := source peekOrNil. |
3296 |
(hereChar == Character space) |
|
3297 |
or:[hereChar isSeparator] |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3298 |
] whileTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3299 |
source next. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3300 |
outStream space. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3301 |
outCol := outCol + 1. |
2481 | 3302 |
hereChar == (Character cr) ifTrue:[ |
3303 |
self eolIsWhiteSpace ifFalse:[ |
|
3204 | 3304 |
source isPositionable ifTrue:[ |
3268 | 3305 |
tokenPosition := source position. |
3204 | 3306 |
]. |
2481 | 3307 |
token := nil. |
3308 |
tokenType := #EOL. |
|
3309 |
^ tokenType |
|
3310 |
]. |
|
3311 |
] |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3312 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3313 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3314 |
hereChar := source skipSeparatorsExceptCR. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3315 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3316 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3317 |
hereChar == (Character cr) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3318 |
lineNr := lineNr + 1. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3319 |
source next. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3320 |
outStream notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3321 |
outStream cr. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3322 |
outCol := 1 |
2481 | 3323 |
]. |
3324 |
self eolIsWhiteSpace ifFalse:[ |
|
3204 | 3325 |
source isPositionable ifTrue:[ |
3268 | 3326 |
tokenPosition := source position. |
3204 | 3327 |
]. |
2481 | 3328 |
token := nil. |
3329 |
tokenType := #EOL. |
|
3330 |
^ tokenType |
|
3331 |
]. |
|
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3332 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3333 |
hereChar == (Character return) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3334 |
outStream notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3335 |
outStream nextPut:hereChar. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3336 |
outCol := 1 |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3337 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3338 |
source next. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3339 |
] ifFalse:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3340 |
(self isCommentCharacter:hereChar) ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3341 |
"start of a comment" |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3342 |
|
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3343 |
self skipComment. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3344 |
hereChar := source peekOrNil. |
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 |
skipping := false |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3347 |
] |
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 |
] |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3350 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3351 |
hereChar isNil ifTrue:[ |
3204 | 3352 |
source isPositionable ifTrue:[ |
3268 | 3353 |
tokenPosition := source position + 1. |
3204 | 3354 |
]. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3355 |
token := nil. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3356 |
tokenType := #EOF. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3357 |
^ tokenType |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3358 |
]. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3359 |
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
|
3360 |
]. |
2134
4f42568104c5
handle non-positionable streams
Claus Gittinger <cg@exept.de>
parents:
2127
diff
changeset
|
3361 |
source isPositionable ifTrue:[ |
3268 | 3362 |
tokenPosition := source position + 1. |
2134
4f42568104c5
handle non-positionable streams
Claus Gittinger <cg@exept.de>
parents:
2127
diff
changeset
|
3363 |
]. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3364 |
tokenLineNr := lineNr. |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3365 |
|
1489
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
3366 |
(v := ch codePoint) == 0 ifTrue:[ |
b844ef2acd37
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
1488
diff
changeset
|
3367 |
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
|
3368 |
]. |
1483 | 3369 |
v <= 16rFF ifTrue:[ |
3370 |
actionBlock := actionArray at:v. |
|
2484 | 3371 |
] ifFalse:[ |
3372 |
actionBlock := unicodeActions at:v ifAbsent:nil |
|
1483 | 3373 |
]. |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3374 |
actionBlock notNil ifTrue:[ |
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3375 |
tok := actionBlock value:self value:ch. |
1027
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3376 |
tok notNil ifTrue:[ |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3377 |
^ tok |
c944d9be2a69
silently scan Foo.Bar as Foo::Bar,
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
3378 |
]. |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3379 |
"/ 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
|
3380 |
] ifFalse:[ |
1705
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3381 |
(ch isNationalLetter and:[parserFlags allowNationalCharactersInIdentifier]) ifTrue:[ |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3382 |
tok := self nextIdentifier. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3383 |
tok notNil ifTrue:[ |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3384 |
^ tok |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3385 |
]. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3386 |
] ifFalse:[ |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3387 |
^ self invalidCharacter:ch. |
19fff84a354a
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1681
diff
changeset
|
3388 |
] |
793
3ee3ebe0145e
allow for action to skip something and continue in nextToken
Claus Gittinger <cg@exept.de>
parents:
785
diff
changeset
|
3389 |
] |
3405 | 3390 |
] 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
|
3391 |
|
2481 | 3392 |
"Modified: / 13-09-1995 / 12:56:14 / claus" |
2484 | 3393 |
"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
|
3394 |
"Modified: / 27-07-2011 / 15:36:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
141 | 3395 |
! |
3396 |
||
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3397 |
nextToken:aCharacter |
1026 | 3398 |
"return a character token" |
3399 |
||
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
3400 |
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
|
3401 |
hereChar notNil ifTrue:[source next]. |
141 | 3402 |
^ 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
|
3403 |
|
707
2fe4b3a7708a
extracted keyword detection into a separate method for easier
Claus Gittinger <cg@exept.de>
parents:
671
diff
changeset
|
3404 |
"Modified: / 13.5.1998 / 15:10:23 / cg" |
141 | 3405 |
! |
3406 |
||
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3407 |
nextUnderline |
3380 | 3408 |
"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
|
3409 |
|
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3410 |
parserFlags allowUnderscoreInIdentifier ifTrue:[ |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3411 |
^ self nextIdentifier |
1636
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3412 |
]. |
98afdcdacde8
compilerflags separated into ParserFlags.
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
3413 |
^ self nextToken:$_ |
1501
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3414 |
! |
ca87aed7eb82
allowUnderline etc. are inst-flags
Claus Gittinger <cg@exept.de>
parents:
1497
diff
changeset
|
3415 |
|
264
f10298cba622
oops - corrupted version checked in
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
3416 |
skipComment |
2983 | 3417 |
"skip over a comment; handles ST/X eol comments (quote-slash) |
3418 |
and multiline-delimiter comment (quote-less-less)." |
|
3419 |
||
3420 |
|commentStream commentType commentText startPos endPos stillInComment anyNonBlank |
|
3454 | 3421 |
delimiter delimiter2 line| |
1653 | 3422 |
|
3423 |
anyNonBlank := false. |
|
141 | 3424 |
|
3425 |
saveComments ifTrue:[ |
|
2148
2b415d61c2f3
care for unicode in skipComment
Claus Gittinger <cg@exept.de>
parents:
2146
diff
changeset
|
3426 |
commentStream := CharacterWriteStream on:''. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3427 |
self beginComment. |
141 | 3428 |
]. |
3429 |
||
3430 |
outStream notNil ifTrue:[ |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3431 |
outStream nextPut:Character doubleQuote. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3432 |
outCol := outCol + 1 |
141 | 3433 |
]. |
3434 |
||
3268 | 3435 |
startPos := source position + 1. |
141 | 3436 |
source next. |
656
e4249b285fd8
using #peekOrNil makes it some 10% faster when scanning
Claus Gittinger <cg@exept.de>
parents:
650
diff
changeset
|
3437 |
hereChar := source peekOrNil. |
2983 | 3438 |
commentType := #regularComment. |
141 | 3439 |
|
3440 |
" |
|
3441 |
special ST/X addition: |
|
3442 |
a $/ right after the initial double quote makes it an up-to-end-of-line comment, |
|
3443 |
which is very useful to comment out parts of filed-in source code. |
|
3312 | 3444 |
Since this is non-standard, you loose compatibility with other Smalltalks, if you use it. |
3445 |
(however, it is so convenient - I don't want to miss it) |
|
3446 |
" |
|
1707
28a94a1701c2
more support for filein of ST/V code
Claus Gittinger <cg@exept.de>
parents:
1705
diff
changeset
|
3447 |
(hereChar == $/ and:[parserFlags allowSTXEOLComments]) ifTrue:[ |
648 | 3448 |
hereChar := source nextPeek. |
2138 | 3449 |
|
3450 |
self skipToEndOfLineRememberingIn:commentStream. |
|
3268 | 3451 |
endPos := source position. |
3452 |
self markCommentFrom:startPos to:endPos+1. |
|
2138 | 3453 |
commentType := #eolComment. |
3268 | 3454 |
self warnSTXSpecialCommentAt:startPos to:endPos. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3455 |
outStream notNil ifTrue:[ |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3456 |
outStream cr. |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3457 |
outCol := 1 |
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3458 |
]. |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3459 |
"skip cr" |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3460 |
source next. |
141 | 3461 |
] ifFalse:[ |
2983 | 3462 |
(hereChar == $< and:[parserFlags allowSTXDelimiterComments]) ifTrue:[ |
3463 |
hereChar := source nextPeek. |
|
3464 |
(hereChar == $<) ifTrue:[ |
|
3312 | 3465 |
" |
3466 |
another special ST/X addition: |
|
3467 |
a << right after the initial double quote makes it a token delimited comment, |
|
3468 |
which continues up to a line consisting of the token alone. |
|
3469 |
This is very useful to comment out which contain any other type of comment. |
|
3470 |
Since this is non-standard, you loose compatibility with other Smalltalks, if you use it. |
|
3471 |
" |
|
2983 | 3472 |
commentStream notNil ifTrue:[ |
3381 | 3473 |
commentStream nextPutAll:'<<' |
1653 | 3474 |
]. |
2983 | 3475 |
hereChar := source nextPeek. |
3476 |
delimiter := String streamContents:[:s | self skipToEndOfLineRememberingIn:s]. |
|
3477 |
delimiter withoutSeparators isEmpty ifTrue:[ |
|
3478 |
self parseError:'invalid delimiter in comment' |
|
3479 |
]. |
|
3480 |
hereChar == Character cr ifTrue:[ |
|
3481 |
hereChar := source nextPeek. |
|
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3482 |
]. |
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3483 |
commentStream notNil ifTrue:[ |
2983 | 3484 |
commentStream nextPutLine:delimiter |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3485 |
]. |
3454 | 3486 |
delimiter2 := delimiter,'>>'. "/ to allow delimiter>>" |
2983 | 3487 |
stillInComment := true. |
3488 |
[stillInComment] whileTrue:[ |
|
3489 |
line := String streamContents:[:s | self skipToEndOfLineRememberingIn:s]. |
|
3490 |
commentStream notNil ifTrue:[ |
|
3491 |
commentStream nextPutLine:line |
|
3492 |
]. |
|
3493 |
hereChar == Character cr ifTrue:[ |
|
3494 |
hereChar := source nextPeek. |
|
3495 |
]. |
|
3454 | 3496 |
stillInComment := hereChar notNil |
3497 |
and:[ ((line = delimiter) or:[ line startsWith:delimiter2 ]) not ]. |
|
2983 | 3498 |
]. |
3454 | 3499 |
hereChar isNil ifTrue:[ |
3500 |
self markCommentFrom:startPos to:(source collectionSize). |
|
3501 |
self warning:'unclosed comment' position:startPos to:(source position + 1) |
|
3502 |
]. |
|
3503 |
self markCommentFrom:startPos to:(source position + 1). |
|
2983 | 3504 |
commentType := #delimiterComment. |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3505 |
] ifFalse:[ |
2983 | 3506 |
commentStream notNil ifTrue:[ |
3381 | 3507 |
commentStream nextPut:$< |
1355
39aba48520ed
scan comments which include "" as a single big comment
Claus Gittinger <cg@exept.de>
parents:
1351
diff
changeset
|
3508 |
]. |
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3509 |
]. |
2983 | 3510 |
]. |
3511 |
||
3512 |
(commentType == #regularComment) ifTrue:[ |
|
3513 |
hereChar == ${ ifTrue:[ |
|
3514 |
" |
|
3515 |
special ST/X addition: |
|
3516 |
a ${ right after the initial double quote starts a directive |
|
3517 |
" |
|
3518 |
self parseDirective |
|
460
c023e3713433
handle identifier in directives;
Claus Gittinger <cg@exept.de>
parents:
453
diff
changeset
|
3519 |
]. |
2983 | 3520 |
|
3521 |
stillInComment := true. |
|
3522 |
[stillInComment] whileTrue:[ |
|
3523 |
stillInComment := false. |
|
3524 |
||
3525 |
[hereChar notNil and:[hereChar ~~ (Character doubleQuote)]] whileTrue:[ |
|
3381 | 3526 |
hereChar isSeparator ifFalse:[ anyNonBlank := true ]. |
2983 | 3527 |
hereChar == (Character cr) ifTrue:[ |
3528 |
lineNr := lineNr + 1. |
|
3529 |
]. |
|
3530 |
commentStream notNil ifTrue:[ |
|
3531 |
commentStream nextPut:hereChar |
|
3532 |
]. |
|
3533 |
outStream notNil ifTrue:[ |
|
3534 |
outStream nextPut:hereChar. |
|
3535 |
outCol := outCol + 1 |
|
3536 |
]. |
|
3537 |
hereChar := source nextPeek |
|
3538 |
]. |
|
3539 |
||
3540 |
hereChar isNil ifTrue:[ |
|
3245 | 3541 |
self markCommentFrom:startPos to:(source collectionSize). |
3268 | 3542 |
self warning:'unclosed comment' position:startPos to:(source position + 1) |
2983 | 3543 |
] ifFalse:[ |
3268 | 3544 |
self markCommentFrom:startPos to:(source position + 1). |
2983 | 3545 |
outStream notNil ifTrue:[ |
3546 |
outStream nextPut:(Character doubleQuote). |
|
3547 |
outCol := outCol + 1 |
|
3548 |
]. |
|
3549 |
]. |
|
3268 | 3550 |
endPos := source position. |
2983 | 3551 |
"skip final dQuote" |
3552 |
source next. |
|
3553 |
||
3554 |
(source peek == Character doubleQuote) ifTrue:[ |
|
3555 |
stillInComment := true. |
|
3556 |
hereChar := source nextPeek. |
|
3557 |
]. |
|
3558 |
]. |
|
3559 |
] |
|
141 | 3560 |
]. |
3561 |
||
3562 |
saveComments ifTrue:[ |
|
1653 | 3563 |
commentText := commentStream contents. |
3564 |
self endComment:commentText type:commentType. |
|
3565 |
]. |
|
3566 |
||
3288 | 3567 |
ignoreWarnings ifFalse:[ |
3568 |
parserFlags warnAboutBadComments ifTrue:[ |
|
3569 |
anyNonBlank ifFalse:[ |
|
3381 | 3570 |
commentType == #regularComment ifTrue:[ |
3288 | 3571 |
self isDoIt ifFalse:[ |
3572 |
self |
|
3573 |
warning:'empty comment' |
|
3574 |
doNotShowAgainAction:[ ParserFlags warnAboutBadComments: false ] |
|
3575 |
position:startPos to:endPos+1. |
|
3576 |
parserFlags warnAboutBadComments:false. |
|
3577 |
] |
|
3578 |
]. |
|
1653 | 3579 |
]. |
3580 |
]. |
|
141 | 3581 |
]. |
3245 | 3582 |
"Modified: / 30-07-2013 / 20:56:33 / cg" |
2138 | 3583 |
! |
3584 |
||
3585 |
skipToEndOfLineRememberingIn:commentStreamOrNil |
|
3586 |
[hereChar notNil and:[hereChar ~~ Character cr]] whileTrue:[ |
|
3587 |
commentStreamOrNil notNil ifTrue:[ |
|
3588 |
commentStreamOrNil nextPut:hereChar |
|
3589 |
]. |
|
3590 |
outStream notNil ifTrue:[ |
|
3591 |
outStream nextPut:hereChar. |
|
3592 |
outCol := outCol + 1 |
|
3593 |
]. |
|
3594 |
hereChar := source nextPeek. |
|
3595 |
]. |
|
2983 | 3596 |
lineNr := lineNr + 1. |
648 | 3597 |
! ! |
3598 |
||
3599 |
!Scanner::Comment methodsFor:'accessing'! |
|
3600 |
||
3601 |
commentString |
|
3602 |
"return the value of the instance variable 'commentString' (automatically generated)" |
|
3603 |
||
3604 |
^ commentString |
|
3605 |
||
3606 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
3607 |
! |
|
3608 |
||
3609 |
commentString:something |
|
3610 |
"set the value of the instance variable 'commentString' (automatically generated)" |
|
3611 |
||
3612 |
commentString := something. |
|
3613 |
||
3614 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
3615 |
! |
|
3616 |
||
1596 | 3617 |
commentString:commentStringArg commentType:commentTypeArg |
3618 |
commentString := commentStringArg. |
|
3619 |
commentType := commentTypeArg. |
|
3620 |
||
3621 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
3622 |
! |
|
3623 |
||
648 | 3624 |
commentType |
3625 |
^ commentType |
|
3626 |
||
3627 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
3628 |
! |
|
3629 |
||
3630 |
commentType:something |
|
3631 |
commentType := something. |
|
3632 |
||
3633 |
"Created: / 17.2.1998 / 14:44:33 / cg" |
|
3634 |
! |
|
3635 |
||
3636 |
string |
|
3637 |
^ commentString |
|
3638 |
||
3639 |
"Created: / 17.2.1998 / 14:49:52 / cg" |
|
0 | 3640 |
! ! |
141 | 3641 |
|
1580 | 3642 |
!Scanner::Comment methodsFor:'converting'! |
3643 |
||
3644 |
asString |
|
3645 |
^ commentString. |
|
1583 | 3646 |
! |
3647 |
||
3648 |
asStringCollection |
|
3649 |
^ commentString asStringCollection. |
|
1580 | 3650 |
! ! |
3651 |
||
1651 | 3652 |
!Scanner::Comment methodsFor:'queries'! |
3653 |
||
3654 |
isEndOfLineComment |
|
3655 |
^ commentType == #eolComment |
|
3656 |
! ! |
|
3657 |
||
1596 | 3658 |
!Scanner::Directive class methodsFor:'instance creation'! |
3659 |
||
3660 |
newClassDirective |
|
3661 |
^ ClassDirective new |
|
3662 |
! |
|
3663 |
||
3664 |
newClassHintDirective |
|
3665 |
^ ClassHintDirective new |
|
3666 |
! ! |
|
3667 |
||
1598 | 3668 |
!Scanner::Directive methodsFor:'queries'! |
3669 |
||
3670 |
isClassHintDirective |
|
3671 |
^ false |
|
3672 |
! ! |
|
3673 |
||
1596 | 3674 |
!Scanner::Directive::ClassDirective methodsFor:'accessing'! |
3675 |
||
3676 |
className |
|
3677 |
^ className |
|
3678 |
! |
|
3679 |
||
3680 |
className:something |
|
3681 |
className := something. |
|
3682 |
! ! |
|
3683 |
||
1598 | 3684 |
!Scanner::Directive::ClassHintDirective methodsFor:'queries'! |
3685 |
||
3686 |
isClassHintDirective |
|
3687 |
^ true |
|
3688 |
! ! |
|
3689 |
||
359
5c3718455360
support for nameSpaces (space::name)
Claus Gittinger <cg@exept.de>
parents:
313
diff
changeset
|
3690 |
!Scanner class methodsFor:'documentation'! |
148 | 3691 |
|
2740 | 3692 |
version |
3454 | 3693 |
^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.317 2014-05-29 12:32:57 cg Exp $' |
2740 | 3694 |
! |
3695 |
||
2290 | 3696 |
version_CVS |
3454 | 3697 |
^ '$Header: /cvs/stx/stx/libcomp/Scanner.st,v 1.317 2014-05-29 12:32:57 cg Exp $' |
148 | 3698 |
! ! |
1321 | 3699 |
|
3056 | 3700 |
|
141 | 3701 |
Scanner initialize! |