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
|
||||
|
||||
: (::) ( -- word def effect )
|
||||
[
|
||||
scan-new-word
|
||||
[ parse-definition ]
|
||||
parse-locals-definition ;
|
||||
parse-locals-definition
|
||||
] in-word-definition ;
|
||||
|
||||
: (M::) ( -- word def )
|
||||
[
|
||||
scan-new-method
|
||||
[
|
||||
[ parse-definition ]
|
||||
parse-locals-method-definition drop
|
||||
] with-method-definition ;
|
||||
] with-method-definition
|
||||
] in-word-definition ;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! 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
|
||||
|
@ -13,6 +13,8 @@ ERROR: stack-effect-omits-dashes ;
|
|||
|
||||
SYMBOL: effect-var
|
||||
|
||||
SYMBOL: in-definition
|
||||
|
||||
<PRIVATE
|
||||
: end-token? ( end token -- token ? ) [ nip ] [ = ] 2bi ; inline
|
||||
: effect-opener? ( token -- token ? ) dup { f "(" "((" "--" } member? ; inline
|
||||
|
@ -52,7 +54,17 @@ PRIVATE>
|
|||
: 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 ;
|
||||
parse-definition swap
|
||||
] in-word-definition ;
|
||||
|
|
|
@ -54,4 +54,6 @@ ERROR: bad-method-effect ;
|
|||
PRIVATE>
|
||||
|
||||
: (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