(parse-locals-definition) ; inline
: (::) ( -- word def effect )
- scan-new-word
- [ parse-definition ]
- parse-locals-definition ;
+ [
+ scan-new-word
+ [ parse-definition ]
+ parse-locals-definition
+ ] in-word-definition ;
: (M::) ( -- word def )
- scan-new-method
[
- [ parse-definition ]
- parse-locals-method-definition drop
- ] with-method-definition ;
+ scan-new-method
+ [
+ [ parse-definition ]
+ parse-locals-method-definition drop
+ ] with-method-definition
+ ] in-word-definition ;
! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: lexer sets sequences kernel splitting effects
-combinators arrays make vocabs.parser classes parser ;
+USING: arrays combinators effects kernel lexer make namespaces
+parser sequences splitting words ;
IN: effects.parser
DEFER: parse-effect
SYMBOL: effect-var
+SYMBOL: in-definition
+
<PRIVATE
: end-token? ( end token -- token ? ) [ nip ] [ = ] 2bi ; inline
: effect-opener? ( token -- token ? ) dup { f "(" "((" "--" } member? ; inline
: parse-call( ( accum word -- accum )
[ ")" parse-effect ] dip 2array append! ;
+ERROR: can't-nest-definitions word ;
+
+: check-in-definition ( -- )
+ in-definition get [ word can't-nest-definitions ] when ;
+
+: in-word-definition ( quot -- )
+ [ check-in-definition t in-definition ] dip with-variable ; inline
+
: (:) ( -- word def effect )
- scan-new-word
- scan-effect
- parse-definition swap ;
+ [
+ scan-new-word
+ scan-effect
+ parse-definition swap
+ ] in-word-definition ;