]> gitweb.factorcode.org Git - factor.git/commitdiff
effects.parser: fix some incorrect can't-nest-definition errors.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 30 Mar 2016 20:16:15 +0000 (13:16 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 30 Mar 2016 20:16:15 +0000 (13:16 -0700)
definitions in one vocabulary can trigger definitions in other vocabularies,
so track them separately instead of using a single boolean.

core/effects/parser/parser.factor

index 45df4d402e7415ec86b31aab33f3e0026033bbbf..7fd84c0ec963af0965fdbaadf78c9c3dc31e801e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators effects kernel lexer make namespaces
-parser sequences splitting words ;
+USING: arrays combinators continuations effects kernel lexer
+make parser sequences sets splitting vocabs.parser words ;
 IN: effects.parser
 
 DEFER: parse-effect
@@ -52,15 +52,19 @@ PRIVATE>
 : parse-call-paren ( accum word -- accum )
     [ ")" parse-effect ] dip 2array append! ;
 
-SYMBOL: in-definition
+CONSTANT: in-definition HS{ }
 
 ERROR: can't-nest-definitions word ;
 
-: check-in-definition ( -- )
-    in-definition get [ last-word can't-nest-definitions ] when ;
+: set-in-definition ( -- )
+    current-vocab in-definition ?adjoin
+    [ last-word can't-nest-definitions ] unless ;
+
+: unset-in-definition ( -- )
+    current-vocab in-definition delete ;
 
 : with-definition ( quot -- )
-    [ check-in-definition t in-definition ] dip with-variable ; inline
+    [ set-in-definition ] prepose [ unset-in-definition ] [ ] cleanup ; inline
 
 : (:) ( -- word def effect )
     [