]> gitweb.factorcode.org Git - factor.git/commitdiff
listener: only call parser-quiet? off when listener starts
authorBjörn Lindqvist <bjourne@gmail.com>
Mon, 5 Oct 2015 15:04:36 +0000 (17:04 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Mon, 5 Oct 2015 15:04:36 +0000 (17:04 +0200)
it probably shouldn't be called on every input loop because then if you
set parser-quiet? to t, the setting will be undone

basis/listener/listener-tests.factor
basis/listener/listener.factor

index 22b423b74bc2edd1a766a8ac78adaf7ff171fade..9a9bb5c6f6ee89d356f56c74ed556b3f0e332860 100644 (file)
@@ -1,6 +1,6 @@
-USING: io io.streams.string io.streams.duplex listener
-tools.test parser math namespaces continuations vocabs kernel
-compiler.units eval vocabs.parser words definitions ;
+USING: compiler.units continuations definitions eval io
+io.streams.string kernel listener listener.private math namespaces
+parser parser.notes tools.test vocabs vocabs.parser words ;
 IN: listener.tests
 
 SYNTAX: hello "Hi" print ;
@@ -56,7 +56,7 @@ SYNTAX: hello "Hi" print ;
 [ "call" "scratchpad" create-word drop ] with-compilation-unit
 
 [
-    [ t ]
+    { t }
     [
         "call" "scratchpad" lookup-word
         [ "call" search ] with-interactive-vocabs
@@ -65,3 +65,14 @@ SYNTAX: hello "Hi" print ;
 ] with-file-vocabs
 
 [ "call" "scratchpad" lookup-word forget ] with-compilation-unit
+
+[
+    { t } [
+        "[ ]" [
+            t parser-quiet? [
+                { } listener-step drop
+                parser-quiet? get
+            ] with-variable
+        ] with-string-reader
+    ] unit-test
+] with-file-vocabs
index 96404dc2dade72b60ee168b3caeffca94d8553db..8d9ac01d3efce96c4d507151263ffb2696879d0c 100644 (file)
@@ -108,8 +108,7 @@ t error-summary? set-global
         [ nl "--- Data stack:" title. trimmed-stack. ] unless-empty
     ] [ drop ] if ;
 
-:: (listener) ( datastack -- )
-    parser-quiet? off
+:: listener-step ( datastack -- datastack' )
     error-summary? get [ error-summary ] when
     visible-vars.
     datastack datastack.
@@ -126,9 +125,10 @@ t error-summary? set-global
         [ call-error-hook datastack ]
         [ rethrow ]
         if
-    ] recover
+    ] recover ;
 
-    (listener) ;
+: (listener) ( datastack -- )
+    listener-step (listener) ;
 
 PRIVATE>
 
@@ -209,7 +209,10 @@ SYMBOL: interactive-vocabs
     ] with-manifest ; inline
 
 : listener ( -- )
-    [ [ { } (listener) ] with-return ] with-interactive-vocabs ;
+    [
+        parser-quiet? off
+        [ { } (listener) ] with-return
+    ] with-interactive-vocabs ;
 
 : listener-main ( -- )
     version-info print flush listener ;