core: Don't allow nested defintions in :, ::, M:, M::. Fixes #469.
parent
1455a5fb17
commit
84402ccf7e
|
@ -86,13 +86,17 @@ M: lambda-parser parse-quotation ( -- quotation )
|
||||||
(parse-locals-definition) ; inline
|
(parse-locals-definition) ; inline
|
||||||
|
|
||||||
: (::) ( -- word def effect )
|
: (::) ( -- word def effect )
|
||||||
|
[
|
||||||
scan-new-word
|
scan-new-word
|
||||||
[ parse-definition ]
|
[ parse-definition ]
|
||||||
parse-locals-definition ;
|
parse-locals-definition
|
||||||
|
] in-word-definition ;
|
||||||
|
|
||||||
: (M::) ( -- word def )
|
: (M::) ( -- word def )
|
||||||
|
[
|
||||||
scan-new-method
|
scan-new-method
|
||||||
[
|
[
|
||||||
[ parse-definition ]
|
[ parse-definition ]
|
||||||
parse-locals-method-definition drop
|
parse-locals-method-definition drop
|
||||||
] with-method-definition ;
|
] with-method-definition
|
||||||
|
] in-word-definition ;
|
||||||
|
|
|
@ -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: lexer sets sequences kernel splitting effects
|
USING: arrays combinators effects kernel lexer make namespaces
|
||||||
combinators arrays make vocabs.parser classes parser ;
|
parser sequences splitting words ;
|
||||||
IN: effects.parser
|
IN: effects.parser
|
||||||
|
|
||||||
DEFER: parse-effect
|
DEFER: parse-effect
|
||||||
|
@ -13,6 +13,8 @@ ERROR: stack-effect-omits-dashes ;
|
||||||
|
|
||||||
SYMBOL: effect-var
|
SYMBOL: effect-var
|
||||||
|
|
||||||
|
SYMBOL: in-definition
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
: end-token? ( end token -- token ? ) [ nip ] [ = ] 2bi ; inline
|
: end-token? ( end token -- token ? ) [ nip ] [ = ] 2bi ; inline
|
||||||
: effect-opener? ( token -- token ? ) dup { f "(" "((" "--" } member? ; inline
|
: effect-opener? ( token -- token ? ) dup { f "(" "((" "--" } member? ; inline
|
||||||
|
@ -52,7 +54,17 @@ PRIVATE>
|
||||||
: parse-call( ( accum word -- accum )
|
: parse-call( ( accum word -- accum )
|
||||||
[ ")" parse-effect ] dip 2array append! ;
|
[ ")" 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 )
|
: (:) ( -- word def effect )
|
||||||
|
[
|
||||||
scan-new-word
|
scan-new-word
|
||||||
scan-effect
|
scan-effect
|
||||||
parse-definition swap ;
|
parse-definition swap
|
||||||
|
] in-word-definition ;
|
||||||
|
|
|
@ -54,4 +54,6 @@ ERROR: bad-method-effect ;
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: (M:) ( -- method def )
|
: (M:) ( -- method def )
|
||||||
scan-new-method [ parse-method-definition ] with-method-definition ;
|
[
|
||||||
|
scan-new-method [ parse-method-definition ] with-method-definition
|
||||||
|
] in-word-definition ;
|
||||||
|
|
Loading…
Reference in New Issue