author | convert-repo |
Thu, 05 Jul 2018 03:33:35 +0000 | |
changeset 23197 | 823c765c176d |
parent 22480 | 15005492d6bd |
child 23988 | fdde978e324a |
permissions | -rw-r--r-- |
22421 | 1 |
"{ Encoding: utf8 }" |
2 |
||
8148 | 3 |
" |
4 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
8047 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
17331 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
8447
9bdea3431846
EncodedStream inherts from PeekableStream
Stefan Vogel <sv@exept.de>
parents:
8444
diff
changeset
|
18 |
PeekableStream subclass:#EncodedStream |
22415 | 19 |
instanceVariableNames:'encoder stream peekChar' |
15618 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
15963 | 22 |
category:'Collections-Text-Encodings' |
8047 | 23 |
! |
24 |
||
8148 | 25 |
!EncodedStream class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
15049 | 39 |
! |
40 |
||
41 |
documentation |
|
42 |
" |
|
15664 | 43 |
a stream which transparently decodes from an external decoding, |
44 |
looking for '{ Encoding: xxx' near the beginning of the file. |
|
15049 | 45 |
|
15664 | 46 |
especially targeted towards reading ST/X source files. |
15049 | 47 |
" |
8148 | 48 |
! ! |
8047 | 49 |
|
50 |
!EncodedStream class methodsFor:'instance creation'! |
|
51 |
||
52 |
stream:streamArg encoder:encoder |
|
53 |
^ (self basicNew) stream:streamArg; encoder:encoder |
|
16394 | 54 |
|
55 |
" |
|
56 |
|s| |
|
57 |
s := EncodedStream stream:Transcript encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode). |
|
22421 | 58 |
s nextPutAll:('öäü' utf8Encoded) |
22480 | 59 |
|
60 |
|s| |
|
61 |
s := EncodedStream stream:('öäü' readStream) encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode). |
|
62 |
s next:3 |
|
16394 | 63 |
" |
22480 | 64 |
|
65 |
"Modified (comment): / 17-01-2018 / 13:36:28 / stefan" |
|
18763 | 66 |
! |
67 |
||
68 |
stream:streamArg encoding:encodingSymbol |
|
69 |
^ self stream:streamArg encoder:(CharacterEncoder encoderFor:encodingSymbol) |
|
70 |
||
71 |
" |
|
72 |
|baseStream s| |
|
73 |
baseStream := '' readWriteStream. |
|
74 |
s := EncodedStream stream:baseStream encoding:#utf8. |
|
22421 | 75 |
s nextPutAll:'öäü'. |
18763 | 76 |
baseStream reset; contents. |
22480 | 77 |
|
78 |
s contents |
|
18763 | 79 |
" |
22480 | 80 |
|
81 |
"Modified (comment): / 17-01-2018 / 13:32:10 / stefan" |
|
8047 | 82 |
! ! |
83 |
||
17650 | 84 |
!EncodedStream class methodsFor:'Compatibility-VW5.4'! |
85 |
||
86 |
on: aStream encodedBy: aStreamEncoder |
|
87 |
||
88 |
^self basicNew on: aStream encodedBy: aStreamEncoder |
|
89 |
! ! |
|
90 |
||
12610 | 91 |
!EncodedStream class methodsFor:'utilities'! |
92 |
||
93 |
decodedStreamFor:aStream |
|
15345 | 94 |
"given a positionable stream, guess its encoding (by reading the |
95 |
first few lines, looking for a string with an encoding hint, |
|
96 |
and return an appropriate encoded string, which does the decoding |
|
97 |
on the fly. Used mostly to read UTF8 files (source code)" |
|
98 |
||
18763 | 99 |
|encodingSymbol decodedStream| |
12610 | 100 |
|
15664 | 101 |
aStream inputStream isPositionable ifTrue:[ |
102 |
encodingSymbol := CharacterEncoder guessEncodingOfStream:aStream inputStream. |
|
18763 | 103 |
decodedStream := self stream:aStream encoding:encodingSymbol. |
15963 | 104 |
"JV@2012-03-27: NO, DO NOT CHANGE POSITION!! Caller might be interested |
105 |
in all data!!!!!!" |
|
106 |
"/decodedStream skipEncodingChunk. |
|
15049 | 107 |
] ifFalse:[ |
108 |
"/ setup for no-encoding; |
|
109 |
"/ switch to a real encoder later, |
|
15664 | 110 |
"/ whenever an encoding pragma is encountered later by #nextChunk. |
111 |
decodedStream := self stream:aStream encoder:CharacterEncoder nullEncoderInstance. |
|
14095 | 112 |
]. |
12610 | 113 |
^ decodedStream |
15963 | 114 |
|
115 |
"Modified: / 23-08-2013 / 17:30:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
15049 | 116 |
! |
117 |
||
118 |
encoderFor:anEncodingSymbol |
|
119 |
(anEncodingSymbol isNil |
|
120 |
or:[ anEncodingSymbol = #'iso8859-1' |
|
121 |
or:[ anEncodingSymbol = #'ascii' ]]) ifTrue:[ |
|
122 |
^ nil |
|
123 |
]. |
|
124 |
^ CharacterEncoder encoderFor:anEncodingSymbol. |
|
12610 | 125 |
! ! |
126 |
||
17650 | 127 |
!EncodedStream methodsFor:'Compatibility-VW5.4'! |
128 |
||
129 |
on:aStream encodedBy:aStreamEncoder |
|
130 |
"Initialize the receiver on aStream with aStreamEncoder." |
|
131 |
||
132 |
"/ skipSize := PositionRecord new. |
|
133 |
"/ aStreamEncoder skipRecord: skipSize. |
|
134 |
"/ binary := false. |
|
135 |
"/ lineEndConvention == nil |
|
136 |
"/ ifTrue: |
|
137 |
"/ [aStream needsFileLineEndConversion |
|
138 |
"/ ifTrue: [self lineEndConvention: IOAccessor defaultLineEndConvention] |
|
139 |
"/ ifFalse: [self lineEndConvention: LineEndTransparent]]. |
|
140 |
self stream: aStream. |
|
141 |
self encoder: aStreamEncoder |
|
142 |
! ! |
|
143 |
||
8047 | 144 |
!EncodedStream methodsFor:'accessing'! |
145 |
||
146 |
encoder |
|
147 |
^ encoder |
|
148 |
! |
|
149 |
||
150 |
encoder:something |
|
151 |
encoder := something. |
|
152 |
! |
|
153 |
||
21642 | 154 |
encoding |
155 |
^ encoder nameOfEncoding |
|
156 |
||
157 |
"Created: / 13-03-2017 / 11:17:56 / stefan" |
|
158 |
! |
|
159 |
||
15593 | 160 |
inputStream |
161 |
^ stream inputStream |
|
162 |
! |
|
163 |
||
164 |
lineNumber |
|
22415 | 165 |
"the linenumber doesn't change when characters are decoded" |
166 |
||
167 |
stream isNil ifTrue:[ |
|
168 |
^ nil. |
|
169 |
]. |
|
15593 | 170 |
^ stream lineNumber |
22415 | 171 |
|
172 |
"Modified: / 02-01-2018 / 20:12:18 / stefan" |
|
173 |
"Modified (comment): / 09-01-2018 / 17:47:20 / stefan" |
|
15593 | 174 |
! |
175 |
||
12646 | 176 |
pathName |
20477 | 177 |
"if our base stream has a pathname, delegate..." |
12646 | 178 |
|
179 |
stream isNil ifTrue:[ |
|
180 |
^ nil. |
|
181 |
]. |
|
182 |
^ stream pathName. |
|
183 |
! |
|
184 |
||
11766 | 185 |
readStream |
21472 | 186 |
"read from self" |
187 |
||
11766 | 188 |
^ self |
21472 | 189 |
|
190 |
"Modified (comment): / 16-02-2017 / 15:59:52 / stefan" |
|
11766 | 191 |
! |
192 |
||
8047 | 193 |
stream |
194 |
^ stream |
|
195 |
! |
|
196 |
||
197 |
stream:something |
|
198 |
stream := something. |
|
199 |
! ! |
|
200 |
||
21472 | 201 |
!EncodedStream methodsFor:'chunk input/output'! |
15963 | 202 |
|
21472 | 203 |
nextChunk |
204 |
"as a side effect, check for an encoding chunk" |
|
205 |
||
22415 | 206 |
|chunk| |
15963 | 207 |
|
22415 | 208 |
chunk := super nextChunk. |
15963 | 209 |
|
22415 | 210 |
(encoder isNullEncoder and:[stream isPositionable not]) ifTrue:[ |
211 |
"/ encoding not already checked |
|
21472 | 212 |
"/ check if we need lazy setup of the encoder |
213 |
"/ (used with non-positionable streams) |
|
22415 | 214 |
"/ encoder for PositionableStream is set up in self class decodedStreamFor: |
215 |
(chunk notNil and:[chunk includesString:'{ Encoding:']) ifTrue:[ |
|
21472 | 216 |
|enc| |
15963 | 217 |
|
21472 | 218 |
enc := self class encoderFor:(CharacterEncoder guessEncodingOfBuffer:chunk). |
219 |
enc notNil ifTrue:[ |
|
22415 | 220 |
encoder := enc. |
221 |
^ encoder decodeString:chunk. |
|
21472 | 222 |
]. |
22415 | 223 |
]. |
15963 | 224 |
]. |
225 |
||
22415 | 226 |
^ chunk. |
227 |
||
228 |
"Modified (format): / 04-01-2018 / 00:33:57 / stefan" |
|
15963 | 229 |
! ! |
230 |
||
21642 | 231 |
!EncodedStream methodsFor:'queries'! |
232 |
||
22415 | 233 |
contentsSpecies |
234 |
^ String |
|
235 |
||
236 |
"Created: / 14-06-2005 / 17:11:01 / janfrog" |
|
237 |
"Modified: / 10-01-2018 / 11:43:57 / stefan" |
|
238 |
! |
|
239 |
||
21642 | 240 |
isEncoderFor:encodingString |
241 |
^ encoder isEncoderFor:encodingString |
|
242 |
||
243 |
"Created: / 13-03-2017 / 11:20:20 / stefan" |
|
244 |
! ! |
|
245 |
||
8047 | 246 |
!EncodedStream methodsFor:'stream protocol'! |
247 |
||
8175 | 248 |
atEnd |
22415 | 249 |
^ peekChar isNil and:[stream atEnd] |
250 |
||
251 |
"Modified: / 02-01-2018 / 21:47:17 / stefan" |
|
8175 | 252 |
! |
253 |
||
8165 | 254 |
close |
22415 | 255 |
peekChar := nil. |
8165 | 256 |
stream close |
22415 | 257 |
|
258 |
"Modified: / 09-01-2018 / 18:33:01 / stefan" |
|
8165 | 259 |
! |
260 |
||
21521 | 261 |
collection |
21522 | 262 |
"return the underlying container; nil, if there is none (eg. external streams). |
263 |
Here we return nil, as the underlying collection (if any) is useless to the outside world" |
|
21521 | 264 |
|
21522 | 265 |
^ nil |
21521 | 266 |
|
267 |
"Created: / 22-02-2017 / 11:15:00 / cg" |
|
268 |
! |
|
269 |
||
13400 | 270 |
contents |
22415 | 271 |
^String streamContents:[:s| |
272 |
[self atEnd] whileFalse:[ |
|
18157 | 273 |
|ch| |
274 |
ch := self next. |
|
275 |
"/ decoder may decide to return nil from #next, even though the |
|
276 |
"/ underlying stream was not at the end before. This is probably a bug... |
|
277 |
ch notNil ifTrue:[ |
|
278 |
s nextPut: ch |
|
279 |
] |
|
13400 | 280 |
] |
18157 | 281 |
] |
13400 | 282 |
|
283 |
"Created: / 25-02-2010 / 23:34:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
22415 | 284 |
"Modified (format): / 02-01-2018 / 19:35:10 / stefan" |
8213 | 285 |
! |
286 |
||
11992 | 287 |
emphasis:anObject |
288 |
||
289 |
stream emphasis:anObject |
|
290 |
||
291 |
"Created: / 15-06-2005 / 11:16:33 / janfrog" |
|
292 |
! |
|
293 |
||
15477 | 294 |
flush |
22415 | 295 |
peekChar := nil. |
15477 | 296 |
stream flush |
22415 | 297 |
|
298 |
"Modified: / 02-01-2018 / 19:17:40 / stefan" |
|
15477 | 299 |
! |
300 |
||
20363 | 301 |
isEmpty |
22415 | 302 |
^ stream isEmptyOrNil. |
20363 | 303 |
|
22415 | 304 |
"Modified: / 02-01-2018 / 19:59:09 / stefan" |
11946 | 305 |
! |
306 |
||
11766 | 307 |
next |
22415 | 308 |
peekChar notNil ifTrue:[ |
309 |
|p| |
|
310 |
p := peekChar. |
|
311 |
peekChar := nil. |
|
312 |
^ p. |
|
313 |
]. |
|
314 |
^ encoder readNextCharacterFrom:stream |
|
11992 | 315 |
|
316 |
"Created: / 14-06-2005 / 17:01:39 / janfrog" |
|
22415 | 317 |
"Modified: / 02-01-2018 / 19:19:29 / stefan" |
11992 | 318 |
! |
11766 | 319 |
|
22415 | 320 |
next:nCharactersToRead |
321 |
|chars| |
|
11992 | 322 |
|
22415 | 323 |
nCharactersToRead == 1 ifTrue:[ |
324 |
^ self next. |
|
325 |
]. |
|
326 |
nCharactersToRead == 0 ifTrue:[ |
|
327 |
^ ''. |
|
328 |
]. |
|
329 |
||
330 |
peekChar isNil ifTrue:[ |
|
331 |
^ encoder readNext:nCharactersToRead charactersFrom:stream. |
|
332 |
]. |
|
333 |
||
334 |
chars := encoder readNext:nCharactersToRead-1 charactersFrom:stream. |
|
335 |
chars := chars copyWithFirst:peekChar. |
|
336 |
peekChar := nil. |
|
337 |
^ chars. |
|
11992 | 338 |
|
339 |
"Created: / 16-06-2005 / 11:43:43 / masca" |
|
22415 | 340 |
"Modified: / 03-01-2018 / 22:22:51 / stefan" |
11766 | 341 |
! |
342 |
||
21472 | 343 |
nextPut:aCharacter |
344 |
encoder encodeCharacter:aCharacter on:stream. |
|
8175 | 345 |
|
21472 | 346 |
"Modified: / 16-02-2017 / 16:22:23 / stefan" |
8047 | 347 |
! |
348 |
||
349 |
nextPutAll:aCollection |
|
17668 | 350 |
encoder encodeString:aCollection on:stream |
8147 | 351 |
! |
352 |
||
17331 | 353 |
nextPutAll:aCollection startingAt:start to:stop |
17668 | 354 |
encoder encodeString:(aCollection copyFrom:start to:stop) on:stream. |
17331 | 355 |
! |
356 |
||
8444 | 357 |
peek |
22415 | 358 |
peekChar isNil ifTrue:[ |
359 |
peekChar := self next. |
|
360 |
]. |
|
361 |
^ peekChar |
|
11992 | 362 |
|
363 |
"Created: / 20-06-2005 / 10:13:03 / masca" |
|
364 |
"Modified: / 20-06-2005 / 13:06:14 / masca" |
|
22415 | 365 |
"Modified (format): / 02-01-2018 / 19:21:00 / stefan" |
8175 | 366 |
! |
367 |
||
8165 | 368 |
position |
22415 | 369 |
"only use #position/#position: to restore a previous position. |
370 |
Computing relative positions does not work!!" |
|
371 |
||
22421 | 372 |
|pos| |
22415 | 373 |
|
22421 | 374 |
pos := stream position. |
375 |
peekChar notNil ifTrue:[ |
|
376 |
"#position: nils peekChar - make sure, that it positions before peekChar" |
|
22423 | 377 |
pos := pos - (encoder characterSize:peekChar). |
22421 | 378 |
]. |
379 |
^ pos. |
|
380 |
||
22423 | 381 |
"Modified: / 15-01-2018 / 22:42:01 / stefan" |
8165 | 382 |
! |
383 |
||
8197 | 384 |
position0Based |
15618 | 385 |
<resource: #obsolete> |
11947 | 386 |
"to be obsoleted - use position" |
387 |
||
15618 | 388 |
^ stream position |
8197 | 389 |
! |
390 |
||
391 |
position0Based:newPosition |
|
15618 | 392 |
<resource: #obsolete> |
11947 | 393 |
"to be obsoleted - use position" |
394 |
||
15618 | 395 |
stream position:newPosition |
8197 | 396 |
! |
397 |
||
8175 | 398 |
position1Based |
15618 | 399 |
<resource: #obsolete> |
11947 | 400 |
"to be obsoleted - use position" |
401 |
||
22415 | 402 |
^ stream position1Based |
403 |
||
404 |
"Modified: / 02-01-2018 / 20:00:57 / stefan" |
|
8175 | 405 |
! |
406 |
||
8147 | 407 |
position1Based:newPosition |
15618 | 408 |
<resource: #obsolete> |
11947 | 409 |
"to be obsoleted - use position" |
410 |
||
22415 | 411 |
stream position1Based:newPosition |
412 |
||
413 |
"Modified: / 02-01-2018 / 20:00:46 / stefan" |
|
8175 | 414 |
! |
415 |
||
8197 | 416 |
position:newPosition |
22415 | 417 |
"only use #position/#position: to restore a previous position. |
418 |
Computing relative positions does not work!! |
|
419 |
Use #skip: to advance forward." |
|
420 |
||
421 |
peekChar := nil. |
|
8197 | 422 |
stream position:newPosition |
22415 | 423 |
|
424 |
"Modified (comment): / 09-01-2018 / 17:53:04 / stefan" |
|
8197 | 425 |
! |
426 |
||
13400 | 427 |
reset |
22415 | 428 |
peekChar := nil. |
13400 | 429 |
stream reset |
430 |
||
431 |
"Created: / 25-02-2010 / 23:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
22415 | 432 |
"Modified: / 02-01-2018 / 19:34:20 / stefan" |
13400 | 433 |
! |
434 |
||
8213 | 435 |
setToEnd |
22415 | 436 |
peekChar := nil. |
8213 | 437 |
stream setToEnd |
22415 | 438 |
|
439 |
"Modified (comment): / 09-01-2018 / 17:50:27 / stefan" |
|
8213 | 440 |
! |
441 |
||
14333 | 442 |
size |
20363 | 443 |
"not always correct, but probably better than 0. |
444 |
Better use #isEmpty." |
|
14333 | 445 |
|
15585 | 446 |
"/ is that better? |
447 |
"/ self error:'size of input is unknown (due to decoding)' |
|
14333 | 448 |
^ stream size |
449 |
||
450 |
"Created: / 31-08-2012 / 16:52:40 / cg" |
|
451 |
! |
|
452 |
||
15477 | 453 |
sync |
454 |
stream sync |
|
455 |
! |
|
456 |
||
457 |
syncData |
|
458 |
stream syncData |
|
8047 | 459 |
! ! |
460 |
||
15049 | 461 |
!EncodedStream methodsFor:'testing'! |
462 |
||
463 |
isEncodedStream |
|
464 |
^ true |
|
15963 | 465 |
|
466 |
"Created: / 04-02-2014 / 20:27:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
15592 | 467 |
! |
468 |
||
22415 | 469 |
isOpen |
470 |
"for compatibility with externalStream: |
|
471 |
return true, if this stream is open." |
|
472 |
||
473 |
^ stream notNil and:[stream isOpen]. |
|
474 |
||
475 |
"Modified (comment): / 09-01-2018 / 18:34:47 / stefan" |
|
476 |
! |
|
477 |
||
16258
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
478 |
isPositionable |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
479 |
^ stream isPositionable |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
480 |
|
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
481 |
"Created: / 14-03-2014 / 16:18:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
482 |
! |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
483 |
|
15592 | 484 |
isReadable |
485 |
^ stream isReadable |
|
486 |
! |
|
487 |
||
488 |
isWritable |
|
489 |
^ stream isWritable |
|
15049 | 490 |
! ! |
491 |
||
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
492 |
!EncodedStream methodsFor:'utilities'! |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
493 |
|
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
494 |
skipEncodingChunk |
14091 | 495 |
|pos chunk token| |
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
496 |
|
13525
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
497 |
stream isPositionable ifFalse:[ |
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
498 |
^ self |
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
499 |
]. |
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
500 |
|
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
501 |
pos := self position. |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
502 |
chunk := self nextChunk. |
14084 | 503 |
[ |
504 |
"/ if this is a valid chunk (i.e. not a comment or encoding-directive), |
|
505 |
"/ then position back, so it will be processed as usual. |
|
14091 | 506 |
"/ We could parse here, but this is overkill, since we are only interested in the fact, |
507 |
"/ that there is anything else than a comment in the chunk. |
|
508 |
"/ result := (Parser for:chunk) |
|
509 |
"/ ignoreErrors:true; |
|
510 |
"/ ignoreWarnings:true; |
|
511 |
"/ parseMethodBody. |
|
512 |
||
513 |
token := (Scanner for:chunk) |
|
514 |
ignoreErrors:true; |
|
515 |
ignoreWarnings:true; |
|
516 |
nextToken. |
|
517 |
||
518 |
token ~= #EOF ifTrue:[ |
|
14084 | 519 |
self position:pos |
520 |
]. |
|
14086 | 521 |
] on:Parser parseWarningSignal do:[:ex| |
14084 | 522 |
"really ignore any error. |
21472 | 523 |
Even setting ignoreError will output diagnostics here |
14084 | 524 |
during standalone startup when debugging" |
14086 | 525 |
ex proceedWith:#ignore. |
14084 | 526 |
]. |
13525
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
527 |
|
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
528 |
"Modified: / 29-07-2011 / 17:42:11 / cg" |
21472 | 529 |
"Modified (format): / 16-02-2017 / 16:01:09 / stefan" |
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
530 |
! ! |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
531 |
|
8047 | 532 |
!EncodedStream class methodsFor:'documentation'! |
533 |
||
14086 | 534 |
version |
18763 | 535 |
^ '$Header$' |
14086 | 536 |
! |
537 |
||
13400 | 538 |
version_CVS |
18763 | 539 |
^ '$Header$' |
12610 | 540 |
! |
541 |
||
13400 | 542 |
version_SVN |
15345 | 543 |
^ '$ Id: EncodedStream.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
8047 | 544 |
! ! |
15049 | 545 |