author | Stefan Vogel <sv@exept.de> |
Mon, 22 Jun 2015 11:33:37 +0200 | |
branch | expecco_2_7_5_branch |
changeset 18499 | b132ac7c9d6a |
parent 16394 | a662e916316c |
child 17331 | b1d8f60e45fb |
permissions | -rw-r--r-- |
8148 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
8047 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
8447
9bdea3431846
EncodedStream inherts from PeekableStream
Stefan Vogel <sv@exept.de>
parents:
8444
diff
changeset
|
14 |
PeekableStream subclass:#EncodedStream |
15618 | 15 |
instanceVariableNames:'encoder stream' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
15963 | 18 |
category:'Collections-Text-Encodings' |
8047 | 19 |
! |
20 |
||
8148 | 21 |
!EncodedStream class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
15049 | 35 |
! |
36 |
||
37 |
documentation |
|
38 |
" |
|
15664 | 39 |
a stream which transparently decodes from an external decoding, |
40 |
looking for '{ Encoding: xxx' near the beginning of the file. |
|
15049 | 41 |
|
15664 | 42 |
especially targeted towards reading ST/X source files. |
15049 | 43 |
" |
8148 | 44 |
! ! |
8047 | 45 |
|
46 |
!EncodedStream class methodsFor:'instance creation'! |
|
47 |
||
48 |
stream:streamArg encoder:encoder |
|
49 |
^ (self basicNew) stream:streamArg; encoder:encoder |
|
16394 | 50 |
|
51 |
" |
|
52 |
|s| |
|
53 |
s := EncodedStream stream:Transcript encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode). |
|
54 |
s nextPutAll:('öäü' utf8Encoded) |
|
55 |
" |
|
8047 | 56 |
! ! |
57 |
||
12610 | 58 |
!EncodedStream class methodsFor:'utilities'! |
59 |
||
60 |
decodedStreamFor:aStream |
|
15345 | 61 |
"given a positionable stream, guess its encoding (by reading the |
62 |
first few lines, looking for a string with an encoding hint, |
|
63 |
and return an appropriate encoded string, which does the decoding |
|
64 |
on the fly. Used mostly to read UTF8 files (source code)" |
|
65 |
||
15049 | 66 |
|encodingSymbol decoder decodedStream| |
12610 | 67 |
|
15664 | 68 |
aStream inputStream isPositionable ifTrue:[ |
69 |
encodingSymbol := CharacterEncoder guessEncodingOfStream:aStream inputStream. |
|
15963 | 70 |
decoder := CharacterEncoder encoderFor:encodingSymbol. |
15049 | 71 |
decoder isNil ifTrue:[ |
72 |
"/ ascii or iso8895-1 |
|
73 |
^ aStream |
|
12610 | 74 |
]. |
15664 | 75 |
decodedStream := self stream:aStream encoder:decoder. |
15963 | 76 |
"JV@2012-03-27: NO, DO NOT CHANGE POSITION!! Caller might be interested |
77 |
in all data!!!!!!" |
|
78 |
"/decodedStream skipEncodingChunk. |
|
15049 | 79 |
] ifFalse:[ |
80 |
"/ setup for no-encoding; |
|
81 |
"/ switch to a real encoder later, |
|
15664 | 82 |
"/ whenever an encoding pragma is encountered later by #nextChunk. |
83 |
decodedStream := self stream:aStream encoder:CharacterEncoder nullEncoderInstance. |
|
14095 | 84 |
]. |
12610 | 85 |
^ decodedStream |
15963 | 86 |
|
87 |
"Modified: / 23-08-2013 / 17:30:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
15049 | 88 |
! |
89 |
||
90 |
encoderFor:anEncodingSymbol |
|
91 |
(anEncodingSymbol isNil |
|
92 |
or:[ anEncodingSymbol = #'iso8859-1' |
|
93 |
or:[ anEncodingSymbol = #'ascii' ]]) ifTrue:[ |
|
94 |
^ nil |
|
95 |
]. |
|
96 |
^ CharacterEncoder encoderFor:anEncodingSymbol. |
|
12610 | 97 |
! ! |
98 |
||
8047 | 99 |
!EncodedStream methodsFor:'accessing'! |
100 |
||
11992 | 101 |
contentsSpecies |
102 |
||
103 |
"Not sure if this is ok" |
|
104 |
||
105 |
^ stream contentsSpecies. |
|
106 |
||
107 |
"/ ^UnicodeString |
|
108 |
||
109 |
"Created: / 14-06-2005 / 17:11:01 / janfrog" |
|
110 |
! |
|
111 |
||
8047 | 112 |
encoder |
113 |
^ encoder |
|
114 |
! |
|
115 |
||
116 |
encoder:something |
|
117 |
encoder := something. |
|
118 |
! |
|
119 |
||
15593 | 120 |
inputStream |
121 |
^ stream inputStream |
|
122 |
! |
|
123 |
||
124 |
lineNumber |
|
125 |
^ stream lineNumber |
|
126 |
! |
|
127 |
||
12646 | 128 |
pathName |
129 |
"if our base stream hat a pathname, delegate..." |
|
130 |
||
131 |
stream isNil ifTrue:[ |
|
132 |
^ nil. |
|
133 |
]. |
|
134 |
^ stream pathName. |
|
135 |
! |
|
136 |
||
11766 | 137 |
readStream |
138 |
^ self |
|
139 |
! |
|
140 |
||
8047 | 141 |
stream |
142 |
^ stream |
|
143 |
! |
|
144 |
||
145 |
stream:something |
|
146 |
stream := something. |
|
147 |
! ! |
|
148 |
||
15963 | 149 |
!EncodedStream methodsFor:'private fileIn'! |
150 |
||
151 |
basicFileInNotifying:someone passChunk:passChunk |
|
152 |
"central method to file in from the receiver, i.e. read chunks and evaluate them - |
|
153 |
return the value of the last chunk. |
|
154 |
Someone (which is usually some codeView) is notified of errors." |
|
155 |
||
156 |
|lastValue pkg nameSpace usedNameSpaces |
|
157 |
packageQuerySignal nameSpaceQuerySignal usedNameSpaceQuerySignal |
|
158 |
changeDefaultApplicationNotificationSignal |
|
159 |
defaultApplicationQuerySignal defaultApplication |
|
160 |
confirmationQuerySignal handledSignals passedSignals askSomeoneForPackage outerContext askForVariableTypeOfUndeclaredQuery| |
|
161 |
||
162 |
self skipSeparators. |
|
163 |
lastValue := self peek. |
|
164 |
lastValue == $< ifTrue:[ |
|
165 |
"/ assume, it's an xml file |
|
166 |
^ self fileInXMLNotifying:someone passChunk:passChunk. |
|
167 |
]. |
|
168 |
lastValue == $# ifTrue:[ |
|
169 |
"assume unix interpreter name: |
|
170 |
'#!!stx -e' or something like this" |
|
171 |
self nextPeek == $!! ifTrue:[ |
|
172 |
"skip the unix command line" |
|
173 |
self nextLine |
|
174 |
] ifFalse:[ |
|
175 |
self error:'Invalid chunk start' |
|
176 |
] |
|
177 |
]. |
|
178 |
||
179 |
Smalltalk::Compiler isNil ifTrue:[ |
|
180 |
self isFileStream ifTrue:[ |
|
181 |
Transcript show:('[' , self pathName , '] '). |
|
182 |
]. |
|
183 |
Transcript showCR:'cannot fileIn (no compiler).'. |
|
184 |
^ nil. |
|
185 |
]. |
|
186 |
||
187 |
"/ support for V'Age applications |
|
188 |
defaultApplicationQuerySignal := Class defaultApplicationQuerySignal. |
|
189 |
changeDefaultApplicationNotificationSignal := Class changeDefaultApplicationNotificationSignal. |
|
190 |
||
191 |
"/ support for ST/X's nameSpaces & packages |
|
192 |
packageQuerySignal := Class packageQuerySignal. |
|
193 |
nameSpaceQuerySignal := Class nameSpaceQuerySignal. |
|
194 |
usedNameSpaceQuerySignal := Class usedNameSpaceQuerySignal. |
|
195 |
||
196 |
(someone respondsTo:#packageToInstall) ifTrue:[ |
|
197 |
pkg := someone packageToInstall. |
|
198 |
askSomeoneForPackage := true. |
|
199 |
] ifFalse:[ |
|
200 |
pkg := packageQuerySignal query. |
|
201 |
askSomeoneForPackage := false. |
|
202 |
]. |
|
203 |
(someone respondsTo:#currentNameSpace) ifTrue:[ |
|
204 |
nameSpace := someone currentNameSpace |
|
205 |
] ifFalse:[ |
|
206 |
nameSpace := nameSpaceQuerySignal query. |
|
207 |
]. |
|
208 |
(someone respondsTo:#usedNameSpaces) ifTrue:[ |
|
209 |
usedNameSpaces := someone usedNameSpaces |
|
210 |
] ifFalse:[ |
|
211 |
usedNameSpaces := usedNameSpaceQuerySignal query. |
|
212 |
]. |
|
213 |
(someone respondsTo:#defaultApplication) ifTrue:[ |
|
214 |
defaultApplication := someone defaultApplication |
|
215 |
] ifFalse:[ |
|
216 |
defaultApplication := defaultApplicationQuerySignal query. |
|
217 |
]. |
|
218 |
||
219 |
confirmationQuerySignal := Metaclass confirmationQuerySignal. |
|
220 |
||
221 |
handledSignals := SignalSet new. |
|
222 |
passedSignals := IdentitySet new. |
|
223 |
||
224 |
handledSignals add:changeDefaultApplicationNotificationSignal. |
|
225 |
passedSignals add:changeDefaultApplicationNotificationSignal. |
|
226 |
handledSignals add:defaultApplicationQuerySignal. |
|
227 |
passedSignals add:defaultApplicationQuerySignal. |
|
228 |
||
229 |
handledSignals add:packageQuerySignal. |
|
230 |
handledSignals add:usedNameSpaceQuerySignal. |
|
231 |
handledSignals add:nameSpaceQuerySignal. |
|
232 |
handledSignals add:confirmationQuerySignal. |
|
233 |
passedSignals add:confirmationQuerySignal. |
|
234 |
Parser notNil ifTrue:[ |
|
235 |
"only if libcomp is present" |
|
236 |
"Also catch a 'Parser askForVariableTypeOfUndeclaredQuery' and proceed with nil. |
|
237 |
Imagine somebody has autodefine workspace variables on and then |
|
238 |
evaluate Smalltalk loadPackage:'xyz' that loads code from source (using file-in), |
|
239 |
certainly we don't want to compile workspace variable access for every |
|
240 |
not-yet-loaded class in some namespace. |
|
241 |
This is demonstrated by Regression::CompilerTests2>>test_01 |
|
242 |
and this change actually fixes this test." |
|
243 |
askForVariableTypeOfUndeclaredQuery := Parser askForVariableTypeOfUndeclaredQuery. |
|
244 |
handledSignals add:askForVariableTypeOfUndeclaredQuery. |
|
245 |
]. |
|
246 |
||
247 |
||
248 |
outerContext := thisContext. |
|
249 |
||
250 |
handledSignals handle:[:ex | |
|
251 |
|sig| |
|
252 |
||
253 |
sig := ex creator. |
|
254 |
((passedSignals includes:sig) and:[sig isHandledIn:outerContext]) ifTrue:[ |
|
255 |
ex reject |
|
256 |
]. |
|
257 |
||
258 |
sig == changeDefaultApplicationNotificationSignal ifTrue:[ |
|
259 |
"/ invoked via #becomeDefault to set the defaultApp and the package. |
|
260 |
"/ (only when filing in V'Age code) |
|
261 |
defaultApplication := ex parameter. |
|
262 |
pkg := defaultApplication name asSymbol. |
|
263 |
ex proceedWith:nil |
|
264 |
]. |
|
265 |
sig == defaultApplicationQuerySignal ifTrue:[ |
|
266 |
"/ query for the application to add classes & methods into |
|
267 |
"/ (only when filing in V'Age code) |
|
268 |
ex proceedWith:defaultApplication |
|
269 |
]. |
|
270 |
sig == packageQuerySignal ifTrue:[ |
|
271 |
"answer the package to use for classes & methods" |
|
272 |
askSomeoneForPackage ifTrue:[ |
|
273 |
ex proceedWith:someone packageToInstall |
|
274 |
] ifFalse:[ |
|
275 |
ex proceedWith:pkg |
|
276 |
] |
|
277 |
]. |
|
278 |
sig == usedNameSpaceQuerySignal ifTrue:[ |
|
279 |
"answer the nameSpaces to be searched when encountering globals" |
|
280 |
ex proceedWith:usedNameSpaces |
|
281 |
]. |
|
282 |
sig == nameSpaceQuerySignal ifTrue:[ |
|
283 |
"answer the nameSpace to install new classes in" |
|
284 |
ex proceedWith:nameSpace |
|
285 |
]. |
|
286 |
sig == confirmationQuerySignal ifTrue:[ |
|
287 |
"don't pop up dialogs" |
|
288 |
ex proceedWith:false |
|
289 |
]. |
|
290 |
sig == askForVariableTypeOfUndeclaredQuery ifTrue:[ |
|
291 |
"no autodefined variables or so" |
|
292 |
ex proceedWith:nil. |
|
293 |
]. |
|
294 |
] do:[ |
|
295 |
[self atEnd] whileFalse:[ |
|
296 |
lastValue := self fileInNextChunkNotifying:someone passChunk:passChunk |
|
297 |
] |
|
298 |
]. |
|
299 |
^ lastValue |
|
300 |
||
301 |
"Modified: / 10.9.1999 / 16:54:01 / stefan" |
|
302 |
"Modified: / 16.11.2001 / 16:21:28 / cg" |
|
303 |
"Modified: / 18-03-2013 / 17:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
304 |
! ! |
|
305 |
||
8047 | 306 |
!EncodedStream methodsFor:'stream protocol'! |
307 |
||
8175 | 308 |
atEnd |
309 |
^ stream atEnd |
|
310 |
! |
|
311 |
||
8165 | 312 |
close |
313 |
stream close |
|
314 |
! |
|
315 |
||
13400 | 316 |
contents |
317 |
||
318 |
^String streamContents: |
|
319 |
[:s| |
|
320 |
[ stream atEnd ] whileFalse: |
|
321 |
[s nextPut: stream next] |
|
322 |
] |
|
323 |
||
324 |
"Created: / 25-02-2010 / 23:34:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
325 |
! |
|
326 |
||
8213 | 327 |
cr |
8459 | 328 |
self nextPutAll:(Character cr asString) |
8213 | 329 |
! |
330 |
||
11992 | 331 |
emphasis:anObject |
332 |
||
333 |
stream emphasis:anObject |
|
334 |
||
335 |
"Created: / 15-06-2005 / 11:16:33 / janfrog" |
|
336 |
! |
|
337 |
||
15477 | 338 |
flush |
339 |
stream flush |
|
340 |
! |
|
341 |
||
11946 | 342 |
isOpen |
12690 | 343 |
^ stream notNil and:[stream isOpen] |
11946 | 344 |
! |
345 |
||
11766 | 346 |
next |
11992 | 347 |
|
348 |
^encoder readNextCharacterFrom:stream |
|
349 |
||
350 |
"Created: / 14-06-2005 / 17:01:39 / janfrog" |
|
351 |
! |
|
11766 | 352 |
|
11992 | 353 |
next:charactersToRead |
354 |
||
355 |
^encoder readNext:charactersToRead charactersFrom:stream |
|
356 |
||
357 |
"Created: / 16-06-2005 / 11:43:43 / masca" |
|
11766 | 358 |
! |
359 |
||
8147 | 360 |
nextChunk |
15049 | 361 |
"as a side effect, check for an encoding chunk" |
15664 | 362 |
|
363 |
|prevEncoder chunk| |
|
8175 | 364 |
|
365 |
chunk := stream nextChunk. |
|
15664 | 366 |
chunk isNil ifTrue:[ |
367 |
^ nil |
|
368 |
]. |
|
15049 | 369 |
prevEncoder := encoder. |
15664 | 370 |
(prevEncoder isNullEncoder and:[stream isPositionable not]) ifTrue:[ |
15049 | 371 |
"/ not already checked |
15664 | 372 |
"/ check if we need lazy setup of the encoder |
373 |
"/ (used with non-positionable streams) |
|
374 |
(chunk includesString:'{ Encoding:') ifTrue:[ |
|
375 |
|enc| |
|
376 |
||
377 |
enc := self class encoderFor:(CharacterEncoder guessEncodingOfBuffer:chunk). |
|
378 |
enc notNil ifTrue:[ |
|
379 |
prevEncoder := encoder := enc. |
|
380 |
]. |
|
381 |
] |
|
15049 | 382 |
]. |
383 |
^ prevEncoder decodeString:chunk |
|
8147 | 384 |
! |
385 |
||
8213 | 386 |
nextChunkPut:chunk |
387 |
stream nextChunkPut:(encoder encodeString:chunk) |
|
388 |
! |
|
389 |
||
8047 | 390 |
nextPut:aCharacter |
391 |
self nextPutAll:(aCharacter asString). |
|
392 |
! |
|
393 |
||
394 |
nextPutAll:aCollection |
|
395 |
stream nextPutAll:(encoder encodeString:aCollection). |
|
8147 | 396 |
! |
397 |
||
8444 | 398 |
peek |
11992 | 399 |
|
400 |
^stream peek |
|
401 |
||
402 |
"Created: / 20-06-2005 / 10:13:03 / masca" |
|
403 |
"Modified: / 20-06-2005 / 13:06:14 / masca" |
|
8444 | 404 |
! |
405 |
||
8175 | 406 |
peekFor:aCharacter |
407 |
^ stream peekFor:aCharacter |
|
408 |
! |
|
409 |
||
8165 | 410 |
position |
411 |
^ stream position |
|
412 |
! |
|
413 |
||
8197 | 414 |
position0Based |
15618 | 415 |
<resource: #obsolete> |
11947 | 416 |
"to be obsoleted - use position" |
417 |
||
15618 | 418 |
^ stream position |
8197 | 419 |
! |
420 |
||
421 |
position0Based:newPosition |
|
15618 | 422 |
<resource: #obsolete> |
11947 | 423 |
"to be obsoleted - use position" |
424 |
||
15618 | 425 |
stream position:newPosition |
8197 | 426 |
! |
427 |
||
8175 | 428 |
position1Based |
15618 | 429 |
<resource: #obsolete> |
11947 | 430 |
"to be obsoleted - use position" |
431 |
||
15618 | 432 |
^ stream position + 1 |
8175 | 433 |
! |
434 |
||
8147 | 435 |
position1Based:newPosition |
15618 | 436 |
<resource: #obsolete> |
11947 | 437 |
"to be obsoleted - use position" |
438 |
||
15618 | 439 |
stream position:newPosition-1 |
8175 | 440 |
! |
441 |
||
8197 | 442 |
position:newPosition |
443 |
stream position:newPosition |
|
444 |
! |
|
445 |
||
13400 | 446 |
reset |
447 |
stream reset |
|
448 |
||
449 |
"Created: / 25-02-2010 / 23:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
450 |
! |
|
451 |
||
8213 | 452 |
setToEnd |
453 |
stream setToEnd |
|
454 |
! |
|
455 |
||
14333 | 456 |
size |
457 |
"not correct, but probably better than 0" |
|
458 |
||
15585 | 459 |
"/ is that better? |
460 |
"/ self error:'size of input is unknown (due to decoding)' |
|
14333 | 461 |
^ stream size |
462 |
||
463 |
"Created: / 31-08-2012 / 16:52:40 / cg" |
|
464 |
! |
|
465 |
||
11992 | 466 |
skip: anInteger |
467 |
||
468 |
"/ Should skip on character basis, not on bytes. This works for XML reader |
|
469 |
^stream skip: anInteger |
|
470 |
||
471 |
"Created: / 20-06-2005 / 13:06:06 / masca" |
|
472 |
! |
|
473 |
||
8175 | 474 |
skipSeparators |
475 |
^ stream skipSeparators |
|
15477 | 476 |
! |
477 |
||
478 |
sync |
|
479 |
stream sync |
|
480 |
! |
|
481 |
||
482 |
syncData |
|
483 |
stream syncData |
|
8047 | 484 |
! ! |
485 |
||
15049 | 486 |
!EncodedStream methodsFor:'testing'! |
487 |
||
488 |
isEncodedStream |
|
489 |
^ true |
|
15963 | 490 |
|
491 |
"Created: / 04-02-2014 / 20:27:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
15592 | 492 |
! |
493 |
||
16258
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
494 |
isPositionable |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
495 |
^ stream isPositionable |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
496 |
|
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
497 |
"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
|
498 |
! |
1582c656cdb0
Added EncodedStream>>isPositionable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15963
diff
changeset
|
499 |
|
15592 | 500 |
isReadable |
501 |
^ stream isReadable |
|
502 |
! |
|
503 |
||
504 |
isWritable |
|
505 |
^ stream isWritable |
|
15049 | 506 |
! ! |
507 |
||
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
508 |
!EncodedStream methodsFor:'utilities'! |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
509 |
|
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
510 |
skipEncodingChunk |
14091 | 511 |
|pos chunk token| |
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
512 |
|
13525
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
513 |
stream isPositionable ifFalse:[ |
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
514 |
^ self |
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
515 |
]. |
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
516 |
|
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
517 |
pos := self position. |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
518 |
chunk := self nextChunk. |
14084 | 519 |
[ |
520 |
"/ if this is a valid chunk (i.e. not a comment or encoding-directive), |
|
521 |
"/ then position back, so it will be processed as usual. |
|
14091 | 522 |
"/ We could parse here, but this is overkill, since we are only interested in the fact, |
523 |
"/ that there is anything else than a comment in the chunk. |
|
524 |
"/ result := (Parser for:chunk) |
|
525 |
"/ ignoreErrors:true; |
|
526 |
"/ ignoreWarnings:true; |
|
527 |
"/ parseMethodBody. |
|
528 |
||
529 |
token := (Scanner for:chunk) |
|
530 |
ignoreErrors:true; |
|
531 |
ignoreWarnings:true; |
|
532 |
nextToken. |
|
533 |
||
534 |
token ~= #EOF ifTrue:[ |
|
14084 | 535 |
self position:pos |
536 |
]. |
|
14086 | 537 |
] on:Parser parseWarningSignal do:[:ex| |
14084 | 538 |
"really ignore any error. |
539 |
Even setting ignorError will output diagnostics here |
|
540 |
during standalone startup when debugging" |
|
14086 | 541 |
ex proceedWith:#ignore. |
14084 | 542 |
]. |
13525
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
543 |
|
e17ebc11ca73
changed: #skipEncodingChunk
Claus Gittinger <cg@exept.de>
parents:
13400
diff
changeset
|
544 |
"Modified: / 29-07-2011 / 17:42:11 / cg" |
8712
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
545 |
! ! |
bcef3a0c0a1d
skipEncodingCHunk now in EncodedStream
Claus Gittinger <cg@exept.de>
parents:
8459
diff
changeset
|
546 |
|
8047 | 547 |
!EncodedStream class methodsFor:'documentation'! |
548 |
||
14086 | 549 |
version |
16394 | 550 |
^ '$Header: /cvs/stx/stx/libbasic/EncodedStream.st,v 1.37 2014-05-06 09:05:46 cg Exp $' |
14086 | 551 |
! |
552 |
||
13400 | 553 |
version_CVS |
16394 | 554 |
^ '$Header: /cvs/stx/stx/libbasic/EncodedStream.st,v 1.37 2014-05-06 09:05:46 cg Exp $' |
12610 | 555 |
! |
556 |
||
13400 | 557 |
version_SVN |
15345 | 558 |
^ '$ Id: EncodedStream.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
8047 | 559 |
! ! |
15049 | 560 |