Execute SNUSP/Perl: Difference between revisions

m
no edit summary
(Perl implementation of SNUSP)
 
mNo edit summary
Line 36:
print qq[do "\Q$include\E" or die;\n];
 
my %commands; = (
$commands{ '<'} => q{ --$col; $col < 0 and die; };,
$commands{ '>'} => q{ ++$col };,
$commands{ '+'} => q{ ++$data[$row][$col] };,
$commands{ '-'} => q{ --$data[$row][$col] };,
$commands{ '.'} => q{ print chr $data[$row][$col] };,
$commands{ ','} => q{ goto (schedule(readchar($data[$row][$col]) ? 'NEXT' : 'REDO')) };,
# /, \, and ! are implemented in the main loop
 
$commands{ '?'} => q{ goto (schedule($data[$row][$col] ? 'NEXT' : 'SKIP')) };,
 
$commands{ '@'} => q{ push @st, 'SKIP' };,
$commands{ '#'} => q{ goto (pop @st) };,
 
$commands{ ':'} => q{ --$row; $row < 0 and die };,
$commands{ ';'} => q{ ++$row };,
$commands{ '%'} => q{ $_ = int rand(1 + $_) for $data[$row][$col] };,
# & is implemented in the main loop.
);
 
tr/;{}// or s/(\s*)\z/;$1/ for values %commands;
Anonymous user