2008-02-26 19:40:32 -05:00
|
|
|
! Copyright (C) 2007, 2008 Slava Pestov.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-11-13 01:09:47 -05:00
|
|
|
USING: parser kernel sequences words effects combinators assocs
|
|
|
|
definitions quotations namespaces memoize accessors ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: macros
|
|
|
|
|
2008-01-09 17:52:37 -05:00
|
|
|
: real-macro-effect ( word -- effect' )
|
2008-08-29 11:27:31 -04:00
|
|
|
"declared-effect" word-prop in>> 1 <effect> ;
|
2008-01-09 17:52:37 -05:00
|
|
|
|
2008-02-26 19:40:32 -05:00
|
|
|
: define-macro ( word definition -- )
|
2008-11-13 01:09:47 -05:00
|
|
|
[ "macro" set-word-prop ]
|
|
|
|
[ over real-macro-effect memoize-quot [ call ] append define ]
|
|
|
|
2bi ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-11-13 01:09:47 -05:00
|
|
|
: MACRO: (:) define-macro ; parsing
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-03-26 19:23:19 -04:00
|
|
|
PREDICATE: macro < word "macro" word-prop >boolean ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
M: macro definer drop \ MACRO: \ ; ;
|
|
|
|
|
|
|
|
M: macro definition "macro" word-prop ;
|
|
|
|
|
2008-05-28 19:17:58 -04:00
|
|
|
M: macro reset-word
|
2008-06-30 04:57:00 -04:00
|
|
|
[ call-next-method ] [ f "macro" set-word-prop ] bi ;
|