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