locals.parser: fix bug where auto-use restarts weren't working properly.

db4
John Benediktsson 2015-07-19 19:17:46 -07:00
parent 296974a057
commit a08926653d
1 changed files with 17 additions and 5 deletions

View File

@ -1,9 +1,10 @@
! Copyright (C) 2007, 2009 Slava Pestov, Eduardo Cavazos. ! Copyright (C) 2007, 2009 Slava Pestov, Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators effects.parser USING: accessors arrays assocs assocs.private combinators
generic.parser kernel lexer locals.errors fry effects.parser fry generic.parser kernel lexer locals.errors
locals.rewrite.closures locals.types make namespaces parser locals.rewrite.closures locals.types make math namespaces
quotations sequences splitting words vocabs.parser ; namespaces.private parser quotations sequences splitting
vocabs.parser words ;
IN: locals.parser IN: locals.parser
SYMBOL: in-lambda? SYMBOL: in-lambda?
@ -31,13 +32,24 @@ ERROR: invalid-local-name name ;
SINGLETON: lambda-parser SINGLETON: lambda-parser
: prev-manifest ( -- manifest )
manifest namestack* [ length 2 - ] keep (assoc-stack) ;
: update-manifest ( manifest -- )
[ prev-manifest ] dip {
[ search-vocab-names>> >>search-vocab-names ]
[ search-vocabs>> >>search-vocabs ]
[ auto-used>> >>auto-used ]
} cleave drop ;
: with-lambda-scope ( assoc reader-quot: ( -- quot ) -- quot ) : with-lambda-scope ( assoc reader-quot: ( -- quot ) -- quot )
'[ '[
in-lambda? on in-lambda? on
lambda-parser quotation-parser set lambda-parser quotation-parser set
manifest [ clone ] change manifest [ clone ] change
use-words @ use-words @
] with-scope ; inline manifest get
] with-scope update-manifest ; inline
: (parse-lambda) ( assoc -- quot ) : (parse-lambda) ( assoc -- quot )
[ \ ] parse-until >quotation ] with-lambda-scope ; [ \ ] parse-until >quotation ] with-lambda-scope ;