# An interpreter for minidei. # Written by Elliott Hird, 2008. # Released into the public domain. $/ = undef; $_ = <>; /\[|\]/ and die "[] found in input"; $_ = "[] ".$_; my $q = qr/\[((?:(?:R)|[^ \[\]]+)*)\]/; my $w = qr/([^ ]+)/; s/\s+/ /g; { print $_, "\n"; s/$w dei/$1 [$1]/g; s/$q wrap/[[$1]]/ and redo; s/$q drop// and redo; s/$q dup/[$1] [$1]/ and redo; s/$q $q swap/[$2] [$1]/ and redo; s/$q i/$1/ and redo; s/$q $q compose/[$1 $2]/ and redo; }