Mercurial > repo
comparison interps/clc-intercal/inst/lib/perl5/Language/INTERCAL/Generate/ByteCode.Data @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
995:6883f5911eb7 | 996:859f9b4339e6 |
---|---|
1 # Data used to generate ByteCode.pm and documentation | |
2 | |
3 # This file is part of CLC-INTERCAL | |
4 | |
5 # Copyright (c) 2007-2008 Claudio Calvelli, all rights reserved. | |
6 | |
7 # CLC-INTERCAL is copyrighted software. However, permission to use, modify, | |
8 # and distribute it is granted provided that the conditions set out in the | |
9 # licence agreement are met. See files README and COPYING in the distribution. | |
10 | |
11 # PERVERSION "CLC-INTERCAL Generate/ByteCode.Data 1.-94.-2"; | |
12 | |
13 # all defined opcodes | |
14 @GROUP OPCODES NAME=w TYPE=s NUMBER=d ARGS=s DESCR=s ASSIGNABLE=d CONST=d DOC=m | |
15 @SOURCE STATEMENTS | |
16 @SOURCE REGISTERS | |
17 @SOURCE PREFIXES | |
18 @SOURCE EXPRESSIONS | |
19 @SOURCE CONSTANTS | |
20 @END OPCODES | |
21 | |
22 # statements - opcodes 0x00..0x3f | |
23 @GROUP STATEMENTS NAME=w TYPE=s NUMBER=d ARGS=s DESCR=s ASSIGNABLE=d CONST=d DOC=m | |
24 STS S 0x00 '###C(#)S' 'STArt of STAtement' 0 0 | |
25 Takes a variable number of constants, not less than four. The | |
26 first constant indicates the byte position in the source code | |
27 where this statement was compiled from; the second constant | |
28 indicates the length of the statement in the source code; | |
29 the third indicates whether the statement may be a comment (it has | |
30 not been recognised using the currently active grammar) or not; | |
31 the fourth indicates the number of constants following. The | |
32 rest of the constants indicate which grammar rules were used to | |
33 compile this particular statement. | |
34 | |
35 At runtime, not all grammar rules may be available at all times, | |
36 depending on the history of I<CRE> and I<DES>. To execute | |
37 a statement corresponding to a given bit of source code, the | |
38 runtime will find all relevant I<STS> statements find the best one | |
39 which could have been compiled given the current state of the | |
40 grammar, and executes it; if a non-comment statement is available, | |
41 it will be used, otherwise a comment one will have to do. | |
42 If execution is to proceed sequentially, | |
43 the second constant is used to figure out how to repeat this | |
44 process. Execution starts at byte offset 0 in the source code. | |
45 | |
46 Grammar rules are numbered at compile time, and may differ from | |
47 program to program. | |
48 STO S 0x01 'EA' 'STOre' 0 0 | |
49 Followed by two expressions, assigns the value of the first | |
50 expression to the second. It is common to have a register as the | |
51 second expression, but any assignable expression will do. | |
52 CRE S 0x02 'EVC(<)C(>)' 'CREate' 0 0 | |
53 Followed by two expressions (a grammar and a symbol), a constant | |
54 (a left count), I<left count> rules, another constant (a right | |
55 count) and I<right count> chunks of code, executes a CREATE | |
56 statement. This is not documented here but the compilers provide | |
57 a large number of examples. | |
58 DES S 0x03 'EVC(<)' 'DEStroy' 0 0 | |
59 Followed by two expressions (a grammar and a symbol) and a constant | |
60 (a left count) and I<left count> rules, executes a DESTROY statement. | |
61 MSP S 0x04 'EC(V)' 'Make SPlat' 0 0 | |
62 Followed by an expression, the splat code, a number, the count, and | |
63 I<count> more expressions, generates a splat. The first expression | |
64 is the splat code, the rest are used to generate the splat message. | |
65 The splat code determines the correct number of arguments, if the | |
66 wrong number is provided the message may look weird. | |
67 DSX S 0x05 'ES' 'Double-oh-Seven eXecution' 0 0 | |
68 Followed by an expression (which should | |
69 have value between 0 and 100), it executes the statement with | |
70 a probability indicated by the expression, between 0% (never) | |
71 and 100% (always). | |
72 NOT S 0x06 'S' 'NOT' 0 0 | |
73 Signals that this statement is initially abstained from. A | |
74 statement might be abstained from without containing a I<NOT>, | |
75 or might contain one and not be abstained from, depending on the | |
76 I<ABL>, I<ABG>, I<REL> and I<REG> executed since the start of | |
77 the program. | |
78 NXT S 0x07 'E' 'NeXT' 0 0 | |
79 Followed by an expression, a label, stashes the address of | |
80 the next statement and continues execution at that label. It is | |
81 an error if the label is multiply defined or not defined at all. | |
82 RES S 0x08 'E' 'RESume' 0 0 | |
83 Followed by an expression, pops that many levels from | |
84 the stash containing the return addresses for I<NXT>, I<NXL> | |
85 and I<NXG>. All the addresses except one are then discarded, and | |
86 execution continues at the last address extracted from the stash. | |
87 FOR S 0x09 'E' 'FORget' 0 0 | |
88 Followed by an expression, pops that many levels from | |
89 the stash containing the return addresses for I<NXT>, I<NXL> | |
90 and I<NXG> and throws these addresses in the bit bucket. | |
91 STA S 0x0a 'C(R)' 'STAsh' 0 0 | |
92 Followed by a constant (the count) and I<count> registers, STASHes | |
93 these registers. | |
94 RET S 0x0b 'C(R)' 'RETrieve' 0 0 | |
95 Followed by a constant (the count) and I<count> registers, RETRIEVEs | |
96 these registers. | |
97 IGN S 0x0c 'C(R)' 'IGNore' 0 0 | |
98 Followed by a constant (a count) and I<count> registers, ignores the | |
99 registers. | |
100 REM S 0x0d 'C(R)' 'REMember' 0 0 | |
101 Followed by a constant (a count) and I<count> registers, remembers | |
102 the registers. | |
103 ABL S 0x0e 'E' 'ABstain from Label' 0 0 | |
104 Followed by an expression, representing a label, ABSTAINs FROM the | |
105 corresponding statement(s). | |
106 ABG S 0x0f 'C(O)' 'ABstain from Gerund' 0 0 | |
107 Followed by a constant (the count) and I<count> gerunds, ABSTAINs FROM | |
108 the corresponding statement(s). | |
109 REL S 0x10 'E' 'REinstate from Label' 0 0 | |
110 Followed by an expression, representing a label, | |
111 REINSTATEs the corresponding statement(s). | |
112 REG S 0x11 'C(O)' 'REinstate from Gerund' 0 0 | |
113 Followed by a constant (the count) and I<count> gerunds, REINSTATEs the | |
114 corresponding statement(s). | |
115 GUP S 0x12 '' 'Give UP' 0 0 | |
116 Causes program termination. When used in a compiler module, causes | |
117 module processing to stop, the compiler will then load the next | |
118 module or, if no more modules are to be loaded, it will start | |
119 compiling the program. | |
120 WIN S 0x13 'C(A)' 'Write IN' 0 0 | |
121 Followed by a constant (a count) and I<count> assignable | |
122 expressions, writes them in. | |
123 ROU S 0x14 'C(E)' 'Read OUt' 0 0 | |
124 Followed by a constant (a count) and I<count> expressions, | |
125 reads them out. | |
126 LAB S 0x15 'ES' 'LABel' 0 0 | |
127 Followed by an expression, indicates this statement's | |
128 label. If the expression is nonzero, after this statement the ICBM | |
129 will go looking for corresponding I<CFL> and I<NFL> statements | |
130 (COME FROMs and NEXT FROMs). It is also used to abstain/reinstate | |
131 by label. | |
132 CFL S 0x16 'E' 'Come From Label' 0 0 | |
133 Followed by an expression, executes a COME FROM | |
134 label. The special register I<%CF> determines, amongst other | |
135 things, whether it is admissible to have multiple COME FROM | |
136 (and NEXT FROM) all pointing at the same label. The default is | |
137 to cause a splat; linking with the object I<thick.io> changes | |
138 this to allow multiple COME FROMs and NEXT FROMs to create threads. | |
139 CFG S 0x17 'C(O)' 'Come From Gerund' 0 0 | |
140 Followed by a constant (the count) and I<count> gerunds (opcodes), | |
141 executes a COME FROM gerund. The special register I<%CF> | |
142 determines, amongst other things, whether these statements | |
143 are really executed or not. The default is not, and linking a | |
144 program with the object I<come-from-gerund.io> will change this | |
145 register to allow these statements: this object is normally linked | |
146 automatically when the program source has a suffix I<.gi>. See | |
147 I<CFL> for other functions of the I<%CF> register. | |
148 QUA S 0x18 'S' 'QUAntum statement' 0 0 | |
149 Executes the rest of the statement in "quantum | |
150 bit creation" mode. This means that anything which modifies data | |
151 will end up creating quantum bits. | |
152 CWB S 0x19 'SS' 'loop: Condition While Body' 0 0 | |
153 Followed by two statements, executes a loop. This implements | |
154 the (default) loop where the condition is before the WHILE and the | |
155 body after. The first statement is the body and the second is | |
156 the condition, not the other way around as one would expect. | |
157 BWC S 0x1a 'SS' 'loop: Body While Condition' 0 0 | |
158 Followed by two statements, executes a loop. This implements | |
159 the (non default) loop where the body is before the WHILE and the | |
160 condition after. The first statement is the condition and the | |
161 second is the body, not the other way around as one would expect. | |
162 ENS S 0x1b 'RR' 'ENSlave' 0 0 | |
163 Followed by two registers, enslaves the first to the second. | |
164 FRE S 0x1c 'RR' 'FREe' 0 0 | |
165 Followed by two registers, frees the first from the | |
166 second. It is an error to free a register from another register | |
167 it was not enslaved to. | |
168 STU S 0x1d 'EER' 'STUdy' 0 0 | |
169 Followed by an expression (the subject), a label (the | |
170 lecture) and a register (the class), executes a STUDY statement. | |
171 ENR S 0x1e 'C(E)R' 'ENRol' 0 0 | |
172 Followed by a count of subjects, I<count> expressions representing | |
173 the subjects, and a register wishing to study these subjects, | |
174 looks for a class teaching the subjects and enrols the register there. | |
175 LEA S 0x1f 'ER' 'LEArns' 0 0 | |
176 Followed by an expression (the subject), and a register (the student) | |
177 looks for a lecture where that subject is taught in one of the | |
178 classes the student is enrolled in. The class register is | |
179 temporarily enslaved to the student and execution continues | |
180 at the start of the lecture. | |
181 FIN S 0x20 '' 'FINish lecture' 0 0 | |
182 Execution continues after the I<LEA> which took | |
183 us to the lecture. Also frees the class register from the student. | |
184 GRA S 0x21 'R' 'GRAduate' 0 0 | |
185 Followed by a register (a student) it causes the | |
186 student to graduate, that is to drop all classes. | |
187 NXL S 0x22 'E' 'Next From Label' 0 0 | |
188 Similar to I<CFL>, but executes a NEXT FROM instead: the difference | |
189 is that I<NXL> stashes the return address in the same way as I<NXT> | |
190 does. See I<CFL> and I<NXT>. | |
191 NXG S 0x23 'C(O)' 'Next From Gerund' 0 0 | |
192 Similar to I<CFG>, but executes a NEXT FROM instead: the difference | |
193 is that I<NXG> stashes the return address in the same way as I<NXT> | |
194 does. See I<CFG> and I<NXT>. | |
195 CON S 0x24 'OO' 'CONvert' 0 0 | |
196 Followed by two opcodes, converts the first into the | |
197 second. The two opcodes must be compatible, in the sense that | |
198 they take the same operands. | |
199 SWA S 0x25 'OO' 'SWAp' 0 0 | |
200 Followed by two opcodes, swaps them. The two opcodes must | |
201 be compatible, in the sense that they take the same operands. | |
202 BUG S 0x26 '#' 'compiler BUG' 0 0 | |
203 This opcode is automatically inserted by the compiler where | |
204 appropriate. Takes one argument, the bug type (#0 - explainable, | |
205 \#1 - unexplainable). | |
206 OPT S 0x27 'C([)C(])' 'OPTimise' 0 0 | |
207 Takes a constant (the left count), I<left count> patterns, a second | |
208 constant (the right count) and I<right count> replacements. Inserts | |
209 the resulting rule into the optimiser, which can do whatever it | |
210 likes with it. | |
211 EBC S 0x28 'ES' 'Event: Body while Condition' 0 0 | |
212 Followed by an expression and a statement, schedules an event. This | |
213 implements the (non default) event where the body is before the WHILE | |
214 and the condition after, and therefore produces a runtime error unless | |
215 its implementation is CONVERTed to or SWAPped with I<ECB>. | |
216 ECB S 0x29 'ES' 'Event: Condition while Body' 0 0 | |
217 Followed by an expression and a statement, schedules an event. This | |
218 implements the (default) event where the condition is before the | |
219 WHILE and the body after. | |
220 FRZ S 0x2a '' 'FReeZe' 0 0 | |
221 Freezes the current program by removing the source code and replacing | |
222 the grammar used to compile it with the "secondary" grammar; this | |
223 means that subsequent I<CRE> and I<DES> will be an error if they | |
224 cause recompilation. A compiler works by creating a secondary grammar, | |
225 then freezing itself and then continuing with the user's program, | |
226 which is compiled using the new grammar just created, rather than | |
227 the one used to compile the compiler itself. | |
228 SYS S 0x2b 'EC(S)' 'SYStem call' 0 0 | |
229 Followed by an expression (the system call number), a count, and | |
230 I<count> statements (the system call implementation), defines a | |
231 system call. | |
232 UNS S 0x2c 'EEC(E)' 'UNdocumented Statement' 0 0 | |
233 This opcode is documented in the CLC-INTERCAL reference manual. | |
234 STE S 0x2d 'C(E)C(E)C(R)' 'STEal' 0 0 | |
235 Followed by a count, I<count> expression, a second count, the | |
236 corresponding number of expressions, a third count and the | |
237 corresponding number of registers, defines a STEAL statement; | |
238 the first two counts should be #0 or #1, representing the presence | |
239 or absence of ON and FROM, respectively. | |
240 SMU S 0x2e 'C(E)C(E)C(R)' 'SMUggle' 0 0 | |
241 Takes the same arguments as I<STE>, but defines a SMUGGLE statement. | |
242 CSE S 0x2f 'EC(ES)' 'CaSE' 0 0 | |
243 Followed by an expression, a count and I<count> pairs of (expression, | |
244 statement), defines a CASE statement. | |
245 # opcodes 0x30 .. 0x3c are reserved | |
246 MKG S 0x3d 'EE' 'MaKe Gerund' 0 0 | |
247 This opcode creates a new internal operation. It is useful to | |
248 extend the compiler (this is fully documented in the CLC-INTERCAL | |
249 reference manual). | |
250 USG S 0x3e 'E' 'USe Gerund' 0 0 | |
251 Uses an opcode created by I<MKG>. It is useful to extend the | |
252 compiler (this is fully documented in the CLC-INTERCAL reference | |
253 manual). | |
254 FLA S 0x3f '' 'set object FLAg' 0 0 | |
255 This opcode should never be executed, and will cause a runtime | |
256 error; compilers can generate this opcode to set an object flag, | |
257 but the opcode will be executed at compile time and replaced | |
258 by a single ABSTAINed FROM I<FLA>. | |
259 @END STATEMENTS | |
260 | |
261 # registers - opcodes 0x40..0x4f | |
262 @GROUP REGISTERS NAME=w TYPE=s NUMBER=d ARGS=s DESCR=s ASSIGNABLE=d CONST=d DOC=m | |
263 SPO R 0x40 'E' 'SPOt' 1 0 | |
264 Spot register (e.g. I<.4>) | |
265 TSP R 0x41 'E' 'Two SPot' 1 0 | |
266 Two spot register (e.g. I<:7>) | |
267 TAI R 0x42 'E' 'TAIl' 1 0 | |
268 Tail register (e.g. I<,2>). This represents the whole array. See | |
269 I<SUB> for subscripting. | |
270 HYB R 0x43 'E' 'HYBrid' 1 0 | |
271 Hybrid register (e.g. I<;9>). This represents the whole array. See | |
272 I<SUB> for subscripting. | |
273 WHP R 0x44 'E' 'WHirlPool' 1 0 | |
274 Whirlpool (e.g. I<@9>). This represents CLC-INTERCAL's class | |
275 registers. When used for I/O, it represents the filehandle | |
276 associated with the class. | |
277 DOS R 0x45 'E' 'Double-Oh-Seven' 1 0 | |
278 Double-oh-seven: a special internal spot register used by the | |
279 compilers. | |
280 SHF R 0x46 'E' 'SHark Fin' 1 0 | |
281 Shark fin: a special internal tail register used by the compilers | |
282 (e.g. I<^1>, the arguments given to the program on startup) | |
283 CHO R 0x47 'E' 'Crawling HOrror' 1 0 | |
284 Crawling horror: a special register holding a compiler, grammar | |
285 or something similar. Currently, these registers cannot be used | |
286 directly, they are implicitely used by I<CRE> and I<DES>. | |
287 # opcodes 0x48..0x4e are reserved for future register types | |
288 TYP R 0x4f 'RE' 'TYPe' 1 0 | |
289 Followed by any register, returns its type. | |
290 For example, I<TYP> I<SPO> I<136> is equivalent | |
291 to I<SPO>. It can be useful to find out the type of an | |
292 indirect register, and is used to translate CLC-INTERCAL's | |
293 intersection-worm. | |
294 @END REGISTERS | |
295 | |
296 # register prefixes - opcodes 0x50..0x5f | |
297 @GROUP PREFIXES NAME=w TYPE=s NUMBER=d ARGS=s DESCR=s ASSIGNABLE=d CONST=d DOC=m | |
298 OVR R 0x50 'ER' 'OVerload Register' 1 0 | |
299 Followed by an expression and a register, | |
300 overloads the register and returns the register itself. | |
301 ROR R 0x51 'R' 'Remove Overload Register' 1 0 | |
302 Followed by a register name, removes any overloads and returns | |
303 the register itself. Used by the optimiser. Assignable. | |
304 OWN R 0x52 'ER' 'OWNer' 1 0 | |
305 Followed by a constant and a register, takes the | |
306 corresponding owner from the register. | |
307 SUB R 0x53 'ER' 'SUBscript' 1 0 | |
308 Followed by an expression and a subscriptable register, | |
309 it accesses the given subscript. For multidimensional arrays, | |
310 repeat as in I<SUB> I<131> I<SUB> I<132> I<TAI> I<133> for I<:5 SUB | |
311 \#4 SUB #3>. In addition to hybrid, tail and shark fin registers, | |
312 whirlpools also accept subscripts, allowing to access the subjects | |
313 directly. | |
314 # opcodes 0x53..0x5f are reserved | |
315 @END PREFIXES | |
316 | |
317 # expressions - opcodes 0x60..0x7b | |
318 @GROUP EXPRESSIONS NAME=w TYPE=s NUMBER=d ARGS=s DESCR=s ASSIGNABLE=d CONST=d DOC=m | |
319 MUL E 0x60 'C(E)' 'MULtiple number' 0 0 | |
320 Followed by an expression (the count) and then a number of | |
321 expressions, represents a ``multiple number''. This can be used | |
322 to assign to an array, to dimension it (e.g. translating the | |
323 statement C<,2 <- #3 BY #5> the value to be assigned would be | |
324 I<MUL> I<130> I<131> I<133>). Not assignable. | |
325 STR E 0x61 'C(N)' 'STRing' 0 0 | |
326 Similar to I<MUL>, but used in the special case where all the | |
327 arguments are constant characters. This may result in internal | |
328 optimisations and the like. Otherwise it is just a more compact | |
329 way of using I<MUL> where all arguments are constants and fit | |
330 in a byte. Not assignable. | |
331 BUT E 0x62 '#E' 'unary BUT' 1 0 | |
332 Followed by two expressions, computes the unary I<BUT> of the | |
333 second expression, preferring the value of the first - so this | |
334 can also be used for unary I<3BUT> etc. The special prevference | |
335 value 7, which is invalid for unary I<BUT>, is used to indicate | |
336 unary I<AND>. Assignable if the second argument is assignable. | |
337 BBT E 0x63 '#EE' 'binary BUT' 1 0 | |
338 Binary version of I<BUT>. Used by the optimiser. Assignable if | |
339 its arguments are. | |
340 SWB E 0x64 'E' 'unary Subtract Without Borrow' 1 0 | |
341 Followed by one expression, it computes the unary subtract | |
342 without borrow. In base 2, corresponds to the unary exclusive | |
343 or. Assignable if the argument is. | |
344 BSW E 0x65 'EE' 'binary Subtract Without Borrow' 1 0 | |
345 Binary version of I<SWB>. Used by the optimiser. Assignable if | |
346 its arguments are. | |
347 AWC E 0x66 'E' 'unary Add Without Carry' 1 0 | |
348 Followed by one expression, it computes the unary Add without | |
349 carry; invalid in base 2. Assignable if the argument is. | |
350 BAW E 0x67 'EE' 'binary Add Without Carry' 1 0 | |
351 Binary version of I<AWC>. Used by the optimiser. Assignable if | |
352 its arguments are. | |
353 SEL E 0x68 'EE' 'SELect' 1 0 | |
354 Followed by two expressions, it selects them. Assignable if the | |
355 arguments are assignable. | |
356 INT E 0x69 'EE' 'INTerleave' 1 0 | |
357 Followed by two expressions, interleaves them. Assignable if both | |
358 arguments are assignable. | |
359 NUM E 0x6a 'R' 'NUMber' 1 0 | |
360 Followed by a register, returns its number. So for example I<NUM> | |
361 I<SPO> I<#2> would be the same as I<#2>. This is more useful when | |
362 the register provided is reached using I<OWN>. Assignable. | |
363 OVM E 0x6b 'EE' 'OVerload Many' 1 0 | |
364 Followed by two expressions, overloads a range of registers. Note | |
365 that all types of registers are overloaded. The range is determined | |
366 by uninterleaving the second argument. See also I<OVR>. Assignable. | |
367 ROM E 0x6c 'E' 'Remove Overload Many' 1 0 | |
368 Followed by an expression, removes overload from a range of | |
369 of registers. Used by the optimiser. Assignable. | |
370 SPL E 0x6d '' 'SPLat' 1 0 | |
371 Returns the code of the last splat. This is only useful if the | |
372 program is quantum or threaded, otherwise it won't be executing | |
373 after a splat. If there was no splat, generates one. Assignable, | |
374 but in this case it unconditionally splats for obvious reasons. | |
375 UDV E 0x6e 'E' 'Unary DiVide' 1 0 | |
376 The "most useless" operation, but surely somebody will find a | |
377 use for it. This operation can be considered arithmetic or | |
378 bitwise, depending on the value of special register I<%DM>. | |
379 RSE E 0x6f 'EE' 'Reverse SElect' 1 0 | |
380 Like I<SEL>, but swaps its operands. | |
381 RIN E 0x70 'EE' 'Reverse INterleave' 1 0 | |
382 Like I<INT>, but swaps its operands. | |
383 UNE E 0x71 'EEC(E)' 'UNdocumented Expression' 0 0 | |
384 This opcode is documented in the CLC-INTERCAL reference manual. | |
385 # opcodes 0x72 .. 0x7d are reserved | |
386 @END EXPRESSIONS | |
387 | |
388 # constants - opcodes 0x7e..0x7f | |
389 @GROUP CONSTANTS NAME=w TYPE=s NUMBER=d ARGS=s DESCR=s ASSIGNABLE=d CONST=d DOC=m | |
390 HSN # 0x7e 'N' 'Half Spot Number' 1 1 | |
391 Followed by a second byte, represents the value of that byte. | |
392 OSN # 0x7f 'NN' 'One Spot Number' 1 1 | |
393 Followed by two bytes, represents the 16 bit number which has the | |
394 first such byte as higher significant half, and the second byte | |
395 as lower significant half. | |
396 @END CONSTANTS | |
397 | |
398 # all special registers | |
399 @GROUP SPECIAL NAME=w TYPE=s NUMBER=d DEFAULT=s CODE=s DESCR=s DOC=m | |
400 @SOURCE DOUBLE_OH_SEVEN | |
401 @SOURCE SHARK_FIN | |
402 @SOURCE WHIRLPOOL | |
403 @END SPECIAL | |
404 | |
405 # special "spot" registers | |
406 @GROUP DOUBLE_OH_SEVEN NAME=w TYPE=s NUMBER=d DEFAULT=s CODE=s DESCR=s DOC=m | |
407 WT '%' 1 '0' 'zeroone' 'Write Type' | |
408 Determines how numeric WRITE IN behaves. The default value of | |
409 \#0 corresponds to the standard, traditional form; the value | |
410 \#1 enables wimp mode for input. Any other value is invalid. | |
411 RT '%' 2 '0' 'roman' 'Read Type' | |
412 Determines how numeric READ OUT produces its output. Assigning | |
413 a number to this register causes the corresponding style to be | |
414 selected; assigning a I<MUL> causes a symbolic lookup to determine | |
415 the style number. See L<Language::INTERCAL::ReadNumbers>. | |
416 IO '%' 3 '0' 'iotype' 'I/O type' | |
417 Determines how non-numeric WRITE IN and READ OUT work. Assigning | |
418 a number to this register causes the corresponding style to be | |
419 selected; assigning a I<MUL> causes a symbolic lookup to determine | |
420 the style number. See L<Language::INTERCAL::ArrayIO>. | |
421 BA '%' 4 '2' 'base' 'BAse' | |
422 Holds the base used for all arithmetic. Assigning a value less | |
423 than 2 or greater than 7 causes an error. | |
424 CF '%' 5 '0' 'comefrom' 'Come From style' | |
425 This register can only hold values from #0 to #3. The lowest bit | |
426 (in base 2) determines what happens when multiple COME FROM or | |
427 NEXT FROM all point at the same label: if zero, you get a splat, | |
428 if one you get a multithreaded program. The other bit determines | |
429 whether COME FROM gerund (and NEXT FROM gerund) will work: zero | |
430 disables these statements, one enables them. Thus all compilers | |
431 set %CF to #0, except I<thick.io> which sets it to #1 and | |
432 I<come-from-gerund.io> which sets it to #2. | |
433 CR '%' 6 '0' 'charset' 'Charset for Reads' | |
434 The character set used by alphanumeric READ OUT when %IO is | |
435 CLC. Assigning a number to this register causes the corresponding | |
436 style to be selected; assigning a I<MUL> causes a symbolic lookup | |
437 to determine the style number. See L<Language::INTERCAL::Charset>. | |
438 CW '%' 7 '0' 'charset' 'Charset for Writes' | |
439 The character set used by alphanumeric WRITE IN when %IO is | |
440 CLC. Assigning a number to this register causes the corresponding | |
441 style to be selected; assigning a I<MUL> causes a symbolic lookup | |
442 to determine the style number. See L<Language::INTERCAL::Charset>. | |
443 OS '%' 8 '0' 'spot' 'Operating System' | |
444 Hidden in the darkest corner of the operating system lurks a | |
445 "DO NEXT FROM %OS". As long as %OS has the default value of zero, | |
446 you are safe from this. | |
447 | |
448 If %OS is assigned some other value, it behaves like a normal | |
449 (?) NEXT FROM, with one added twist to do with parameter | |
450 passing. Every time your program assigns a value to a register, | |
451 %OS is freed from any existing masters and enslaved to the | |
452 register you've just assigned to. This allows the system call code | |
453 to refer to I<$%OS> to try to guess what you want. The system call | |
454 will use up to five arguments, provided by registers I<.-$%OS>, | |
455 I<:-$%OS>, I<,-$%OS>, I<;-$%OS> and I<@%$OS>, in other words the spot, | |
456 two spot, tail, hybrid and whirlpool register with the same number as whatever | |
457 you last assigned to. This is called "call by vague resemblance | |
458 to the last assignment" and, to our knowledge, no other language | |
459 has ever used this style of parameter passing. | |
460 | |
461 To use, you do something like "(666) DO .5 <- #1" which would | |
462 execute syscall #1, assuming %OS has the value #666. This | |
463 particular example would store the version number of CLC-INTERCAL | |
464 in ,5. | |
465 TM '%' 9 '0' 'zeroone' 'Trace Mode' | |
466 If %TM is zero, the program is not traced. If it is #1 the program | |
467 will send bytecode trace information to @TRFH. Assigning any other | |
468 value to %TM is an error. | |
469 AR '%' 10 '0' 'spot' 'Array read value' | |
470 Contains the last byte READ OUT when %IO is C. | |
471 AW '%' 11 '0' 'spot' 'Array write value' | |
472 Contains the last byte WRITtEn IN when %IO is C. | |
473 JS '%' 12 "'END_JUNK'" 'symbol' 'Junk Symbol' | |
474 When parsing a comment, the compiler needs to be told how to | |
475 recognise the start of next statement: for example, I<1972.io> and | |
476 I<ick.io> set this to a grammar symbol meaning "optional (number) | |
477 followed by DO or PLEASE"; I<sick.io> does something similar, but | |
478 the complication caused by computed labels (if enabled) makes it | |
479 alightly more difficult to describe what this symbol does. | |
480 | |
481 Changing the value of this register at runtime can be a great | |
482 obfuscation tool. | |
483 SS '%' 13 "'SPACE'" 'symbol' 'Space symbol' | |
484 The compiler will automatically ignore anything matched by this | |
485 symbol. If the Whitespace extension is installed, anything matched | |
486 by this symbol is passed to the Whitespace compiler. See the | |
487 documentation which comes with the Whitespace extension. Changing | |
488 the value of this register at runtime can be a great obfuscation | |
489 tool. | |
490 PS '%' 14 "'PROGRAM'" 'symbol' 'Program symbol' | |
491 Determines where the compiler starts when parsing a program. | |
492 This should be a grammar symbol corresponding to a single | |
493 statement, the symbol is automaticaly used repeatedly to | |
494 parse the whole program. Changing the value of this register | |
495 at runtime can be a great obfuscation tool. See also I<%IS>. | |
496 FS '%' 15 "'CALC_FULL'" 'symbol' '"full" symbol' | |
497 Used by the Intercal calculator (intercalc) to determine how to | |
498 parse lines when operating in "full" mode. | |
499 ES '%' 16 "'CALC_EXPR'" 'symbol' '"expr" symbol' | |
500 Used by the Intercal calculator (intercalc) to determine how to | |
501 parse lines when operating in "expr" mode. | |
502 IS '%' 17 '0' 'symbol' 'Intersection symbol' | |
503 Determines what separates statements in the program; this is | |
504 not currently used in any compiler and can be left at the | |
505 default, zero. If set to any other value, the corresponding | |
506 grammar symbol is used to compile the bit of source between | |
507 consecutive statements; if this generates code, it will be | |
508 executed with the preceding statement. Changing the value of | |
509 this register at runtime can be a great obfuscation tool. | |
510 See also I<%PS>. | |
511 DM '%' 18 '0' 'zeroone' 'unary Division mode' | |
512 This register can only have value #0 or #1, and determines | |
513 the style of unary division employed. The default value #0 | |
514 corresponds to the "arithmetic" style of division, while | |
515 value #1 corresponds to the "bitwise" style. See the | |
516 I<UDV> opcode. | |
517 SP '%' 19 '1000' 'splat' 'SPlat' | |
518 This register contains the code of the last splat, just like | |
519 the '*' expression. Assigning to it, however, does not cause | |
520 a splat, but will trigger any events depending on splats. | |
521 This register is intended for internal use by the compiler; | |
522 programs should use I<SPL> instead. | |
523 TH '%' 20 '0' 'zeroone' 'THeft' | |
524 This register determines whether a program has been compiled | |
525 with INTERNET support. If the register is #0, the program | |
526 cannot be a victim of theft, but cannot steal or smuggle | |
527 anything; if the register is #1, the program has full network | |
528 support. | |
529 RM '%' 21 '0' 'zeroone' 'Reinstate Mode' | |
530 This register can only have value #0 or #1, and determines | |
531 whether a REINSTATE of an IGNOREd register behaves in the | |
532 traditional way (#0) or in the way documented by the CLC-INTERCAL | |
533 documentation (#1). | |
534 @END DOUBLE_OH_SEVEN | |
535 | |
536 # special "tail" registers | |
537 @GROUP SHARK_FIN NAME=w TYPE=s NUMBER=d DEFAULT=s CODE=s DESCR=s DOC=m | |
538 AV '^' 1 '[]' 'vector' 'Argument Vector' | |
539 The runtime initialises it with any command-line arguments provided | |
540 to the program. | |
541 EV '^' 2 '[]' 'vector' 'Environment Vector' | |
542 The runtime initialises it with environment variables available | |
543 when the program starts. | |
544 @END SHARK_FIN | |
545 | |
546 # whirlpool registers are not special, but they get some added value | |
547 @GROUP WHIRLPOOL NAME=w TYPE=s NUMBER=d DEFAULT=s CODE=s DESCR=s DOC=m | |
548 OR '@' 0 'undef' 'whirlpool' 'Overload Register' | |
549 This register cannot be used directly. During overload, it is | |
550 temporarily enslaved to the register being overloaded, so it | |
551 is possible to refer to this register's owner (I<OWN> I<1> I<WHP> I<0>, | |
552 corresponding to I<$@0>) within the second argument of I<OVR> or | |
553 I<OVM> opcodes. | |
554 OWFH '@' 1 '$stdwrite' 'whirlpool' 'Object\'s write filehandle' | |
555 Used by default for all WRITE IN statements. Defaults to the standard | |
556 write filehandle, which your operating system may call "standard | |
557 input". | |
558 ORFH '@' 2 '$stdread' 'whirlpool' 'Object\'s read filehandle' | |
559 Used by default for all READ OUT statements. Defaults to the standard | |
560 read filehandle, which your operating system may call "standard | |
561 output" | |
562 OSFH '@' 3 '$stdsplat' 'whirlpool' 'Object\'s splat filehandle' | |
563 Used by default for the text produced by a splat. Defaults to the | |
564 standard splat filehandle, which your operating system may call | |
565 "standard error". | |
566 SNFH '@' 7 '$devnull' 'whirlpool' 'Null filehandle' | |
567 If you READ OUT to @7 nothing happens. If you WRITE IN from @7 | |
568 you get an empty write (for numeric writes, a value of #0, for | |
569 non-numeric writes an empty array). | |
570 TRFH '@' 9 '$stdsplat' 'whirlpool' 'Trace filehandle' | |
571 Trace output, if enabled by I<%TM>, is sent here. Defaults to the | |
572 standard splat filehandle, which your operating system may call | |
573 "standard error" | |
574 @END WHIRLPOOL | |
575 |