Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created August 29, 2010 20:39
Show Gist options
  • Save lsparrish/556671 to your computer and use it in GitHub Desktop.
Save lsparrish/556671 to your computer and use it in GitHub Desktop.
( stack for nesting quotes )
chain: quote
create stack here , 10 allot
: push stack dup ++ @ ! ;
: pop stack dup @ @ swap -- ;
: empty? stack dup @ = ;
;chain
chain: parable
: __: header ; parsing
: nest compiler on here \quote.push 0 , 0 , ;
: unnest \quote.pop \quote.empty? not !compiler ;
: [ nest ; immediate
: ] unnest @compiler if 9 , here over 1+ ! 8 over ! 2 + 1 , , ;then 9 , ; immediate
: def ( a- ) @last &.word over !d->class !d->xt ;
[ rot if drop .word ;then nip .word ] :if def
[ [ ] if ] :ifTrue def
[ [ ] swap if ] :ifFalse def
;chain
with parable
-1 [ 10 . ] [ 20 . ] if
[ 0 [ 10 . ] [ 20 . ] if ] :foo def foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment