annotate interps/7/7.pl @ 12500:e48c08805365 draft default tip

<b_jonas> ` learn \'The password of the month is Cthulhuquagdonic Mothraquagdonic Narwhalicorn.\' # https://logs.esolangs.org/libera-esolangs/2024-04.html#lKE Infinite craft
author HackEso <hackeso@esolangs.org>
date Wed, 01 May 2024 06:39:10 +0000
parents d0cc5812f4bb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11883
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
1 #!/usr/bin/env perl
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
2 use utf8;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
3 q{
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
4
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
5 =pod
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
6
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
7 =encoding UTF8
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
8
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
9 =head1 NAME
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
10
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
11 7 - an esoteric programming language
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
12
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
13 =head1 SYNOPSIS
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
14
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
15 ./7 program.7 # run
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
16 ./7 -d program.7 # debug
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
17
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
18 =head1 DESCRIPTION
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
19
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
20 7 is an esoteric programming language, inspired by Underload (although
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
21 it has diverged somewhat), but aiming for small source code
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
22 representation.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
23
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
24 The language operates using two main pieces of internal state: the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
25 I<frame>, which is a vaguely stack-like construct that holds data; and
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
26 the I<command list>. The frame consists of a sequence of commands
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
27 separated by I<bars>; the command list is also a sequence of commands.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
28
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
29 The program operates by repeatedly removing the first command from the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
30 command list, then performing the action specified by that command on
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
31 the frame. Once the command list is empty, the portion of the frame
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
32 to the right of the last bar is copied to the start of the command
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
33 list; this operation is called "cycling". (Cycling exits the program
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
34 if the frame is completely empty, and is an error if the frame is
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
35 nonempty but has no bars; also, as a special case, it deletes the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
36 rightmost bar if nothing is to its right, in order to avoid a trivial
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
37 infinite loop.) These are the only ways in which the command list can
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
38 be modified.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
39
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
40 The frame is a "working space" for the program, and so can be modified
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
41 in rather more interesting ways than the command list. However,
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
42 typically only the section to the right of the rightmost bar is
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
43 modified, so operations tend to be fairly local and self-contained.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
44
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
45 =head2 Frame operations
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
46
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
47 There is a range of basic operations that can be performed on the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
48 frame:
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
49
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
50 =over 4
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
51
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
52 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
53
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
54 You can I<append> something to the frame, either a bar or a command.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
55 This adds the bar or command in question to the right of the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
56
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
57 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
58
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
59 You can I<disbar> the frame, removing the rightmost bar ("closing the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
60 gap" where the bar was in the process).
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
61
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
62 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
63
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
64 You can I<copy> a section of the frame to the end. A section is the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
65 region of the frame between two bars, or from a bar to an end of the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
66 frame. When copying a section, a bar is placed to separate the copy
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
67 from the rest of the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
68
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
69 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
70
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
71 You can I<move> a section of the frame to the end. This is like
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
72 copying, except that original section (together with one of the bars
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
73 between it and the adjacent sections) is removed.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
74
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
75 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
76
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
77 You can I<delete> the end of the frame, again from the rightmost bar
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
78 onwards. This will delete the bar in the process.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
79
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
80 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
81
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
82 You can I<output> the end of the frame to the user. This outputs the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
83 area strictly beyond the rightmost bar. (Bars themselves are never
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
84 output, because they have no representation as a sequence of bits.)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
85
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
86 =item *
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
87
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
88 You can I<pacify> the end of the frame, beyond the rightmost bar; this
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
89 is the most complex operation. To understand this, the first thing to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
90 note is that the commands come in pairs; each I<active> command is
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
91 paired with a I<passive> command. Additionally, some commands have
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
92 names, and some do not have names, We can then describe the process as
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
93 follows:
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
94
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
95 =over 4
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
96
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
97 =item 1.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
98
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
99 The "passive regions" of the section are identified. These are
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
100 regions in which all the commands are named, and for which C<7> and
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
101 C<6> commands are correctly matched, as though they were parentheses;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
102 additionally, the substring C<76> cannot appear in a passive region.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
103 Passive regions are made as long as possible while respecting these
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
104 rules.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
105
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
106 =item 2.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
107
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
108 Each passive region is enclosed between a C<7> and C<6> command.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
109
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
110 =item 3.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
111
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
112 Each command outside any passive region (which must by definition be
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
113 active, as all anonymous commands are active, as are C<6> and C<7>) is
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
114 converted to the corresponding passive command.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
115
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
116 =back
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
117
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
118 =back
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
119
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
120 =head2 Commands
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
121
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
122 Now that we've defined the basic frame operations, it's possible to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
123 define the commands.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
124
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
125 Eight of the twelve commands have numerical names, used in the source
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
126 code representation: the six passive commands, and two active
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
127 commands. The other four active commands have no numerical name (and
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
128 cannot appear in the source), and are given names in English to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
129 identify them.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
130
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
131 =over 4
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
132
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
133 =item C<6> (active), C<0> (passive): Pacify then disbar
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
134
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
135 The C<6> command pacifies the rightmost section of the frame, and then
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
136 the frame is disbarred. The passive equivalent C<0> appends a C<6>
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
137 command to the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
138
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
139 =item C<7> (active), C<1> (passive): Append a bar
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
140
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
141 The C<7> command appends a bar to the frame. The passive equivalent
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
142 C<1> appends a C<7> command to the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
143
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
144 =item "copy" (active), C<2> (passive): Copy the rightmost section
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
145
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
146 The "copy" command copies the rightmost section of the frame to the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
147 end of the frame. The passive equivalent C<2> appends a "copy"
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
148 command to the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
149
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
150 =item "recycle" (active) C<5> (passive): Cycle early, then delete
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
151
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
152 The "recycle" command cycles a copy of the rightmost section of the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
153 frame onto the command list, even if the command list isn't empty.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
154 After doing that, it deletes the rightmost section of the frame
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
155 (including the bar that separates it from the rest of the frame). The
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
156 passive equivalent C<5> appends a "recycle" command to the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
157
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
158 =item "grab" (active), C<4> (passive): Swap, with extra bars
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
159
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
160 The "grab" command appends an extra bar to the frame then moves the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
161 new third-rightmost section (the original second-rightmost section) of
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
162 the frame to the end of the frame. The passive equivalent C<4>
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
163 appends a "grab" command to the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
164
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
165 =item "eject" (active), C<3> (passive): Output, then delete twice
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
166
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
167 The "eject" command outputs the end of the frame (beyond the rightmost
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
168 bar) to the user, then deletes the end of the frame from the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
169 second-rightmost bar onwards (i.e. deletes the end of the frame
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
170 twice). Exception: if the section of the frame that would be output
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
171 contains any unnamed commands, it is pacified first (pacification
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
172 leaves a region with only named commands), and a C<7> is prepended to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
173 the output. The passive equivalent C<3> appends an "eject" command to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
174 the frame.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
175
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
176 This command is also capable of producing input in some circumstances
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
177 (via outputting special codes which mean "read input"). Although the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
178 input can be in more than one form, it's always provided to the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
179 program as a nonnegative integer, and affects the program like this:
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
180 after the deletions from the frame, the new rightmost section of the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
181 frame (not including the bar to its left) has its content repeated a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
182 number of times equal to the input (e.g. 0 would remove everything to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
183 the right of the rightmost bar, 1 would do nothing, 2 would add an
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
184 extra copy of the text to the rightmost bar, and so on.) When reading
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
185 in integers from the user, any leading whitespace and commas are
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
186 skipped, then a decimal integer is read, with any stray characters
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
187 "after" the integer being left for future input commands; if there's
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
188 no integer available, 0 will be returned (this is also a valid
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
189 integer, so you may want to alternate between character and integer
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
190 reading to detect invalid input and EOF). When reading in characters,
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
191 they're converted to a character code, and 1 is added to them (EOF
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
192 counts as character code -1, and thus will produce 0 copies).
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
193
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
194 The very first command output via this command does not produce
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
195 output, but rather specifies the format of future output:
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
196
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
197 =over 4
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
198
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
199 =item Numerical (C<0>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
200
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
201 In each command list output, a value is calculated like this: the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
202 total number of C<7> and C<1> commands, minus the total number of C<6>
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
203 and C<0> commands. Exception: if the output was automatically
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
204 pacified (and thus had a C<7> prepended), that C<7> does not count in
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
205 the total count of C<7> commands. This integer is converted to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
206 decimal and output.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
207
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
208 Formatting can be controlled via outputting commands other than
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
209 strings of C<0>, C<1>, C<6>, C<7>. The output will be preceded by a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
210 space, unless it's the first output on the line. A C<2> at the end of
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
211 the string will output a trailing newline. A C<3> at the end of the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
212 string will append a comma to it. C<4> and C<5> can be placed at
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
213 either end of the string, and will turn into opening and closing
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
214 square brackets respectively.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
215
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
216 Input can be obtained via attempting to output C<23> (numerical input)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
217 or C<24> (character input). Outputting C<25> allows selection of a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
218 new output format (basically by "resetting" the format, meaning that
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
219 the next command to be output will select a format again).
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
220
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
221 =item Byte-per-command (C<1>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
222
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
223 Each command is output as an individual byte (thus the only bytes
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
224 output will be the digits C<0> to C<7> inclusive, as those are the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
225 only bytes that name commands). This format does not support input.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
226
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
227 =item Character code as number (C<2>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
228
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
229 This is similar to the numerical output C<0> explained above, except
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
230 that 1 is subracted from the number, and it's then used as a character
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
231 code (rather than being output in decimal). By default, this is in
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
232 binary (i.e. octets mod 256), but this can be changed by attempting to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
233 output a negative number; C<-1> selects binary, C<-2> selects UTF-8,
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
234 C<-3> inputs a number, C<-4> inputs a character, and C<-5> allows
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
235 selection of a new output format. Commands other than C<0>, C<1>,
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
236 C<6>, and C<7> aren't recognised here.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
237
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
238 =item Byte-per-three-commands (C<3>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
239
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
240 Any C<6> and C<7> commands in the output are ignored. The others are
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
241 taken as triples and interpreted as base-6 numbers (as usual, in a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
242 big-endian way), giving a value from 0 to 215 (decimal), 0 to 555
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
243 (base 6). This is is encoded as follows: if the value is 127
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
244 (decimal) or lower (that's 331 in base 6), it's output as an octet
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
245 directly; if the value is in the range 128 to 191 (decimal) inclusive
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
246 (that's 332 to 515 in base 6), then 64 (decimal), which is 144 (base
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
247 6), might or might not be added to it. Values above 192 (decimal) or
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
248 520 (base 6) control this addition; outputting 522 (the default)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
249 requests the addition to happen in a way that makes the output look as
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
250 much like UTF-8 as possible; 520 specifies never adding (until this
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
251 condition is changed); 521 specifies always adding. You can also
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
252 request input, with 523 requesting an integer and 524 requesting a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
253 character; 525 allows selection of a new output format. Other values
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
254 are currently reserved for future expansion and should not be used.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
255
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
256 =item Truncated octal (C<4>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
257
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
258 The output is encoded using the octal source encoding. However, if it
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
259 does not come to a whole number of bytes, any spare bits are discarded
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
260 (as opposed to padding them out, as would for example happen with the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
261 source format C<7> when the source were in binary). This format does
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
262 not support input.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
263
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
264 =item US-TTY (C<5>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
265
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
266 Any C<6> and C<7> commands in the output are ignored. The others are
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
267 taken in pairs and interpreted as base-6 numbers (as usual, in a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
268 big-endian way), giving a value from 0 to 35 (decimal), 0 to 55 (base
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
269 6). These are then in turn interpreted as being in an expanded
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
270 version of the US-TTY character set. This is a 5-bit character set
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
271 (thus using values from 0 to 31 (decimal), 0 to 51 (base 6)); the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
272 remaining four codes are reserved for giving instructions to the 7
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
273 interpreter itself. It can encode more than just 31 characters via
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
274 the use of shift states; it has five different states, notated here as
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
275 Ł, ł, Ŧ, Ø, ø, with Ł being the default. (Ł and Ŧ are identical,
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
276 except that immediately after outputting any character in state Ŧ, the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
277 shift state becomes ł; other shift states are stable until changed
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
278 explicitly. State ø is an expansion based on CLC-INTERCAL's version of
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
279 Baudot, a very similar character set to US-TTY; US-TTY reserves the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
280 state for use by expansions but does not specify what form those might
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
281 take. Note that the tables below are not I<quite> the same as
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
282 CLC-INTERCAL's, although they are very close; however, the only
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
283 differences are in the meanings of some shift codes, and in the fact
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
284 that C<#> appears in two places in order to improve compatibility with
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
285 existing US-TTY and CLC-INTERCAL-encoded text.) The character (or
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
286 control sequence) encoded depends on the shift state and the sequence
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
287 seen.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
288
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
289 Here's how the character set looks (shift state down the left side,
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
290 character encoding (first then second command) at the top, Ŧ encodes
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
291 the same characters as Ł):
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
292
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
293 00000011111122222233333344444455
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
294 01234501234501234501234501234501
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
295
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
296 Ł E A SIU DRJNFCKTZLWHYPQOBGØMXVł
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
297 ł e a siu drjnfcktzlwhypqobgØmxvŦ
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
298 Ø 3 - 87 $4',!:(5")2#6019?&ø./;Ł
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
299 ø ¢ + \#= *{~∀|^<[}>] @ £¬ Ø%_ Ł
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
300
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
301 C<00> encodes NUL, C<02> encodes newline, C<04> encodes space, C<12>
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
302 encodes carriage return, C<05> in state Ø encodes BEL, C<32> in state
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
303 ø encodes backspace, C<41> in state ø encodes DEL, other blank squares
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
304 are currently undefined and should not be used.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
305
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
306 As for the remaining codes, C<53> requests input of an integer, C<54>
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
307 requests input of a character, and C<55> allows selection of a new
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
308 output format. C<52> is currently undefined and should not be used.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
309
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
310 =item Source (C<7>)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
311
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
312 The output is encoded the same way that the source was (and, if
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
313 necessary, will be padded with C<1> bits; note that this padding only
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
314 occurs if the program ends "naturally", not if it ends abruptly due to
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
315 ejecting beyond the bottom of the stack).
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
316
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
317 =item Other values
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
318
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
319 Other values are currently undefined and reserved for future extension.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
320
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
321 =back
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
322
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
323 If an attempt is made to delete more sections than exist on the frame
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
324 via use of this command, the program exits immediately (although any
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
325 output will still be produced). (A program also exits if the frame
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
326 and command list are both empty.)
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
327
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
328 =back
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
329
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
330 =head2 Source Encoding
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
331
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
332 A 7 source file is written via the use of the eight named commands;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
333 the four anonymous commands cannot appear in the original
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
334 program. These form the initial command list; the initial frame
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
335 consists of two bars (with no commands before, after, or between
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
336 them). Additionally, it is not legal for a program to end with a C<7>
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
337 command. A file can either be written in ASCII, using one byte per
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
338 command, or in octal, using three bits per command. In the latter
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
339 case, when storing the program in a file, the commands are written in
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
340 such a way that the bit sequence of the commands and of the file are
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
341 the same when viewed in a big-endian way. If there's a need to pad
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
342 the end of the program, e.g. to make it round up to a multiple of 8
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
343 bits, the program can be padded by appending any number of C<1> bits
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
344 (the fact that programs may not end with a C<7> command makes this
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
345 unambiguous). Similarly, any number of consecutive C<1> bits at the
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
346 end of the file can be deleted (they're implied into the file when a
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
347 partial command is seen).
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
348
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
349 =cut
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
350
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
351 } or exit;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
352
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
353 use warnings;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
354 use strict;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
355 use feature qw/state/;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
356 use Encode qw/encode/;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
357 use 5.012;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
358
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
359 my $debug;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
360
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
361 while (@ARGV && $ARGV[0] =~ /^-/) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
362 my $option = shift @ARGV;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
363 $option eq '-d' ? $debug = 1 :
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
364 $option eq '-' ? last :
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
365 die "Unknown option $option";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
366 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
367
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
368 my %usttytable = (
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
369 # 0 0 0000 11 11 1122222 233 333344 444455
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
370 # 0 1 2345 01 23 4501234 501 234501 234501
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
371 'Ł' => "\0"."E\nA S" ."IU\rD". "RJNFCKT".'ZLW'. "HYPQOB". "GØMXVł",
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
372 'ł' => "\0"."e\na s" ."iu\rd". "rjnfckt".'zlw'. "hypqob". "gØmxvŦ",
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
373 'Ø' => "\0"."3\n- \a"."87\r\$"."4',!:(5".'")2'. "#6019?". "&ø./;Ł",
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
374 'ø' => "\0"."¢\n+ \\"."#=\r*". "{~∀|^<[".'}>]'."\b@—£¬\x7F"."—Ø%_—Ł");
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
375 $usttytable{'Ŧ'} = $usttytable{'Ł'};
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
376
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
377 $| = 1; undef $/;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
378 binmode STDIN;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
379 # Note: we leave STDOUT in text mode until the user selects an output format
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
380 # that clearly requires binary.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
381 my $program = <>;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
382 my $program_was_binary = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
383 my $bits_per_byte = length unpack "B*", "\0";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
384
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
385 if ($program =~ y/01234567 \n\r\t\f//c) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
386 # If the program contains anything other than digits, spaces, and
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
387 # \n,\r,\t,\f, then unpack it from binary.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
388 my $binary = unpack "B*", $program;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
389 $binary =~ s/1+$//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
390 $binary .= 1 while (length $binary) % 3;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
391 $program = "";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
392 $program .= oct "0b$&" while $binary =~ s/^...//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
393 $program_was_binary = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
394 } else {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
395 $program =~ s/\s//g;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
396 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
397
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
398 # Technically we should start with the program on the command list, but
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
399 # it's easier to start it on the frame and do an explicit-cycle in order
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
400 # to move it into place.
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
401 my $frame = "|||$program";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
402 my $delayed_frame_copy = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
403 my @commandlist = ();
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
404
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
405 my $outformat = undef;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
406
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
407 sub pacify {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
408 local $_ = shift;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
409 s/((7(?2)+6|[0-5])+)/"7${1}6"=~y:67:89:r/ge;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
410 y/67cegr89/0-7/;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
411 $_;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
412 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
413
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
414 my $pending_octal = "";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
415 my $getc_buffer = undef;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
416
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
417 sub getin {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
418 if ($getc_buffer) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
419 my $c = $getc_buffer;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
420 undef $getc_buffer;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
421 $debug and printf STDERR "\tRereading character code $c\n";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
422 return $c;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
423 } else {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
424 my $c = getc;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
425 $c = defined $c ? (ord $c) + 1 : 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
426 return $c;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
427 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
428 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
429
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
430 sub input_number {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
431 my $c;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
432 my $n = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
433 while (($c = getin) && (chr $c - 1) =~ /\s/) {}
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
434 if (!$c) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
435 $debug and print STDERR "\tRead EOF, expecting number\n";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
436 $delayed_frame_copy = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
437 return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
438 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
439 while ((chr $c - 1) =~ /(\d)/) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
440 $n *= 10;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
441 $n += $1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
442 $c = getin;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
443 !$c and last;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
444 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
445 $getc_buffer = $c if $c;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
446 $debug and print STDERR "\tRead integer value $n\n";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
447 $delayed_frame_copy = $n;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
448 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
449
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
450 sub input_char {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
451 my $c = getin;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
452 $debug and print STDERR (!$c ? "\tRead EOF, expecting character\n" :
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
453 "Read character code ".($c - 1));
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
454 $delayed_frame_copy = $c;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
455 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
456
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
457 sub oprint {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
458 local $_ = shift;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
459 my $autopacify = /\D/;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
460 state $after_newline = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
461 $autopacify and $_ = "7" . pacify $_;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
462 length $_ or return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
463
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
464 unless (defined $outformat) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
465 s/(.)//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
466 $outformat = $1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
467 $outformat == 7 and !$program_was_binary and $outformat = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
468 $debug and print STDERR "\tSelected output format $outformat\n";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
469 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
470 [
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
471 sub { # 0: numerical
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
472 $_ eq '23' and input_number, return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
473 $_ eq '24' and input_char, return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
474 $_ eq '25' and (undef $outformat), return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
475 my $result = y/71//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
476 $result -= y/60//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
477 $result-- if $autopacify;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
478 print " " unless $after_newline;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
479 $after_newline = !!/2$/;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
480 s/^[45]+// and print ($& =~ y/45/[]/r);
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
481 print $result;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
482 s/[2345]+$// and print ($& =~ y/2345/\n,[]/r);
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
483 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
484 sub { # 1: byte per command
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
485 print;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
486 $after_newline = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
487 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
488 sub { # 2: read numbers, write character codes
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
489 binmode STDOUT;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
490 state $utf8mode = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
491 my $result = y/71//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
492 $result -= y/60//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
493 $result-- if $autopacify;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
494 if ($result > 0) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
495 print $utf8mode ? encode("UTF-8", chr($result - 1)) :
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
496 encode("ISO-8859-1", chr ($result - 1));
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
497 } else {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
498 $result == -1 and ($utf8mode = 0), return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
499 $result == -2 and ($utf8mode = 1), return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
500 $result == -3 and input_number, return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
501 $result == -4 and input_char, return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
502 $result == -5 and (undef $outformat), return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
503 $result == 0 and die "Attempted to output EOF";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
504 die "Attempted to output negative character code $result";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
505 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
506 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
507 sub { # 3: byte per three commands
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
508 state $partial = "";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
509 state $add64 = 194;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
510 state $utf8bytes = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
511 binmode STDOUT;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
512 s/[67]//g;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
513 $partial .= $_;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
514 while ($partial =~ s/^(.)(.)(.)//) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
515 my $v = $1*36 + $2 * 6 + $3;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
516 if ($v < 128) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
517 print chr $v;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
518 $utf8bytes = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
519 } elsif ($v < 192) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
520 if ($add64 == 192 || ($add64 == 194 && $utf8bytes)) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
521 print chr $v;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
522 $utf8bytes and $utf8bytes--;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
523 } elsif ($add64 == 193 || ($add64 == 194 && !$utf8bytes)) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
524 $v += 64;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
525 print chr $v;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
526 $utf8bytes = 1; # always at least 1 trailing byte
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
527 $v >= 0xE0 and ++$utf8bytes;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
528 $v >= 0xF0 and ++$utf8bytes;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
529 $v >= 0xF8 and ++$utf8bytes;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
530 $v >= 0xFC and ++$utf8bytes;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
531 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
532 } elsif ($v < 195) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
533 $add64 = $v;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
534 } elsif ($v == 195) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
535 input_number;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
536 } elsif ($v == 196) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
537 input_char;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
538 } elsif ($v == 197) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
539 undef $outformat;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
540 } else {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
541 die "Unknown byte-per-three-commands value $v";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
542 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
543 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
544 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
545 sub { # 4: octal
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
546 state $partial = "";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
547 binmode STDOUT;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
548 $partial .= sprintf "%03b", $& while s/%.//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
549 print chr oct "0b$&" while $partial =~ s/^.{$bits_per_byte}//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
550 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
551 sub { # 5: US-TTY
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
552 s/[67]//g;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
553 state $partial = "";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
554 state $shiftstate = 'Ł';
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
555 $partial .= $_;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
556 while ($partial =~ s/^(.)(.)//) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
557 my $v = $1 * 6 + $2;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
558 $v == 33 and input_number, return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
559 $v == 34 and input_char, return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
560 $v == 35 and (undef $outformat), return;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
561 my $c = substr $usttytable{$shiftstate}, $v, 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
562 if ($usttytable{$c}) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
563 $shiftstate = $c;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
564 } elsif ($c eq '—') { # represents an invalid character
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
565 ...;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
566 } else {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
567 # TODO: Adapt to locale encoding?
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
568 print encode("UTF-8",$c);
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
569 $shiftstate eq 'Ŧ' and $shiftstate = 'ł';
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
570 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
571 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
572 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
573 sub { # 6: Unimplemented
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
574 die "Output format 6 is currently undefined";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
575 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
576 sub { # 7: Like source; if we get here, it's octal encoding
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
577 binmode STDOUT;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
578 $pending_octal .= sprintf "%03b", $& while s/^.//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
579 print chr oct "0b$&" while $pending_octal =~ s/^.{$bits_per_byte}//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
580 },
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
581 ]->[$outformat]->();
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
582 $debug and print STDERR "\n";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
583 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
584
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
585 my $explicit = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
586 CYCLE: while ($frame ne '') {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
587 $frame =~ /[|](\w*)$/
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
588 or die "when cycling, frame is nonempty but has no bar";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
589 my $commandlist = $1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
590 $commandlist eq '' and $explicit = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
591 $explicit and $frame =~ s/[|](\w*)$//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
592 $explicit = 0;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
593 unshift @commandlist, split /([0-57]*)/, $commandlist;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
594 while (@commandlist) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
595 if ($delayed_frame_copy != 1) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
596 $frame =~ s/[|]\K(\w*)$/$1 x $delayed_frame_copy/e
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
597 || die "Attempt to read input with no bar in the frame";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
598 $delayed_frame_copy = 1;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
599 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
600 $debug and print STDERR "\t$frame ", @commandlist, "\n";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
601 my $command = shift @commandlist;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
602 length $command or next;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
603 for ($command) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
604 /[0-57]/ and $frame .= $command =~ y/0-57/67cegr|/r;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
605 /6/ and $frame =~ s/[|](\w*)$/pacify $1/e
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
606 || die "6 command run with no bar in the frame";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
607 /c/ and $frame =~ s/[|](\w*)$/|$1|$1/
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
608 || die "'copy' command run with no bar in the frame";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
609 /e/ and $frame =~ s/[|]\w*[|](\w*)$/(oprint $1), ""/e
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
610 || $frame =~ s/(\w*)$/ (oprint $1), exit/e;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
611 /g/ and $frame =~ s/(\w*)[|](\w*)$/$2||$1/
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
612 || die "'grab' command run with no bar in the frame";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
613 /r/ and $explicit = 1 and next CYCLE;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
614 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
615 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
616 }
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
617
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
618 $pending_octal =~ s/1+$//;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
619 if (length $pending_octal) {
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
620 $pending_octal .= 1 until length $pending_octal == $bits_per_byte;
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
621 print chr oct "0b$pending_octal";
766bdea3dbe9 <ais523> fetch http://nethack4.org/esolangs/7/7.pl
HackEso <hackeso@esolangs.org>
parents:
diff changeset
622 }