[Vm-dev] VM Maker: CogTools-Listener-eem.1.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Dec 16 03:20:46 UTC 2014
Eliot Miranda uploaded a new version of CogTools-Listener to project VM Maker:
http://source.squeak.org/VMMaker/CogTools-Listener-eem.1.mcz
==================== Summary ====================
Name: CogTools-Listener-eem.1
Author: eem
Time: 15 December 2014, 7:19:41.238 pm
UUID: 9e09b0f4-95a2-4cc0-98ef-c398e34f0ce9
Ancestors:
Extract the simple listener into a package
==================== Snapshot ====================
SystemOrganization addCategory: #'CogTools-Listener'!
----- Method: PositionableStream>>nextChunkNoTag (in category '*CogTools-Listener') -----
nextChunkNoTag
"Answer the contents of the receiver, up to the next terminator character.
Doubled terminators indicate an embedded terminator character.
Unlike nextChunk, do not look for ]lang[ tags."
| skippingSeparators terminator out ch |
terminator := $!!.
skippingSeparators := true. "inline skipSeparators since restoreStateOf:with: is not reliable"
out := WriteStream on: (String new: 1000).
[(ch := self next) == nil] whileFalse:
[ch == terminator ifTrue:
[self peek == terminator
ifTrue:"skip doubled terminator"
[self next]
ifFalse:
[^out contents "terminator is not doubled; we're done!!"]].
(skippingSeparators and: [ch isSeparator]) ifFalse:
[out nextPut: ch.
skippingSeparators := false]].
^out contents!
Object subclass: #StdioListener
instanceVariableNames: 'quitOnEof stdin stdout stderr'
classVariableNames: ''
poolDictionaries: ''
category: 'CogTools-Listener'!
----- Method: StdioListener>>initialize (in category 'initialize-release') -----
initialize
quitOnEof := true.
stdin := FileStream stdin.
stdout := FileStream stdout.
stderr := FileStream stderr!
----- Method: StdioListener>>logError:inContext:to: (in category 'run loop') -----
logError: errMsg inContext: aContext to: aStream
aStream nextPutAll: errMsg; cr.
aContext errorReportOn: aStream.
aStream cr!
----- Method: StdioListener>>quitOnEof (in category 'accessing') -----
quitOnEof
^quitOnEof!
----- Method: StdioListener>>quitOnEof: (in category 'accessing') -----
quitOnEof: aBoolean
quitOnEof := aBoolean!
----- Method: StdioListener>>run (in category 'run loop') -----
run
[stdin atEnd] whileFalse:
[| nextChunk |
stdout nextPutAll: 'squeak> '; flush.
nextChunk := stdin nextChunkNoTag.
[nextChunk notEmpty and: [nextChunk first isSeparator]] whileTrue:
[nextChunk := nextChunk allButFirst].
Transcript cr; nextPutAll: nextChunk; cr; flush.
[stdout print: (Compiler evaluate: nextChunk); cr; flush]
on: Error
do: [:ex| self logError: ex description inContext: ex signalerContext to: stderr]].
quitOnEof ifTrue:
[Smalltalk snapshot: false andQuit: true]!
More information about the Vm-dev
mailing list