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