]> gitweb.factorcode.org Git - factor.git/blobdiff - core/listener/listener.factor
Debugging threads
[factor.git] / core / listener / listener.factor
index ddb29bb7686ddfa10ae5731b37b763027304f0c7..e00e64f4bcfc7e0f0d656747760bb687071eb86e 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays hashtables io kernel math math.parser memory
 namespaces parser sequences strings io.styles
-io.streams.duplex vectors words generic system combinators
-continuations debugger definitions compiler.units accessors ;
+vectors words generic system combinators continuations debugger
+definitions compiler.units accessors ;
 IN: listener
 
 SYMBOL: quit-flag
@@ -35,10 +35,7 @@ GENERIC: stream-read-quot ( stream -- quot/f )
 M: object stream-read-quot
     V{ } clone read-quot-loop ;
 
-M: duplex-stream stream-read-quot
-    duplex-stream-in stream-read-quot ;
-
-: read-quot ( -- quot/f ) stdio get stream-read-quot ;
+: read-quot ( -- quot/f ) input-stream get stream-read-quot ;
 
 : bye ( -- ) quit-flag on ;
 
@@ -46,9 +43,13 @@ M: duplex-stream stream-read-quot
     "( " in get " )" 3append
     H{ { background { 1 0.7 0.7 1 } } } format bl flush ;
 
+SYMBOL: error-hook
+
+[ print-error-and-restarts ] error-hook set-global
+
 : listen ( -- )
     listener-hook get call prompt.
-    [ read-quot [ try ] [ bye ] if* ]
+    [ read-quot [ [ error-hook get call ] recover ] [ bye ] if* ]
     [
         dup parse-error? [
             error-hook get call