effects.parser: fix some incorrect can't-nest-definition errors.

definitions in one vocabulary can trigger definitions in other vocabularies,
so track them separately instead of using a single boolean.
locals-and-roots
John Benediktsson 2016-03-30 13:16:15 -07:00
parent ca82929ffb
commit dcf8aa16c7
1 changed files with 10 additions and 6 deletions

View File

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