ReadEvalPrintLoop.st
changeset 10265 c0df5e5f99c8
parent 10264 0522c2d7c4cf
child 10266 34da5ea787a9
--- a/ReadEvalPrintLoop.st	Thu Dec 07 19:37:36 2006 +0100
+++ b/ReadEvalPrintLoop.st	Thu Dec 07 19:39:42 2006 +0100
@@ -225,89 +225,93 @@
      If the chunkFormat-argument is true, chunks are read.
      Otherwise, lines up to an empty line (or EOF) are read."
 
-    [
-        |input output error lines chunk compilerClass|
+    ControlInterrupt handle:[:ex |
+        ex restart.
+    ] do:[
+        [
+            |input output error lines chunk compilerClass|
 
-        "/ re-evaluate these in the loop, so they can be changed dynamically
-        input := self inputStream.
-        output := self outputStream.
-        error := self errorStream.
-        compilerClass := compiler ? Compiler.
+            "/ re-evaluate these in the loop, so they can be changed dynamically
+            input := self inputStream.
+            output := self outputStream.
+            error := self errorStream.
+            compilerClass := compiler ? Compiler.
 
-        prompt notNil ifTrue:[
-            error nextPutAll:prompt.
-        ].
-
-        input atEnd ifTrue:[
-            ^ self.
-        ].
+            prompt notNil ifTrue:[
+                error nextPutAll:prompt.
+            ].
 
-        (doChunkFormat ? true) ifTrue:[
-            input skipSeparators.
-            chunk := input nextChunk.
-        ] ifFalse:[
-            lines := OrderedCollection new.
-            [
-                |line|
+            input atEnd ifTrue:[
+                ^ self.
+            ].
 
-                line := input nextLine.
-                line notEmptyOrNil ifTrue:[
-                    line = '?' ifTrue:[
-                        self cmd_help:nil.
-                        prompt notNil ifTrue:[
-                            error nextPutAll:prompt.
-                        ].
-                    ] ifFalse:[
-                        (line startsWith:'#') ifTrue:[
-                            self directive:line.
+            (doChunkFormat ? true) ifTrue:[
+                input skipSeparators.
+                chunk := input nextChunk.
+            ] ifFalse:[
+                lines := OrderedCollection new.
+                [
+                    |line|
+
+                    line := input nextLine.
+                    line notEmptyOrNil ifTrue:[
+                        line = '?' ifTrue:[
+                            self cmd_help:nil.
                             prompt notNil ifTrue:[
                                 error nextPutAll:prompt.
                             ].
                         ] ifFalse:[
-                            lines add:line.
+                            (line startsWith:'#') ifTrue:[
+                                self directive:line.
+                                prompt notNil ifTrue:[
+                                    error nextPutAll:prompt.
+                                ].
+                            ] ifFalse:[
+                                lines add:line.
+                            ]
                         ]
-                    ]
-                ].
-                line notEmptyOrNil.
-            ] whileTrue.
-            chunk := lines asStringWith:Character cr.
-        ].
+                    ].
+                    line notEmptyOrNil.
+                ] whileTrue.
+                chunk := lines asStringWith:Character cr.
+            ].
 
-        chunk notEmptyOrNil ifTrue:[
-            (AbortOperationRequest,AbortAllOperationRequest) handle:[:ex |
-                error nextPutLine:('Evaluation aborted: ', ex description)
-            ] do:[ 
-                (Error, ControlInterrupt) handle:[:ex |
-                    prompt isNil ifTrue:[
-                        ex reject
+            chunk notEmptyOrNil ifTrue:[
+                (AbortOperationRequest,AbortAllOperationRequest) handle:[:ex |
+                    error nextPutLine:('Evaluation aborted: ', ex description)
+                ] do:[ 
+                    (Error, ControlInterrupt) handle:[:ex |
+                        prompt isNil ifTrue:[
+                            ex reject
+                        ].
+                        MiniDebugger enterWithMessage:(ex errorString) mayProceed:true.
+                        ex mayProceed ifTrue:[
+                            ex proceed.
+                        ].
+                        error nextPutLine:('Evaluation aborted: ', ex description).
+                        ex return.
+                    ] do:[
+                        |value|
+
+                        value := (compilerClass new requestor:self) evaluate:chunk compile:true.
+                        value printOn:output.
+                        output cr.
                     ].
-                    MiniDebugger enterWithMessage:(ex errorString) mayProceed:true.
-                    ex mayProceed ifTrue:[
-                        ex proceed.
-                    ].
-                    error nextPutLine:('Evaluation aborted: ', ex description).
-                    ex return.
-                ] do:[
-                    |value|
-
-                    value := (compilerClass new requestor:self) evaluate:chunk compile:true.
-                    value printOn:output.
-                    output cr.
                 ].
             ].
-        ].
-    ] loop.
+        ] loop.
+    ]
 
     "
      (ReadEvalPrintLoop new prompt:'>') readEvalPrintLoop
     "
 
     "Created: / 07-12-2006 / 17:27:21 / cg"
-    "Modified: / 07-12-2006 / 19:38:11 / cg"
+    "Modified: / 07-12-2006 / 19:40:16 / cg"
 ! !
 
 !ReadEvalPrintLoop class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ReadEvalPrintLoop.st,v 1.15 2006-12-07 18:37:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ReadEvalPrintLoop.st,v 1.16 2006-12-07 18:39:42 cg Exp $'
 ! !