There are still some known bugs in INTERCAL (and no doubt many we don't even
suspect as yet). The following list accumulates current bug reports and
-TO DO agenda items from the major INTERCAL hackers through version 0.13.
+TO DO agenda items through the current release.
ESR = Eric S. Raymond
SS = Steve Swales
LLH = Louis Howell
+BR = Brian Raiter
1) (ESR) INTERCAL would be intrinsically a crock even if it worked right.
-2) (ESR) Error-checking could be improved. Not all the errors listed in the
- manual are actually detected (of those listed in lose.h, E000, E197, E200,
- and E774 are never emitted). In this respect C-INTERCAL follows
- nobly in the tradition of many production compilers.
+2) (SS) The system library syslib.i does not appear to work 100% as advertised.
+ (ESR) Louis has corrected several bugs. The gods alone know what others
+ are lurking in there...
-3) (SS) The system library syslib.i does not appear to work 100% as advertised.
-
-4) (LLH) The lexical analyzer is not completely independent of newlines.
+3) (LLH) The lexical analyzer is not completely independent of newlines.
There is a conflict between the fact that newlines should be
ignored almost everywhere, and the facts that the error mechanism
wants to know about line numbers and the splat mechanism wants
relatively small gain, and anyone trying it should make sure
the result isn't buggier than the current version.
+4) (BR) I have hacked up a fix to the problem with line numbers being off
+ due to statements sharing/spanning lines. The parser now stores the
+ starting line number for all tuples, not just the splatted
+ ones. Not only does this give synchronized lines in the comments in
+ the degenerated C code, but run-time error messages are just as
+ reliable as the parse/compile-time ones. The line number in the
+ error message is actually the line number of the next statement
+ (e.g., if the next statement is on the same line, the line number
+ of both statements will be used).
+
+ Note that I said "just as reliable," as opposed to "fully
+ reliable". Since the lexer doesn't know where the line ends until
+ after it's already parsed the preamble (DO-PLEASE combo, line
+ label, oh-oh-seven number, etc) of the following line, it actually
+ stores as the starting line number the first non-whitespace of the
+ statement proper. So if a statement has its preamble on one line
+ and the rest of it on the next, the preamble will be beheaded.
+
+ Still, it's a vast improvement, and as LLH points out, it's not
+ going to get much better without writing a preprocessing lexer that
+ can actually separate out the statements before any real parsing
+ begins. Until someone wants to do that, this will do nicely, I think.
+
+ As a side bonus, splatting now shows the entire statement. (Er,
+ except when the statement both spans and shares a line. If a multi-
+ line statement ends on the same line as the beginning of the next
+ statement, the last part will get truncated. Again, not a case we
+ want to be encouraging people to explore anyway.)
+
TO DO
-1. (ESR) Add more optimization templates, esp. the idioms for &, |, ^, ~.
+1. (ESR) Add more optimization templates, esp. idioms for +, -, *, /.
2. (ESR) Forget this @!%$#! crock and take a long vacation.
--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
#
# Utility productions for the INTERCAL distribution
#
-ick.tar:
- (cd ..; tar cvf ick.tar `cat intercal-0.13/MANIFEST`)
- mv ../ick.tar .
+VERSION = 0.15
+MANIFEST = `sed <intercal-$(VERSION)/MANIFEST -e "s/^/intercal-$(VERSION)\//"`
-ick.tar.Z: ick.tar
- compress ick.tar
+tgz: intercal-$(VERSION).tar.gz
+tar: intercal-$(VERSION).tar
-ick.tar.gz: ick.tar
- gzip ick.tar
+intercal-$(VERSION).tar.gz: intercal-$(VERSION).tar
+ gzip -f intercal-$(VERSION).tar
+intercal-$(VERSION).tar:
+ (cd ..; tar cvf ick.tar $(MANIFEST))
+ mv ../ick.tar ./intercal-$(VERSION).tar
SHAROPTS = -l63 -n intercal -o intercal -a -s esr@snark.thyrsus.com
-ick.shar:
- (cd ..; shar $(SHAROPTS) `cat intercal-0.13/MANIFEST` >ick.shar)
+shar:
+ (cd ..; shar $(SHAROPTS) $(MANIFEST) >intercal-$(VERSION).shar)
+
+clean:
+ rm -f intercal-$(VERSION).shar intercal-$(VERSION).tar intercal-$(VERSION).tar.gz
+
NEW IN THIS RELEASE
- Release 0.13 (by Eric S. Raymond)
+ Release 0.15 (by Eric S. Raymond) 20 Jun 1996
+
+1. Switched the intercal manual master to mgm in order to be able to handle
+ section crossrferences properly. The manual has now been carefully
+ proofread against the paper version by ESR and seems to match. It's
+ also been independently proofread for typos by Brian Raiter.
+
+2. The optimizer now does complete analysis and evaluation of constant
+ expressions at compile time.
+
+3. Added optimization templates for ~, |, &, ^ expressions. Also added
+ |, &, ^ idioms to the system library, and documented them.
+
+(The following changes are due to Brian Raiter)
+
+4. Every one of the INTERCAl-72 messages is now emitted when appropriate.
+ including the previously un-emitted E000, E197, and E200 (and see below).
+
+5. A close reading (while proofing) of the sections of the manual on
+ error messages seems to indicate that splatted lines were only
+ splatted in the default listing printed after a successful
+ compile. (This seems to be a standard feature of IBM compilers; I
+ remember that RPG did this as well.) My understanding of the manual is
+ when the syntactically offensive line is encountered at runtime, it is
+ printed as error E000. I have modified the code to do this.
+
+6. I have fixed INTERCAL in order to add another bug. Namely, I have
+ implemented the BUG/NOBUG option in the Princeton compiler. By
+ default, there is a chance that INTERCAL will randomly insert error
+ E774 into your executable. (The odds are 1/128 per statement, not
+ counting COME FROMs. Is there any way to find out what the
+ Princeton compiler's odds were?) The new option -b turns this
+ feature off.
+
+7. The new file pit/lib/numio.i contains routines for wimpmode I/O.
+ These routines are documented in the file pit/lib/numio.doc.
+ It is my earnest hope that C-INTERCAL programmers everywhere will
+ flock to these handy routines, and C-INTERCAL users will thus no
+ longer need to fear that they might succumb to the foul and awful
+ temptation to use the dastardly +wimpmode option.
+
+ Release 0.14 (by Eric S. Raymond) 9 Jun 1996
+
+1. The documentation has been reorganized and cleaned up (you can now
+ format either a C-INTERCAL or INTERCAL-72 manual from the same master).
+ The diagrams in the paper original have been transcribed as pic figures.
+ See doc/READ.ME for details.
+
+2. Yet more code. The pit now includes a second random-number generator,
+ a ROT13 filter, and even two programs in TriINTERCAL!
+
+3. Louis Howell's corrected system library is now included.
+
+4. The distribution is now formally GPLed.
+
+ Release 0.13 (by Eric S. Raymond) 5 Jun 1996
1. I folded in patches by Brian Raiter <breadbox@muppetlabs.com> that port
this code to Linux and enable it to use flex. Note: This version has
been tested on Linux and SunOS but not yet elsewhere.
- Release 0.12 (by Eric S. Raymond)
+2. Another piece of nontrivial INTERCAL code has been found! (Doubtless
+ hell is freezing over even as I write.) We've added to the pit the
+ `beer' program by Matt DiMeo <mdimeo@brooktree.com>, courtesy of the
+ infamous Beer List (URL:http://www.ionet.net/~timtroyr/funhouse/beer.html).
+
+ Release 0.12 (by Eric S. Raymond) 22 Mar 1995
1. The code now compiles and runs under Linux, using bison and lex. It does
*not* yet work with flex; C.P. Osborne's patches for 0.11 turned out not
checked for conformance. Also, the politesse error message now tells
you the offending program's line count.
- Release 0.11 (by Eric S. Raymond)
+ Release 0.11 (by Eric S. Raymond) 24 Sep 1994
1. Incorporated changes by Jan-Pieter Cornet <cornet@OTech.fgg.EUR.nl> for
magical inclusion of the system library. These address an outstanding bug
5. Volapuk digits are now recognized on input. TO DO: Recognize Volapuk
keywords, including gerunds.
- Release 0.10 (by Eric S. Raymond)
+ Release 0.10 (by Eric S. Raymond) 9 Sep 1994
1. It is now possible to undo a line-number abstention with a gerund
reinstatement, or undo a gerund abstention with a line-number
The twisted loons in the alt.folklore.computers crowd loved this idea,
and I actually got sent digit lists for Nahuatl, Tagalog, Sanskrit, and
- Basque -- also, Kwakiutl, Georgian, Ojibwe. and Albanian. I've left
+ Basque -- also, Kwakiutl, Georgian, Ojibwe, and Albanian. I've left
out Albanian (didn't want to keep track of the dipthong diacritical)
and Ojibwe (no zero digit). So: Nahuatl, Tagalog, Sanskrit, Basque,
Georgian, and Kwakiutl are now supported in addition to English.
3. The THEORY document has been significantly revised.
- Release 0.9 (by Eric S. Raymond)
+ Release 0.9 (by Eric S. Raymond) 5 Mar 1993
1. An embarrassing port bug in the INTERCAL skeleton has been fixed
5. You can now set the C compiler to be used as a back end by INTERCAL
by setting the environment variable CC. The default is cc.
- Release 0.8 (many hacks on 0.7 by Eric Raymond)
+ Release 0.8 (many hacks on 0.7 by Eric Raymond) 21 Jan 1992
1. A previously undocumented `feature' of the Princeton compiler,
revealed by Don Woods, is now emulated. If fewer than 1/5 or more
The documentation has been updated to reflect these changes.
- Release 0.7 (by Louis Howell)
+ Release 0.7 (by Louis Howell) 21 Dec 1991
In addition to bug fixes, new features in this version include arrays,
character I/O, modified (hopefully improved!) semantics for the COME
FROM statement, extensions to bases other than 2, new INTERCAL programs,
and new documentation.
- Release 0.6 (by Steve Swales)
+ Release 0.6 (by Steve Swales) 5 Jan 1991
1. Restored Princeton documentation (courtesy of Michael Ernst).
4. Various bug fixes, esp. in lexical analysis.
- Release 0.5 (ESR's original pre-release)
+ Release 0.5 (ESR's original pre-release) 5 Jun 1990
1. As a convenience to all you junior birdmen out there, `NINER' is accepted as
a synonym for `NINE' in INTERCAL input.
-------------
-For details on COME FROM and other extensions to C-INTERCAL, see
-doc/ick.txt.
+The resurrection of INTERCAL from its grave took place on 12 May 90
+when ESR released 0.3 on an unsuspecting USENET.
+
Release Notes for C-INTERCAL
- version 0.13
DISCREDITS
during a fit of lunacy from which he has since mostly recovered. It has
been considerably hacked upon and improved by Steve Swales, Michael Ernst,
Louis Howell (who wrote the array support stubbed out in Eric's original
-version), and others. Brian Raiter ported it to Linux and enabled it to use
-flex.
-
-You can surf to the latest version of this package, and related resources, from
-http://www.ccil.org/~esr/home.html.
+version), and others. Brian Raiter ported it to Linux (doing ANSI cleanup
+along the way), enabled it to use flex, and proofed the manual.
FILES
NEWS -- info on features and fixes new in this release
intercal.el -- elisp for editing INTERCAL code under GNU Emacs
-doc/intercal.txt -- The INTERCAL manual (read this next!)
-doc/intercal.tex -- TeX source form
-doc/intercal.sty -- TeX style file
-doc/intercal.ms -- the manual in nroffable form
-doc/ick.txt -- new features in C-INTERCAL
+doc/READ.ME -- historical notes on the docs
+doc/intercal.mm -- the manual in groffable form
doc/THEORY -- some notes on the internals of the INTERCAL compiler
src/Makefile -- makefile for the INTERCAL compiler
(suppressing compilation to machine code), a -d option that enables verbose
parse reporting from the yacc/bison parser, a -t option that requires strict
INTERCAL-72 compliance (rejecting COME FROM and the extensions for bases other
-than two) and an -O option that enables the (hah!) optimizer. Invoking ick -?
+than two), a -b option that disables the INTERCAL-72 random-bug feature,
+and an -O option that enables the (hah!) optimizer. Invoking ick -?
prints a usage message. Other than that, yer on yer own.
Another switch affects C-INTERCAL's runtime behavior. The `-C'
Steve writes: "The wimpmode option is the most interesting. I found myself
always running my test programs with filters on both ends to work around the
-'nifty' intercal number representations. This was so painful that I decided it
+'nifty' INTERCAL number representations. This was so painful that I decided it
would be LESS painful (and a lot less code) if I added a 'wimp' option. With
the +wimpmode option, the user is subjected to a humiliating message about what
a wimp he or she is to use this mode, but after that is allowed to use
SPREADING THE BLAME
-The latest version of INTERCAL is kept available at the Retrocomputing Museun,
-http://www.ccil.org/retro.
+There is an INTERCAL Resource Page at http://www.ccil.org/intercal
+
+The latest version of INTERCAL is also kept available at the
+Retrocomputing Museun, http://www.ccil.org/retro.
There is, in addition, an occasionally active USENET newsgroup devoted to the
language: alt.lang.intercal.
using the current versions of gcc, flex, and bison, C-INTERCAL should
build with no warnings.
+ LICENSING
-
-
-
+C-INTERCAL is now distributed under the General Public License,
+except for the C skeleton file which is explicitly *not* GPLed
+in order to avoid the (possibly mythical) "license virus" effect.
+See the file COPYING for details on the General Public License.
--- /dev/null
+#
+# Makefile for the Intercal documentation
+#
+
+# To see the Revised Manual, generate intercal.txt or intercal.ps
+# To see the original INTERCAL-72 manual, generate original.txt or original.ps.
+
+# We make two passes in order to resolve SETR/GETNH references.
+# The sed hackery strips the trailing dots from level 1 section references.
+
+all: intercal.ps intercal.txt original.ps original.txt
+
+intercal.ps: intercal.mm
+ groff -dc=y -Tps -p -t -mgm intercal.mm >/dev/null
+ sed <intercal.refs.tmp -e '/hn \([0-9]*\)\.$$/s//hn \1/' >tmp.refs;
+ mv tmp.refs intercal.refs.tmp
+ groff -dc=y -Tps -p -t -mgm intercal.mm >intercal.ps
+ rm intercal.refs.qrf
+
+original.ps: intercal.mm
+ groff -dc=n -Tps -p -t -mgm intercal.mm >/dev/null
+ sed <intercal.refs.tmp -e '/hn \([0-9]*\)\.$$/s//hn \1/' >tmp.refs;
+ mv tmp.refs intercal.refs.tmp
+ groff -dc=n -Tps -p -t -mgm intercal.mm >original.ps
+ rm intercal.refs.qrf
+
+intercal.txt: intercal.mm
+ groff -dc=y -Tascii -p -t -mgm intercal.mm >/dev/null
+ sed <intercal.refs.tmp -e '/hn \([0-9]*\)\.$$/s//hn \1/' >tmp.refs;
+ mv tmp.refs intercal.refs.tmp
+ groff -dc=y -Tascii -p -t -mgm intercal.mm >intercal.txt
+ rm intercal.refs.qrf
+
+original.txt: intercal.mm
+ groff -dc=n -Tascii -p -t -mgm intercal.mm >/dev/null
+ sed <intercal.refs.tmp -e '/hn \([0-9]*\)\.$$/s//hn \1/' >tmp.refs;
+ mv tmp.refs intercal.refs.tmp
+ groff -dc=n -Tascii -p -t -mgm intercal.mm >original.txt
+ rm intercal.refs.qrf
+
+clean:
+ rm -f *.ps *.txt *.refs*
+
--- /dev/null
+This directory contains the documentation (such as it is) for INTERCAL.
+
+READ.ME
+ This file.
+
+intercal.ms:
+ Masters for the INTERCAL manual (needs pic to render illos)
+ This has been carefully proofread against the original paper
+ version.
+
+THEORY
+ Implementation notes on the C-INTERCAL implementation.
+
+chip.spec:
+ Christian Brunschen's spec sheet for the INTERCAL chip.
+
+Note 1: The TeX version we formerly distributed has been dropped. The
+combination of groff and pic does an effective job of rendering the
+illustrations and is easier to maintain.
+
+Note 2: The supplemental reference manual, ick.txt, has been merged
+into the intercal manual. (It is still possible to generate the
+original; see the Makefile.)
+
+Note 3: The flat-ASCII directly transcribed from the paper original is
+also gone. You can regenerate something very close to it with \&`make
+original.txt'. The differences will be (a) page breaks may fall in
+different places, (b) the circuit diagrams present in the paper
+version but absent in the ASCII transcription are instead poorly
+approximated with ASCII boxology, (c) every "butchered Roman numeral"
+is preceded and followed by a line break, (d) the hanging-indent list
+of Princeton compiler options is has all marks above each description,
+rather than to its left.
+
+The aim of these changes was to reduce to one the number of manual masters that
+need to be maintained.
INTERCAL IMPLEMENTOR'S NOTES
by ESR
-The C-INTERCAL compiler has a very conventional implementation using YACC and
-LEX. Each line of INTERCAL is translated into a C if()-then; the guard part
-is used to implement abstentions and RESUMES, and the arm part translates the
-`body' of the corresponding INTERCAL statement.
+The C-INTERCAL compiler has a very conventional implementation using
+YACC and LEX (latterly, bison and flex). It generates C, which
+is then passed to your C compiler.
-The generated C code is plugged into the template file ick-wrap.c
-inside main(). It needs to be linked with cesspool.o, fiddle.o and
-lose.o (these are in libick.a, with the new routine, arrgghh.o).
-Cesspool.o is the code that implements the storage manager; fiddle.o
-implements the INTERCAL operators; and lose.o is the code that
-generates INTERCAL's error messages. The routine arrgghh.o parses the
-new command line arguments.
+ Lexical issues
-The abstain[] array in the generated C is used to track line and label
-abstentions; if member i is on, the statement on line i is being
-abstained from. If gerund abstentions/reinstatements are present in
-the code, a second array recording the type of each statement in
-generated into the runtime, and used to ensure that these operations
-are translated into abstention-guard changes on all appropriate line numbers.
+Note that the spectacular ugliness of INTERCAL syntax requires that
+the lexical analyzer have two levels. One, embedded in the input()
+function, handles the backquote and bang constructs, and stashes the
+input line away in a buffer for the splat construct's benefit. The
+upper level is generated by lex(1) and does normal tokenizing for YACC.
-Labels are mapped to line numbers in the code checker, just before
-optimization.
+In order to splatter erroneous statements correctly, the generated code has
+to track both logical and physical lines. That's the reason for the
+`lineno' variable in the generated C, it's actually tracking physical lines.
-RESUMES are implemented with a branch to a generated switch statement
-that executes a goto to the appropriate label.
+Numeral tokens for input are defined in a symbol table (numerals.c)
+that is directly included in the run-time library module (cesspool.c).
+This avoids having to put the the size of the numerals array in an
+extern. To add new numeral tokens, simply put them in the numerals
+initializer.
+
+ Compilation
The parser builds an array of tuples, one for each INTERCAL statement. Most
tuples have node trees attached. Once all tuples have been generated,
and expression-tree rewrites. Finally, the tuples are ground out as C code
by the emit() function.
-The optimizer does constant folding for all five operators. It also checks
-for the idioms for `test for equality' and `test for nonzeroness'.
-
Calculations are fully type-checked at compile time; they have to be because
(as I read the manual) the 16- and 32-bit versions of the unary ops do
different things. The only potential problem here is that the typechecker
irritation value of it (yes, C-INTERCAL *does* enforce the 16-bit limit
on constants).
-Note that the spectacular ugliness of INTERCAL syntax requires that
-the lexical analyzer have two levels. One, embedded in the input()
-function, handles the backquote and bang constructs, and stashes the
-input line away in a buffer for the splat construct's benefit. The
-upper level is generated by lex(1) and does normal tokenizing for YACC.
+Labels are mapped to tuple indices (logical line numbers) in the code
+checker, just before optimization.
+
+The optimizer does full recursive folding of all constant expressions
+at compile time (evaluating away all the irritating little kluges you
+have to use to generate 32-bit constants). It also checks for known
+INTERCAL idioms for `test for equality', `test for nonzeroness', and
+the C logical operators &, |, ^, and ~.
+
+ Code Generation
+
+Each line of INTERCAL is translated into a C if()-then; the guard part
+is used to implement abstentions and RESUMES, and the arm part
+translates the `body' of the corresponding INTERCAL statement.
+
+The generated C code is plugged into the template file ick-wrap.c
+inside main(). It needs to be linked with cesspool.o, fiddle.o and
+lose.o (these are in libick.a, with the support for runtime switches,
+arrgghh.o). Cesspool.o is the code that implements the storage
+manager; fiddle.o implements the INTERCAL operators; and lose.o is the
+code that generates INTERCAL's error messages. The routine arrgghh.o
+parses the runtime command line arguments.
+
+The abstain[] array in the generated C is used to track line and label
+abstentions; if member i is on, the statement on line i is being
+abstained from. If gerund abstentions/reinstatements are present in
+the code, a second array recording the type of each statement in
+generated into the runtime, and used to ensure that these operations
+are translated into abstention-guard changes on all appropriate line numbers.
+
+RESUMES are implemented with a branch to a generated switch statement
+that executes a goto to the appropriate label. If there are no RESUMES,
+no such switch is generated.
+
+The compiler places a simple label at the location of each COME FROM
+in the program, while all of the machinery for checking for abstention
+and conditional execution and actually performing the jump is placed
+immediately after the code for the target statement.
+
+ Credits
+
+I wrote the first version of this compiler over a weekend using a
+pre-ANSI C compiler. It worked, but it wasn't pretty. Louis Howell
+added the array support later; he also torture-tested the COME FROM
+implementation by actually using it for the life2.i program included
+in this distribution, and fixed some bugs. Brian Raiter did a
+much-needed delinting while porting it for ANSI C, flex and Linux. He
+also improved the lexical analyzer's line tracking.
-Note that numeral tokens for input are defined in a symbol table (numerals.c)
-that is directly included in the run-time library module (cesspool.c). This
-avoids having to put the the size of the numerals array in an extern. To add
-new numeral tokens, simply put them in the numerals initializer.
--- /dev/null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The Intercal Machine Machine Language Specification File
+ (c) 1990 Christian Brunschen,
+ a. k. a. d89cb@efd.lth.se
+\f
+This file contains the specifications for the Machine / Assembly Language
+used by the Intercal Machine Microprocesor, which closely follows the
+definition of the Intercal Compiler Language as defined by Woods/Lyon
+in 1972. It also contains ideas as to the actual implementation,
+hard- or softwarewise, of the Processor Instruction Set in an actual
+environment.
+
+It should be noted that the Intercal Machine Microprocessor is the first
+actual RISC processor (RISC being, of course, the acronym for
+Ridiculous Instruction Set Computer).
+\f
+Overview of processor capabilities / requirements
+
+Schematic overview of processor I/O busses:
+
+ +----------------\ /--------------+
+ _| \_/ |_
+ D +--- |_| D0 A04 |_| ---+
+ a | _| |_ |
+ t | |_| D1 A05 |_| |
+ a | _| |_ |
+ | |_| D2 A06 |_| |
+ b | _| |_ |
+ u | |_| D3 A07 |_| |
+ s ---+ _| |_ |
+ | |_| D4 A08 |_| |
+ 8 | _| |_ | A
+ | |_| D5 A09 |_| | d
+ b | _| |_ | d
+ i | |_| D6 A10 |_| | r
+ t | _| |_ | e
+ s +--- |_| D7 A11 |_| | s
+ _| |_ | s
+ |_| DACK A12 |_| |
+ _| |_ |
+ |_| GND A13 |_| |
+ _| _____ |_ | b
+ |_| RESET A14 |_| +--- u
+ _| ____ |_ | s
+ |_| MEM/WRLD A15 |_| |
+ _| _ |_ | 2
+ |_| R/W A16 |_| | 4
+ _| |_ |
+ |_| CLK A17 |_| | b
+ _| |_ | i
+ |_| VCC A18 |_| | t
+ _| |_ | s
+ |_| ERROR A19 |_| |
+ _| |_ |
+ +--- |_| A00 A20 |_| |
+ | _| |_ |
+ | |_| A01 A21 |_| |
+ | _| |_ |
+ | |_| A02 A22 |_| |
+ | _| |_ |
+ | |_| A03 A23 |_| |
+ | | | |
+ | +-----------------------------------+ |
+ | |
+ | |
+ +-------------------------------------------------+
+
+The only signals that might require some explanation are probably
+ _
+R/W : When this signal is low, The processor is reading data from the databus.
+ When it is high, the processor is driving the the databus.
+_____
+RESET : When this signal goes low, the processor is reset, and starts reading
+ incoming data from the databus, one byte each clock cycle, until the
+ line goes high again, at which time the processor will resume execution
+ of the program at memory location (Hex) 000000 (24 bits, remeber ?)
+ ____
+MEM/WRLD : _
+ Indicates the `target' or `source' (depending on the status of the R/W
+ line) of the data bus, sort of like an additional address bit. If this
+ line is low, the processor is communicating with the outside world. If
+ it is high, the processor is talking to its memory.
+
+DACK : Data ACKnowledge. Used when the processor communicates with the
+ outside world. Two cases:
+ a) Processor Talking
+ After the processor put the data on the databus, it will wait
+ until the DACK has been raised, and then dropped again. Then
+ it will put the next byte of data (if any) on the bus, or
+ proceed to the next instruction.
+ b) Processor listening
+ The same procedure as above, but in the other direction :
+ After the processor has read one byte of data, it quickly raises &
+ drops the line, and then expects the next data item to be present.
+
+ERROR : Indicates the fact that an error condition has occurred somewhere
+ in the program. The error number is present on the data bus.
+ After the error number has ben read, the address of the next statement
+ to be executed, had the eror not occurred, can be read in three
+ consecutive bytes from the databus.
+\f
+Processor Memory Management
+
+Since the Intercal Language provides quite a few interesting ways to manipulate
+arrays, stash and retrieve data, etc, all of which operations require
+manipulations of memory, and it was the intention of this implementation to
+provide an instruction set which immediately makes the average Intercal
+programmer feel right at home, quite a few very complex instructions have been
+provided.
+\f
+Intercal Machine Language Reference Part
+
+Summary of instructions:
+
+ABG ABstain from Gerund
+ABL ABstain from Label
+ALA ALlocate Aray
+BAA Begin Array Allocation
+BIA Begin Indexing Array
+BIN BINary operator
+CAL CALculate
+DLD Data LoaD
+EAA End Array Allocation
+FRG FoRGet
+IDA InDex Array
+IGN IGNore
+INS INitiate Statement
+NEX NEXt
+OST Open STorage
+PCT PerCenTage qualifier
+POP POP
+PPA PoP Array pointers
+PSA PuSh Array pointers
+PSH PuSH
+RDO ReaD Out
+REG Reinstate Gerund
+REL Reinstate Label
+RMB ReMemBer
+RSM ReSuMe
+RTV ReTrieVe
+STS STaSh
+UNO UNary Operator
+WRI WRite In
+
+General Format:
+
+ i i i i i p p s <optional arguments>
+
+where
+
+ i = instruction field
+ p = private field
+ s = size field
+\f
+ABstain from Label
+
+ABL Label
+
+ 0 1 1 1 1 0 0 0
+
+Sets the abstain bit of instruction at Label
+\f
+ABstain from Gerund
+
+ABG mnm
+
+ 0 1 1 1 1 1 0 0
+
+Sets the abstain bit of all statements whosde main instruction is mnm
+\f
+Allocate Array
+
+
+ALA #num
+ALA .var
+ALA :var
+ALA ,
+ALA ;
+ALA RES
+
+
+ 0 0 0 1 1 p p s
+
+where p p specifies the source,
+ 0 0 : immediate data <16 bits>
+ 0 1 : Variable <variable specifier, 16 bits>
+ 1 0 : Array, as pointed to by the Read Array Pointer
+ 1 1 : the contents of the RES register
+
+Takes the ALA argument, multiplies it with the current contents of the
+Temproary Register, and puts the result in the Temporary Register.
+\f
+Begin Allocating Array
+
+BAA ,var
+BAA ;var
+
+
+ 0 0 0 1 0 0 0 s
+ array specifier, 16 bits
+ jump offset, 16 bits
+
+Deallocates the memory block currently allocated to array `var',
+opens the Arrray Entry for array `var' for writing, and puts a pointer
+to the Array Entry in the Wite Array Data pointer register. If the array
+is being ignored, none of these things actually happen -- instead, the
+jump offset is added to the program counter.
+\f
+Begin Indexing Array
+
+BIA R ,var
+BIA W ,var
+BIA R ;var
+BIA W ;var
+
+
+ 0 0 1 0 1 0 t s
+ array specifier, 16 bits
+
+where t = type, 0 = Read or 1 = Write
+
+Sets the Read Array Data pointer to the address of the first array element,
+and the Read Array Dimension pointer to the first Dimension entry in the
+Array Table, thus preparing for further indexing.
+\f
+BINary operator
+
+BIN ~ Select
+BIN c\b/ Interleave,
+BIN $ aka Mingle
+
+ 0 1 1 0 0 t 0 0
+
+where t is the operation specifier:
+ 0 : Select
+ 1 : Interleave / Mingle
+
+The operation is performed on the OP1 and OP2 registers, and the result is
+placed in the RES register.
+\f
+CALculate
+
+CAL .
+CAL :
+CAL ,
+CAL ;
+
+
+ 0 1 0 1 0 0 0 s
+
+Puts the contents of the RES register in the memory location pointed to by
+the Write Array Data pointer
+\f
+Data LoaD
+
+DLD t #num
+DLD t .var
+DLD t :var
+DLD t ,
+DLD t ;
+DLD t RES
+
+
+ 0 1 0 0 t p p s
+
+where t = target register, 0 = OP1 or 1 = OP2
+ p p = source :
+ 0 0 : Immediate data <16 bits>
+ 0 1 : Variable <specifier, 16 bits>
+ 1 0 : Array item (as indexed by the Read Array Data pointer)
+ 1 1 : RES register
+
+Loads the target register with the contents of the source
+\f
+End Allocating Array
+
+EAA
+
+
+ 0 0 1 0 0 0 0 0
+
+Allocates a chunk of memory to the size of
+\f
+FoRGet
+
+FRG #num
+FRG .var
+FRG :var
+FRG ,
+FRG ;
+FRG RES
+
+
+ 1 0 0 0 0 p p s
+
+where p p = source :
+ 0 0 : Immediate <16 bits>
+ 0 1 : variable <specifier, 16 bits>
+ 1 0 : array (as indexed by the Read Array Data pointer)
+ 1 1 : RES register
+
+Pops source number of addresses from the stack, discarding them.
+\f
+InDex Array
+IDA R #num
+IDA W #num
+IDA R .var
+IDA W .var
+IDA R :var
+IDA W :var
+IDA R RES
+IDA W RES
+
+
+ 0 0 1 1 t p p s
+
+where t = type, 0 = Read or 1 = Write
+ p p = source :
+ 0 0 : Immediate Data <16 bits>
+ 0 1 : variable <specifier, 16 bits>
+ 1 0 : ILLEGAL
+ 1 1 : RES register
+
+Takes the Array Dimension (i.e, what the Array Dimension Pointer points to),
+adds (#num or RES) instances of it to the Array Data Pointer, and adds 2 to the
+Array Dimension Pointer.
+\f
+IGNore
+
+IGN .var
+IGN :var
+IGN ,var
+IGN ;var
+
+ 1 0 1 0 1 0 0 s
+ variable specifier, 16 bits
+
+Sets the ignore flag of the variable specified
+\f
+INitiate Statement
+
+INS mnm Label
+
+where `mnm' is one of the following 3-character mnemonics:
+
+ABS ABStain
+REI REInstate
+CAL CALculate
+NEX NEXt
+FRG FoRGet
+RES RESume
+STS STaSh
+RTV ReTrieVe
+IGN IGNore
+RMB ReMemBer
+WRI WRite In
+RDO ReaD Out
+
+
+ 1 1 1 p p p p p
+ 2 bytes :
+ a o o o o o o o o o o o o o o o
+
+where p p p p p = major instruction opcode
+
+where a is the abstain bit of the instruction : set if this instruction
+is to be abstained from. The remaining 15 bits are the jump offset, which will
+be added to the program counter should the instruction be abstained from.
+It is presumed that no statement will result in code exceeding 32.767 bytes.
+\f
+NEXt
+
+NEX Label
+
+ 0 1 1 0 1 0 0 0
+ Target Address, 24 bits
+
+Pushes the address of the next instruction on the return stack and puts the
+Target addres in the Program counter
+\f
+Open STorage
+
+OST .var Label
+OST :var Label
+OST ,var Label
+OST ;var Label
+
+
+ 0 0 0 0 1 0 0 s
+ variable/array specifier, 16 bits
+ jump offset, 8 bits
+
+
+Trys to open the specified variable for writing.
+If it being ignored (i.e, its ignore flag is set) the jump offset is
+added to the program counter.
+If it is an array, the Write Array Data pointer is set to the address
+of the first element of the array, and the Write Array Dimension pointer
+to the first dimension entry in the Array Table.
+If it is a Variable, the Write Array Data pointer is set to the address
+of the Variable.
+\f
+PerCenTage qualifier
+
+PCT #num Label
+
+
+ 0 0 0 0 0 0 0 0
+ 0 c c c c c c c
+ Jump offset, 16 bits
+
+where c c c c c c c is a 7 bit binary number between 0 and 100
+
+Gets a random number in the range 0 .. 99, compares it to the percent chance
+and acts on the result:
+- if the random number is less than the percent chance, nothing is done
+- if it is equal or greater, the jump offset is added to the program counter
+\f
+POP
+
+POP
+
+
+ 1 1 0 0 0 0 1 0
+
+Gets the top item on the stack and puts it in the RES register -- 32 bits
+\f
+PoP Array pointers
+
+PPA
+
+ 1 1 0 0 1 0 1 0
+
+Retrieves the contents of the Read Array Data pointer from the stack
+\f
+PuSh Array pointers
+
+PSA
+
+
+ 1 1 0 0 1 0 0 0
+
+Pushes the contents of the Read Array Data pointer to an internal stack
+\f
+PuSH
+
+PSH
+
+
+ 1 1 0 0 0 0 0 0
+
+Pushes the RES register to the stack -- 32 bits
+\f
+ReaD Out
+
+RDO #num
+RDO .var
+RDO :var
+RDO ,
+RDO ;
+RDO RES
+
+
+ 1 0 1 1 1 p p s
+
+where p p = source:
+ 0 0 : Immediate <16 bits>
+ 0 1 : Variable <specifier, 16 bits>
+ 1 0 : Array (as pointed to by the Read Array Data pointer)
+ 1 1 : RES register
+
+Writes 2 or 4 bytes (16 or 32 bits) on the data bus
+\f
+REinstate Gerund
+
+REG mnm
+
+ 0 1 1 1 0 1 0 0
+ operation specifier, 8 bits
+
+In this form, the hole program will be searched to find instructions of the
+specified type, and their abstain bits will be reset.
+\f
+REinstate Label
+
+REL Label
+
+ 0 1 1 1 0 0 0 0
+ Label, 24 bits
+
+In this form, the instruction at the address of Label will have its abstain
+bit set/reset.
+\f
+ReMemBer
+
+RMB .var
+RMB :var
+RMB ,var
+RMB ;var
+
+ 1 0 1 0 0 0 0 s
+ variable specifier, 16 bits
+
+Clears the specified variable's ignore flag
+\f
+ReSuMe
+
+RSM #num
+RSM .var
+RSM :var
+RSM ,
+RSM ;
+RSM RES
+
+ 1 0 0 0 1 p p s
+
+where p p = source :
+ 0 0 : Immediate <16 bits>
+ 0 1 : variable <specifier, 16 bits>
+ 1 0 : array (as indexed by the Read Array Data pointer)
+ 1 1 : RES register
+
+Pops source number of addresses from the stack.
+If there are less than `source' items on the stack, the procesor is halted
+and an error signaled
+If no error occurs, the last popped address is NOT discarded, but instead
+placed in the Program counter.
+\f
+ReTrieVe
+
+RTV .var
+RTV :var
+RTV ,var
+RTV ;var
+
+ 1 0 0 1 1 0 0 s
+ Variable/Array Specifier, 16 bits
+
+Retrieves the latest stashed instance of the variable or array specified
+\f
+STaSh
+
+STS .var
+STS :var
+STS ,var
+STS ;var
+
+ 1 0 0 1 0 0 0 s
+ Variable/Array specifier, 16 bits
+
+Stashes the variable or array specified
+\f
+UNary Operator
+
+UNO & AND
+UNO V OR
+UNO V\b- XOR
+UNO ? XOR
+
+ 0 1 0 1 1 t t s
+
+where t is the operation specifier:
+ 00 : AND
+ 01 : OR
+ 10 : XOR
+ 11 : Illegal
+
+The specified operation is performed on the RESult register, leaving it there.
+\f
+WRite In
+
+WRI .
+WRI :
+WRI ,
+WRI ;
+
+
+ 1 0 1 1 0 0 0 s
+
+Reads 2 or 4 bytes (16 or 32 bits) from the data bus and puts them in
+the variable pointed to by the Write Array Data pointer
+\f
+++ /dev/null
-
-
- THE C-INTERCAL SUPPLEMENTAL REFERENCE MANUAL
-
- Version 0.7 by Louis Howell, 12/16/91
- Version 0.8 info by Eric S. Raymond, 01/18/92
-
-
-1. CONTRADICTION (with apologies to A. A. Milne)
-
-In which we attempt to justify the existence of this file to you,
-the reader, who since you are reading the file have probably already
-accepted, at least provisionally, its right to exist.
-
-1.1 JUSTIFICATION
-
-Verily it is written, "When a program is useful it must be changed,
-when it is useless it must be documented."
-
-The intention is that, unlike the original manual, this file should
-not be cast in stone, but rather should change to reflect later
-additions or modifications to the language. Just keep it neat and
-accurate, ok?
-
-
-2. CONSTRUCTS FROM INTERCAL-72
-
-In which we discuss the detailed behavior of some features that have
-either changed from the original version of the language, or were not
-completely specified in the original manual.
-
-2.1 SELECT
-
-The original manual defines the return type of a SELECT operation
-to depend on the number of bits SELECTed. The present compiler
-takes the easier route of defining the return type to be that of
-the right operand, independent of its actual value. This form has
-the advantage that all types can be determined at compile time.
-Putting in run time type checking would add significant overhead and
-complication, to effect a very minor change in language semantics.
-
-The only time this distinction makes any difference is when a
-unary operator is applied to the SELECT result. This happens
-extremely rarely in practice, the only known instance being the
-32-bit greater-than test in the standard library, where an XOR
-operator is applied to the result of SELECTing a number against
-itself. The authors first SELECT the result against #65535$#65535
-to insure that XOR sees a 32-bit value. With the current compiler
-this extra step is unnecessary, but harmless.
-
-The cautious programmer should write code that does not depend on
-the compiler version being used. We therefore suggest the following
-guideline for determining the SELECT return type:
-
- A SELECT operation with a 16-bit right operand returns a 16-bit
- value. The return type of a SELECT operation with a 32-bit right
- operand is undefined, but is guaranteed to be an acceptable input
- to a MINGLE operation so long as 16 or fewer bits are actually
- selected. Correct code should not depend on whether the return
- type is 16 or 32 bits.
-
-2.2 IGNORE
-
-Though the manual states that the value of an IGNOREd variable cannot
-change, it is unclear about whether or not a statement which appears
-to change an IGNOREd variable is executed or not. This may appear to
-be a "If a tree falls in the forest..." type of question, but if the
-statement in question has other side effects it is not.
-
-Since another mechanism already exists for ABSTAINing from a
-statement, we suggest that IGNORE only prevent the changing of the
-specific variable in question, not the execution of the entire
-statement. In the present version of the language this only makes
-a difference for the WRITE IN statement. Attempting to WRITE IN
-to an IGNOREd variable will cause a number to be read from the input,
-which will be discarded since it cannot be stored in the variable.
-
-Various proposals to make assignment an operator, unlike the '='
-operator in C, would depend more heavily on this condition. It's
-not clear whether such a feature is worth adding to the language, but
-if it is it should be done right.
-
-
-3. COME FROM
-
-In which we try to precisely define a statement that should never
-have been born, but is nevertheless one of the more useful statements
-in INTERCAL.
-
-3.1 BACKGROUND
-
-The earliest known description of the COME FROM statement in the computing
-literature is in [R. L. Clark, "A linguistic contribution to GOTO-less
-programming," Commun. ACM 27 (1984), pp. 349--350], part of the famous April
-Fools issue of CACM. The subsequent rush by language designers to include the
-statement in their languages was underwhelming, one might even say nonexistent.
-Eric Raymond therefore decided that COME FROM would be an appropriate addition
-to INTERCAL, and proceeded to implement it in his C-INTERCAL compiler. Louis
-Howell tested the implementation by actually using it for the life2.i program
-included in this distribution and fixed some bugs.
-
-3.2 DESCRIPTION
-
-There are two useful ways to visualize the action of the COME FROM
-statement. The simpler is to see that it acts like a GOTO when the
-program is traced backwards in time. More precisely, the statements
-
-(1) DO <any statement>
- .
- .
- .
-(2) DO COME FROM (1)
-
-should be thought of as being equivalent to
-
-(1) DO <any statement>
-(2) DO GOTO (3)
- .
- .
- .
-(3) DO NOTHING
-
-if INTERCAL actually had a GOTO statement at all, which of course it
-doesn't.
-
-What this boils down to is that the statement DO COME FROM (label),
-anywhere in the program, places a kind of invisible trap door
-immediately after statement (label). Execution or abstention of that
-statement is immediately followed by an unconditional jump to the
-COME FROM, unless the (label)ed statement is an executed NEXT, in which
-case the jump occurs if the program attempts to RESUME back to that
-NEXT statement. It is an error for more than one COME FROM to refer
-to the same (label).
-
-Modification of the target statement by ABSTAIN or by the % qualifier
-affects only that statement, not the subsequent jump. Such
-modifications to the COME FROM itself, however, do affect the jump.
-Encountering the COME FROM statement itself, rather than its target,
-has no effect.
-
-In the current C-INTERCAL implementation, the compiler places a simple
-label at the location of the COME FROM in the program, while all of the
-machinery for checking for abstention and conditional execution and
-actually performing the jump is placed immediately after the code for
-the target statement.
-
-
-4. OUTSIDE COMMUNICATION
-
-In which we try to remedy the fact that, due to I/O limitations, INTERCAL
-can not even in principle perform the same tasks as other languages. It
-is hoped that this addition will permit INTERCAL users to waste vast
-quantities of computer time well into the 21st century.
-
-4.1 MOTIVATION
-
-One of the goals of INTERCAL was to provide a language which, though
-different from all other languages, is nevertheless theoretically
-capable of all the same tasks. The original version failed to
-accomplish this because its I/O functions could not handle arbitrary
-streams of bits, or even arbitrary sequences of characters. A
-language which can't even send its input directly to its output
-can hardly be considered as capable as other languages.
-
-4.2 TURING TEXT MODEL
-
-To remedy this problem, character I/O is now provided in a form based
-on the "Turing Text" model, originally proposed by Jon Blow. The
-INTERCAL programmer can access this capability by placing a one-
-dimensional array in the list of items given to a WRITE IN or READ OUT
-statement. On execution of the statement, the elements of the array
-will, from first to last, be either loaded from the input or sent
-to the output, as appropriate, in the manner described below. There
-is currently no support for I/O involving higher-dimensional arrays,
-but some form of graphics might be a possible 2-D interpretation.
-
-The heart of the Turing Text model is the idea of a continuous loop
-of tape containing, in order, all the characters in the machine's
-character set. When a character is received by the input routine,
-the tape is advanced the appropriate number of spaces to bring
-that character under the tape head, and the number of spaces the
-tape was moved is the number that is actually seen by the INTERCAL
-program. Another way to say this is that the number placed in an
-INTERCAL array is the difference between the character just
-received and the previous character, modulo the number of characters
-in the machine character set.
-
-Output works in just the opposite fashion, except that the characters
-being output come from the other side of the tape. From this position
-the characters on the tape appear to be in reverse order, and are
-individually backwards as well. (We would show you what it looks
-like, but we don't have a font with backwards letters available.
-Use your imagination.) The effect is that a number is taken out
-of an INTERCAL array, subtracted from the last character output---
-i.e., the result of the last subtraction---and then sent on down
-the output channel. The only catch is that the character as seen
-by the INTERCAL program is the mirror-image of the character as
-seen by the machine and the user. The bits of the character are
-therefore taken in reverse order as it is sent to the output.
-Note that this bit reversal affects only the character seen by
-the outside world; it does not affect the character stored internally
-by the program, from which the next output number will be subtracted.
-All subtractions are done modulo the number of characters in the
-character set.
-
-Two different tapes are used for input and for output to allow for
-future expansion of the language to include multiple input and
-output channels. Both tapes start at character 0 when a program
-begins execution. On input, when an end of file marker is reached
-the number placed in the array is one greater than the highest-
-numbered character on the tape.
-
-4.3 EXAMPLE PROGRAM
-
-If all this seems terribly complicated, it should be made perfectly
-clear by the following example program, which simply maps its input
-to its output (like a simplified UN*X "cat"). It assumes that
-characters are 8 bits long, but that's fine since the current version
-of the compiler does too. Standard library routines for addition
-and subtraction are not included here, as they are listed in the
-original manual.
-
- DO ,1 <- #1
- DO .4 <- #0
- DO .5 <- #0
- DO COME FROM (30)
- DO WRITE IN ,1
- DO .1 <- ,1SUB#1
- DO (10) NEXT
- PLEASE GIVE UP
-(20) PLEASE RESUME '?.1$#256'~'#256$#256'
-(10) DO (20) NEXT
- DO FORGET #1
- DO .2 <- .4
- DO (1000) NEXT
- DO .4 <- .3~#255
- DO .3 <- !3~#15'$!3~#240'
- DO .3 <- !3~#15'$!3~#240'
- DO .2 <- !3~#15'$!3~#240'
- DO .1 <- .5
- DO (1010) NEXT
- DO .5 <- .2
- DO ,1SUB#1 <- .3
-(30) PLEASE READ OUT ,1
-
-For each number received in the input array, the program first tests
-the #256 bit to see if the end of file has been reached. If not, the
-previous input character is subtracted off to obtain the current
-input character. Then the order of the bits is reversed to find
-out what character should be sent to the output, and the result
-is subtracted from the last character sent. Finally, the difference
-is placed in an array and given to a READ OUT statement. See?
-We told you it was simple!
-
-
-5. TriINTERCAL
-
-In which it is revealed that bitwise operations are too ordinary for
-hard-core INTERCAL programmers, and extensions to other bases are
-discussed. These are not, strictly speaking, extensions to INTERCAL
-itself, but rather new dialects sharing most of the features of the
-parent language.
-
-5.1 MOTIVATION
-
-INTERCAL is really a pretty sissy language. It tries hard to be
-different, but when you get right down to its roots, what do you find?
-You find bits, that's what. Plain old ones and zeroes, in groups of
-16 and 32, just like every other language you've ever heard of. And
-what operations can you perform on these bits? The INTERCAL operators
-may arrange and permute them in weird and wonderful ways, but at the
-bit level the operators are the same AND, OR and XOR you've seen
-countless times before.
-
-Once the prospective INTERCAL programmer masters the unusual syntax,
-she finds herself working with the familiar Boolean operators on
-perfectly ordinary unsigned integer words. Even the constants she uses
-are familiar. After all, who would not immediately recognize #65535
-and #32768? It may take a just a moment more to figure out #65280,
-and #21845 and #43690 could be puzzles until she notices that they
-sum to #65535, but basically she's still on her home turf. The 16-bit
-limit on constants actually works in the programmer's favor by insuring
-that very long anonymous constants can not appear in INTERCAL programs.
-And this is in a language that is supposed to be different from any
-other!
-
-5.2 ABANDON ALL HOPE...
-
-Standard INTERCAL is based on variables consisting of ordinary bits
-and familiar Boolean operations on those bits. In pursuit of uniqueness,
-it seems appropriate to provide a new dialect, otherwise identical to
-INTERCAL, which instead uses variables consisting of trits, i.e. ternary
-digits, and operators based on tritwise logical operations. This is
-intended to be a separate dialect, rather than an extension to INTERCAL
-itself, for a number of reasons. Doing it this way avoids word-length
-conflicts, does not spoil the elegance of the Spartan INTERCAL operator
-set, and dodges the objections of those who might feel it too great an
-alteration to the original language. Primarily, though, giving INTERCAL
-programmers the ability to switch numeric base at will amounts to
-excessive functionality. So much better that a programmer choose a base
-at the outset and then be forced to stick with it for the remainder of
-the program.
-
-5.3 COMPILER OPERATION
-
-The same compiler, ick, supports both INTERCAL and TriINTERCAL.
-This has the advantage that future bug fixes and additions to the
-language not related to arithmetic immediately apply to both versions.
-The compiler recognizes INTERCAL source files by the extension '.i',
-and TriINTERCAL source files by the extension '.3i'. It's as simple
-as that. There is no way to mix INTERCAL and TriINTERCAL source in
-the same program, and it is not always possible to determine which
-dialect a program is written in just by looking at the source code.
-
-5.4 DATA TYPES
-
-The two TriINTERCAL data types are 10-trit unsigned integers and
-20-trit unsigned integers. All INTERCAL syntax for distinguishing
-data types is ported to these new types in the obvious way. Small
-words may contain numbers from #0 to #59048, large words may contain
-numbers from #0$#0 to #59048$#59048. Errors are signaled for constants
-greater than #59048 and for attempts to WRITE IN numbers too large
-for a given variable or array element to hold.
-
-Note that though TriINTERCAL considers all numbers to be unsigned,
-nothing prevents the programmer from implementing arithmetic operations
-that treat their operands as signed. Three's complement is one obvious
-choice, but balanced ternary notation is also a possibility. This
-latter is a very pretty and symmetrical system in which all 2 trits
-are treated as if they had the value -1.
-
-5.5 OPERATORS
-
-The TriINTERCAL operators are designed to inherit the relevant properties
-of the standard INTERCAL operators, so that both can be considered as
-merely different aspects of the same Platonic ideal. (Not that the word
-"ideal" is ever particularly relevant when used in connection with
-INTERCAL.)
-
-5.5.1 BINARY OPERATORS I
-
-The binary operators carry over from the original language with only
-minor changes. The MINGLE operator ($) creates a 20-trit word by
-alternating trits from its two 10-trit operands. The SELECT operator (~)
-is a little more complicated, since the ternary tritmask may contain 0, 1,
-and 2 trits. If we observe that the SELECT operation on binary operands
-amounts to a bitwise AND and some rearrangement of bits, it seems
-appropriate to base the SELECT for ternary operands on a tritwise AND in
-the analogous fashion. We therefore postpone the definition of SELECT
-until we know what a tritwise AND looks like.
-
-5.5.2 UNARY OPERATORS
-
-The unary operators in INTERCAL are all derived from the familiar
-Boolean operations on single bits. To extend these operations to trits,
-we first ask ourselves what the important properties of these operations
-are that we wish to be preserved, then design the tritwise operators so
-that they behave in a similar fashion.
-
-5.5.2.1 UNARY LOGICAL OPERATORS
-
-Let's start with AND and OR. To begin with, these can be considered
-"choice" or "preference" operators, as they always return one of their
-operands. AND can be described as wanting to return 0, but returning 1
-if it is given no other choice, i.e., if both operands are 1. Similarly,
-OR wants to return 1 but returns 0 if that is its only choice. From
-this it is immediately apparent that each operator has an identity
-element that "always loses", and a dominator element that "always wins".
-
-AND and OR are commutative and associative, and each distributes
-over the other. They are also symmetric with each other, in the sense
-that AND looks like OR and OR looks like AND when the roles of 0 and 1
-are interchanged (De Morgan's Laws). This symmetry property seems to be
-a key element to the idea that these are logical, rather than arithmetic,
-operators. In a three-valued logic we would similarly expect a three-
-way symmetry among the three values 0, 1 and 2 and the three operators
-AND, OR and (of course) BUT.
-
-The following tritwise operations have all the desired properties:
-OR returns the greater of its two operands. That is, it returns 2 if
-it can get it, else it tries to return 1, and it returns 0 only if both
-operands are 0. AND wants to return 0, will return 2 if it can't get
-0, and returns 1 only if forced. BUT wants 1, will take 0, and tries
-to avoid 2. The equivalents to De Morgan's Laws apply to rotations
-of the three elements, e.g., 0 -> 1, 1 -> 2, 2 -> 0. Each operator
-distributes over exactly one other operator, so the property
-"X distributes over Y" is not transitive. The question of which way
-this distributivity ring goes around is left as an exercise for the
-student.
-
-In TriINTERCAL programs the '@' (whirlpool) symbol denotes the unary
-tritwise BUT operation. You can think of the whirlpool as drawing
-values preferentially towards the central value 1. Alternatively,
-you can think of it as drawing your soul and your sanity inexorably
-down...
-
-On the other hand, maybe it's best you NOT think of it that way.
-
-A few comments about how these operators can be used. OR acts like
-a tritwise maximum operation. AND can be used with tritmasks. 0's
-in a mask wipe out the corresponding elements in the other operand,
-while 1's let the corresponding elements pass through unchanged. 2's
-in a mask consolidate the values of nonzero elements, as both 1's and
-2's in the other operand yield 2's in the output. BUT can be used to
-create "partial tritmasks". 0's in a mask let BUT eliminate 2's from
-the other operand while leaving other values unchanged. Of course,
-the symmetry property guarantees that the operators don't really
-behave differently from each other in any fundamental way; the apparent
-differences come from the intuitive view that a 0 trit is "not set"
-while a 1 or 2 trit is "set".
-
-5.5.2.1.1 BINARY OPERATORS II
-
-At this point we can define SELECT, since we now know what the
-tritwise AND looks like. SELECT takes the binary tritwise AND of
-its two operands. It shifts all the trits of the result corresponding
-to 2's in the right operand over to the right (low) end of the result,
-then follows them with all the output trits corresponding to 1's in
-the right operand. Trits corresponding to 0's in the right operand,
-which are all 0 anyway, occupy the remaining space at the left end of
-the output word. Both 10-trit and 20-trit operands are accepted,
-and are padded with zeroes on the left if necessary. The output
-type is determined the same way as in standard INTERCAL.
-
-5.5.2.2 UNARY ARITHMETIC OPERATORS
-
-Now that we've got all that settled, what about XOR? This is
-easily the most-useful of the three unary INTERCAL operators,
-because it combines in one package the operations ADD WITHOUT CARRY,
-SUBTRACT WITHOUT BORROW, BITWISE NOT-EQUAL, and BITWISE NOT. In
-TriINTERCAL we can't have all of these in the same operator, since
-addition and subtraction are no longer the same thing. The solution
-is to split the XOR concept into two operators. The ADD WITHOUT CARRY
-operation is represented by the new '^' (sharkfin) symbol, while the
-old '?' symbol represents SUBTRACT WITHOUT BORROW. The reason for
-this choice is so that '?' will also represent the TRITWISE NOT-EQUAL
-operation.
-
-Note that '?', unlike the other four unary operators, is not
-symmetrical. It should be thought of as rotating its operand one trit
-to the right (with wraparound) and then subtracting off the trits of
-the original number. These subtractions are done without borrowing,
-i.e., trit-by-trit modulo 3.
-
-5.5.3 EXAMPLES
-
-The TriINTERCAL operators really aren't all that bad once you get
-used to them. Let's look at a few examples to show how they can
-be used in practice. In all of these examples the input value is
-contained in the 10-trit variable .3.
-
-In INTERCAL, single-bit values often have to be converted from
-{0,1} to {1,2} for use in RESUME statements. Examples of how to do
-this appear in the original manual. In TriINTERCAL the expression
-"^.3$#1"~#1 sends 0 -> 1 and 1 -> 2. If the 1-trit input value can
-take on any of its three possible states, however, we will also have
-to deal with the 2 case. The expression "V.3$#1"~#1 sends {0,1} -> 1
-and 2 -> 2. To test if a trit is set, we can use "V'"&.3$#2"~#1'$#1"~#1,
-sending 0 -> 1 and {1,2} -> 2. To reverse the test we use
-"?'"&.3$#2"~#1'$#1"~#1, sending 0 -> 2 and {1,2} -> 1. Note that we
-have not been taking full advantage of the new SELECT operator. These
-last two expressions can be simplified into "V!3~#2'$#1"~#1 and
-"?!3~#2'$#1"~#1, which perform exactly the same mappings. Finally, if
-we need a 3-way test, we can use "@'"^.3$#7"~#4'$#2"~#10, which
-obviously sends 0 -> 1, 1 -> 2, and 2 -> 3.
-
-For an unrelated example, the expression "^.3$.3"~"#0$#29524"
-converts all of the 1-trits of .3 into 2's and all of the 2-trits
-into 1's. In balanced ternary, where 2-trits represent -1 values,
-this is the negation operation.
-
-5.6 BEYOND TERNARY...
-
-While we're at it, we might as well extend this multiple bases
-business a little farther. The ick compiler actually recognizes
-filename suffixes of the form '.Ni', where N is any number from 2
-to 7. 2 of course gives standard INTERCAL, while 3 gives TriINTERCAL.
-We cut off before 8 because octal notation is the smallest base used
-to facilitate human-to-machine communication, and this seems quite
-contrary to the basic principles behind INTERCAL. The small data
-types hold 16 bits, 10 trits, 8 quarts, 6 quints, 6 sexts, or 5 septs,
-and the large types are always twice this size.
-
-As for operators, '?' is always SUBTRACT WITHOUT BORROW, and '^'
-is always ADD WITHOUT CARRY. 'V' is the OR operation and always
-returns the max of its inputs. '&' is the AND operation, which chooses
-0 if possible but otherwise returns the max of the inputs. '@' is BUT,
-which prefers 1, then 0, then the max of the remaining possibilities.
-Rather than add more special symbols forever, a numeric modifier may
-be placed directly before the '@' symbol to indicate the operation
-that prefers one of the digits not already represented. Thus in files
-ending in '.5i', the permitted unary operators are '?', '^', '&', '@',
-'2@', '3@', and 'V'. Use of such barbarisms as '0@' to represent '&'
-are not permitted, nor is the use of '@' or '^' in files with either
-of the extensions '.i' or '.2i'. Why not? You just can't, that's why.
-Don't ask so many questions.
-
-As a closing example, we note that in balanced quinary notation,
-where 3 means -2 and 4 means -1, the negation operation can be written
-as either
-
- DO .1 <- "^'"^.3$.3"~"#0$#3906"'$'"^.3$.3"~"#0$#3906"'"~"#0$#3906"
-
-or as
-
- DO .1 <- "^.3$.3"~"#0$#3906"
- DO .1 <- "^.1$.1"~"#0$#3906"
-
-These work because multiplication by -1 is the same as multiplication
-by 4, modulo 5.
-
-Now go beat your head up against the wall for a while.
-
-
-6. UNDOCUMENTED FEATURES FROM INTERCAL-72
-
-A feature of INTERCAL-72 not documented in the manual was that it
-required a certain level of politesse from the programmer. If fewer than
-1/5th of the program statements included the PLEASE qualifier, the program
-would be rejected as insufficiently polite. If more than 1/3rd of them
-included PLEASE, the program would be rejected as excessively polite.
-
-This check has been implemented in C-INTERCAL. To assist programmers in
-coping with it, the intercal.el mode included with the distribution randomly
-expands "do " in entered source to "DO PLEASE" or "PLEASE DO" 1/4th of the
-time.
-
-
-7. AUTOMAGICAL INCLUSION OF THE SYSTEM LIBRARY
-
-The C-INTERCAL compiler will automatically include the system library if a DO
-(1xxx) NEXT statement is used, and if no (1xxx) labels are defined anywhere,
-where (1xxx) is a label in the 1000-1999 range, inclusive. This was not
-an INTERCAL-72 feature.
-
-
-8. MODIFIED INPUT BEHAVIOR
-
-The INTERCAL-72 implementation, instead of accepting an entire multiple-digit
-number per line of input, expected one digit per *card image* (input line).
-It is unclear how INTERCAL-72 programs ever managed to input more than one
-number.
-
-
-9. NEW ERROR MESSAGES IN C-INTERCAL
-
-The following error codes are new in C-INTERCAL.
-
-111 You tried to use a C-INTERCAL extension with the `traditional' flag on.
-
-127 Can't find syslib.i file when it's needed for magical inclusion.
-
-222 Out of stash space.
-
-333 Too many variables.
-
-444 A COME FROM statement references a non-existent line label.
-
-555 More than one COME FROM references the same label.
-
-666 Too many source lines.
-
-777 No such source file.
-
-888 Can't open C output file
-
-999 Can't open C skeleton file.
-
-998 Source file name with invalid extension (use .i or .[3-7]i).
-
-997 Illegal possession of a controlled unary operator.
-
-
-9. END OF FILE
-
-Can't you read? Beat it! There's nothing left. Why don't you lie
-down and take a stress pill?
--- /dev/null
+.\" Note: This is both a current manual and an archeological exhibit.
+.\" All revisions must be properly conditioned on the c string so that
+.\" it's still possible to format the INTERCAL-72 manual.
+.\"
+.\" This document is free; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This document is distributed in the hope that it will be amusing,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this document; if not, write to the Free Software
+.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+.ND
+.ds vb V\v'-0.2'\h'-0.6'\-\v'0.2'
+.if n .ds es \o"O|"
+.if t .ds es \(es
+.if n .ds ct \o"c/"
+.if t .ds ct \(ct
+.if n .ds no \o"-'"
+.if t .ds no \(no
+.if n .ds ov -
+.if t .ds ov \(rn
+.INITR intercal.refs
+.TL
+THE INTERCAL PROGRAMMING LANGUAGE
+.br
+.if '\*c'y' REVISED REFERENCE MANUAL
+.if '!\*c'n' REFERENCE MANUAL
+
+.AU "Donald R. Woods"
+.AF ""
+.AU "and"
+.AF ""
+.AU "James M. Lyon"
+.AF ""
+.if '\*c'y' \{\
+.AU ""
+.AU "C-INTERCAL revisions:"
+.AU "Louis Howell"
+.AF ""
+.AU "and"
+.AF ""
+.AU "Eric S. Raymond" \}
+.AF ""
+.AST ""
+.AS 2
+.ce 2
+\fICopyright (C) 1973 by Donald R. Woods
+and James M. Lyon\fR
+.if '\*c'y' \{\
+.ce 2
+\fICopyright (C) 1996 by Eric S. Raymond
+Redistribution encouraged under GPL\}
+.sp
+.ce 1
+(This version distributed with C-INTERCAL 0.15)
+.AE
+.MT 4
+.nr % 0
+.nr Hs 5
+.nr Ej 1
+.bp
+.H 1 "INTRODUCTION"
+.P
+The names you are about to ignore are true. However, the story has been changed
+significantly. Any resemblance of the programming language portrayed here
+to other programming languages, living or dead, is purely coincidental.
+.H 2 "Origin and Purpose"
+.P
+The INTERCAL programming language was designed the morning of May 26, 1972
+by Donald R. Woods and James M. Lyon, at Princeton University. Exactly when
+in the morning will become apparent in the course of this manual.
+.ie '\*c'y' \{\
+.P
+Eighteen years later (give or take a few months) Eric S. Raymond perpetrated
+a UNIX-hosted INTERCAL compiler as a weekend hack. The C-INTERCAL
+implementation has since been maintained and extended by an international
+community of technomasochists, including Louis Howell, Steve Swales,
+Michael Ernst, and Brian Raiter.
+.P
+(There was evidently an Atari implementation sometime between these
+two; notes on it got appended to the INTERCAL-72 manual. The culprits
+have sensibly declined to identify themselves.)
+.P
+INTERCAL \}
+.el It
+was inspired by one ambition: to have a compiler language which has nothing at
+all in common with any other major language. By 'major' was meant anything
+with which the authors were at all familiar, e.g., FORTRAN, BASIC, COBOL,
+ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PL/I. For the
+most part, INTERCAL has remained true to this goal, sharing only the basic
+elements such as variables, arrays, and the ability to do I/O, and eschewing
+all conventional operations other than the assignment statement (FORTRAN
+"=").
+.H 2 "Acronym"
+.P
+The full name of the compiler is "Compiler Language With No Pronounceable
+Acronym", which is, for obvious reasons, abbreviated "INTERCAL".
+.H 2 "Acknowledgments"
+.P
+The authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,
+without whose unwitting assistance this manual would still have been
+possible.
+.H 1 "FUNDAMENTAL CONCEPTS"
+.P
+In this section an attempt is made to describe how and why INTERCAL may be
+used; i.e., what it is like and what it is good for.
+.H 2 "Sample Program"
+.SETR example1
+.P
+Shown below is a relatively simple INTERCAL program which will read in 32-bit
+unsigned integers, treat them as signed, 2's-complement numbers, and print out
+their absolute values. The program exits if the absolute value is zero. Note
+in particular the inversion routine (statements 6 through 14), which could
+be greatly simplified if the subroutine library (see section
+.GETHN sublib
+) were used.
+.P
+A more detailed analysis of a program is made in section
+.GETHN proghints
+ of this manual.
+.DS L
+.cs R 24
+ DO (5) NEXT
+ (5) DO FORGET #1
+ PLEASE WRITE IN :1
+ DO .1 <- '\*(vb":1~'#32768\*(ct#0'"\*(ct#1'~#3
+ DO (1) NEXT
+ DO :1 <- "'\*(vb":1~'#65535\*(ct#0'"\*(ct#65535'
+ ~'#0\*(ct#65535'"\*(ct"'\*(vb":1~'#0\*(ct#65535'"
+ \*(ct#65535'~'#0\*(ct#65535'"
+ DO :2 <- #1
+ PLEASE DO (4) NEXT
+ (4) DO FORGET #1
+ DO .1 <- "\*(vb':1~:2'\*(ct#1"~#3
+ DO :1 <- "'\*(vb":1~'#65535\*(ct#0'"\*(ct":2~'#65535
+ \*(ct#0'"'~'#0\*(ct#65535'"\*(ct"'\*(vb":1~'#0
+ \*(ct#65535'"\*(ct":2~'#65535\*(ct#0'"'~'#0\*(ct#65535'"
+ DO (1) NEXT
+ DO :2 <- ":2~'#0\*(ct#65535'"
+ \*(ct"'":2~'#65535\*(ct#0'"\*(ct#0'~'#32767\*(ct#1'"
+ DO (4) NEXT
+ (2) DO RESUME .1
+ (1) PLEASE DO (2) NEXT
+ PLEASE FORGET #1
+ DO READ OUT :1
+ PLEASE DO .1 <- '\*(vb"':1~:1'~#1"\*(ct#1'~#3
+ DO (3) NEXT
+ PLEASE DO (5) NEXT
+ (3) DO (2) NEXT
+ PLEASE GIVE UP
+.cs R
+.DE
+.H 2 "Uses for INTERCAL"
+.P
+INTERCAL's main advantage over other programming languages is its strict
+simplicity. It has few capabilities, and thus there are few restrictions to
+be kept in mind. Since it is an exceedingly easy language to learn, one
+might expect it would be a good language for initiating novice programmers.
+Perhaps surprising, than, is the fact that it would be more likely to
+initiate a novice into a search for another line of work. As it turns out,
+INTERCAL is more useful (which isn't saying much) as a challenge to
+professional programmers. Those who doubt this need only refer back to the
+sample program in section
+.GETHN example1
+\&. This 22-statement program took somewhere
+from 15 to 30 minutes to write, whereas the same objectives can be achieved
+by single-statement programs in either SNOBOL;
+.DS L
+ PLEASE INPUT POS(0) ('-' ! '')
+ + (SPAN('0123456789') $ OUTPUT)
+ + *NE(OUTPUT) :S(PLEASE)F(END)
+.DE
+or APL;
+.DS L
+ [1] \(->0\(!=\(sq\(<-\(or\(sq
+.DE
+Admittedly, neither of these is likely to appear more intelligible to
+anyone unfamiliar with the languages involved, but they took roughly 60
+seconds and 15 seconds, respectively, to write. Such is the overwhelming
+power of INTERCAL!
+.P
+The other major importance of INTERCAL lies in its seemingly inexhaustible
+capacity for amazing one's fellow programmers, confounding programming shop
+managers, winning friends, and influencing people. It is a well-known and
+oft-demonstrated fact that a person whose work is incomprehensible is held
+in high esteem. For example, if one were to state that the simplest way to
+store a value of 65536 in a 32-bit INTERCAL variable is:
+.DS L
+ DO :1 <- #0\*(ct#256
+.DE
+any sensible programmer would say that that was absurd. Since this is
+indeed the simplest method, the programmer would be made to look foolish in
+front of his boss, who would of course happened to turn up, as bosses are
+wont to do. The effect would be no less devastating for the programmer
+having been correct.
+.H 1 "DESCRIPTION"
+.P
+The examples of INTERCAL programming which have appeared in the preceding
+sections of this manual have probably seemed highly esoteric to the reader
+unfamiliar with the language. With the aim of making them more so, we
+present here a description of INTERCAL.
+.H 2 "Variables"
+.P
+INTERCAL allows only 2 different types of variables, the
+.B "16-bit integer"
+and the
+.B "32-bit integer."
+These are represented by a spot (.) or two-spot
+(:), respectively, followed by any number between 1 and 65535, inclusive.
+These variables may contain only non-negative numbers; thus they have the
+respective ranges of values: 0 to 65535 and 0 to 4294967295. Note: .123 and
+:123 are two distinct variables. On the other hand, .1 and .0001 are
+identical. Furthermore, the latter may NOT be written as 1E-3.
+.H 2 "Constants"
+.P
+.B Constants
+are 16-bit values only and may range from 0 to 65535. They are
+prefixed by a mesh (#). Caution! Under no circumstances confuse the mesh
+with the interleave operator, except under confusing circumstances!
+.H 2 "Arrays"
+.P
+.B Arrays
+are represented by a tail (,) for 16-bit values, or a hybrid (;) for
+32-bit values, followed by a number between 1 and 65535, inclusive. The
+number is suffixed by the word SUB, followed by the subscripts, separated
+optionally by spaces. Subscripts may be any expressions, including those
+involving subscripted variables. This occasionally leads to ambiguous
+constructions, which are resolved as discussed in section
+.GETHN precedence
+\&. Definition
+of array dimensions will be discussed later in greater detail, since
+discussing it in less detail would be difficult. As before, ,123 and ;123
+are distinct. In summary, .123, :123, #123, ,123, and :123 are all
+distinct.
+.H 2 "Operators"
+.P
+INTERCAL recognizes 5 operators -- 2 binary and 3 unary. Please be kind to
+our operators: they may not be very intelligent, but they're all we've got.
+In a sense, all 5 operators are binary, as they are all bit-oriented, but
+it is not our purpose here to quibble about bits of trivia.
+.H 3 "Binary Operators"
+.P
+The binary operators are \fBinterleave\fR (also called \fBmingle\fR)
+and \fBselect\fR, which
+are represented by a change (\*(ct) and a sqiggle [sic] (~), respectively.
+.if '\*c'y' \{\
+(In C-INTERCAL'S ASCII environment, EBCDIC \*(ct is replaced by a big
+money ($).) \}
+.P
+The interleave operator takes two 16-bit values and produces a 32-bit result
+by alternating the bits of the operands. Thus, #65535\*(ct#0 has the 32-bit
+binary form 101010....10 or 2863311530 decimal, while #0\*(ct#65535 =
+0101....01 binary = 1431655765 decimal, and #255\*(ct#255 is equivalent to
+#65535.
+.P
+The select operator takes from the first operand whichever bits correspond
+to 1's in the second operand, and packs these bits to the right in the result.
+Both operands are automatically padded on the left with zeros to 32 bits
+before the selection takes place, so the variable types are unrestricted.
+If more than 16 bits are selected, the result is a 32-bit value, otherwise
+it is a 16-bit value. For example, #179~#201 (binary value 10110011~11001001)
+selects from the first argument the 8th, 7th, 4th, and 1st from last bits,
+namely, 1001, which = 9. But #201~#179 selects from binary 11001001 the 8th,
+6th, 5th, 2nd, and 1st from last bits, giving 10001 = 17. #179~#179 has the
+value 31, while #201~#201 has the value 15.
+.if '\*c'y' \{\
+.H 4 "Return type of SELECT"
+.P
+INTERCAL-72 defined the return type of a SELECT operation
+to depend on the number of bits SELECTed. The C-INTERCAL compiler
+takes the easier route of defining the return type to be that of
+the right operand, independent of its actual value. This form has
+the advantage that all types can be determined at compile time.
+Putting in run time type checking would add significant overhead and
+complication, to effect a very minor change in language semantics.
+.P
+The only time this distinction makes any difference is when a unary
+operator is applied to the SELECT result. This happens extremely
+rarely in practice, the only known instance being the 32-bit
+greater-than test in the standard library, where an XOR operator is
+applied to the result of SELECTing a number against itself. The
+INTERCAL-72 authors first SELECT the result against #65535\*(ct#65535 to
+insure that XOR sees a 32-bit value. With the current compiler this
+extra step is unnecessary, but harmless.
+.P
+The cautious programmer should write code that does not depend on
+the compiler version being used. We therefore suggest the following
+guideline for determining the SELECT return type:
+.P
+A SELECT operation with a 16-bit right operand returns a 16-bit
+value. The return type of a SELECT operation with a 32-bit right
+operand is undefined, but is guaranteed to be an acceptable input
+to a MINGLE operation so long as 16 or fewer bits are actually
+selected. Correct code should not depend on whether the return
+type is 16 or 32 bits.\}
+.P
+Perhaps a simpler way of understanding the operation of the select operator
+would be to examine the logic diagram on the following page (Figure 1), which
+performs the select operation upon two 8-bit values, A and B. The gates used
+are Warmenhovian logic gates, which means the outputs have four possible
+values: low, high, undefined (value of an uninitialized flip-flop), and
+oscillating (output of a NOR gate with one input low and the other input
+connected to the output). These values are represented symbolically
+by '0', '1', '?', and '\*(es'.
+Note in particular that, while NOT-0 is 1 and NOT-1
+is 0 as in two-valued logic, NOT-? is ? and NOT-\*(es is \*(es. The functions
+of the various gates are listed in Table 1.
+.if n \{\
+.P
+[Warning: The following picture will be garbled or missing.
+Get a better output device.]
+.sp 1 \}
+.PS
+# The CIRCUITOUS DIAGRAM, Figure 1 of the INTERCAL manual.
+#
+# Transcribed to PIC by Eric S. Raymond from the paper original.
+# The transcription to topologically correct but not geometrically perfect.
+#
+# I discovered late in the process that the gate spacing to gate width
+# ratio should be 6/5, not 5/5. The only place the difference shows is
+# in the zigzag part of the adventitious lead below gate 37, which is
+# a bit narrower in this version than in the paper original.
+#
+# Minor liberties have been taken with the sizes of some features at the
+# left and right sides to fit the diagram on a letter-sized page. The
+# A/B input leads should really be a whole boxwidth wide, and the bus line
+# rectangle was slightly wider and further right in the paper original.
+# Also, there are only 15 "New York" terminals rather than 16, and in the
+# original the bus terminal label texts were rotated 90 degrees clockwise.
+#
+# The whole diagram can be scaled horizontally or vertically by changing
+# the boxwid and boxht variables. At default scale the values boxwid =
+# 0.60 boxht = 0.525 reproduce the paper version most exactly; they get
+# the gate grid and leads nearly perfect.
+#
+scale=6/5 # This is how we scale the whole thing to fit on 8.5x11
+boxwid = 0.60
+boxht = 0.525
+linewid = boxwid
+lineht = boxht
+movewid = boxwid
+moveht = boxht
+
+# Offset of top and bottom pins from gate midline
+define pinoffset {(2/3)}
+
+define warmengate {
+# Draw a Warmenhovian gate box
+ [
+ box invis;
+ line from last box .sw \
+ to last box .nw \
+ to 1/2 <last box .ne, last box .n> \
+ to 1/2 <last box .e, last box .ne> \
+ to 1/2 <last box .e, last box .se> \
+ to 1/2 <last box .se, last box .s> \
+ to last box .sw;
+ IN: last box .w;
+ UP: pinoffset <last box .w, last box .nw>
+ DN: pinoffset <last box .w, last box .sw>
+ OUT: last box .e;
+ "$1" at last box .center;
+ ]
+}
+
+[ # Beginning of diagram object
+
+# Draw the gate array
+copy thru % move to (($1-1) * movewid * 2, ($2-1) * moveht * 2); warmengate($3) % until "END"
+0 1 6
+0 2 6
+0 3 1
+0 4 1
+0 5 1
+0 6 1
+0 7 1
+0 8 1
+0 9 1
+0 10 1
+END
+copy thru % move to ((boxwid + movewid * 7 / 5) + ($1-2) * movewid * 2, ($2-1) * moveht * 2); warmengate($3) % until "END"
+1 1 1
+1 2 2
+1 3 2
+1 4 2
+1 5 2
+1 6 2
+1 7 2
+1 8 2
+1 9 2
+1 10 2
+2 1 1
+2 2 7
+2 3 4
+2 4 3
+2 5 3
+2 6 3
+2 7 7
+2 8 3
+2 9 7
+2 10 3
+3 1 1
+3 2 3
+3 3 3
+3 4 4
+3 5 4
+3 6 3
+3 7 3
+3 8 3
+3 9 3
+3 10 3
+4 1 1
+4 2 4
+4 3 5
+4 4 5
+4 5 4
+4 6 5
+4 7 4
+4 8 3
+4 9 2
+4 10 1
+END
+
+# Draw bus line:
+BUSLINE: box with .sw at 41st [].se + (boxwid/2, 0) \
+ wid (boxwid / 2) \
+ ht (50th [].n.y - 41st [] .s.y)
+copy thru % move to $1 / 40 <last box .n, last box .s>; "$2" % until "END"
+9 B
+11 U
+13 S
+17 L
+19 I
+21 N
+23 E
+30 8
+END
+define newyork {
+ line right boxwid/3
+ box invis "" "TO" "NEW" "YORK" ""
+}
+define philly {
+ line right boxwid/3
+ box invis "" "TO" "PHILA-" "DELPHIA" ""
+}
+for i = 0 to 14 do {
+ move to (i+1)/18 <BUSLINE.ne,BUSLINE.se>
+ newyork
+}
+move to (i+1)/18 <BUSLINE.ne,BUSLINE.se>
+philly
+
+define dot {circle rad 0.03 filled 1}
+
+# Place a junction dot wherever we are
+define junction % {dot at Here}; %
+
+# Draw inputs
+define inwidth {boxwid*3/4}
+define drawinputs {
+ line left inwidth from $1.UP;
+ "A" at last line .end - (0.1, 0) rjust;
+ "$2" at last line .end - (0.05, 0.1) rjust;
+ move to last line .center; A$2: junction
+ line left inwidth from $1.DN;
+ "B" at last line .end - (0.1, 0) rjust;
+ "$2" at last line .end - (0.05, 0.1) rjust;
+ move to last line .center; B$2: junction
+}
+drawinputs(3rd [],8)
+drawinputs(4th [],7)
+drawinputs(5th [],6)
+drawinputs(6th [],5)
+drawinputs(7th [],4)
+drawinputs(8th [],3)
+drawinputs(9rd [],2)
+# Gate 10 inputs have to be done by hand
+
+define go {move to $1;}
+
+# Define `gate' to *refer* to nth gate
+define gate {`$1'th []}
+
+# Go to specified pin of given gate
+define pin {gate($1).$2}
+
+# We exploit the quantization of lead placements here
+# Draw from left edge of box $1 quanta of inter-box horizontal distance
+define left_mv {line left boxwid * $1 / 5;}
+# Draw from right edge of box $1 quanta of inter-box horizontal distance
+define right_mv {line right boxwid * $1 / 5;}
+# Draw from top pin of box $1 quanta of inter-box vertical distance up
+define up_mv {line up (boxht * (2 - pinoffset)) * $1 / 4;}
+# Draw from bottom pin of box $1 quanta of inter-box vertical distance down
+define dn_mv {line down (boxht * (2 - pinoffset)) * $1 / 4;}
+
+# Draw from here to given object, with directional constraint
+define vert {line up ($1.y - Here.y);}
+define horz {line right ($1.x - Here.x);}
+define zig {vert($1) horz($1)}
+define to_bus {line to (BUSLINE.w, Here)}
+
+define ground {
+ dn_mv(1)
+ [
+ boxwid = boxwid * (3/4)
+ boxht = boxht / 3
+ box invis
+ line from last box .ne to last box .nw
+ line from 1/3 <last box.e,last box.c> to 1/3 <last box.w,last box.c>
+ line from 2/3 <last box.se,last box.s> to 2/3 <last box.sw,last box.s>
+ ]
+}
+
+# Now all those connections
+# Gate 1:
+go(pin(1,OUT)) right_mv(3) CORNER:Here; zig(pin(12,DN))
+go(CORNER) vert(pin(1,UP)) \
+ {junction horz(pin(11,UP))} \
+ up_mv(2) junction
+ horz(gate(32).e) right_mv(3) junction
+ {zig(pin(43,IN))}
+ horz(gate(42).e) right_mv(1) junction
+ {to_bus}
+ vert(pin(43,UP)) up_mv(2) to_bus
+
+# Gate 2
+go(pin(2,OUT)) right_mv(2) zig(pin(12,UP))
+# Gate 3
+go(A8) up_mv(1) horz(gate(13).e) right_mv(3) zig(pin(23,IN))
+go(B8) dn_mv(1) horz(gate(13))
+ right_mv(1) dn_mv(1)
+ horz(gate(23).e) right_mv(2) dn_mv(2) horz(pin(32,UP))
+go(pin(3,OUT)) right_mv(2)
+ vert(gate(3).UP) up_mv(3)
+ horz(gate(13).e) right_mv(2)
+ vert(gate(15,UP)) up_mv(4) #??? don't know why 4 is necessary
+ horz(gate(16).w) left_mv(1)
+ vert(gate(6).w) up_mv(4)
+ left_mv(2) zig(pin(7,OUT))
+# Gate 4
+go(A7) up_mv(1) horz(gate(14).e) right_mv(1) zig(pin(24,UP))
+go(B7) dn_mv(1) horz(gate(4))
+ right_mv(1) dn_mv(1)
+ horz(gate(14).e) right_mv(3)
+ vert(pin(26,UP)) up_mv(1)
+ horz(gate(25)) up_mv(2)
+ horz(gate(25).e) right_mv(4)
+ vert(pin(38,UP)) up_mv(1)
+ horz(gate(48).e) right_mv(1)
+ vert(pin(47,DN)) dn_mv(1)
+ horz(gate(47).w) left_mv(3)
+ vert(gate(46).DN) dn_mv(2) right_mv(2)
+ vert(gate(45).DN) dn_mv(2) left_mv(3)
+ vert(gate(44).DN) right_mv(3) dn_mv(2)
+ horz(gate(33).w) left_mv(1)
+ vert(gate(33).DN) dn_mv(3)
+ horz(gate(32).e) up_mv(2)
+ horz(gate(42).e) dn_mv(2) line down boxwid/5
+ to_bus
+go(pin(4,OUT)) right_mv(3) junction
+ {zig(pin(13,UP))}
+ vert(pin(4,UP)) up_mv(3) junction
+ {right_mv(3) zig(pin(15,IN))}
+ left_mv(2) vert(pin(7,UP)) up_mv(3)
+ right_mv(3) zig(pin(19,DN))
+# Gate 5
+go(A6) up_mv(1) horz(gate(15).e) right_mv(1) vert(pin(15,UP)) junction
+ {horz(pin(25,UP))}
+ vert(pin(15,DN)) dn_mv(1)
+ horz(gate(25).e) right_mv(1)
+ zig(pin(34,UP))
+go(B6) dn_mv(2) horz(gate(25).e) dn_mv(1) right_mv(4)
+ vert(pin(24,DN)) dn_mv(1)
+ horz(gate(34).e) right_mv(1)
+ vert(pin(32,DN)) dn_mv(1)
+ right_mv(3) zig(pin(42,IN))
+go(pin(5,OUT)) right_mv(5) junction
+ {vert(pin(14,IN)) junction {horz(pin(14,IN))} zig(pin(13,IN)) }
+ vert(pin(17,DN)) junction {horz(pin(17,DN))} zig(pin(18,DN))
+# Gate 6
+go(A5) up_mv(1) horz(gate(16).e) right_mv(1) zig(pin(26,UP))
+go(B5) dn_mv(2) horz(gate(26).e) right_mv(3) zig(pin(34,IN))
+go(pin(6,OUT)) right_mv(4) junction
+ {horz(pin(16,IN))}
+ vert(pin(15,DN)) junction
+ {horz(pin(15,DN))}
+ vert(pin(14,DN)) junction
+ {horz(pin(14,DN))}
+ zig(pin(13,DN))
+# Gate 7
+go(A4) up_mv(1) horz(gate(27).e) right_mv(3) vert(pin(37,IN)) junction
+ {horz(pin(37,IN))}
+ vert(pin(37,DN)) dn_mv(2) right_mv(1) junction
+ {zig(pin(36,IN))}
+ horz(gate(37).e) right_mv(3)
+ zig(pin(45,IN))
+go(B4) dn_mv(2) horz(gate(17).e) right_mv(4)
+ vert(pin(26,DN)) dn_mv(1)
+ horz(gate(26).e) dn_mv(2)
+ right_mv(4) vert(pin(35,DN)) dn_mv(1)
+ horz(gate(35).e) right_mv(2) junction
+ {zig(pin(45,UP))} {zig(pin(44,UP))}
+# Gate 8
+go(A3) up_mv(1) horz(gate(28).e) right_mv(1) zig(pin(38,UP))
+go(B3) dn_mv(2) horz(gate(28).e) right_mv(2) zig(pin(37,UP))
+go(pin(8,OUT)) right_mv(6) junction
+ {zig(pin(17,IN))}
+ up_mv(4) left_mv(1) vert(pin(19,UP)) junction
+ {horz(pin(19,UP))}
+ zig(pin(20,UP))
+# Gate 9
+go(A2) up_mv(1) horz(gate(19).e) right_mv(1) zig(pin(28,UP))
+go(B2) dn_mv(2) horz(gate(39).e) right_mv(1)
+ vert(pin(38,DN)) dn_mv(2) right_mv(2) zig(pin(47,IN))
+go(pin(9,OUT)) right_mv(3) junction
+ {zig(pin(20,DN))}
+ {horz(pin(19,IN))}
+ vert(pin(16,DN)) junction
+ {horz(pin(16,DN))}
+ zig(pin(15,UP))
+# Gate 10
+line left inwidth from 10th[].UP;
+"A" at last line .end - (0.1, 0) rjust;
+"1" at last line .end - (0.05, 0.1) rjust;
+move to last line .center; A1: junction
+line left inwidth from 10th [].DN;
+"B" at last line .end - (0.1, 0) rjust;
+"1" at last line .end - (0.05, 0.1) rjust;
+move to 1/2 <last line .center, last line .start>; B1: junction
+go(A1) vert(pin(10,DN)) dn_mv(1) horz(gate(20).e) right_mv(2) zig(pin(30,UP))
+go(B1) dn_mv(2) horz(gate(30).e) right_mv(1) junction
+ {zig(pin(39,UP))}
+ right_mv(3) zig(pin(40,DN))
+go(pin(10,OUT)) right_mv(2) junction
+ {horz(pin(20,IN))}
+ vert(pin(18,UP)) junction
+ {horz(pin(18,UP))}
+ vert(pin(16,UP)) junction
+ {horz(pin(16,UP))}
+ zig(pin(14,UP))
+# Gate 11
+go(pin(11, DN)) left_mv(3) vert(pin(11,UP)) up_mv(1) \
+ horz(gate(31).e) right_mv(1) zig(pin(41,DN))
+go(pin(11,OUT)) right_mv(2) zig(pin(21,DN))
+# Gate 12
+go(pin(12,OUT)) right_mv(3) junction
+ {horz(pin(22,IN))}
+ vert(pin(12,UP)) up_mv(1)
+ horz(gate(12).w) left_mv(3)
+ zig(pin(12,IN))
+# Gate 13
+go(pin(13,OUT)) right_mv(1) zig(pin(23,UP))
+# Gate 14
+go(pin(14,OUT)) horz(pin(24,IN))
+# Gate 15
+go(pin(15,OUT)) horz(pin(25,IN))
+# Gate 16
+go(pin(16,OUT)) right_mv(2) junction
+ {horz(pin(26,IN))}
+ vert(pin(27,UP)) junction
+ {horz(pin(27,UP))}
+ zig(pin(29,DN))
+# Gate 17
+go(pin(17,OUT)) horz(pin(27,IN))
+# Gate 18
+go(pin(18,OUT)) right_mv(3) junction
+ {horz(pin(28,IN))}
+ zig(pin(27,DN))
+# Gate 19
+go(pin(19,OUT)) horz(pin(29,IN))
+# Gate 20
+go(pin(20,OUT)) right_mv(3) junction
+ {horz(pin(30,IN))}
+ zig(pin(29,UP))
+# Gate 21
+go(pin(21,UP)) left_mv(2) vert(pin(21,DN)) ground
+go(pin(21,OUT)) right_mv(2) junction
+ {zig(pin(31,DN))}
+ up_mv(2) junction
+# Gate 22
+go(pin(22,UP)) left_mv(3) up_mv(2) junction
+go(pin(22,DN)) left_mv(4)
+ vert(pin(22,UP)) up_mv(3) right_mv(3)
+ vert(pin(23,UP)) up_mv(3)
+ horz(gate(23).e) right_mv(2)
+ vert(pin(25,UP)) left_mv(1)
+ vert(pin(28,DN)) right_mv(1)
+ zig(pin(40,IN))
+go(pin(22,OUT)) right_mv(3) junction
+ {horz(pin(32,IN))}
+ {zig(pin(33,IN))}
+ zig(pin(31,UP))
+# Gate 23
+go(pin(23,OUT)) right_mv(1)
+ vert(gate(23).DN) dn_mv(1)
+ horz(gate(33)) right_mv(1)
+ dn_mv(1) to_bus
+# Gate 24
+go(pin(24,OUT)) right_mv(1) zig(pin(33,UP))
+# Gate 25
+go(pin(25,OUT)) horz(pin(35,IN))
+# Gate 26
+go(pin(26,OUT)) right_mv(2) vert(pin(26,DN)) dn_mv(1) junction
+ {to_bus}
+ zig(pin(35,UP))
+# Gate 27
+go(pin(27,OUT)) right_mv(2) zig(pin(36,UP))
+# Gate 28
+go(pin(28,OUT)) right_mv(3) junction
+ {horz(pin(38,IN))}
+ vert(pin(38, DN)) dn_mv(1) to_bus
+# Gate 29
+go(pin(29,OUT)) right_mv(3) junction
+ {horz(pin(39,IN))}
+ {vert(pin(39, DN)) dn_mv(1) to_bus}
+ zig(pin(40,UP))
+# Gate 30
+go(pin(30,OUT)) right_mv(1)
+ vert(pin(30,DN)) dn_mv(1)
+ horz(gate(40).e) right_mv(2)
+ zig(pin(50,UP))
+# Gate 31
+go(pin(31,OUT)) right_mv(2) zig(pin(41,UP))
+# Gate 32
+go(pin(32,OUT)) right_mv(2) vert(pin(32,UP)) junction
+ {horz(pin(42,UP))}
+ up_mv(1) to_bus
+# Gate 33
+go(pin(33,OUT)) right_mv(2) zig(pin(43,UP))
+# Gate 34
+go(pin(34,OUT)) right_mv(3) junction
+ {horz(pin(44,IN))}
+ vert(pin(44, DN)) dn_mv(1) to_bus
+# Gate 35
+go(pin(35,OUT)) right_mv(1) dn_mv(1) right_mv(2) dn_mv(1) to_bus
+# Gate 36
+go(pin(36,OUT)) horz(pin(46,IN))
+# Gate 37
+go(pin(37,OUT)) right_mv(2) vert(pin(48,UP)) junction
+ {horz(pin(48,UP))}
+ zig(pin(49,DN))
+# Gate 38
+go(pin(38,OUT)) right_mv(3) junction
+ {horz(pin(48,IN))}
+ vert(pin(48,DN)) right_mv(1) dn_mv(3) left_mv(3)
+ vert(pin(47,UP)) junction
+ {horz(pin(47,UP))}
+ zig(pin(46,UP))
+# Gate 39
+go(pin(39,OUT)) right_mv(3) junction
+ {horz(pin(49,IN))}
+ {vert(pin(49, DN)) dn_mv(2) to_bus}
+ zig(pin(50,IN))
+# Gate 40
+go(pin(40,OUT)) right_mv(1)
+ vert(pin(40,DN))
+ dn_mv(2) junction
+ {horz(gate(40).w); dn_mv(1); horz(gate(40).e); right_mv(1)}
+ dn_mv(1) junction
+ zig(pin(49,UP))
+# Gate 41
+# (should be right_mv(2) but we've squeezed the bus line a bit left)
+go(pin(41,OUT)) right_mv(1) vert(pin(41,DN)) ground
+# Gate 42
+go(pin(42,OUT)) to_bus
+# Gate 43
+go(pin(43,OUT)) to_bus
+# Gate 44
+go(pin(44,OUT)) to_bus
+# Gate 45
+go(pin(45,OUT)) to_bus
+# Gate 46
+go(pin(46,OUT)) to_bus
+# Gate 47
+go(pin(47,OUT)) to_bus
+# Gate 48
+go(pin(48,OUT)) to_bus
+# Gate 49
+go(pin(49,OUT)) to_bus
+# Gate 50
+go(pin(50,OUT)) to_bus
+# The adventitious lead
+go(pin(17,OUT)) right_mv(1)
+ {vert(pin(17,UP)) up_mv(3) horz(gate(17))}
+ vert(pin(17,DN)) dn_mv(1)
+ horz(gate(27).w) dn_mv(1) horz(gate(27).e)
+ dn_mv(1) horz(gate(36).w)
+ up_mv(2) right_mv(1) dn_mv(2)
+ right_mv(1) up_mv(2) right_mv(1) dn_mv(2)
+ right_mv(1) up_mv(2) right_mv(1)
+ vert(pin(37,DN)) right_mv(4) dn_mv(2)
+ right_mv(3) dn_mv(1) left_mv(3)
+ vert(pin(46,DN)) left_mv(3) dn_mv(3)
+ horz(gate(36).w) up_mv(1) horz(gate(36)) right_mv(1)
+
+] # End of diagram object
+.PE
+.ce 1
+FIGURE 1. CIRCUITOUS DIAGRAM
+.bp
+.sp 10
+.ps 8
+.vs 10
+.nf
+.cs R 24
+.ec %
+.ds EO %(ci%v'-0.08'%h'-0.67'+%v'0.08'
+.%" This is dodgy, but it's the last place es is used
+.if n .ds es %o"O|"
+.if t .ds es %(es
+ __________________________________________________________
+ |\ \
+ | \ 1. Logic gate. Inputs A, B. Output O = AB. \
+ | \ \
+ | \ \ 2. Logic gate. Inputs A, B, C. Output O = A+BC. \
+ | |\ \ \
+ | | \ \ 3. Logic gate. Inputs A, B. Output O = A+AB. \
+ | | \ \ \
+ | | |\ \ 4. Logic gate. Inputs A, B. Output O = AB %*(EO -(A+-B) \
+ | | | \ \ \
+ | | | \ \ 5. Logic gate. Inputs A, B. Output O = A%*(EOA + AA \
+ | | | \ \ \
+ | | | \ \ 6. Uninitialized flip-flop. Inputs none. Output O = ? \
+ | | | \ \ \
+ | | | \ \ 7. Flip-flop-flap. Inputs A, B, C. Output O = 1 if \
+ | | | \ \ A=0 or B+C=0 and A=1. O = 0 if AC=1, B=0. O = %*(es if \
+ | | | \ \ AB=1, C=0. O = ? if ABC=1. O as yet undetermined \
+ | | | \ \ for other Warmenhovian inputs. See Figure 2. \
+ | | | \ \ \
+ | | | \ \ 8. Bus line. \
+ | | | \ \_________________________________________________________\
+ | | | \ | |
+ | | | | | _____________________________________________________ |
+ | | | | | | | | | | | |
+ | | | | | | | | | | | |
+ | | | | | | | | | | | |
+ | | | | | | | | | | | |
+ | | | | | | | | | | | |
+ \|__| | | | \|__| | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ \|__| \|__|
+.ec \
+.cs R
+.fi
+.ps 10
+.vs 12
+.sp
+.ce 1
+Table 1. Logical (and other) functions.
+.bp
+.if n \{\
+.P
+[Warning: The following picture will be garbled or missing.
+Get a better output device.] \}
+.sp 10
+.PS
+# The FLIP FLAP FLOP, Figure 2 of the INTERCAL manual
+down;
+A: warmengate();
+move; move;
+B: warmengate();
+move; move;
+C: warmengate();
+move; move;
+D: warmengate();
+dot at 1st [];
+dot at 2nd [];
+dot at 3rd [];
+circle rad 0.06 at last [];
+line from last circle.w to last circle.e;
+line from last circle.n to last circle.s;
+line left 3 from A.UP; "A" rjust
+line left 3 from B.IN; "B" rjust
+line left 3 from C.UP; "C" rjust
+line left 2 from C.IN then down 2 then left; "1" rjust
+right; circle rad 0.06 with .w at A.OUT;
+line right 0.5; junction {line right 1.5; "D" ljust}
+line down 0.25; X1: Here
+line left 0.5 from A.IN; line down 0.25; X2: Here
+line left 0.5 from B.UP; line up 0.25; line to X1;
+line right 1.0 from D.OUT; vert(B.UP) line up 0.25; line to X2;
+right; circle rad 0.06 with .w at B.OUT;
+line right 0.5; vert(C.DN) line down 0.25; X3: Here;
+line left 0.25 from D.UP then up 0.25 then to X3;
+right; circle rad 0.06 with .w at C.OUT;
+line right 0.3; vert(C.DN) line down 0.25; X4: Here
+line left 0.5 from D.IN; vert(D.UP) line up 0.25 then to X4;
+.PE
+.sp 10
+.ce 1
+FIGURE 2. FLIP FLAP FLOP
+.bp
+.if n \{\
+.P
+[Warning: The following picture will be garbled or missing.
+Get a better output device.] \}
+.PS
+[
+ NYC: box ht 4 wid 0.5 "9";
+ for i = 0 to 16 do {
+ move to (i+1)/18 <NYC.nw,NYC.sw>
+ line left 0.5
+ }
+ for i = 0 to 8 do {
+ move to (i+1)/10 <NYC.ne,NYC.se>
+ line right 0.5
+ }
+]
+move right from last [].w;
+box invis wid 6 \
+ "GATE TYPE 9. BLACK BOX" ljust \
+ "INPUTS A1-8, B1-8. " ljust \
+ "OUTPUT D1-8 = A1-8~B1=8" ljust
+.PE
+.sp 10
+.ce 1
+FIGURE 1 (CONTINUED). NEW YORK
+.bp
+.H 3 "Unary Operators"
+.P
+The unary operators are & (logical \fBAND\fR), V (logical \fBOR\fR),
+and \*(vb (logical
+\fBXOR\fR). This last character is obtained by overpunching a worm (\-) on a V
+(V).
+.if '\*c'y' \{\
+(In C-INTERCAL'S ASCII environment, EBCDIC \*(vb is replaced by the
+what (?). The compiler recognizes -<backspace>V as a valid
+equivalent, in case you are concerned about compatibility with the
+Princeton compiler.) \}
+The operator is inserted between the spot, two-spot, mesh, or
+what-have-you, and the integer, thus: .&123, #\*(vb123. Multiple unary
+operators may not be concatenated, thus the form #\*(vb&123 is invalid. This
+will be covered later when precedence is discussed. These operators perform
+their respective logical operations on all pairs of adjacent bits, the
+result from the first and last bits going into the first bit of the result.
+The effect is that of rotating the operand one place to the right and
+ANDing, ORing, or XORing with its initial value. Thus, #&77 (binary =
+1001101) is binary 0000000000000100 = 4, #V77 is binary 1000000001101111 =
+32879, and #\*(vb77 is binary 1000000001101011 = 32875.
+.H 3 "Precedence"
+.SETR precedence
+.P
+Precedence of operators is as follows:
+.sp 10
+(The remainder of this page intentionally left blank)\*F
+.FS
+Keep in mind that the aim in designing INTERCAL was to have no
+precedents.
+.FE
+.bp
+.P
+This precedence (or lack thereof) may be overruled by grouping expressions
+between pairs of sparks (') or rabbit-ears ("). Thus '#165\*(ct#203'~#358
+(binary value '10100101\*(ct11001011'~101100110) has the value 15, but
+#165\*(ct'#203~#358' has the value 34915, and #165\*(ct#203~#358 is invalid
+syntax and is completely valueless (except perhaps as an educational tool
+to the programmer). A unary operator is applied to a sparked or rabbit-eared
+expression by inserting the operator immediately following the opening spark
+or ears. Thus, the invalid expression #\*(vb&123,
+which was described earlier,
+could be coded as '\*(vb#&123' or '\*(vb"{"'.
+Note: In the interests of
+simplifying the sometimes overly-complex form of expressions, INTERCAL allows
+a spark-spot combination ('.) to be replaced with a wow (!). Thus '.1~.2'
+is equivalent to !1~.2', and 'V.1\*(ct.2' is equivalent to "V!1\*(ct.2'".
+.P
+Combining a rabbit-ears with a spot to form a rabbit (\o'".') is not permitted,
+although the programmer is free to use it should he find an EBCDIC reader
+which will properly translate a 12-3-7-8 punch.
+.P
+Sparks and/or rabbit-ears must also be used to distinguish among such
+otherwise ambiguous subscripted and multiply-subscripted expressions as:
+.DS L
+ ,1 SUB #1 ~ #2
+ ,1 SUB ,2 SUB #1 #2 #3
+ ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "
+.DE
+The third case may be isolated into either of its possible interpretations
+by simply changing some pairs of rabbit-ears to sparks, instead of adding
+more ears (which would only confuse the issue further). Ambiguous cases are
+defined as those for which the compiler being used finds a legitimate
+interpretation which is different from that which the user had in mind. See
+also section
+.GETHN princeton
+\&.
+.H 1 "STATEMENTS"
+.P
+In this section is described the format of INTERCAL statements.
+.H 2 "General Format"
+.P
+Statements may be entered in 'free format'. That is, more than one statement
+may occur on a single card, and a statement may begin on one card and end
+on a later one. Note that if this is done, all intervening cards and portions
+thereof must be part of the same statement. That this restriction is necessary
+is immediately apparent from the following example of what might occur if
+statements could be interlaced.
+.DS L
+ DO .1 <- ".1\*(ct'&:51~"#\*(vb1c!12~;&75SUB"\*(vb'V.1~
+ DO .2 <- '"!1\*(ct"&';\*(vb79SUB",&7SUB:173"'~!\*(vb9\*(ct
+ .2'\*(ct,&1SUB:5~#33578"'"'"~'#65535\*(ct"\*(vb'V#&85'"'
+ #8196'"'~.1"\*(ct.2'~'#&5\*(ct"'#1279\*(ct#4351'~#65535"'
+.DE
+The above statements are obviously meaningless. (For that matter, so are
+the statements
+.DS L
+ DO .1 <- ".1\*(ct"&:51~"#\*(vb1\*(ct!12~;&75SUB"\*(vb'V.1~
+ .2'\*(ct,&1SUB:5~#333578"'"'"~#65535\*(ct"\*(vb'V#&85'"'
+ DO .2 <- '"!1\*(ct"&';\*(vb79SUB",&7SUB:173"'~!\*(vb9\*(ct
+ #8196'"'~.1"\*(ct.2'~'#&5\*(ct"'#1279\*(ct#4351'~#65535"'
+.DE
+but this is not of interest here.)
+.P
+Spaces may be used freely to enhance program legibility (or at least reduce
+program illegibility), with the restriction that no word of a statement
+identifier (see section
+.GETHN identifiers
+) may contain any spaces.
+.H 2 "Labels"
+.P
+A statement may begin with a
+.B "logical line label"
+enclosed in wax-wane pairs
+(()). A statement may not have more than one label, although it is possible
+to omit the label entirely. A line label is any integer from 1 to 65535,
+which must be unique within each program. The user is cautioned, however,
+that many line labels between 1000 and 1999 are used in the INTERCAL System
+Library functions.
+.H 2 "Identifiers and Qualifiers"
+.SETR identifiers
+.P
+After the line label (if any), must follow one of the following statement
+identifiers: DO, PLEASE, or PLEASE DO. These may be used interchangeably to
+improve the aesthetics of the program. The identifier is then followed by
+either, neither, or both of the following optional parameters (qualifiers):
+(1) either of the character strings NOT or N'T, which causes the statement
+to be automatically abstained from (see section
+.GETHN abstain
+) when execution
+begins, and (2) a number between 0 and 100, preceded by a double-oh-seven
+(%), which causes the statement to have only the specified percent chance
+of being executed each time it is encountered in the course of execution.
+.H 2 "Statements"
+.P
+Following the qualifiers (or, if none are used, the identifier) must occur
+one of the 13 valid operations. (Exception: see section
+.GETHN comments
+\&.) These are
+described individually in sections
+.GETHN calculate
+ through
+.GETHN last_statement
+\&.
+.H 3 "Calculate"
+.SETR calculate
+.P
+The INTERCAL equivalent of the half-mesh (=) in FORTRAN, BASIC, PL/I, and
+others, is represented by an angle (<) followed by a worm (-). This
+combination is read 'gets'. 32-bit variables may be assigned 16-bit values,
+which are padded on the left with 16 zero bits. 16-bit variables may be
+assigned 32-bit values only if the value is less than 65535. Thus, to
+invert the least significant bit of the first element of 16-bit
+2-dimensional array number 1, one could write:
+.DS
+,1SUB#1#1 <- '\*(vb,1SUB#1#1\*(ct#1'~'#0\*(ct#65535'
+.DE
+Similarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define the
+dimensions of arrays. An example will probably best describe the format.
+To define 32-bit array number 7 as 3-dimensional, the first dimension being
+seven, the second being the current value of 16-bit variable number seven,
+and the third being the current value of the seventh element of 16-bit array
+number seven (which is one-dimensional) mingled with the last three bits of
+32-bit variable number seven, one would write (just before they came to take
+him away):
+.DS
+;7 <- #7 BY .7 BY ",7SUB#7"\*(ct':7~#7'
+.DE
+This is, of course, different from the statement:
+.DS
+;7 <- #7 BY .7 BY ,7SUB"#7\*(ct':7~#7'"
+.DE
+INTERCAL also permits the redefining of array dimensioning, which is done
+the same way as is the initial dimensioning. All values of items in an array
+are lost upon redimensioning, unless they have been STASHed (see section
+.GETHN stash
+), in which case restoring them also restores the old dimensions.
+.H 3 "NEXT"
+.SETR next
+.P
+The NEXT statement is used both for subroutine calls and for unconditional
+transfers. This statement takes the form:
+.DS
+DO (label) NEXT
+.DE
+(or, of course,
+.DS
+PLEASE DO (label) NEXT
+.DE
+etc.), where (label) represents any logical line label which appears in the
+program. The effect of such a statement is to transfer control to the
+statement specified, and to store in a push down list (which is initially
+empty) the location from which the transfer takes place. Items may be
+removed from this list and may be discarded or used to return to the
+statement immediately following the NEXT statement. These operations are
+described in sections
+.GETHN forget
+ and
+.GETHN resume
+ respectively. The programmer is
+generally advised to discard any stack entries which he does not intend to
+utilize, since the stack has a maximum depth of 79 entries. A program's
+attempting to initiate an 80th level of NEXTing will result in the fatal
+error message, "PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON."
+.H 3 "FORGET"
+.SETR forget
+.P
+The statement PLEASE FORGET exp, where exp represents any expression
+(except colloquial and facial expressions), causes the expression to be
+evaluated, and the specified number of entries to be removed from the
+NEXTing stack and discarded. An attempt to FORGET more levels of NEXTing
+than are currently stacked will cause the stack to be emptied, and no error
+condition is indicated. This is because the condition is not considered to
+be an error. As described in section
+.GETHN next
+\&, it is good programming practice
+to execute a DO FORGET #1 after using a NEXT statement as an unconditional
+transfer, so that the stack does not get cluttered up with unused entries:
+.DS L
+.cs R 24
+ DO (123) NEXT
+ .
+ .
+ (123) DO FORGET #1
+.cs R
+.DE
+.H 3 "RESUME"
+.SETR resume
+.P
+The statement PLEASE RESUME exp has the same effect as FORGET, except that
+program control is returned to the statement immediately following the NEXT
+statement which stored in the stack the last entry to be removed. Note that
+a rough equivalent of the FORTRAN computed GO TO and BASIC ON exp GO TO is
+performed by a sequence of the form:
+.DS L
+.cs R 24
+ DO (1) NEXT
+ .
+ .
+ (1) DO (2) NEXT
+ PLEASE FORGET #1
+ .
+ .
+ (2) DO RESUME .1
+.cs R
+.DE
+Unlike the FORGET statement, an attempt to RESUME more levels of NEXTing than
+been stacked will cause program termination. See also section
+.GETHN give_up
+\&.
+.H 3 "STASH"
+.SETR stash
+.P
+Since subroutines are not explicitly implemented in INTERCAL, the NEXT and
+RESUME statements must be used to execute common routines. However, as
+these routines might use the same variables as the main program, it is
+necessary for them to save the values of any variables whose values they
+alter, and later restore them. This process is simplified by the STASH
+statement, which has the form DO STASH list, where list represents a
+string of one or more variable or array names, separated by intersections
+(+). Thus
+.DS
+PLEASE STASH .123+:123+,123
+.DE
+stashes the values of two variables and one entire array. The values are
+left intact, and copies thereof are saved for later retrieval by (what else?)
+the RETRIEVE statement (see section
+.GETHN retrieve
+). It is not possible to STASH
+single array items.
+.H 3 "RETRIEVE"
+.SETR retrieve
+.P
+PLEASE RETRIEVE list restores the previously STASHed values of the variables
+and arrays named in the list. If a value has been stashed more than once,
+the most recently STASHed values are RETRIEVEd, and a second RETRIEVE will
+restore the second most recent values STASHed. Attempting to RETRIEVE a
+value which has not been STASHed will result in the error message, "THROW
+STICK BEFORE RETRIEVING."
+.H 3 "IGNORE"
+.SETR ignore
+.P
+The statement DO IGNORE list causes all subsequent statements to have no
+effect upon variables and/or arrays named in the list. Thus, for example,
+after the sequence
+.DS L
+ DO .1 <- #1
+ PLEASE IGNORE .1
+ DO .1 <- #0
+.DE
+16-bit variable number 1 would have the value 1, not 0. Inputting (see
+section
+.GETHN input
+) into an IGNOREd variable also has no effect. The condition
+is annulled via the REMEMBER statement (see section
+.GETHN remember
+). Note that, when
+a variable is being IGNOREd, its value, though immutable, is still
+available for use in expressions and the like.
+.if '\*c'y' \{\
+.P
+Though the INTERCAL-72 manual laid down that the value of an IGNOREd
+variable cannot change, it was unclear about whether or not a
+statement which appears to change an IGNOREd variable is executed or
+not. This may appear to be a "If a tree falls in the forest..." type
+of question, but if the statement in question has other side effects
+it is not.
+.P
+Since another mechanism already exists for ABSTAINing from a
+statement, C-INTERCAL's IGNORE only prevents the changing of the
+specific variable in question, not the execution of the entire
+statement. In the present version of the language this only makes
+a difference for the WRITE IN statement. Attempting to WRITE IN
+to an IGNOREd variable will cause a number to be read from the input,
+which will be discarded since it cannot be stored in the variable. \}
+.H 3 "REMEMBER"
+.SETR remember
+.P
+PLEASE REMEMBER list terminates the effect of the IGNORE statement for all
+variables and/or arrays named in the list. It does not matter if a variable
+has been IGNOREd more than once, nor is it an error if the variable has not
+been IGNOREd at all.
+.H 3 "ABSTAIN"
+.SETR abstain
+.P
+INTERCAL contains no simple equivalent to an IF statement or computed GO
+TO, making it difficult to combine similar sections of code into a single
+routine which occasionally skips around certain statements. The IGNORE
+statement (see section
+.GETHN ignore
+) is helpful in some cases, but a more viable
+method is often required. In keeping with the goal of INTERCAL having
+nothing in common with any other language, this is made possible via the
+ABSTAIN statement.
+.P
+This statement takes on one of two forms. It may not take on both at any one
+time. DO ABSTAIN FROM (label) causes the statement whose logical line label
+is (label) to be abstained from. PLEASE ABSTAIN FROM gerund list causes all
+statements of the specified type(s) to be abstained from, as in
+.DS L
+ PLEASE ABSTAIN FROM STASHING
+ PLEASE ABSTAIN FROM IGNORING + FORGETTING
+ PLEASE ABSTAIN FROM NEXTING
+ or PLEASE ABSTAIN FROM CALCULATING
+.DE
+Statements may also be automatically abstained from at the start of
+execution via the NOT or N'T parameter (see section
+.GETHN identifiers
+).
+.P
+If, in the course of execution, a statement is encountered which is being
+abstained from, it is ignored and control passes to the next statement in
+the program (unless it, too, is being abstained from).
+.P
+The statement DO ABSTAIN FROM ABSTAINING is perfectly valid, as is DO ABSTAIN
+FROM REINSTATING (although this latter is not usually recommended). However,
+the statement DO ABSTAIN FROM GIVING UP is not accepted, even though DON'T
+GIVE UP is.
+.H 3 "REINSTATE"
+.SETR reinstate
+.P
+The REINSTATE statement, like the ABSTAIN, takes as an argument either a
+line label or a gerund list. No other form of argument is permitted. For
+example, the following is an invalid argument:
+.DS L
+ Given: x\(!=0, y\(!=0, Prove: x+y=0
+ Since x\(!=0, then x+1\(!=1, x+a\(!=a, x+y\(!=y.
+ But what is y? y is anything but 0.
+ Thus x+y \(!= anything but 0.
+ Since x+y cannot equal anything but 0, x+y=0.
+ Q.E.D.
+.DE
+REINSTATEment nullifies the effects of an abstention. Either form of
+REINSTATEment can be used to "free" a statement, regardless of whether the
+statement was abstained from by gerund list, line label, or NOT. Thus,
+PLEASE REINSTATE REINSTATING is not necessarily an irrelevant statement,
+since it might free a DON'T REINSTATE command or a REINSTATE the line label
+of which was abstained from. However, DO REINSTATE GIVING UP is invalid,
+and attempting to REINSTATE a GIVE UP statement by line label will have no
+effect. Note that this insures that DON'T GIVE UP will always be a
+"do-nothing" statement.
+.H 3 "GIVE UP"
+.SETR give_up
+.P
+PLEASE GIVE UP is used to exit from a program. It has the effect of a PLEASE
+RESUME #80. DON'T GIVE UP, as noted in section
+.GETHN reinstate
+\&, is effectively a null
+statement.
+.H 3 "Input"
+.SETR input
+.P
+Input is accomplished with the statement DO WRITE IN list, where list
+represents a string of variables and/or elements or arrays, separated by
+intersections. Numbers are represented on cards, each number on a separate
+card, by spelling out each digit (in English) and separating the digits
+with one or more spaces. A zero (0) may be spelled as either ZERO or OH.
+Thus the range of (32-bit) input values permissible extends from ZERO (or
+OH) through FOUR TWO NINE FOUR NINE SIX SEVEN TWO NINE FIVE.
+.if '\*c'y' \{\
+(For the convenience of aviators, C-INTERCAL accepts the spelling
+NINER for NINE. In the service of internationalization, C-INTERCAL
+also accepts input digits in Sanskrit, Basque, Tagalog, Classical
+Nahuatl, Georgian, Kwakiutl, and Volapuk. \}
+.P
+Attempting to write in a value greater than or equal to SIX FIVE FIVE THREE
+SIX for a 16-bit variable will result in the error message, "DON'T BYTE OFF
+MORE THAN YOU CAN CHEW."
+.H 3 "Output"
+.P
+Values may be output to the printer, one value per line, via the statement
+DO READ OUT list, where the list contains variables, array elements, and/or
+constants. Output is in the form of "extended" Roman numerals (also called
+"butchered" Roman numerals), with an overline
+.if t (\(rn)
+indicating the value below
+is "times 1000", and lower-case letters indicating "times 1000000". Zero
+is indicated by an overline with no character underneath. Thus, the range
+of (32-bit) output values possible is from
+.if t \(rn
+.if n \{\
+.nf
+_
+
+.fi \}
+through
+.ie t \o"i\(rn"\o"v\(rn"ccxciv\o"C\(rn"\o"M\(rn"\o"L\(rn"\o"X\(rn"\o"V\(rn"\o"I\(rn"\o"I\(rn"CCXCV.
+.el \{\
+.br
+.nf
+__ ____________
+ivccxcivCMLXVIICCXCV.
+.fi \}
+Note: For values whose residues modulo 1000000 are less than 4000, M is
+used to represent 1000; for values whose residues are 4000 or greater,
+.if t \o"I\(rn"
+.if n \{\
+.nf
+_
+I
+.fi \}
+.\" This is the one place we corrected the original manual.
+is used. Thus #3999 would read out as MMMCMXCIX \*F while #4000 would
+.FS
+The original INTERCAL-72 manual claimed
+that #3999 should render as MMMIM, but the C-INTERCAL developers have
+been unable to find an algorithm that does this and is consistent
+with the rest of the rules.
+.FE
+readout as
+.if t \o"I\(rn"\o"V\(rn".
+.if n \{\
+.nf
+__
+IV
+.fi \}
+Similar rules apply to the use of
+.if t \o"M\(rn"
+.if n \{\
+.nf
+_
+M
+.fi \}
+and i for 1000000, and to that of m and
+.if t \o"i\(rn"
+.if n \{\
+.nf
+_
+i
+.fi \}
+for 1000000000.
+.if '\*c'y' \{\
+.H 3 "COME FROM"
+.P
+In which we try to precisely define a statement that should never
+have been born, but is nevertheless one of the more useful statements
+in INTERCAL.
+.H 4 "Background"
+.P
+The earliest known description of the COME FROM statement in the computing
+literature is in [R. L. Clark, "A linguistic contribution to GOTO-less
+programming," Commun. ACM 27 (1984), pp. 349--350], part of the famous April
+Fools issue of CACM. The subsequent rush by language designers to include the
+statement in their languages was underwhelming, one might even say nonexistent.
+It was therefore decided that COME FROM would be an appropriate addition
+to C-INTERCAL.
+.H 4 "Description"
+.P
+There are two useful ways to visualize the action of the COME FROM
+statement. The simpler is to see that it acts like a GOTO when the
+program is traced backwards in time. More precisely, the statements
+.DS L
+(1) DO <any statement>
+ .
+ .
+ .
+(2) DO COME FROM (1)
+.DE
+should be thought of as being equivalent to
+.DS L
+(1) DO <any statement>
+(2) DO GOTO (3)
+ .
+ .
+ .
+(3) DO NOTHING
+.DE
+if INTERCAL actually had a GOTO statement at all, which of course it
+doesn't.
+.P
+What this boils down to is that the statement DO COME FROM (label),
+anywhere in the program, places a kind of invisible trap door
+immediately after statement (label). Execution or abstention of that
+statement is immediately followed by an unconditional jump to the
+COME FROM, unless the (label)ed statement is an executed NEXT, in which
+case the jump occurs if the program attempts to RESUME back to that
+NEXT statement. It is an error for more than one COME FROM to refer
+to the same (label).
+.P
+Modification of the target statement by ABSTAIN or by the % qualifier
+affects only that statement, not the subsequent jump. Such
+modifications to the COME FROM itself, however, do affect the jump.
+Encountering the COME FROM statement itself, rather than its target,
+has no effect. \}
+.SETR last_statement
+.H 2 "Comments"
+.SETR comments
+.P
+Unrecognizable statements, as noted in section
+.GETHN error_messages
+\&, are flagged with a splat
+(*) during compilation, and are not considered fatal errors unless they
+are encountered during execution, at which time the statement (as input at
+compilation time) is printed and execution is terminated. This allows for
+an interesting (and, by necessity, unique) means of including comments in
+an INTERCAL listing. For example, the statement:
+.sp 1
+* PLEASE NOTE THAT THIS LINE HAS NO EFFECT
+.P
+will be ignored during execution due to the inclusion of the NOT qualifier.
+User-supplied error messages are also easy to implement:
+.sp 1
+* DO SOMETHING ABOUT OVERFLOW IN ;3
+.P
+as are certain simple conditional errors:
+.DS L
+.cs R 24
+* (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED
+ ONCE?
+ PLEASE REINSTATE (123)
+.cs R
+.DE
+This pair of statements will cause an error exit the second time they are
+encountered. Caution!! The appearance of a statement identifier in an
+intended comment will be taken as the beginning of a new statement. Thus,
+the first example on the preceding page could not have been:
+.sp 1
+* PLEASE NOTE THAT THIS LINE DOES NOTHING
+.P
+The third example, however, is valid, despite the appearance of two cases
+of D-space-O, since INTERCAL does not ignore extraneous spaces in statement
+identifiers.
+.if '\*c'y' \{\
+.H 1 "OUTSIDE COMMUNICATION"
+.P
+In which we try to remedy the fact that, due to I/O limitations, INTERCAL
+can not even in principle perform the same tasks as other languages. It
+is hoped that this addition will permit INTERCAL users to waste vast
+quantities of computer time well into the 21st century.
+.H 2 "Motivation"
+.P
+One of the goals of INTERCAL was to provide a language which, though
+different from all other languages, is nevertheless theoretically
+capable of all the same tasks. INTERCAL-72 failed to
+accomplish this because its I/O functions could not handle arbitrary
+streams of bits, or even arbitrary sequences of characters. A
+language which can't even send its input directly to its output
+can hardly be considered as capable as other languages.
+.H 2 "Turing Text Model"
+.P
+To remedy this problem, character I/O is now provided in a form based
+on the "Turing Text" model, originally proposed by Jon Blow. The
+C-INTERCAL programmer can access this capability by placing a one-
+dimensional array in the list of items given to a WRITE IN or READ OUT
+statement. On execution of the statement, the elements of the array
+will, from first to last, be either loaded from the input or sent
+to the output, as appropriate, in the manner described below. There
+is currently no support for I/O involving higher-dimensional arrays,
+but some form of graphics might be a possible 2-D interpretation.
+.P
+The heart of the Turing Text model is the idea of a continuous loop
+of tape containing, in order, all the characters in the machine's
+character set. When a character is received by the input routine,
+the tape is advanced the appropriate number of spaces to bring
+that character under the tape head, and the number of spaces the
+tape was moved is the number that is actually seen by the INTERCAL
+program. Another way to say this is that the number placed in an
+INTERCAL array is the difference between the character just
+received and the previous character, modulo the number of characters
+in the machine character set.
+.P
+Output works in just the opposite fashion, except that the characters
+being output come from the other side of the tape. From this position
+the characters on the tape appear to be in reverse order, and are
+individually backwards as well. (We would show you what it looks
+like, but we don't have a font with backwards letters available.
+Use your imagination.) The effect is that a number is taken out
+of an INTERCAL array, subtracted from the last character output---
+i.e., the result of the last subtraction---and then sent on down
+the output channel. The only catch is that the character as seen
+by the INTERCAL program is the mirror-image of the character as
+seen by the machine and the user. The bits of the character are
+therefore taken in reverse order as it is sent to the output.
+Note that this bit reversal affects only the character seen by
+the outside world; it does not affect the character stored internally
+by the program, from which the next output number will be subtracted.
+All subtractions are done modulo the number of characters in the
+character set.
+.P
+Two different tapes are used for input and for output to allow for
+future expansion of the language to include multiple input and
+output channels. Both tapes start at character 0 when a program
+begins execution. On input, when an end of file marker is reached
+the number placed in the array is one greater than the highest-
+numbered character on the tape.
+.H 2 "Example Program"
+.P
+If all this seems terribly complicated, it should be made perfectly
+clear by the following example program, which simply maps its input
+to its output (like a simplified UNIX "cat"). It assumes that
+characters are 8 bits long, but that's fine since the current version
+of C-INTERCAL does too. It uses the standard library routines for addition
+and subtraction.
+.DS L
+ DO ,1 <- #1
+ DO .4 <- #0
+ DO .5 <- #0
+ DO COME FROM (30)
+ DO WRITE IN ,1
+ DO .1 <- ,1SUB#1
+ DO (10) NEXT
+ PLEASE GIVE UP
+(20) PLEASE RESUME '?.1$#256'~'#256$#256'
+(10) DO (20) NEXT
+ DO FORGET #1
+ DO .2 <- .4
+ DO (1000) NEXT
+ DO .4 <- .3~#255
+ DO .3 <- !3~#15'$!3~#240'
+ DO .3 <- !3~#15'$!3~#240'
+ DO .2 <- !3~#15'$!3~#240'
+ DO .1 <- .5
+ DO (1010) NEXT
+ DO .5 <- .2
+ DO ,1SUB#1 <- .3
+(30) PLEASE READ OUT ,1
+.DE
+For each number received in the input array, the program first tests
+the #256 bit to see if the end of file has been reached. If not, the
+previous input character is subtracted off to obtain the current
+input character. Then the order of the bits is reversed to find
+out what character should be sent to the output, and the result
+is subtracted from the last character sent. Finally, the difference
+is placed in an array and given to a READ OUT statement. See?
+We told you it was simple! \}
+.if '\*c'y' \{\
+.H 1 "TriINTERCAL"
+.P
+In which it is revealed that bitwise operations are too ordinary for
+hard-core INTERCAL programmers, and extensions to other bases are
+discussed. These are not, strictly speaking, extensions to INTERCAL
+itself, but rather new dialects sharing most of the features of the
+parent language.
+.H 2 "Motivation"
+.P
+INTERCAL is really a pretty sissy language. It tries hard to be
+different, but when you get right down to its roots, what do you find?
+You find bits, that's what. Plain old ones and zeroes, in groups of
+16 and 32, just like every other language you've ever heard of. And
+what operations can you perform on these bits? The INTERCAL operators
+may arrange and permute them in weird and wonderful ways, but at the
+bit level the operators are the same AND, OR and XOR you've seen
+countless times before.
+.P
+Once the prospective INTERCAL programmer masters the unusual syntax,
+she finds herself working with the familiar Boolean operators on
+perfectly ordinary unsigned integer words. Even the constants she uses
+are familiar. After all, who would not immediately recognize #65535
+and #32768? It may take a just a moment more to figure out #65280,
+and #21845 and #43690 could be puzzles until she notices that they
+sum to #65535, but basically she's still on her home turf. The 16-bit
+limit on constants actually works in the programmer's favor by insuring
+that very long anonymous constants can not appear in INTERCAL programs.
+And this is in a language that is supposed to be different from any
+other!
+.H 2 "Abandon All Hope..."
+.P
+Standard INTERCAL is based on variables consisting of ordinary bits
+and familiar Boolean operations on those bits. In pursuit of uniqueness,
+it seems appropriate to provide a new dialect, otherwise identical to
+INTERCAL, which instead uses variables consisting of trits, i.e. ternary
+digits, and operators based on tritwise logical operations. This is
+intended to be a separate dialect, rather than an extension to INTERCAL
+itself, for a number of reasons. Doing it this way avoids word-length
+conflicts, does not spoil the elegance of the Spartan INTERCAL operator
+set, and dodges the objections of those who might feel it too great an
+alteration to the original language. Primarily, though, giving INTERCAL
+programmers the ability to switch numeric base at will amounts to
+excessive functionality. So much better that a programmer choose a base
+at the outset and then be forced to stick with it for the remainder of
+the program.
+.H 2 "Compiler Operation"
+.P
+The same compiler, ick, supports both INTERCAL and TriINTERCAL.
+This has the advantage that future bug fixes and additions to the
+language not related to arithmetic immediately apply to both versions.
+The compiler recognizes INTERCAL source files by the extension '.i',
+and TriINTERCAL source files by the extension '.3i'. It's as simple
+as that. There is no way to mix INTERCAL and TriINTERCAL source in
+the same program, and it is not always possible to determine which
+dialect a program is written in just by looking at the source code.
+.H 2 "Data Types"
+.P
+The two TriINTERCAL data types are 10-trit unsigned integers and
+20-trit unsigned integers. All INTERCAL syntax for distinguishing
+data types is ported to these new types in the obvious way. Small
+words may contain numbers from #0 to #59048, large words may contain
+numbers from #0$#0 to #59048$#59048. Errors are signaled for constants
+greater than #59048 and for attempts to WRITE IN numbers too large
+for a given variable or array element to hold.
+.P
+Note that though TriINTERCAL considers all numbers to be unsigned,
+nothing prevents the programmer from implementing arithmetic operations
+that treat their operands as signed. Three's complement is one obvious
+choice, but balanced ternary notation is also a possibility. This
+latter is a very pretty and symmetrical system in which all 2 trits
+are treated as if they had the value -1.
+.H 2 "Operators"
+.P
+The TriINTERCAL operators are designed to inherit the relevant properties
+of the standard INTERCAL operators, so that both can be considered as
+merely different aspects of the same Platonic ideal. (Not that the word
+"ideal" is ever particularly relevant when used in connection with
+INTERCAL.)
+.H 3 "Binary Operators I"
+.P
+The binary operators carry over from the original language with only
+minor changes. The MINGLE operator ($) creates a 20-trit word by
+alternating trits from its two 10-trit operands. The SELECT operator (~)
+is a little more complicated, since the ternary tritmask may contain 0, 1,
+and 2 trits. If we observe that the SELECT operation on binary operands
+amounts to a bitwise AND and some rearrangement of bits, it seems
+appropriate to base the SELECT for ternary operands on a tritwise AND in
+the analogous fashion. We therefore postpone the definition of SELECT
+until we know what a tritwise AND looks like.
+.H 3 "Unary Operators"
+.P
+The unary operators in INTERCAL are all derived from the familiar
+Boolean operations on single bits. To extend these operations to trits,
+we first ask ourselves what the important properties of these operations
+are that we wish to be preserved, then design the tritwise operators so
+that they behave in a similar fashion.
+.H 4 "Unary Logical Operators"
+.P
+Let's start with AND and OR. To begin with, these can be considered
+"choice" or "preference" operators, as they always return one of their
+operands. AND can be described as wanting to return 0, but returning 1
+if it is given no other choice, i.e., if both operands are 1. Similarly,
+OR wants to return 1 but returns 0 if that is its only choice. From
+this it is immediately apparent that each operator has an identity
+element that "always loses", and a dominator element that "always wins".
+.P
+AND and OR are commutative and associative, and each distributes
+over the other. They are also symmetric with each other, in the sense
+that AND looks like OR and OR looks like AND when the roles of 0 and 1
+are interchanged (De Morgan's Laws). This symmetry property seems to be
+a key element to the idea that these are logical, rather than arithmetic,
+operators. In a three-valued logic we would similarly expect a three-
+way symmetry among the three values 0, 1 and 2 and the three operators
+AND, OR and (of course) BUT.
+.P
+The following tritwise operations have all the desired properties:
+OR returns the greater of its two operands. That is, it returns 2 if
+it can get it, else it tries to return 1, and it returns 0 only if both
+operands are 0. AND wants to return 0, will return 2 if it can't get
+0, and returns 1 only if forced. BUT wants 1, will take 0, and tries
+to avoid 2. The equivalents to De Morgan's Laws apply to rotations
+of the three elements, e.g., 0 -> 1, 1 -> 2, 2 -> 0. Each operator
+distributes over exactly one other operator, so the property
+"X distributes over Y" is not transitive. The question of which way
+this distributivity ring goes around is left as an exercise for the
+student.
+.P
+In TriINTERCAL programs the whirlpool (@) symbol denotes the unary
+tritwise BUT operation. You can think of the whirlpool as drawing
+values preferentially towards the central value 1. Alternatively,
+you can think of it as drawing your soul and your sanity inexorably
+down...
+.P
+On the other hand, maybe it's best you \fInot\fR think of it that way.
+.P
+A few comments about how these operators can be used. OR acts like
+a tritwise maximum operation. AND can be used with tritmasks. 0's
+in a mask wipe out the corresponding elements in the other operand,
+while 1's let the corresponding elements pass through unchanged. 2's
+in a mask consolidate the values of nonzero elements, as both 1's and
+2's in the other operand yield 2's in the output. BUT can be used to
+create "partial tritmasks". 0's in a mask let BUT eliminate 2's from
+the other operand while leaving other values unchanged. Of course,
+the symmetry property guarantees that the operators don't really
+behave differently from each other in any fundamental way; the apparent
+differences come from the intuitive view that a 0 trit is "not set"
+while a 1 or 2 trit is "set".
+.H 4 "Binary Operators II"
+.P
+At this point we can define SELECT, since we now know what the
+tritwise AND looks like. SELECT takes the binary tritwise AND of
+its two operands. It shifts all the trits of the result corresponding
+to 2's in the right operand over to the right (low) end of the result,
+then follows them with all the output trits corresponding to 1's in
+the right operand. Trits corresponding to 0's in the right operand,
+which are all 0 anyway, occupy the remaining space at the left end of
+the output word. Both 10-trit and 20-trit operands are accepted,
+and are padded with zeroes on the left if necessary. The output
+type is determined the same way as in standard INTERCAL.
+.H 4 "Unary Arithmetic Operators"
+.P
+Now that we've got all that settled, what about XOR? This is
+easily the most-useful of the three unary INTERCAL operators,
+because it combines in one package the operations ADD WITHOUT CARRY,
+SUBTRACT WITHOUT BORROW, BITWISE NOT-EQUAL, and BITWISE NOT. In
+TriINTERCAL we can't have all of these in the same operator, since
+addition and subtraction are no longer the same thing. The solution
+is to split the XOR concept into two operators. The ADD WITHOUT CARRY
+operation is represented by the new sharkfin (^) symbol, while the
+old what (?) symbol represents SUBTRACT WITHOUT BORROW. The reason for
+this choice is so that what (?) will also represent the TRITWISE NOT-EQUAL
+operation.
+.P
+Note that what (?), unlike the other four unary operators, is not
+symmetrical. It should be thought of as rotating its operand one trit
+to the right (with wraparound) and then subtracting off the trits of
+the original number. These subtractions are done without borrowing,
+i.e., trit-by-trit modulo 3.
+.H 3 "Examples"
+.P
+The TriINTERCAL operators really aren't all that bad once you get
+used to them. Let's look at a few examples to show how they can
+be used in practice. In all of these examples the input value is
+contained in the 10-trit variable .3.
+.P
+In INTERCAL, single-bit values often have to be converted from
+{0,1} to {1,2} for use in RESUME statements. Examples of how to do
+this appear in the original manual. In TriINTERCAL the expression
+"^.3$#1"~#1 sends 0 -> 1 and 1 -> 2. If the 1-trit input value can
+take on any of its three possible states, however, we will also have
+to deal with the 2 case. The expression "V.3$#1"~#1 sends {0,1} -> 1
+and 2 -> 2. To test if a trit is set, we can use "V'"&.3$#2"~#1'$#1"~#1,
+sending 0 -> 1 and {1,2} -> 2. To reverse the test we use
+"?'"&.3$#2"~#1'$#1"~#1, sending 0 -> 2 and {1,2} -> 1. Note that we
+have not been taking full advantage of the new SELECT operator. These
+last two expressions can be simplified into "V!3~#2'$#1"~#1 and
+"?!3~#2'$#1"~#1, which perform exactly the same mappings. Finally, if
+we need a 3-way test, we can use "@'"^.3$#7"~#4'$#2"~#10, which
+obviously sends 0 -> 1, 1 -> 2, and 2 -> 3.
+.P
+For an unrelated example, the expression "^.3$.3"~"#0$#29524"
+converts all of the 1-trits of .3 into 2's and all of the 2-trits
+into 1's. In balanced ternary, where 2-trits represent -1 values,
+this is the negation operation.
+.H 2 "Beyond Ternary..."
+.P
+While we're at it, we might as well extend this multiple bases
+business a little farther. The ick compiler actually recognizes
+filename suffixes of the form '.Ni', where N is any number from 2
+to 7. 2 of course gives standard INTERCAL, while 3 gives TriINTERCAL.
+We cut off before 8 because octal notation is the smallest base used
+to facilitate human-to-machine communication, and this seems quite
+contrary to the basic principles behind INTERCAL. The small data
+types hold 16 bits, 10 trits, 8 quarts, 6 quints, 6 sexts, or 5 septs,
+and the large types are always twice this size.
+.P
+As for operators, '?' is always SUBTRACT WITHOUT BORROW, and '^'
+is always ADD WITHOUT CARRY. 'V' is the OR operation and always
+returns the max of its inputs. '&' is the AND operation, which chooses
+0 if possible but otherwise returns the max of the inputs. '@' is BUT,
+which prefers 1, then 0, then the max of the remaining possibilities.
+Rather than add more special symbols forever, a numeric modifier may
+be placed directly before the '@' symbol to indicate the operation
+that prefers one of the digits not already represented. Thus in files
+ending in '.5i', the permitted unary operators are '?', '^', '&', '@',
+\&'2@', '3@', and 'V'. Use of such barbarisms as '0@' to represent '&'
+are not permitted, nor is the use of '@' or '^' in files with either
+of the extensions '.i' or '.2i'. Why not? You just can't, that's why.
+Don't ask so many questions.
+.P
+As a closing example, we note that in balanced quinary notation,
+where 3 means -2 and 4 means -1, the negation operation can be written
+as either
+.DS L
+ DO .1 <- "^'"^.3$.3"~"#0$#3906"'$'"^.3$.3"~"#0$#3906"'"~"#0$#3906"
+.DE
+or as
+.DS L
+ DO .1 <- "^.3$.3"~"#0$#3906"
+ DO .1 <- "^.1$.1"~"#0$#3906"
+.DE
+These work because multiplication by -1 is the same as multiplication
+by 4, modulo 5.
+.P
+Now go beat your head against the wall for a while.\}
+.H 1 "SUBROUTINE LIBRARY"
+.SETR sublib
+.P
+INTERCAL provides several built-in subroutines to which control can be
+transferred to perform various operations. These operations include many
+useful functions which are not easily representable in INTERCAL, such as
+addition, subtraction, etc.
+.H 2 "Usage"
+.P
+In general, the operands are .1, .2, etc., or :1, :2, etc., and the result(s)
+are stored in what would have been the next operand(s). For instance, one
+routine adds .1 to .2 and store the sum in .3, with .4 being used to indicate
+overflow. All variables not used for results are left unchanged.
+.H 2 "Available Functions"
+.SETR functions
+.P
+At the time of this writing, only the most fundamental operations are offered
+in the library, as a more complete selection would require prohibitive time
+and coree to implement. These functions, along with their corresponding entry
+points (entered via DO (entry) NEXT) are listed below.
+.DS L
+.cs R 24
+ (1000) .3 <- .1 plus .2, error exit on overflow
+ (1009) .3 <- .1 plus .2
+ .4 <- #1 if no overflow, else .4 <- #2
+ (1010) .3 <- .1 minus .2, no action on overflow
+ (1020) .1 <- .1 plus #1, no action on overflow
+ (1030) .3 <- .1 times .2, error exit on overflow
+ (1039) .3 <- .1 times .2
+ .4 <- #1 if no overflow, else .4 <- #2
+ (1040) .3 <- .1 divided by .2
+ .3 <- #0 if .2 is #0
+ (1050) .2 <- :1 divided by .1, error exit on overflow
+ .2 <- #0 if .1 is #0
+.if '\*c'y' \{\
+ (1060) .3 <- logical or of .1 and .2
+ (1070) .3 <- logical and of .1 and .2
+ (1080) .3 <- logical xor of .1 and .2 \}
+
+ (1500) :3 <- :1 plus :2, error exit on overflow
+ (1509) :3 <- :1 plus :2
+ :4 <- #1 if no overflow, else :4 <- #2
+ (1510) :3 <- :1 minus :2, no action on overflow
+ (1520) :1 <- .1 concatenated with .2
+ (1525) This subroutine is intended solely for internal
+ use within the subroutine library and is therefore
+ not described here. Its effect is to shift .3
+ logically 8 bits to the left.
+ (1530) :1 <- .1 times .2
+ (1540) :3 <- :1 times :2, error exit on overflow
+ (1549) :3 <- :1 times :2
+ :4 <- #1 if no overflow, else :4 <- #2
+ (1550) :3 <- :1 divided by :2
+ :3 <- #0 if :2 is #0
+
+ (1900) .1 <- uniform random no. from #0 to #65535
+ (1910) .2 <- normal random no. from #0 to .1, with
+ standard deviation .1 divided by #12
+.cs R
+.DE
+.if '\*c'y' \{\
+.H 2 "Automagical Inclusion Of The Subroutine Library"
+.P
+The C-INTERCAL compiler will automatically include the system library if a DO
+(1xxx) NEXT statement is used, and if no (1xxx) labels are defined anywhere,
+where (1xxx) is a label in the 1000-1999 range, inclusive. This was not
+an INTERCAL-72 feature. \}
+.H 1 "PROGRAMMING HINTS"
+.SETR proghints
+.P
+For the user looking to become more familiar with the INTERCAL language, we
+present in this section an analysis of a complex program, as well as some
+suggested projects for the ambitious programmer.
+.P
+Considering the effort involved in writing an INTERCAL program, it was
+decided in putting together this manual to use an already existing program
+for instructive analysis. Since there was only one such program available,
+we have proceeded to use it. It is known as the "INTERCAL System Library."
+.H 2 "Description"
+.P
+The program listing begins on the second page following. It is in the same
+format as would be produced by the Princeton INTERCAL compiler in FORMAT
+mode with WIDTH=62 (see section
+.GETHN princeton
+). For a description of the functions
+performed by the Library, see section
+.GETHN functions
+\&.
+.H 2 "Analysis"
+.P
+We shall not attempt to discuss here the algorithms used, but rather we
+shall point out some of the general techniques applicable to a wide range
+of problems.
+.P
+Statements 10, 14, 15, and 26 make up a virtual "computed GO TO". When
+statement 10 is executed, control passes eventually to statement 16 or 11,
+depending on whether .5 contains #1 or #2, respectively. The value of .5
+is determined in statement 9, which demonstrates another handy technique.
+To turn an expression, exp, with value #0 or #1, into #1 or #2 (for use in
+a "GO TO"), use "\*(vb'exp'\*(ct#1"~#3.
+To reverse the condition (i.e., convert #0
+to #2 and leave #1 alone) use "\*(vb'exp'\*(ct#2"~#3.
+.P
+Certain conditions are easily checked. For example, to test for zero,
+select the value from itself and select the bottom bit (see statement 54).
+To test for all bits being 1's, select the value from itself and select the
+top bit (see statement 261). The test for greater than, performed in
+statements 192 and 193 on 32-bit values, employs binary logical operations,
+which are performed as follows:
+.DS
+\&'\*(vb.1\*(ct.2'~'#0\*(ct#65535'
+.DE
+for 16-bit values or, for 32-bit values:
+.DS L
+ "'\*(vb":1~'#65535\*(ct30'"\*(ct":2~'#65535\*(ct#0'"'~'#0
+ \*(ct#65535'"\*(ct"'\*(vb":1~'#0\*(ct#65535'"\*(ct":2~'#0
+ \*(ct#65535'"'~'#0\*(ct#65535'"
+.DE
+(The proofs are left as an exercise to the reader.)
+.P
+Testing for greater-than with 16-bit values is somewhat simpler and is done
+with the pair of statements:
+.DS L
+ DO .C <- '\*(vb.Ac.B'~'#0\*(ct#65535'
+ DO .C <- '&"'.A~.C'~'"\*(vb'\*(vb.C~.C'\*(ct#32768"
+ ~"#0\*(ct#65535"'"\*(ct".C~.C"'~#1
+.DE
+This sets .C (a dummy variable) to #1 if .A > .B, and #0 otherwise. The
+expression may be expanded as described above to instead set .C to #1 or
+#2.
+.P
+Note also in statement 220 the occurrence of ~"#65535\*(ct#65535". Although
+these operations select the entire value, they are not extraneous, as they
+ensure that the forthcoming \*(vbs will be operating on 32-bit values.
+.P
+In several virtual computed GO TOs the DO FORGET #1 (statement 15 in the
+earlier example) has been omitted, since the next transfer of control would
+be a DO RESUME #1. By making this a DO RESUME #2 instead, the FORGET may
+be forgotten.
+.P
+In statement 64, note that .2 is STASHed twice by a single statement. This
+is perfectly legal.
+.P
+Lastly, note in statements 243 and 214 respectively, expressions for
+shifting 16- and 32-bit variables logically one place to the left.
+Statement 231 demonstrates right-shifting for 32-bit variables.
+.bp
+.H 2 "Program Listing"
+.DS L
+.cs R 24
+ 1 (1000) PLEASE IGNORE .4
+ 2 PLEASE ABSTAIN FROM (1005)
+ 3 (1009) DO STASH .1 + .2 + .5 + .6
+ 4 DO .4 <- #1
+ 5 DO (1004) NEXT
+ 6 (1004) PLEASE FORGET #1
+ 7 DO .3 <- '\*(vb.1\*(ct.2'~'#0\*(ct#65535'
+ 8 DO .6 <- '&.1\*(ct.2'~'#0\*(ct#65535'
+ 9 PLEASE DO .5 <- "\*(vb!6~#32768'\*(ct#1"~#3
+ 10 DO (1002) NEXT
+ 11 DO .4 <- #2
+ 12 (1005) DO (1006) NEXT
+* 13 (1999) DOUBLE OR SINGLE PRECISION OVERFLOW
+ 14 (1002) DO (1001) NEXT
+ 15 (1006) PLEASE FORGET #1
+ 16 DO .5 <- '\*(vb"!6~.6'~#1"\*(ct#1'~#3
+ 17 DO (1003) NEXT
+ 18 DO .1 <- .3
+ 19 DO .2 <- !6\*(ct#0'~'#32767\*(ct#1'
+ 20 DO (1004) NEXT
+ 21 (1003) DO (1001) NEXT
+ 22 DO REINSTATE (1005)
+ 23 (1007) PLEASE RETRIEVE .1 + .2 + .5 + .6
+ 24 DO REMEMBER .4
+ 25 PLEASE RESUME #2
+ 26 (1001) DO RESUME .5
+ 27 (1010) DO STASH .1 + .2 + .4
+ 28 DO .4 <- .1
+ 29 DO .1 <- '\*(vb.2\*(ct#65535'~'#0\*(ct#65535'
+ 30 DO (1020) NEXT
+ 31 PLEASE DO .2 <- .4
+ 32 PLEASE DO (1009) NEXT
+ 33 DO RETRIEVE .1 + .2 + .4
+ 34 PLEASE RESUME #1
+ 35 (1020) DO STASH .2 + .3
+ 36 DO .2 <- #1
+ 37 PLEASE DO (1021) NEXT
+ 38 (1021) DO FORGET #1
+ 39 DO .3 <- "\*(vb!1~.2'\*(ct#1"~#3
+ 40 PLEASE DO .1 <- '\*(vb.1\*(ct.2'~'#0\*(ct#65535'
+ 41 DO (1022) NEXT
+ 42 DO .2 <- !2\*(ct#0'~'#32767\*(ct#1'
+ 43 DO (1021) NEXT
+ 44 (1023) PLEASE RESUME .3
+ 45 (1022) DO (1023) NEXT
+ 46 PLEASE RETRIEVE .2 + .3
+ 47 PLEASE RESUME #2
+ 48 (1030) DO ABSTAIN FROM (1033)
+ 49 PLEASE ABSTAIN FROM (1032)
+ 50 (1039) DO STASH :1 + .5
+ 51 DO (1530) NEXT
+ 52 DO .3 <- :1~#65535
+ 53 PLEASE DO .5 <- :1~'#65280\*(ct#65280'
+ 54 DO .5 <- '\*(vb"!5~.5'~#1"\*(ct#1'~#3
+ 55 DO (1031) NEXT
+ 56 (1032) DO (1033) NEXT
+ 57 DO (1999) NEXT
+ 58 (1031) DO (1001) NEXT
+ 59 (1033) DO .4 <- .5
+ 60 DO REINSTATE (1032)
+ 61 PLEASE REINSTATE (1033)
+ 62 DO RETRIEVE :1 + .5
+ 63 PLEASE RESUME #2
+ 64 (1040) PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3
+ 65 DO .2 <- #0
+ 66 DO (1520) NEXT
+ 67 DO STASH :1
+ 68 PLEASE RETRIEVE .2
+ 69 DO .1 <- .2
+ 70 DO .2 <- #0
+ 71 PLEASE DO (1520) NEXT
+ 72 DO :2 <- :1
+ 73 DO RETRIEVE .1 + .2 + :1
+ 74 DO (1550) NEXT
+ 75 PLEASE DO .3 <- :3
+ 76 DO RETRIEVE :1 + :2 + :3
+ 77 DO RESUME #1
+ 78 (1050) PLEASE STASH :2 + :3 + .5
+ 79 DO :2 <- .1
+ 80 PLEASE DO (1550) NEXT
+ 81 DO .5 <- :3~'#65280\*(ct#65280'
+ 82 DO .5 <- '\*(vb"!5~.5'~#1"\*(ct#1'~#3
+ 83 DO (1051) NEXT
+ 84 DO (1999) NEXT
+ 85 (1051) DO (1001) NEXT
+ 86 DO .2 <- :3
+ 87 PLEASE RETRIEVE :2 + :3 + .5
+ 88 DO RESUME #2
+ 89 (1500) PLEASE ABSTAIN FROM (1502)
+ 90 PLEASE ABSTAIN FROM (1506)
+ 91 (1509) PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6
+ 92 DO .1 <- :1~#65535
+ 93 PLEASE DO .2 <- :2~#65535
+ 94 DO (1009) NEXT
+ 95 DO .5 <- .3
+ 96 PLEASE DO .6 <- .4
+ 97 DO .1 <- :1~'#65280\*(ct#65280'
+ 98 DO .2 <- :2~'#65280\*(ct#65280'
+ 99 DO (1009) NEXT
+ 100 DO .1 <- .3
+ 101 PLEASE DO (1503) NEXT
+ 102 DO .6 <- .4
+ 103 DO .2 <- #1
+ 104 DO (1009) NEXT
+ 105 DO .1 <- .3
+ 106 DO (1501) NEXT
+ 107 (1504) PLEASE RESUME .6
+ 108 (1503) DO (1504) NEXT
+ 109 (1501) DO .2 <- .5
+ 110 DO .5 <- '\*(vb"'&.6\*(ct.4'~#1"\*(ct#2'~#3
+ 111 DO (1505) NEXT
+ 112 (1506) DO (1502) NEXT
+ 113 PLEASE DO (1999) NEXT
+ 114 (1505) DO (1001) NEXT
+ 115 (1502) DO :4 <- .5
+ 116 DO (1520) NEXT
+ 117 DO :3 <- :1
+ 118 PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6
+ 119 DO REINSTATE (1502)
+ 120 DO REINSTATE (1506)
+ 121 PLEASE RESUME #3
+ 122 (1510) DO STASH :1 + :2 + :4
+ 123 DO :1 <- "'\*(vb":2~'#65535\*(ct#0'"\*(ct#65535'~'#0\*(ct#6553
+ 5'"\*(ct"'\*(vb":2~'#0\*(ct#65535'"\*(ct#65535'~'#0\*(ct#65535
+ '"
+ 124 DO :2 <- #1
+ 125 DO (1509) NEXT
+ 126 PLEASE RETRIEVE :1
+ 127 DO :2 <- :3
+ 128 PLEASE DO (1509) NEXT
+ 129 DO RETRIEVE :2 + :4
+ 130 PLEASE RESUME #1
+ 131 (1520) PLEASE STASH .3 + .4
+ 132 DO .3 <- .1~#43690
+ 133 DO (1525) NEXT
+ 134 PLEASE DO .4 <- 'V.3\*(ct".2~#43690"'~'#0\*(ct#65535'
+ 135 DO .3 <- .1~#21845
+ 136 PLEASE DO (1525) NEXT
+ 137 DO :1 <- .4\*(ct"'V.3\*(ct".2~#21845"'~'#0\*(ct#65535'"
+ 138 PLEASE RETRIEVE .3 + .4
+ 139 DO RESUME #1
+ 140 (1525) DO .3 <- '"'"'"!3\*(ct#0'~'#32767\*(ct#1'"\*(ct#0'~'#32767
+ \*(ct#1'"\*(ct#0'~'#16383\*(ct#3'"\*(ct#0'~'#4095\*(ct#15'
+ 141 PLEASE RESUME #1
+ 142 (1530) DO STASH :2 + :3 + .3 + .5
+ 143 DO :1 <- #0
+ 144 DO :2 <- .2
+ 145 DO .3 <- #1
+ 146 DO (1535) NEXT
+ 147 (1535) PLEASE FORGET #1
+ 148 DO .5 <- "\*(vb!1~.3'\*(ct#1"~#3
+ 149 DO (1531) NEXT
+ 150 DO (1500) NEXT
+ 151 DO :1 <- :3
+ 152 PLEASE DO (1533) NEXT
+ 153 (1531) PLEASE DO (1001) NEXT
+ 154 (1533) DO FORGET #1
+ 155 DO .3 <- !3\*(ct#0'~'#32767\*(ct#1'
+ 156 DO :2 <- ":2~'#0\*(ct#65535'"\*(ct"'":2~'#32767\*(ct#0'"\*(ct#
+ 0'~'#32767\*(ct#1'"
+ 157 PLEASE DO .5 <- "\*(vb!3~.3'\*(ct#1"~#3
+ 158 DO (1532) NEXT
+ 159 DO (1535) NEXT
+ 160 (1532) DO (1001) NEXT
+ 161 PLEASE RETRIEVE :2 + :3 + .3 + .5
+ 162 DO RESUME #2
+ 163 (1540) PLEASE ABSTAIN FROM (1541)
+ 164 DO ABSTAIN FROM (1542)
+ 165 (1549) PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5
+ 166 DO .1 <- :1~#65535
+ 167 PLEASE DO .2 <- :2~'#65280\*(ct#65280'
+ 168 DO .5 <- :1~'#65280\*(ct#65280'
+ 169 DO (1530) NEXT
+ 170 DO :3 <- :1
+ 171 DO .2 <- :2~#65535
+ 172 PLEASE DO (1530) NEXT
+ 173 DO :5 <- :1
+ 174 DO .1 <- .5
+ 175 DO (1530) NEXT
+ 176 DO :4 <- :1
+ 177 PLEASE DO :1 <- ":3~'#65280\*(ct#65280'"\*(ct":5~'#652
+ 80\*(ct#65280'"
+ 178 DO .5 <- ':1~:1'~#1
+ 179 DO .2 <- :2~'#65280\*(ct#65280'
+ 180 DO (1530) NEXT
+ 181 PLEASE DO .5 <- '"':1~:1'~#1"\*(ct.5'~#3
+ 182 DO .1 <- :3~#65535
+ 183 DO .2 <- #0
+ 184 DO (1520) NEXT
+ 185 PLEASE DO :2 <- :1
+ 186 PLEASE DO .1 <- :4~#65535
+ 187 DO (1520) NEXT
+ 188 DO (1509) NEXT
+ 189 DO .5 <- !5\*(ct":4~#3"'~#15
+ 190 DO :1 <- :3
+ 191 DO :2 <- :5
+ 192 DO (1509) NEXT
+ 193 PLEASE DO .5 <- !5\*(ct":4~#3"'~#63
+ 194 DO .5 <- '\*(vb"!5~.5'~#1"\*(ct#1'~#3
+ 195 PLEASE RETRIEVE :4
+ 196 (1541) DO :4 <- .5
+ 197 DO (1543) NEXT
+ 198 (1542) DO (1544) NEXT
+ 199 PLEASE DO (1999) NEXT
+ 200 (1543) DO (1001) NEXT
+ 201 (1544) DO REINSTATE (1541)
+ 202 PLEASE REINSTATE (1542)
+ 203 PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5
+ 204 DO RESUME #2
+ 205 (1550) DO STASH :1 + :4 + :5 + .5
+ 206 DO :3 <- #0
+ 207 DO .5 <- '\*(vb"':2~:2'~#1"\*(ct#1'~#3
+ 208 PLEASE DO (1551) NEXT
+ 209 DO :4 <- #1
+ 210 PLEASE DO (1553) NEXT
+ 211 (1553) DO FORGET #1
+ 212 DO .5 <- '\*(vb":2~'#32768\*(ct#0'"\*(ct#2'~#3
+ 213 DO (1552) NEXT
+ 214 DO :2 <- ":2~'#0\*(ct#65535'"\*(ct"'":2~'#32767\*(ct#0'"\*(ct#
+ 0'~'#32767\*(ct#1'"
+ 215 PLEASE DO :4 <- ":4~'#0\*(ct#65535'"\*(ct"'":4~'#32767
+ \*(ct#0'"\*(ct#0'~'#32767\*(ct#1'"
+ 216 DO (1553) NEXT
+ 217 (1552) DO (1001) NEXT
+ 218 (1556) PLEASE FORGET #1
+ 219 DO :5 <- "'\*(vb":1~'#65535\*(ct#0'"\*(ct":2~'#65535\*(ct#0'"'
+ ~'#0\*(ct#65535'"\*(ct"'\*(vb":1~'#0\*(ct#65535'"\*(ct":2~'#0\*(ct
+ #65535'"'~'#0\*(ct#65535'"
+ 220 DO .5 <- '\*(vb"'&"':2~:5'~'"'\*(vb"'\*(vb":5~:5"~"#65535~
+ #65535"'~'#65535\*(ct#0'"\*(ct#32768'~'#0\*(ct#65535'"
+ \*(ct"'\*(vb":5~:5"~"#65535\*(ct#65535"'~'#0\*(ct#65535'"'
+ "\*(ct"':5~:5'~#1"'~#1"\*(ct#2'~#3
+ 221 DO (1554) NEXT
+ 222 DO :5 <- :3
+ 223 DO (1510) NEXT
+ 224 PLEASE DO :1 <- :3
+ 225 DO :3 <- "'V":4~'#65535\*(ct#0'"\*(ct":5~'#65535\*(ct#0'"'
+ ~'#0\*(ct#65535'"\*(ct"'V":4~'#0\*(ct#65535'"\*(ct":5~'#0\*(ct
+ #65535'"'~'#0\*(ct#65535'"
+ 226 DO (1555) NEXT
+ 227 (1554) PLEASE DO (1001) NEXT
+ 228 (1555) DO FORGET #1
+ 229 DO .5 <- "\*(vb':4~#1'\*(ct#2"~#3
+ 230 DO (1551) NEXT
+ 231 DO :2 <- ":2~'#0\*(ct#65534'"\*(ct":2~'#65535\*(ct#0'"
+ 232 DO :4 <- ":4~'#0\*(ct#65534'"\*(ct":4~'#65535\*(ct#0'"
+ 233 PLEASE DO (1556) NEXT
+ 234 (1551) DO (1001) NEXT
+ 235 PLEASE RETRIEVE :1 + :4 + :5 + .5
+ 236 PLEASE RESUME #2
+ 237 (1900) DO STASH .2 + .3 + .5
+ 238 DO .1 <- #0
+ 239 DO .2 <- #1
+ 240 PLEASE DO (1901) NEXT
+ 241 (1901) DO FORGET #1
+ 242 DO %50 .1 <- 'V.1\*(ct.2'~'#0\*(ct#65535'
+ 243 DO .2 <- !2\*(ct#0'~'#32767\*(ct#1'
+ 244 PLEASE DO .5 <- "\*(vb!2~.2'\*(ct#1"~#3
+ 245 DO (1902) NEXT
+ 246 DO (1901) NEXT
+ 247 (1902) DO (1001) NEXT
+ 248 DO RETRIEVE .2 + .3 + .5
+ 249 PLEASE RESUME #2
+ 250 (1910) PLEASE STASH .1 + .3 + .5 + :1 + :2 + :3
+ 251 DO .3 <- #65524
+ 252 DO :1 <- #6
+ 253 DO (1911) NEXT
+* 254 PLEASE NOTE THAT YOU CAN'T GET THERE FROM HERE
+ 255 (1912) DO (1001) NEXT
+ 256 (1911) DO FORGET #1
+ 257 PLEASE DO (1900) NEXT
+ 258 DO :2 <- .1
+ 259 DO (1500) NEXT
+ 260 PLEASE DO :1 <- :3
+ 261 DO .1 <- .3
+ 262 DO (1020) NEXT
+ 263 PLEASE DO .3 <- .1
+ 264 DO .5 <- '\*(vb"!3~.3'~#1"\*(ct#2'~#3
+ 265 DO (1912) NEXT
+ 266 DO .1 <- #12
+ 267 PLEASE DO (1050) NEXT
+ 268 DO RETRIEVE .1
+ 269 DO (1530) NEXT
+ 270 DO :2 <- #32768
+ 271 DO (1500) NEXT
+ 272 PLEASE DO .2 <- :3~'#65280\*(ct#65280'
+ 273 PLEASE RETRIEVE .3 + .5 + :1 + :2 + :3
+ 274 DO RESUME #1
+.if '\*c'y' \{\
+ 275 (1060) DO .3<-'V".1\*(ct.2"'~'#0\*(ct#65535'
+ 276 DO RESUME #1
+ 277 (1070) DO .3<-'&".1\*(ct.2"'~'#0\*(ct#65535'
+ 278 DO RESUME #1
+ 279 (1080) DO .3<-'\*(vb".1\*(ct.2"'~'#0\*(ct#65535' \}
+ 280 DO RESUME #1
+.cs R
+.DE
+.bp
+.H 2 "Programming Suggestions"
+.P
+For the novice INTERCAL programmer, we provide here a list of suggested
+INTERCAL programming projects:
+.P
+Write an integer exponentiation subroutine. :1 <- .1 raised to the .2 power.
+.P
+Write a double-precision sorting subroutine. Given 32-bit array ;1 of size
+:1, sort the contents into numerically increasing order, leaving the results
+in ;1.
+.P
+Generate a table of prime numbers.
+.P
+Put together a floating-point library, using 32-bit variables to represent
+floating-point numbers (let the upper half be the mantissa and the lower
+half be the characteristic). The library should be capable of performing
+floating-point addition, subtraction, multiplication, and division, as well
+as the natural logarithm function.
+.P
+Program a Fast Fourier Transform (FFT). This project would probably entail
+the writing of the floating-point library as well as sine and cosine functions.
+.P
+Calculate, to :1 places, the value of pi.
+.if '\*c'y' \{\
+.P
+(The first three and last one of the preceding suggested projects from
+the INTERCAL-72 manual are included in the C-INTERCAL distribution's
+pit directory of sample code. The floating-point library and FFT
+routine remain as worthy challenges...) \}
+.bp
+.H 1 "ERROR MESSAGES"
+.SETR error_messages
+.P
+Due to INTERCAL's implementation of comment lines (see section 4.5), most
+error messages are produced during execution instead of during compilation.
+All errors except those not causing immediate termination of program execution
+are treated as fatal.
+.H 2 "Format"
+.P
+All error messages appear in the following form:
+.DS L
+ ICLnnnI (error message)
+ ON THE WAY TO STATEMENT nnnn
+ CORRECT SOURCE AND RESUBMIT
+.DE
+The message varies depending upon the error involved. For undecodable
+statements the message is the statement itself. The second line tells
+which statement would have been executed next had the error not occurred.
+Note that if the error is due to 80 attempted levels of NEXTing, the
+statement which would have been executed next need not be anywhere near the
+statement causing the error.
+.H 2 "Messages"
+.P
+Brief descriptions of the different error types are listed below according
+to message number.
+.BL
+.LI 000
+An undecodable statement has been encountered in the course of
+execution. Note that keypunching errors can be slightly disastrous,
+since if 'FORGET' were misspelled F-O-R-G-E-R, the results would
+probably not be those desired. Extreme misspellings may have even
+more surprising consequences. For example, misspelling 'FORGET'
+R-E-S-U-M-E could have drastic results.
+.LI 017
+An expression contains a syntax error.
+.LI 079
+Improper use has been made of statement identifiers.
+.LI 099
+Improper use has been made of statement identifiers.
+.LI 123
+Program has attempted 80 levels of NEXTing.
+.LI 129
+Program has attempted to transfer to a non-existent line label.
+.LI 139
+An ABSTAIN or REINSTATE statement references a non-existent line label.
+.LI 182
+A line label has been multiply defined.
+.LI 197
+An invalid line label has been encountered.
+.LI 200
+An expression involves an unidentified variable.
+.LI 240
+An attempt has been made to give an array a dimension of zero.
+.LI 241
+Invalid dimensioning information was supplied in defining or using
+an array.
+.LI 275
+A 32-bit value has been assigned to a 16-bit variable.
+.LI 436
+A retrieval has been attempted for an unSTASHed value.
+.LI 533
+A WRITE IN statement or interleave (\*(ct) operation has produced a
+value requiring over 32 bits to represent.
+.LI 562
+Insufficient data.
+.LI 579
+Input data is invalid.
+.LI 621
+The expression of a RESUME statement evaluated to #0.
+.LI 632
+Program execution was terminated via a RESUME statement instead of
+GIVE UP.
+.LI 633
+Execution has passed beyond the last statement of the program.
+.LI 774
+A compiler error has occurred (see section
+.GETHN princeton
+).
+.LI 778
+.ie '\*c'n' \{\
+An unexplainable compiler error has occurred (see J. Lyon or D. Woods)\}.
+.el An unexplainable compiler error has occurred.
+.LE
+.if '\*c'y' \{\
+.P
+The following error codes are new in C-INTERCAL:
+.BL
+.LI 111
+You tried to use a C-INTERCAL extension with the `traditional' flag on.
+.LI 127
+Can't find syslib.i file when it's needed for magical inclusion.
+.LI 222
+Out of stash space.
+.LI 333
+Too many variables.
+.LI 444
+A COME FROM statement references a non-existent line label.
+.LI 555
+More than one COME FROM references the same label.
+.LI 666
+Too many source lines.
+.LI 777
+No such source file.
+.LI 888
+Can't open C output file
+.LI 999
+Can't open C skeleton file.
+.LI 998
+Source file name with invalid extension (use .i or .[3-7]i).
+.LI 997
+Illegal possession of a controlled unary operator.
+.LE \}
+.if '\*c'y' \{\
+.H 1 "The C-INTERCAL Compiler"
+.H 2 "Character Set"
+.P
+The C-INTERCAL compiler uses ASCII rather than EBCDIC. We follow the
+Atari implementation by (a) replacing the change sign (\*(ct) with
+big money ($) as the mingle operator, and (b) replacing the
+bookworm (\*(vb) symbol with what (?) as the exclusive-or
+operator.
+.H 2 "Usage and Compilation Options"
+.P
+To compile an INTERCAL program `foo.i' to executable code, just do
+
+ ick foo.i
+
+There's a -c option that leaves the generated C code in place for
+inspection (suppressing compilation to machine code), a -d option that
+enables verbose parse reporting from the yacc/bison parser, a -t
+option that requires strict INTERCAL-72 compliance (rejecting COME
+FROM and the extensions for bases other than two), a -b option that
+disables the INTERCAL-72 random-bug feature (E774), and an -O option
+that enables the (hah!) optimizer. Invoking ick -? prints a usage
+message.
+.P
+Another compilation switch affects C-INTERCAL's runtime behavior. The `-C'
+option forces output in "clockface" mode, for superstitious users who
+believe writing "IV" upside-down offends IVPITER and would rather
+see IIII.
+.H 2 "Runtime Options"
+.P
+Every C-INTERCAL runtime also accepts certain options at runtime.
+These include [+/-]help, [+/-]traditional, and [+/-]wimpmode.
+The help option (with either + or -) triggers a 'usage' message. The
++traditional option is presently a no-op.
+.P
+Steve explains: "The wimpmode option is the most interesting. I found
+myself always running my test programs with filters on both ends to
+work around the \&'nifty' INTERCAL number representations. This was so
+painful that I decided it would be LESS painful (and a lot less code)
+if I added a 'wimp' option. With the +wimpmode option, the user is
+subjected to a humiliating message about what a wimp he or she is to
+use this mode, but after that is allowed to use conventional numerical
+notation. While such a mode doubtless violates to some extent the
+INTERCAL philosophy, the fact that a 'unbutcher' command has been
+posted clearly indicates the need for it. Anyway... if you don't like
+it, don't use it... the default is -wimpmode (i.e. NOT wimp mode)."
+.H 2 "PLEASE Politesse Checking"
+.P
+A feature of INTERCAL-72 not documented in the original manual was that it
+required a certain level of politesse from the programmer. If fewer than
+1/5th of the program statements included the PLEASE qualifier, the program
+would be rejected as insufficiently polite. If more than 1/3rd of them
+included PLEASE, the program would be rejected as excessively polite.
+.P
+This check has been implemented in C-INTERCAL. To assist programmers in
+coping with it, the intercal.el mode included with the distribution randomly
+expands "do " in entered source to "DO PLEASE" or "PLEASE DO" 1/4th of the
+time. \}
+.if '\*c'y' \{\
+.\" This is the same text as the ATARI NOTES at the end of the manual.
+.H 1 "The Atari Implementation"
+.P
+The Atari implementation of INTERCAL differs from the original Princeton
+version primarily in the use of ASCII rather than EBCDIC. Since there is no
+"change" sign (\*(ct) in ASCII, we have substituted the "big money" ($) as the
+mingle operator. We feel that this correctly represents the increasing cost
+of software in relation to hardware. (Consider that in 1970 one could get
+RUNOFF for free, to run on a $20K machine, whereas today a not quite as
+powerful formatter costs $99 and runs on a $75 machine.) We also feel that
+there should be no defensible contention that INTERCAL has any sense.
+Also, since overpunches are difficult to read on the average VDT, the
+exclusive-or operator may be written ?. This correctly expresses the
+average person's reaction on first encountering exclusive-or, especially on
+a PDP-11. Note that in both of these cases, the over-punched symbol may
+also be used if one is masochistic, or concerned with portability to the
+Princeton compiler. The correct over-punch for "change" is "c<backspace>/"
+and the correct over-punch for \*(vb is "V<backspace>-". These codes will be
+properly printed if you have a proper printer, and the corresponding EBCDIC
+code will be produced by the /IBM option on the LIST command. \}
+.ie '\*c'n' \{\
+.H 1 "JCL"
+.P
+The information contained in the following section applies
+only to the Princeton compiler, run under OS/360.
+.H 2 "The Princeton Compiler" \}
+.el .H 1 "The Princeton Compiler"
+.P
+The Princeton compiler, written in SPITBOL (a variant of
+SNOBOL), performs the compilation in two stages. First the
+INTERCAL source is converted into SPITBOL source, then the
+latter is compiled and executed.
+.SETR princeton
+.P
+It should be noted that the Princeton compiler fails to
+properly interpret certain multiply-subscripted expressions,
+such as:
+.DS
+ ",1SUB",2SUB#1"#2"
+.DE
+.P
+This is not a "bug". Being documented, it is merely a
+"restriction". Such cases may be resolved by alternating
+sparks and ears in various levels of expression nesting:
+.DS
+ ",1SUB',2SUB#1'#2"
+.DE
+which is advisable in any case, since INTERCAL expressions
+are unreadable enough as is.
+.P
+Since there is currently no catalogued procedure for
+invoking the compiler, the user must include the in-line
+procedure shown on the following page in his job before the
+compilation step. Copies of this in-line procedure may be
+obtained at any keypunch if the proper keys are struck.
+.P
+The compiler is then executed in the usual manner:
+.DS L
+
+ // EXEC INTERCAL[,PARM='parameters']
+ //COMPILE.SYSIN DD *
+ {INTERCAL source deck}
+ /*
+ //EXECUTE.SYSWRITE DD *
+ {input data}
+ /*
+
+.DE
+The various parameters are described following the in-line
+procedure. At most one parameter from each set may apply to
+a given compilation; if more than one are specified, the
+results are undefined, and may vary depending upon the
+particular set of options. The default parameters are
+underlined.
+.DS L
+ //INTERCAL PROC
+ //COMPILE EXEC PGM=INTERCAL
+ //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
+ // DD DSN=SYS1.FORTLIB,DISP=SHR
+ //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
+ //SYSPUNCH DD DUMMY
+ //SCRATCH DD DSN=&COMPSET,UNIT=SYSDA,SPACE=(CYL,(3,1)),DISP=(,PASS)
+ //EXECUTE EXEC PGM=EXECUTE,COND=(4,LT) \*F
+ //SOURCES DD DSN=U.INTERCAL.SOURCES,DISP=SHR
+ //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
+ // DD DSN=SYS5.SPITLIB,DISP=SHR
+ // DD DSN=SYS1.FORTLIB,DISP=SHR
+ //SYSIN DD DSN=&COMPSET,DISP=(OLD,DELETE)
+ //SYSOBJ DD SYSOUT=B,DCB=(BLKSIZE=80,LRECL=80,RECFM=F)
+ //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
+ //SYSPUNCH DD DUMMY
+ // PEND
+.DE
+.FS
+Pending acquisition of SPITBOL release 3.0, the SOURCES
+DD card must be replaced by the five cards:
+.DS L
+ //NOOPTPFX DD DSN=U.INTERCAL.SOURCES(NOOPTPFX),DISP=SHR
+ //NOOPTSUB DD DSN=U.INTERCAL.SOURCES(NOOPTSUB),DISP=SHR
+ //OPTPFX DD DSN=U.INTERCAL.SOURCES(OPTPFX),DISP=SHR
+ //OPTSUB DD DSN=U.INTERCAL.SOURCES(OPTSUB),DISP=SHR
+ //PRELIM DD DSN=U.INTERCAL.SOURCES(PRELIM),DISP=SHR
+.DE
+.FE
+.ce 1
+Figure 3. Inline procedure for using INTERCAL.
+.P
+.LB 5 0 " " 0 * 0 0
+.LI "\fBOPT\fR"
+.LI "NOOPT"
+.LI " "
+In the default mode, the compiler will print a
+list of all options in effect, including the
+defaults for unspecified parameter groups and the
+effective option for those sets where one was
+specified. If NOOPT is requested, it causes the
+default mode to be assumed.
+
+.LI "\fBOPTSUB\fR
+.LI "NOOPTSUB"
+.LI "NOSUB"
+.LI " "
+Unless 'NOOPTSUB' is requested, the System Library
+is optimized, resulting in much more rapid
+NOSUB processing of function calls. Specifying NOOPTSUB
+causes the non-optimized INTERCAL code shown in
+section 6.3 to be used, whereas NOSUB requests
+that the System Library be omitted altogether.
+
+.LI IAMBIC
+.LI "\fBPROSE\fR
+.LI " "
+The IAMBIC parameter permits the programmer to use
+poetic license and thus write in verse. If the
+reader does not believe it possible to write verse
+in INTERCAL, he should send the authors a stamped,
+self-addressed envelope, along with any INTERCAL
+program, and they will provide one which is verse.
+
+.LI "\fBFORMAT\fR"
+.LI NOFORMAT
+.LI " "
+In FORMAT mode, each statement printed is put on a
+separate line (or lines). In NOFORMAT mode, the
+free-format source is printed exactly as input.
+In this latter case, statement numbers are
+provided only for the first statement on a card,
+and they may be only approximate. Also,
+unrecognizable statements are not flagged.
+
+.LI SEQ
+.LI "\fBNOSEQ\fR"
+.LI " "
+If the source deck has sequence numbers in columns
+73 through 80, specifying 'SEQ' will cause them to
+be ignored.
+
+.LI "SOURCE"
+.LI "\fBNOSOURCE\fR"
+.LI " "
+If NOSOURCE is selected, all source listing is
+suppressed.
+
+.LI LIST
+.LI "\fBNOLIST\fR"
+.LI " "
+If LIST is specified, the compiler will provide a
+list of statement numbers catalogued according to
+type of statement. The compiler uses this table
+to perform abstentions by gerund.
+
+.LI "WIDTH=nn"
+.LI " "
+This sets the width (in number of characters) of
+the output line for FORMAT mode output. The
+default is
+.B 132.
+
+.LI "CODE"
+.LI "\fBNOCODE\fR"
+.LI " "
+Include 'CODE' in the parameter list to obtain a
+listing of the SPITBOL code produced for each
+INTERCAL statement.
+
+.LI "LINES=nn"
+.LI " "
+This determines the number of lines per page,
+during both compilation and execution. The
+default is
+.B 60.
+
+.LI DECK
+.LI "\fBNODECK\fR"
+.LI " "
+Selecting 'DECK' will cause the compiler to punch
+out a SPITBOL object deck which may then be run
+without reinvoking the INTERCAL (or SPITBOL)
+compiler.
+
+.LI "\fBKIDDING\fR"
+.LI NOKIDDING
+.LI " "
+Select NOKIDDING to eliminate the snide remarks
+which ordinarily accompany INTERCAL error
+messages.
+
+.LI "\fBGO\fR"
+.LI NOGO
+.LI " "
+Specifying 'NOGO' will cause the program to be
+compiled but not executed. EXECUTE/NOEXECUTE may
+be substituted for GO/NOGO, but this will result
+in an error, and GO will be assumed.
+
+.LI "\fBBUG\fR"
+.LI NOBUG
+.LI " "
+Under the default, there is a fixed probability of
+a fatal compiler bug being worked at random into
+the program being compiled. Encountering this bug
+during execution results in error message 774 (see
+section 7.2). This probability is reduced to zero
+under 'NOBUG'. This does not affect the
+probability (presumably negligible) of error
+message 778.
+.LE
+.H 2 "Other INTERCAL Compilers"
+.P
+There are no other INTERCAL compilers. \*F
+.FS
+This assertion in the INTERCAL-72 manual was blatantly contradicted by
+some notes on an Atari implementation included at the end of the manual.
+So, you expect compiler manuals to be consistent?
+.FE
+.ds App TONSIL
+.APP A ""
+.P
+The Official INTERCAL Character Set
+.FS
+Since all other reference manuals have Appendices, it was decided that
+the INTERCAL manual should contain some other type of removable organ.
+.FE
+.\".nr * \n*+1
+.nr PG \n%+1
+.P
+Tabulated on page \n(PG are all the characters used in INTERCAL, excepting
+letters and digits, along with their names and interpretations. Also
+included are several characters not used in INTERCAL, which are presented
+for completeness and to allow for future expansion.
+.FS
+\*F This footnote intentionally unreferenced.
+.FE
+.ds CH - % -
+.bp
+.\".nr * \n*-1
+.TS
+box;
+c c c
+l l l.
+Character Name Use (if any)
+=
+\&. spot identify 16-bit variable
+: two-spot identify 32-bit variable
+, tail identify 16-bit array
+; hybrid identify 32-bit array
+# mesh identify constant
+\&= half-mesh
+\' spark grouper
+` backspark
+! wow equivalent to spark-spot
+? what \fIunary exlusive OR (ASCII)\fR
+" rabbit-ears grouper
+\o'".' rabbit equivalent to ears-spot
+| spike
+% double-oh-seven percentage qualifier
+\- worm used with angles
+< angle used with worms
+> right angle
+( wax precedes line label
+) wane follows line label
+[ U turn
+] U turn back
+{ embrace
+} bracelet
+* splat flags invalid statements
+& ampersand\*F unary logical AND
+V V (or book) unary logical OR
+\*(vb bookworm (or universal qualifier) unary exclusive OR
+$ big money \fIbinary mingle (ASCII)\fR
+\*(ct change binary mingle
+~ sqiggle binary select
+\&_ flat worm
+\*(ov overline indicates "times 1000"
++ intersection separates list items
+/ slat
+\e backslat
+@ whirlpool
+\*(no hookworm
+^ shark (or simply sharkfin)
+\o"#*\(sq" blotch
+.TE
+.ce 1
+Table 2 (top view). INTERCAL character set.
+.FS
+Got any better ideas?
+.FE
+.if '\*c'n' \{\
+.APP "B" "NOTES ON THE ATARI IMPLEMENTATION"
+.P
+The Atari implementation of INTERCAL differs from the original Princeton
+.ds CH INTERCAL
+version primarily in the use of ASCII rather than EBCDIC. Since there is no
+"change" sign (\*(ct) in ASCII, we have substituted the "big money" ($) as the
+mingle operator. We feel that this correctly represents the increasing cost
+of software in relation to hardware. (Consider that in 1970 one could get
+RUNOFF for free, to run on a $20K machine, whereas today a not quite as
+powerful formatter costs $99 and runs on a $75 machine.) We also feel that
+there should be no defensible contention that INTERCAL has any sense.
+Also, since overpunches are difficult to read on the average VDT, the
+exclusive-or operator may be written ?. This correctly expresses the
+average person's reaction on first encountering exclusive-or, especially on
+a PDP-11. Note that in both of these cases, the over-punched symbol may
+also be used if one is masochistic, or concerned with portability to the
+Princeton compiler. The correct over-punch for "change" is "c<backspace>/"
+and the correct over-punch for \*(vb is "V<backspace>-". These codes will be
+properly printed if you have a proper printer, and the corresponding EBCDIC
+code will be produced by the /IBM option on the LIST command. \}
+++ /dev/null
-.ND
-.ds vb V\v'-0.2'\h'-0.6'\-\v'0.2'
-.TL
-.sp 3
-THE INTERCAL PROGRAMMING LANGUAGE
-.br
-REFERENCE MANUAL
-.AU
-.sp 3
-Donald R. Woods
-.br
-and
-.br
-James M. Lyon
-.AB no
-.AE
-.LP
-.sp 20
-.ce 2
-\(co \fICopyright Donald R. Woods
-and James M. Lyon 1973\fR
-.ds CH INTERCAL
-.bp
-.NH 1
-INTRODUCTION
-.LP
-The names you are about to ignore are true. However, the story has been changed
-significantly. Any resemblance of the programming language portrayed here
-to other programming languages, living or dead, is purely coincidental.
-.NH 2
-Origin and Purpose
-.LP
-The INTERCAL programming language was designed the morning of May 26, 1972
-by Donald R. Woods and James M. Lyon, at Princeton University. Exactly when
-in the morning will become apparent in the course of this manual. It was
-inspired by one ambition; to have a compiler language which has nothing at
-all in common with any other major language. By 'major' was meant anything
-with which the authors were at all familiar, e.g., FORTRAN, BASIC, COBOL,
-ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PL/I. For the
-most part, INTERCAL has remained true to this goal, sharing only the basic
-elements such as variables, arrays, and the ability to do I/O, and eschewing
-all conventional operations other than the assignment statement (FORTRAN
-"=").
-.NH 2
-Acronym
-.LP
-The full name of the compiler is "Compiler Language With No Pronounceable
-Acronym", which is, for obvious reasons, abbreviated "INTERCAL".
-.NH 2
-Acknowledgments
-.LP
-The authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,
-without whose unwitting assistance this manual would still have been
-possible.
-.nr % 1
-.ds CH - % -
-.NH 1
-FUNDAMENTAL CONCEPTS
-.LP
-In this section an attempt is made to describe how and why INTERCAL may be
-used; i.e., what it is like and what it is good for.
-.NH 2
-Sample Program
-.LP
-Shown below is a relatively simple INTERCAL program which will read in 32-bit
-unsigned integers, treat them as signed, 2's-complement numbers, and print out
-their absolute values. The program exits if the absolute value is zero. Note
-in particular the inversion routine (statements 6 through 14), which could
-be greatly simplified if the subroutine library (see section 5) were used.
-.LP
-A more detailed analysis of a program is made in section 6 of this manual.
-.LP
-.nf
-.cs R 24
- DO (5) NEXT
- (5) DO FORGET #1
- PLEASE WRITE IN :1
- DO .1 <- '\*(vb":1~'#32768\(ct#0'"\(ct#1'~#3
- DO (1) NEXT
- DO :1 <- "'\*(vb":1~'#65535\(ct#0'"\(ct#65535'
- ~'#0\(ct#65535'"\(ct"'\*(vb":1~'#0\(ct#65535'"
- \(ct#65535'~'#0\(ct#65535'"
- DO :2 <- #1
- PLEASE DO (4) NEXT
- (4) DO FORGET #1
- DO .1 <- "\*(vb':1~:2'\(ct#1"~#3
- DO :1 <- "'\*(vb":1~'#65535\(ct#0'"\(ct":2~'#65535
- \(ct#0'"'~'#0\(ct#65535'"\(ct"'\*(vb":1~'#0
- \(ct#65535'"\(ct":2~'#65535\(ct#0'"'~'#0\(ct#65535'"
- DO (1) NEXT
- DO :2 <- ":2~'#0\(ct#65535'"
- \(ct"'":2~'#65535\(ct#0'"\(ct#0'~'#32767\(ct#1'"
- DO (4) NEXT
- (2) DO RESUME .1
- (1) PLEASE DO (2) NEXT
- PLEASE FORGET #1
- DO READ OUT :1
- PLEASE DO .1 <- '\*(vb"':1~:1'~#1"\(ct#1'~#3
- DO (3) NEXT
- PLEASE DO (5) NEXT
- (3) DO (2) NEXT
- PLEASE GIVE UP
-.cs R
-.fi
-.NH 2
-Uses for INTERCAL
-.LP
-INTERCAL's main advantage over other programming languages is its strict
-simplicity. It has few capabilities, and thus there are few restrictions to
-be kept in mind. Since it is an exceedingly easy language to learn, one
-might expect it would be a good language for initiating novice programmers.
-Perhaps surprising, than, is the fact that it would be more likely to
-initiate a novice into a search for another line of work. As it turns out,
-INTERCAL is more useful (which isn't saying much) as a challenge to
-professional programmers. Those who doubt this need only refer back to the
-sample program in section 2.1. This 22-statement program took somewhere
-from 15 to 30 minutes to write, whereas the same objectives can be achieved
-by single-statement programs in either SNOBOL;
-.LP
-.nf
- PLEASE INPUT POS(0) ('-' ! '')
- + (SPAN('0123456789') $ OUTPUT)
- + *NE(OUTPUT) :S(PLEASE)F(END)
-.fi
-.LP
-or APL;
-.LP
-.nf
- [1] \(->0\(!=\(sq\(<-\(or\(sq
-.fi
-.LP
-Admittedly, neither of these is likely to appear more intelligible to
-anyone unfamiliar with the languages involved, but they took roughly 60
-seconds and 15 seconds, respectively, to write. Such is the overwhelming
-power of INTERCAL!
-.LP
-The other major importance of INTERCAL lies in its seemingly inexhaustible
-capacity for amazing one's fellow programmers, confounding programming shop
-managers, winning friends, and influencing people. It is a well-known and
-oft-demonstrated fact that a person whose work is incomprehensible is held
-in high esteem. For example, if one were to state that the simplest way to
-store a value of 65536 in a 32-bit INTERCAL variable is:
-.IP
- DO :1 <- #0\(ct#256
-.LP
-any sensible programmer would say that that was absurd. Since this is
-indeed the simplest method, the programmer would be made to look foolish in
-front of his boss, who would of course happened to turn up, as bosses are
-wont to do. The effect would be no less devastating for the programmer
-having been correct.
-.NH 1
-DESCRIPTION
-.LP
-The examples of INTERCAL programming which have appeared in the preceding
-sections of this manual have probably seemed highly esoteric to the reader
-unfamiliar with the language. With the aim of making them more so, we
-present here a description of INTERCAL.
-.NH 2
-Variables
-.LP
-INTERCAL allows only 2 different types of variables, the
-.B "16-bit integer"
-and the
-.B "32-bit integer."
-These are represented by a spot (.) or two-spot
-(:), respectively, followed by any number between 1 and 65535, inclusive.
-These variables may contain only non-negative numbers; thus they have the
-respective ranges of values: 0 to 65535 and 0 to 4294967295. Note: .123 and
-:123 are two distinct variables. On the other hand, .1 and .0001 are
-identical. Furthermore, the latter may NOT be written as 1E-3.
-.NH 2
-Constants
-.LP
-.B Constants
-are 16-bit values only and may range from 0 to 65535. They are
-prefixed by a mesh (#). Caution! Under no circumstances confuse the mesh
-with the interleave operator, except under confusing circumstances!
-.NH 2
-Arrays
-.LP
-.B Arrays
-are represented by a tail (,) for 16-bit values, or a hybrid (;) for
-32-bit values, followed by a number between 1 and 65535, inclusive. The
-number is suffixed by the word SUB, followed by the subscripts, separated
-optionally by spaces. Subscripts may be any expressions, including those
-involving subscripted variables. This occasionally leads to ambiguous
-constructions, which are resolved as discussed in section 3.4.3. Definition
-of array dimensions will be discussed later in greater detail, since
-discussing it in less detail would be difficult. As before, ,123 and ;123
-are distinct. In summary, .123, :123, #123, ,123, and :123 are all
-distinct.
-.NH 2
-Operators
-.LP
-INTERCAL recognizes 5 operators--2 binary and 3 unary. Please be kind to
-our operators: they may not be very intelligent, but they're all we've got.
-In a sense, all 5 operators are binary, as they are all bit-oriented, but
-it is not our purpose here to quibble about bits of trivia.
-.NH 3
-Binary Operators
-.LP
-The binary operators are \fBinterleave\fR (also called \fBmingle\fR)
-and \fBselect\fR, which
-are represented by a change (\(ct) and a sqiggle [sic] (~), respectively.
-.LP
-The interleave operator takes two 16-bit values and produces a 32-bit result
-by alternating the bits of the operands. Thus, #65535\(ct#0 has the 32-bit
-binary form 101010....10 or 2863311530 decimal, while #0\(ct#65535 =
-0101....01 binary = 1431655765 decimal, and #255\(ct#255 is equivalent to
-#65535.
-.LP
-The select operator takes from the first operand whichever bits correspond
-to 1's in the second operand, and packs these bits to the right in the result.
-Both operands are automatically padded on the left with zeros to 32 bits
-before the selection takes place, so the variable types are unrestricted.
-If more than 16 bits are selected, the result is a 32-bit value, otherwise
-it is a 16-bit value. For example, #179~#201 (binary value 10110011~11001001)
-selects from the first argument the 8th, 7th, 4th, and 1st from last bits,
-namely, 1001, which = 9. But #201~#179 selects from binary 11001001 the 8th,
-6th, 5th, 2nd, and 1st from last bits, giving 10001 = 17. #179~#179 has the
-value 31, while #201~#201 has the value 15.
-.LP
-Perhaps a simpler way of understanding the operation of the select operator
-would be to examine the logic diagram on the following page (Figure 1), which
-performs the select operation upon two 8-bit values, A and B. The gates used
-are Warmenhovian logic gates, which means the outputs have four possible
-values: low, high, undefined (value of an uninitialized flip-flop), and
-oscillating (output of a NOR gate with one input low and the other input
-connected to the output). These values are represented symbolically
-by '0', '1', '?', and '\(es'.
-Note in particular that, while NOT-0 is 1 and NOT-1
-is 0 as in two-valued logic, NOT-? is ? and NOT-\(es is \(es. The functions
-of the various gates are listed in Table 1.
-.bp
-.sp 20
-.ce 1
-Figure 1 goes here with above page number.
-.bp
-.sp 10
-.ps 8
-.vs 10
-.nf
-.cs R 24
-.ds cp \(ci\v'-0.08'\h'-0.67'+\v'0.08'
- __________________________________________________________
- |\e \e
- | \e 1. Logic gate. Inputs A, B. Output O = AB. \e
- | \e \e
- | \e \e 2. Logic gate. Inputs A, B, C. Output O = A+BC. \e
- | |\e \e \e
- | | \e \e 3. Logic gate. Inputs A, B. Output O = A+AB. \e
- | | \e \e \e
- | | |\e \e 4. Logic gate. Inputs A, B. Output O = AB \*(cp -(A+-B) \e
- | | | \e \e \e
- | | | \e \e 5. Logic gate. Inputs A, B. Output O = A\*(cpA + AA \e
- | | | \e \e \e
- | | | \e \e 6. Uninitialized flip-flop. Inputs none. Output O = ? \e
- | | | \e \e \e
- | | | \e \e 7. Flip-flop-flap. Inputs A, B, C. Output O = 1 if \e
- | | | \e \e A=0 or B+C=0 and A=1. O = 0 if AC=1, B=0. O = \(es if \e
- | | | \e \e AB=1, C=0. O = ? if ABC=1. O as yet undetermined \e
- | | | \e \e for other Warmenhovian inputs. See Figure 2. \e
- | | | \e \e \e
- | | | \e \e 8. Bus line. \e
- | | | \e \e \e
-.sp -1
- __________________________________________________________
- | | | \e | |
- | | | | | _____________________________________________________ |
- | | | | | | | | | | | |
- | | | | | | | | | | | |
- | | | | | | | | | | | |
- | | | | | | | | | | | |
- | | | | | | | | | | | |
- \e|__| | | | \e|__| | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- | | | | | |
- \e|__| \e|__|
-.cs R
-.fi
-.ps 10
-.vs 12
-.sp
-.ce 1
-Table 1. Logical (and other) functions.
-.bp
-.sp 20
-.ce 1
-Figure 2 goes here with above page number.
-.bp
-.sp 20
-.ce 1
-Rest of Figure 1 goes here with above page number.
-.bp
-.NH 3
-Unary Operators
-.LP
-The unary operators are & (logical \fBAND\fR), V (logical \fBOR\fR),
-and \*(vb (logical
-\fBXOR\fR). This last character is obtained by overpunching a worm (\-) on a V
-(V). The operator is inserted between the spot, two-spot, mesh, or
-what-have-you, and the integer, thus: .&123, #\*(vb123. Multiple unary
-operators may not be concatenated, thus the form #\*(vb&123 is invalid. This
-will be covered later when precedence is discussed. These operators perform
-their respective logical operations on all pairs of adjacent bits, the
-result from the first and last bits going into the first bit of the result.
-The effect is that of rotating the operand one place to the right and
-ANDing, ORing, or XORing with its initial value. Thus, #&77 (binary =
-1001101) is binary 0000000000000100 = 4, #V77 is binary 1000000001101111 =
-32879, and #\*(vb77 is binary 1000000001101011 = 32875.
-.NH 3
-Precedence
-.LP
-Precedence of operators is as follows:
-.sp 10
-(The remainder of this page intentionally left blank)\**
-.FS
-Keep in mind that the aim in designing INTERCAL was to have no
-precedents.
-.FE
-.bp
-.LP
-This precedence (or lack thereof) may be overruled by grouping expressions
-between pairs of sparks (') or rabbit-ears ("). Thus '#165\(ct#203'~#358
-(binary value '10100101\(ct11001011'~101100110) has the value 15, but
-#165\(ct'#203~#358' has the value 34815, and #165\(ct#203~#358 is invalid
-syntax and is completely valueless (except perhaps as an educational tool
-to the programmer). A unary operator is applied to a sparked or rabbit-eared
-expression by inserting the operator immediately following the opening spark
-or ears. Thus, the invalid expression #\*(vb&123,
-which was described earlier,
-could be coded as '\*(vb#&123' or '\*(vb"{"'.
-Note: In the interests of
-simplifying the sometimes overly-complex form of expressions, INTERCAL allows
-a spark-spot combination ('.) to be replaced with a wow (!). Thus '.1~.2'
-is equivalent to !1~.2', and 'V.1\(ct.2' is equivalent to "V!1\(ct.2'".
-.LP
-Combining a rabbit-ears with a spot to form a rabbit (\o'".') is not permitted,
-although the programmer is free to use it should he find an EBCDIC reader
-which will properly translate a 12-3-7-8 punch.
-.LP
-Sparks and/or rabbit-ears must also be used to distinguish among such
-otherwise ambiguous subscripted and multiply-subscripted expressions as:
-.LP
-.nf
- ,1 SUB #1 ~ #2
- ,1 SUB ,2 SUB #1 #2 #3
- ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "
-.fi
-.LP
-The third case may be isolated into either of its possible interpretations
-by simply changing some pairs of rabbit-ears to sparks, instead of adding
-more ears (which would only confuse the issue further). Ambiguous cases are
-defined as those for which the compiler being used finds a legitimate
-interpretation which is different from that which the user had in mind. See
-also section 8.1.
-.NH 1
-STATEMENTS
-.LP
-In this section is described the format of INTERCAL statements.
-.NH 2
-General Format
-.LP
-Statements may be entered in 'free format'. That is, more than one statement
-may occur on a single card, and a statement may begin on one card and end
-on a later one. Note that if this is done, all intervening cards and portions
-thereof must be part of the same statement. That this restriction is necessary
-is immediately apparent from the following example of what might occur if
-statements could be interlaced.
-.LP
-.nf
- DO .1 <- ".1\(ct'&:51~"#\*(vb1c!12~;&75SUB"\*(vb'V.1~
- DO .2 <- '"!1\(ct"&';\*(vb79SUB",&7SUB:173"'~!\*(vb9\(ct
- .2'\(ct,&1SUB:5~#33578"'"'"~'#65535\(ct"\*(vb'V#&85'"'
- #8196'"'~.1"\(ct.2'~'#&5\(ct"'#1279\(ct#4351'~#65535"'
-.fi
-.LP
-The above statements are obviously meaningless. (For that matter, so are
-the statements
-.LP
-.nf
- DO .1 <- ".1\(ct"&:51~"#\*(vb1\(ct!12~;&75SUB"\*(vb'V.1~
- .2'\(ct,&1SUB:5~#333578"'"'"~#65535\(ct"\*(vb'V#&85'"'
- DO .2 <- '"!1\(ct"&';\*(vb79SUB",&7SUB:173"'~!\*(vb9\(ct
- #8196'"'~.1"\(ct.2'~'#&5\(ct"'#1279\(ct#4351'~#65535"'
-.fi
-.LP
-but this is not of interest here.)
-.LP
-Spaces may be used freely to enhance program legibility (or at least reduce
-program illegibility), with the restriction that no word of a statement
-identifier (see section 4.3) may contain any spaces.
-.NH 2
-Labels
-.LP
-A statement may begin with a
-.B "logical line label"
-enclosed in wax-wane pairs
-(()). A statement may not have more than one label, although it is possible
-to omit the label entirely. A line label is any integer from 1 to 65535,
-which must be unique within each program. The user is cautioned, however,
-that many line labels between 1000 and 1999 are used in the INTERCAL System
-Library functions.
-.NH 2
-Identifiers and Qualifiers
-.LP
-After the line label (if any), must follow one of the following statement
-identifiers: DO, PLEASE, or PLEASE DO. These may be used interchangeably to
-improve the aesthetics of the program. The identifier is then followed by
-either, neither, or both of the following optional parameters (qualifiers):
-(1) either of the character strings NOT or N'T, which causes the statement
-to be automatically abstained from (see section 4.4.9) when execution
-begins, and (2) a number between 0 and 100, preceded by a double-oh-seven
-(%), which causes the statement to have only the specified percent chance
-of being executed each time it is encountered in the course of execution.
-.NH 2
-Statements
-.LP
-Following the qualifiers (or, if none are used, the identifier) must occur
-one of the 13 valid operations. (Exception: see section 4.5.) These are
-described individually in sections 4.4.1 through 4.4.13.
-.NH 3
-Calculate
-.LP
-The INTERCAL equivalent of the half-mesh (=) in FORTRAN, BASIC, PL/I, and
-others, is represented by an angle (<) followed by a worm (-). This
-combination is read 'gets'. 32-bit variables may be assigned 16-bit values,
-which are padded on the left with 16 zero bits. 16-bit variables may be
-assigned 32-bit values only if the value is less than 65535. Thus, to
-invert the least significant bit of the first element of 16-bit
-2-dimensional array number 1, one could write:
-.IP
-,1SUB#1#1 <- '\*(vb,1SUB#1#1\(ct#1'~'#0\(ct#65535'
-.LP
-Similarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define the
-dimensions of arrays. An example will probably best describe the format.
-To define 32-bit array number 7 as 3-dimensional, the first dimension being
-seven, the second being the current value of 16-bit variable number seven,
-and the third being the current value of the seventh element of 16-bit array
-number seven (which is one-dimensional) mingled with the last three bits of
-32-bit variable number seven, one would write (just before they came to take
-him away):
-.IP
-;7 <- #7 BY .7 BY ",7SUB#7"\(ct':7~#7'
-.LP
-This is, of course, different from the statement:
-.IP
-;7 <- #7 BY .7 BY ,7SUB"#7\(ct':7~#7'"
-.LP
-INTERCAL also permits the redefining of array dimensioning, which is done
-the same way as is the initial dimensioning. All values of items in an array
-are lost upon redimensioning, unless they have been STASHed (see section
-4.4.5), in which case restoring them also restores the old dimensions.
-.NH 3
-NEXT
-.LP
-The NEXT statement is used both for subroutine calls and for unconditional
-transfers. This statement takes the form:
-.IP
-DO (label) NEXT
-.LP
-(or, of course,
-.IP
-PLEASE DO (label) NEXT
-.LP
-etc.), where (label) represents any logical line label which appears in the
-program. The effect of such a statement is to transfer control to the
-statement specified, and to store in a push down list (which is initially
-empty) the location from which the transfer takes place. Items may be
-removed from this list and may be discarded or used to return to the
-statement immediately following the NEXT statement. These operations are
-described in sections 4.4.3 and 4.4.4 respectively. The programmer is
-generally advised to discard any stack entries which he does not intend to
-utilize, since the stack has a maximum depth of 79 entries. A program's
-attempting to initiate an 80th level of NEXTing will result on the fatal
-error message, "PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON."
-.NH 3
-FORGET
-.LP
-The statement PLEASE FORGET exp, where exp represents any expression
-(except colloquial and facial expressions), causes the expression to be
-evaluated, and the specified number of entries to be removed from the
-NEXTing stack and discarded. An attempt to FORGET more levels of NEXTing
-than are currently stacked will cause the stack to be emptied, and no error
-condition is indicated. This is because the condition is not considered to
-be an error. As described in section 4.4.2, it is good programming practice
-to execute a DO FORGET #1 after using a NEXT statement as an unconditional
-transfer, so that the stack does not get cluttered up with unused entries:
-.LP
-.nf
-.cs R 24
- DO (123) NEXT
- .
- .
- (123) DO FORGET #1
-.cs R
-.fi
-.NH 3
-RESUME
-.LP
-The statement PLEASE RESUME exp has the same effect as FORGET, except that
-program control is returned to the statement immediately following the NEXT
-statement which stored in the stack the last entry to be removed. Note that
-a rough equivalent of the FORTRAN computed GO TO and BASIC ON exp GO TO is
-performed by a sequence of the form:
-.LP
-.nf
-.cs R 24
- DO (1) NEXT
- .
- .
- (1) DO (2) NEXT
- PLEASE FORGET #1
- .
- .
- (2) DO RESUME .1
-.cs R
-.fi
-.LP
-Unlike the FORGET statement, an attempt to RESUME more levels of NEXTing than
-been stacked will cause program termination. See also section 4.4.11.
-.NH 3
-STASH
-.LP
-Since subroutines are not explicitly implemented in INTERCAL, the NEXT and
-RESUME statements must be used to execute common routines. However, as
-these routines might use the same variables as the main program, it is
-necessary for them to save the values of any variables whose values they
-alter, and later restore them. This process is simplified by the STASH
-state ment, which has the form DO STASH list, where list represents a
-string of one or more variable or array names, separated by intersections
-(+). Thus
-.IP
-PLEASE STASH .123+:123+,123
-.LP
-stashes the values of two variables and one entire array. The values are
-left intact, and copies thereof are saved for later retrieval by (what else?)
-the RETRIEVE statement (see section 4.4.6). It is not possible to STASH
-single array items.
-.NH 3
-RETRIEVE
-.LP
-PLEASE RETRIEVE list restores the previously STASHed values of the variables
-and arrays named in the list. If a value has been stashed more than once,
-the most recently STASHed values are RETRIEVEd, and a second RETRIEVE will
-restore the second most recent values STASHed. Attempting to RETRIEVE a
-value which has not been STASHed will result in the error message, "THROW
-STICK BEFORE RETRIEVING."
-.NH 3
-IGNORE
-.LP
-The statement DO IGNORE list causes all subsequent statements to have no
-effect upon variables and/or arrays named in the list. Thus, for example,
-after the sequence
-.LP
-.nf
- DO .1 <- #1
- PLEASE IGNORE .1
- DO .1 <- #0
-.fi
-.LP
-16-bit variable number 1 would have the value 1, not 0. Inputting (see
-section 4.4.12) into an IGNOREd variable also has no effect. The condition
-is annulled via the REMEMBER statement (see section 4.4.8). Note that, when
-a variable is being IGNOREd, its value, though immutable, is still
-available for use in expressions and the like.
-.NH 3
-REMEMBER
-.LP
-PLEASE REMEMBER list terminates the effect of the IGNORE statement for all
-variables and/or arrays named in the list. It does not matter if a variable
-has been IGNOREd more than once, nor is it an error if the variable has not
-been IGNOREd at all.
-.NH 3
-ABSTAIN
-.LP
-INTERCAL contains no simple equivalent to an IF statement or computed GO
-TO, making it difficult to combine similar sections of code into a single
-routine which occasionally skips around certain statements. The IGNORE
-statement (see section 4.4.7) is helpful in some cases, but a more viable
-method is often required. In keeping with the goal of INTERCAL having
-nothing in common with any other language, this is made possible via the
-ABSTAIN statement.
-.LP
-This statement takes on one of two forms. It may not take on both at any one
-time. DO ABSTAIN FROM (label) causes the statement whose logical line label
-is (label) to be abstained form. PLEASE ABSTAIN FROM gerund list causes all
-statements of the specified type(s) to be abstained from, as in
-.LP
-.nf
- PLEASE ABSTAIN FROM STASHING
- PLEASE ABSTAIN FROM IGNORING + FORGETTING
- PLEASE ABSTAIN FROM NEXTING
- or PLEASE ABSTAIN FROM CALCULATING
-.fi
-.LP
-Statements may also be automatically abstained from at the start of
-execution via the NOT or N'T parameter (see section 4.3).
-.LP
-If, in the course of execution, a statement is encountered which is being
-abstained from, it is ignored and control passes to the next statement in
-the program (unless it, too, is being abstained from).
-.LP
-The statement DO ABSTAIN FROM ABSTAINING is perfectly valid, as is DO ABSTAIN
-FROM REINSTATING (although this latter is not usually recommended). However,
-the statement DO ABSTAIN FROM GIVING UP is not accepted, even though DON'T
-GIVE UP is.
-.NH 3
-REINSTATE
-.LP
-The REINSTATE statement, like the ABSTAIN, takes as an argument either a
-line label or a gerund list. No other form of argument is permitted. For
-example, the following is an invalid argument:
-.LP
-.nf
- Given: x\(!=0, y\(!=0, Prove: x+y=0
- Since x\(!=0, then x+1\(!=1, x+a\(!=a, x+y\(!=y.
- But what is y? y is anything but 0.
- Thus x+y \(!= anything but 0.
- Since x+y cannot equal anything but 0, x+y=0.
-
- Q.E.D.
-.fi
-.LP
-REINSTATEment nullifies the effects of an abstention. Either form of
-REINSTATEment can be used to "free" a statement, regardless of whether the
-statement was abstained from by gerund list, line label, or NOT. Thus,
-PLEASE REINSTATE REINSTATING is not necessarily an irrelevant statement,
-since it might free a DON'T REINSTATE command or a REINSTATE the line label
-of which was abstained from. However, DO REINSTATE GIVING UP is invalid,
-and attempting to REINSTATE a GIVE UP statement by line label will have no
-effect. Note that this insures that DON'T GIVE UP will always be a
-"do-nothing" statement.
-.NH 3
-GIVE UP
-.LP
-PLEASE GIVE UP is used to exit from a program. It has the effect of a PLEASE
-RESUME #80. DON'T GIVE UP, as noted in section 4.4.10, is effectively a null
-statement.
-.NH 3
-Input
-.LP
-Input is accomplished with the statement DO WRITE IN list, where list
-represents a string of variables and/or elements or arrays, separated by
-intersections. Numbers are represented on cards, each number on a separate
-card, by spelling out each digit (in English) and separating the digits
-with one or more spaces. A zero (0) may be spelled as either ZERO or OH.
-Thus the range of (32-bit) input values permissible extends from ZERO (or
-OH) through FOUR TWO NINE FOUR NINE SIX SEVEN TWO NINE FIVE.
-.LP
-Attempting to write in a value greater than or equal to SIX FIVE FIVE three
-six for a 16-bit variable will result in the error message, "DON'T BYTE OFF
-MORE THAN YOU CAN CHEW."
-.NH 3
-Output
-.LP
-Values may be output to the printer, one value per line, via the statement
-DO READ OUT list, where the list contains variables, array elements, and/or
-constants. Output is in the form of "extended" Roman numerals (also called
-"butchered" Roman numerals), with an overline (\(rn) indicating the value below
-is "times 1000", and lower-case letters indicating "times 1000000". Zero
-is indicated by an overline with no character underneath. Thus, the range
-of (32-bit) output values possible is from \(rn through
-\o"i\(rn"\o"v\(rn"ccxciv\o"C\(rn"\o"M\(rn"\o"L\(rn"\o"X\(rn"\o"V\(rn"\o"I\(rn"\o"I\(rn"CCXCV.
-Note: For values whose residues modulo 1000000 are less than 4000, M is
-used to represent 1000; for values whose residues are 4000 or greater,
-\o"I\(rn" is
-used. Thus #3999 would read out as MMMIM while #4000 would read out as
-\o"I\(rn"\o"V\(rn".
-Similar rules apply to the use of \o"M\(rn" and i for 1000000,
-and to that of m and \o"i\(rn"
-for 1000000000.
-.NH 2
-Comments
-.LP
-Unrecognizable statements, as noted in section 7, are flagged with a splat
-(*) during compilation, and are not considered fatal errors unless they
-are encountered during execution, at which time the statement (as input at
-compilation time) is printed and execution is terminated. This allows for
-an interesting (and, by necessity, unique) means of including comments in
-an INTERCAL listing. For example, the statement:
-.sp 1
-* PLEASE NOTE THAT THIS LINE HAS NO EFFECT
-.LP
-will be ignored during execution due to the inclusion of the NOT qualifier.
-User-supplied error messages are also easy to implement:
-.sp 1
-* DO SOMETHING ABOUT OVERFLOW IN ;3
-.LP
-as are certain simple conditional errors:
-.LP
-.nf
-.cs R 24
-* (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED
- ONCE?
- PLEASE REINSTATE (123)
-.cs R
-.fi
-.LP
-This pair of statements will cause an error exit the second time they are
-encountered. Caution!! The appearance of a statement identifier in an
-intended comment will be taken as the beginning of a new statement. Thus,
-the first example on the preceding page could not have been:
-.sp 1
-* PLEASE NOTE THAT THIS LINE DOES NOTHING
-.LP
-The third example, however, is valid, despite the appearance of two cases
-of D-space-O, since INTERCAL does not ignore extraneous spaces in statement
-identifiers.
-.bp
-.NH 1
-SUBROUTINE LIBRARY
-.LP
-INTERCAL provides several built-in subroutines to which control can be
-transferred to perform various operations. These operations include many
-useful functions which are not easily representable in INTERCAL, such as
-addition, subtraction, etc.
-.NH 2
-Usage
-.LP
-In general, the operands are .1, .2, etc., or :1, :2, etc., and the result(s)
-are stored in what would have been the next operand(s). For instance, one
-routine adds .1 to .2 and store the sum in .3, with .4 being used to indicate
-overflow. All variables not used for results are left unchanged.
-.NH 2
-Available Functions
-.LP
-At the time of this writing, only the most fundamental operations are offered
-in the library, as a more complete selection would require prohibitive time
-and coree to implement. These functions, along with their corresponding entry
-points (entered via DO (entry) NEXT) are listed below.
-.LP
-.nf
-.cs R 24
- (1000) .3 <- .1 plus .2, error exit on overflow
- (1009) .3 <- .1 plus .2
- .4 <- #1 if no overflow, else .4 <- #2
- (1010) .3 <- .1 minus .2, no action on overflow
- (1020) .1 <- .1 plus #1, no action on overflow
- (1030) .3 <- .1 times .2, error exit on overflow
- (1039) .3 <- .1 times .2
- .4 <- #1 if no overflow, else .4 <- #2
- (1040) .3 <- .1 divided by .2
- .3 <- #0 if .2 is #0
- (1050) .2 <- :1 divided by .1, error exit on overflow
- .2 <- #0 if .1 is #0
-
- (1500) :3 <- :1 plus :2, error exit on overflow
- (1509) :3 <- :1 plus :2
- :4 <- #1 if no overflow, else :4 <- #2
- (1510) :3 <- :1 minus :2, no action on overflow
- (1520) :1 <- .1 concatenated with .2
- (1525) This subroutine is intended solely for internal
- use within the subroutine library and is therefore
- not described here. Its effect is to shift .3
- logically 8 bits to the left.
- (1530) :1 <- .1 times .2
- (1540) :3 <- :1 times :2, error exit on overflow
- (1549) :3 <- :1 times :2
- :4 <- #1 if no overflow, else :4 <- #2
- (1550) :3 <- :1 divided by :2
- :3 <- #0 if :2 is #0
-
- (1900) .1 <- uniform random no. from #0 to #65535
- (1910) .2 <- normal random no. from #0 to .1, with
- standard deviation .1 divided by #12
-.cs R
-.fi
-.bp
-.NH 1
-PROGRAMMING HINTS
-.LP
-For the user looking to become more familiar with the INTERCAL language, we
-present in this section an analysis of a complex program, as well as some
-suggested projects for the ambitious programmer.
-.LP
-Considering the effort involved in writing an INTERCAL program, it was
-decided in putting together this manual to use an already existing program
-for instructive analysis. Since there was only one such program available,
-we have proceeded to use it. It is known as the "INTERCAL System Library."
-.NH 2
-Description
-.LP
-The program listing begins on the second page following. It is in the same
-format as would be produced by the Princeton INTERCAL compiler in FORMAT
-mode with WIDTH=62 (see section 8). For a description of the functions
-performed by the Library, see section 5.2.
-.NH 2
-Analysis
-.LP
-We shall not attempt to discuss here the algorithms used, but rather we
-shall point out some of the general techniques applicable to a wide range
-of problems.
-.LP
-Statements 10, 14, 15, and 26 make up a virtual "computed GO TO". When
-statement 10 is executed, control passes eventually to statement 16 or 11,
-depending on whether .5 contains #1 or #2, respectively. The value of .5
-is determined in statement 9, which demonstrates another handy technique.
-To turn an expression, exp, with value #0 or #1, into #1 or #2 (for use in
-a "GO TO"), use "\*(vb'exp'\(ct#1"~#3.
-To reverse the condition (i.e., convert #0
-to #2 and leave #1 alone) use "\*(vb'exp'\(ct#2"~#3.
-.LP
-Certain conditions are easily checked. For example, to test for zero,
-select the value from itself and select the bottom bit (see statement 54).
-To test for all bits being 1's, select the value from itself and select the
-top bit (see statement 261). The test for greater than, performed in
-statements 192 and 193 on 32-bit values, employs binary logical operations,
-which are performed as follows:
-.IP
-'\*(vb.1\(ct.2'~'#0\(ct#65535'
-.LP
-for 16-bit values or, for 32-bit values:
-.LP
-.nf
- "'\*(vb":1~'#65535\(ct30'"\(ct":2~'#65535\(ct#0'"'~'#0
- \(ct#65535'"\(ct"'\*(vb":1~'#0\(ct#65535'"\(ct":2~'#0
- \(ct#65535'"'~'#0\(ct#65535'"
-.fi
-.LP
-(The proofs are left as an exercise to the reader.)
-.LP
-Testing for greater-than with 16-bit values is somewhat simpler and is done
-with the pair of statements:
-.LP
-.nf
- DO .C <- '\*(vb.Ac.B'~'#0\(ct#65535'
- DO .C <- '&"'.A~.C'~'"\*(vb'\*(vb.C~.C'\(ct#32768"
- ~"#0\(ct#65535"'"\(ct".C~.C"'~#1
-.fi
-.LP
-This sets .C (a dummy variable) to #1 if .A > .B, and #0 otherwise. The
-expression may be expanded as described above to instead set .C to #1 or
-#2.
-.LP
-Note also in statement 220 the occurrence of ~"#65535\(ct#65535". Although
-these operations select the entire value, they are not extraneous, as they
-ensure that the forthcoming \*(vbs will be operating on 32-bit values.
-.LP
-In several virtual computed GO TOs the DO FORGET #1 (statement 15 in the
-earlier example) has been omitted, since the next transfer of control would
-be a DO RESUME #1. By making this a DO RESUME #2 instead, the FORGET may
-be forgotten.
-.LP
-In statement 64, note that .2 is STASHed twice by a single statement. This
-is perfectly legal.
-.LP
-Lastly, note in statements 243 and 214 respectively, expressions for
-shifting 16- and 32-bit variables logically one place to the left.
-Statement 231 demonstrates right-shifting for 32-bit variables.
-.bp
-.NH 2
-Program Listing
-.LP
-.nf
-.cs R 24
- 1 (1000) PLEASE IGNORE .4
- 2 PLEASE ABSTAIN FROM (1005)
- 3 (1009) DO STASH .1 + .2 + .5 + .6
- 4 DO .4 <- #1
- 5 DO (1004) NEXT
- 6 (1004) PLEASE FORGET #1
- 7 DO .3 <- '\*(vb.1\(ct.2'~'#0\(ct#65535'
- 8 DO .6 <- '&.1\(ct.2'~'#0\(ct#65535'
- 9 PLEASE DO .5 <- "\*(vb!6~#32768'\(ct#1"~#3
- 10 DO (1002) NEXT
- 11 DO .4 <- #2
- 12 (1005) DO (1006) NEXT
-* 13 (1999) DOUBLE OR SINGLE PRECISION OVERFLOW
- 14 (1002) DO (1001) NEXT
- 15 (1006) PLEASE FORGET #1
- 16 DO .5 <- '\*(vb"!6~.6'~#1"\(ct#1'~#3
- 17 DO (1003) NEXT
- 18 DO .1 <- .3
- 19 DO .2 <- !6\(ct#0'~'#32767\(ct#1'
- 20 DO (1004) NEXT
- 21 (1003) DO (1001) NEXT
- 22 DO REINSTATE (1005)
- 23 (1007) PLEASE RETRIEVE .1 + .2 + .5 + .6
- 24 DO REMEMBER .4
- 25 PLEASE RESUME #2
- 26 (1001) DO RESUME .5
- 27 (1010) DO STASH .1 + .2 + .4
- 28 DO .4 <- .1
- 29 DO .1 <- '\*(vb.2\(ct#65535'~'#0\(ct#65535'
- 30 DO (1020) NEXT
- 31 PLEASE DO .2 <- .4
- 32 PLEASE DO (1009) NEXT
- 33 DO RETRIEVE .1 + .2 + .4
- 34 PLEASE RESUME #1
- 35 (1020) DO STASH .2 + .3
- 36 DO .2 <- #1
- 37 PLEASE DO (1021) NEXT
- 38 (1021) DO FORGET #1
- 39 DO .3 <- "\*(vb!1~.2'\(ct#1"~#3
- 40 PLEASE DO .1 <- '\*(vb.1\(ct.2'~'#0\(ct#65535'
- 41 DO (1022) NEXT
- 42 DO .2 <- !2\(ct#0'~'#32767\(ct#1'
- 43 DO (1021) NEXT
- 44 (1023) PLEASE RESUME .3
- 45 (1022) DO (1023) NEXT
- 46 PLEASE RETRIEVE .2 + .3
- 47 PLEASE RESUME #2
- 48 (1030) DO ABSTAIN FROM (1033)
- 49 PLEASE ABSTAIN FROM (1032)
- 50 (1039) DO STASH :1 + .5
- 51 DO (1530) NEXT
- 52 DO .3 <- :1~#65535
- 53 PLEASE DO .5 <- :1~'#65280\(ct#65280'
- 54 DO .5 <- '\*(vb"!5~.5'~#1"\(ct#1'~#3
- 55 DO (1031) NEXT
- 56 (1032) DO (1033) NEXT
- 57 DO (1999) NEXT
- 58 (1031) DO (1001) NEXT
- 59 (1033) DO .4 <- .5
- 60 DO REINSTATE (1032)
- 61 PLEASE REINSTATE (1033)
- 62 DO RETRIEVE :1 + .5
- 63 PLEASE RESUME #2
- 64 (1040) PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3
- 65 DO .2 <- #0
- 66 DO (1520) NEXT
- 67 DO STASH :1
- 68 PLEASE RETRIEVE .2
- 69 DO .1 <- .2
- 70 DO .2 <- #0
- 71 PLEASE DO (1520) NEXT
- 72 DO :2 <- :1
- 73 DO RETRIEVE .1 + .2 + :1
- 74 DO (1550) NEXT
- 75 PLEASE DO .3 <- :3
- 76 DO RETRIEVE :1 + :2 + :3
- 77 DO RESUME #1
- 78 (1050) PLEASE STASH :2 + :3 + .5
- 79 DO :2 <- .1
- 80 PLEASE DO (1550) NEXT
- 81 DO .5 <- :3~'#65280\(ct#65280'
- 82 DO .5 <- '\*(vb"!5~.5'~#1"\(ct#1'~#3
- 83 DO (1051) NEXT
- 84 DO (1999) NEXT
- 85 (1051) DO (1001) NEXT
- 86 DO .2 <- :3
- 87 PLEASE RETRIEVE :2 + :3 + .5
- 88 DO RESUME #2
- 89 (1500) PLEASE ABSTAIN FROM (1502)
- 90 PLEASE ABSTAIN FROM (1506)
- 91 (1509) PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6
- 92 DO .1 <- :1~#65535
- 93 PLEASE DO .2 <- :2~#65535
- 94 DO (1009) NEXT
- 95 DO .5 <- .3
- 96 PLEASE DO .6 <- .4
- 97 DO .1 <- :1~'#65280\(ct#65280'
- 98 DO .2 <- :2~'#65280\(ct#65280'
- 99 DO (1009) NEXT
- 100 DO .1 <- .3
- 101 PLEASE DO (1503) NEXT
- 102 DO .6 <- .4
- 103 DO .2 <- #1
- 104 DO (1009) NEXT
- 105 DO .1 <- .3
- 106 DO (1501) NEXT
- 107 (1504) PLEASE RESUME .6
- 108 (1503) DO (1504) NEXT
- 109 (1501) DO .2 <- .5
- 110 DO .5 <- '\*(vb"'&.6\(ct.4'~#1"\(ct#2'~#3
- 111 DO (1505) NEXT
- 112 (1506) DO (1502) NEXT
- 113 PLEASE DO (1999) NEXT
- 114 (1505) DO (1001) NEXT
- 115 (1502) DO :4 <- .5
- 116 DO (1520) NEXT
- 117 DO :3 <- :1
- 118 PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6
- 119 DO REINSTATE (1502)
- 120 DO REINSTATE (1506)
- 121 PLEASE RESUME #3
- 122 (1510) DO STASH :1 + :2 + :4
- 123 DO :1 <- "'\*(vb":2~'#65535\(ct#0'"\(ct#65535'~'#0\(ct#6553
- 5'"\(ct"'\*(vb":2~'#0\(ct#65535'"\(ct#65535'~'#0\(ct#65535
- '"
- 124 DO :2 <- #1
- 125 DO (1509) NEXT
- 126 PLEASE RETRIEVE :1
- 127 DO :2 <- :3
- 128 PLEASE DO (1509) NEXT
- 129 DO RETRIEVE :2 + :4
- 130 PLEASE RESUME #1
- 131 (1520) PLEASE STASH .3 + .4
- 132 DO .3 <- .1~#43690
- 133 DO (1525) NEXT
- 134 PLEASE DO .4 <- 'V.3\(ct".2~#43690"'~'#0\(ct#65535'
- 135 DO .3 <- .1~#21845
- 136 PLEASE DO (1525) NEXT
- 137 DO :1 <- .4\(ct"'V.3\(ct".2~#21845"'~'#0\(ct#65535'"
- 138 PLEASE RETRIEVE .3 + .4
- 139 DO RESUME #1
- 140 (1525) DO .3 <- '"'"'"!3\(ct#0'~'#32767\(ct#1'"\(ct#0'~'#32767
- \(ct#1'"\(ct#0'~'#16383\(ct#3'"\(ct#0'~'#4095\(ct#15'
- 141 PLEASE RESUME #1
- 142 (1530) DO STASH :2 + :3 + .3 + .5
- 143 DO :1 <- #0
- 144 DO :2 <- .2
- 145 DO .3 <- #1
- 146 DO (1535) NEXT
- 147 (1535) PLEASE FORGET #1
- 148 DO .5 <- "\*(vb!1~.3'\(ct#1"~#3
- 149 DO (1531) NEXT
- 150 DO (1500) NEXT
- 151 DO :1 <- :3
- 152 PLEASE DO (1533) NEXT
- 153 (1531) PLEASE DO (1001) NEXT
- 154 (1533) DO FORGET #1
- 155 DO .3 <- !3\(ct#0'~'#32767\(ct#1'
- 156 DO :2 <- ":2~'#0\(ct#65535'"\(ct"'":2~'#32767\(ct#0'"\(ct#
- 0'~'#32767\(ct#1'"
- 157 PLEASE DO .5 <- "\*(vb!3~.3'\(ct#1"~#3
- 158 DO (1532) NEXT
- 159 DO (1535) NEXT
- 160 (1532) DO (1001) NEXT
- 161 PLEASE RETRIEVE :2 + :3 + .3 + .5
- 162 DO RESUME #2
- 163 (1540) PLEASE ABSTAIN FROM (1541)
- 164 DO ABSTAIN FROM (1542)
- 165 (1549) PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5
- 166 DO .1 <- :1~#65535
- 167 PLEASE DO .2 <- :2~'#65280\(ct#65280'
- 168 DO .5 <- :1~'#65280\(ct#65280'
- 169 DO (1530) NEXT
- 170 DO :3 <- :1
- 171 DO .2 <- :2~#65535
- 172 PLEASE DO (1530) NEXT
- 173 DO :5 <- :1
- 174 DO .1 <- .5
- 175 DO (1530) NEXT
- 176 DO :4 <- :1
- 177 PLEASE DO :1 <- ":3~'#65280\(ct#65280'"\(ct":5~'#652
- 80\(ct#65280'"
- 178 DO .5 <- ':1~:1'~#1
- 179 DO .2 <- :2~'#65280\(ct#65280'
- 180 DO (1530) NEXT
- 181 PLEASE DO .5 <- '"':1~:1'~#1"\(ct.5'~#3
- 182 DO .1 <- :3~#65535
- 183 DO .2 <- #0
- 184 DO (1520) NEXT
- 185 PLEASE DO :2 <- :1
- 186 PLEASE DO .1 <- :4~#65535
- 187 DO (1520) NEXT
- 188 DO (1509) NEXT
- 189 DO .5 <- !5\(ct":4~#3"'~#15
- 190 DO :1 <- :3
- 191 DO :2 <- :5
- 192 DO (1509) NEXT
- 193 PLEASE DO .5 <- !5\(ct":4~#3"'~#63
- 194 DO .5 <- '\*(vb"!5~.5'~#1"\(ct#1'~#3
- 195 PLEASE RETRIEVE :4
- 196 (1541) DO :4 <- .5
- 197 DO (1543) NEXT
- 198 (1542) DO (1544) NEXT
- 199 PLEASE DO (1999) NEXT
- 200 (1543) DO (1001) NEXT
- 201 (1544) DO REINSTATE (1541)
- 202 PLEASE REINSTATE (1542)
- 203 PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5
- 204 DO RESUME #2
- 205 (1550) DO STASH :1 + :4 + :5 + .5
- 206 DO :3 <- #0
- 207 DO .5 <- '\*(vb"':2~:2'~#1"\(ct#1'~#3
- 208 PLEASE DO (1551) NEXT
- 209 DO :4 <- #1
- 210 PLEASE DO (1553) NEXT
- 211 (1553) DO FORGET #1
- 212 DO .5 <- '\*(vb":2~'#32768\(ct#0'"\(ct#2'~#3
- 213 DO (1552) NEXT
- 214 DO :2 <- ":2~'#0\(ct#65535'"\(ct"'":2~'#32767\(ct#0'"\(ct#
- 0'~'#32767\(ct#1'"
- 215 PLEASE DO :4 <- ":4~'#0\(ct#65535'"\(ct"'":4~'#32767
- \(ct#0'"\(ct#0'~'#32767\(ct#1'"
- 216 DO (1553) NEXT
- 217 (1552) DO (1001) NEXT
- 218 (1556) PLEASE FORGET #1
- 219 DO :5 <- "'\*(vb":1~'#65535\(ct#0'"\(ct":2~'#65535\(ct#0'"'
- ~'#0\(ct#65535'"\(ct"'\*(vb":1~'#0\(ct#65535'"\(ct":2~'#0\(ct
- #65535'"'~'#0\(ct#65535'"
- 220 DO .5 <- '\*(vb"'&"':2~:5'~'"'\*(vb"'\*(vb":5~:5"~"#65535~
- #65535"'~'#65535\(ct#0'"\(ct#32768'~'#0\(ct#65535'"
- \(ct"'\*(vb":5~:5"~"#65535\(ct#65535"'~'#0\(ct#65535'"'
- "\(ct"':5~:5'~#1"'~#1"\(ct#2'~#3
- 221 DO (1554) NEXT
- 222 DO :5 <- :3
- 223 DO (1510) NEXT
- 224 PLEASE DO :1 <- :3
- 225 DO :3 <- "'V":4~'#65535\(ct#0'"\(ct":5~'#65535\(ct#0'"'
- ~'#0\(ct#65535'"\(ct"'V":4~'#0\(ct#65535'"\(ct":5~'#0\(ct
- #65535'"'~'#0\(ct#65535'"
- 226 DO (1555) NEXT
- 227 (1554) PLEASE DO (1001) NEXT
- 228 (1555) DO FORGET #1
- 229 DO .5 <- "\*(vb':4~#1'\(ct#2"~#3
- 230 DO (1551) NEXT
- 231 DO :2 <- ":2~'#0\(ct#65534'"\(ct":2~'#65535\(ct#0'"
- 232 DO :4 <- ":4~'#0\(ct#65534'"\(ct":4~'#65535\(ct#0'"
- 233 PLEASE DO (1556) NEXT
- 234 (1551) DO (1001) NEXT
- 235 PLEASE RETRIEVE :1 + :4 + :5 + .5
- 236 PLEASE RESUME #2
- 237 (1900) DO STASH .2 + .3 + .5
- 238 DO .1 <- #0
- 239 DO .2 <- #1
- 240 PLEASE DO (1901) NEXT
- 241 (1901) DO FORGET #1
- 242 DO %50 .1 <- 'V.1\(ct.2'~'#0\(ct#65535'
- 243 DO .2 <- !2\(ct#0'~'#32767\(ct#1'
- 244 PLEASE DO .5 <- "\*(vb!2~.2'\(ct#1"~#3
- 245 DO (1902) NEXT
- 246 DO (1901) NEXT
- 247 (1902) DO (1001) NEXT
- 248 DO RETRIEVE .2 + .3 + .5
- 249 PLEASE RESUME #2
- 250 (1910) PLEASE STASH .1 + .3 + .5 + :1 + :2 + :3
- 251 DO .3 <- #65524
- 252 DO :1 <- #6
- 253 DO (1911) NEXT
-* 254 PLEASE NOTE THAT YOU CAN'T GET THERE FROM HERE
- 255 (1912) DO (1001) NEXT
- 256 (1911) DO FORGET #1
- 257 PLEASE DO (1900) NEXT
- 258 DO :2 <- .1
- 259 DO (1500) NEXT
- 260 PLEASE DO :1 <- :3
- 261 DO .1 <- .3
- 262 DO (1020) NEXT
- 263 PLEASE DO .3 <- .1
- 264 DO .5 <- '\*(vb"!3~.3'~#1"\(ct#2'~#3
- 265 DO (1912) NEXT
- 266 DO .1 <- #12
- 267 PLEASE DO (1050) NEXT
- 268 DO RETRIEVE .1
- 269 DO (1530) NEXT
- 270 DO :2 <- #32768
- 271 DO (1500) NEXT
- 272 PLEASE DO .2 <- :3~'#65280\(ct#65280'
- 273 PLEASE RETRIEVE .3 + .5 + :1 + :2 + :3
- 274 DO RESUME #1
-.cs R
-.fi
-.bp
-.NH 2
-Programming Suggestions
-.LP
-For the novice INTERCAL programmer, we provide here a list of suggested
-INTERCAL programming projects:
-.LP
-Write an integer exponentiation subroutine. :1 <- .1 raised to the .2 power.
-.LP
-Write a double-precision sorting subroutine. Given 32-bit array ;1 of size
-:1, sort the contents into numerically increasing order, leaving the results
-in ;1.
-.LP
-Generate a table of prime numbers.
-.LP
-Put together a floating-point library, using 32-bit variables to represent
-floating-point numbers (let the upper half be the mantissa and the lower
-half be the characteristic). The library should be capable of performing
-floating-point addition, subtraction, multiplication, and division, as well
-as the natural logarithm function.
-.LP
-Program a Fast Fourier Transform (FFT). This project would probably entail
-the writing of the floating-point library as well as sine and cosine functions.
-.LP
-Calculate, to :1 places, the value of pi.
-.bp
-.NH 1
-ERROR MESSAGES
-.LP
-Due to INTERCAL's implementation of comment lines (see section 4.5), most
-error messages are produced during execution instead of during compilation.
-All errors except those not causing immediate termination of program execution
-are treated as fatal.
-.NH 2
-Format
-.LP
-All error messages appear in the following form:
-.LP
-.nf
- ICLnnnI (error message)
- ON THE WAY TO STATEMENT nnnn
- CORRECT SOURCE AND RESUBMIT
-.fi
-.LP
-The message varies depending upon the error involved. For undecodable
-statements the message is the statement itself. The second line tells
-which statement would have been executed next had the error not occurred.
-Note that if the error is due to 80 attempted levels of NEXTing, the
-statement which would have been executed next need not be anywhere near the
-statement causing the error.
-.NH 2
-Messages
-.LP
-Brief descriptions of the different error types are listed below according
-to message number.
-.IP 000
-An undecodable statement has been encountered in the course of
-execution. Note that keypunching errors can be slightly disastrous,
-since if 'FORGET' were misspelled F-O-R-G-E-R, the results would
-probably not be those desired. Extreme misspellings may have even
-more surprising consequences. For example, misspelling 'FORGET'
-R-E-S-U-M-E could have drastic results.
-.IP 017
-An expression contains a syntax error.
-.IP 079
-Improper use has been made of statement identifiers.
-.IP 099
-Improper use has been made of statement identifiers.
-.IP 123
-Program has attempted 80 levels of NEXTing.
-.IP 129
-Program has attempted to transfer to a non-existent line label.
-.IP 139
-An ABSTAIN or REINSTATE statement references a non-existent line label.
-.IP 182
-A line label has been multiply defined.
-.IP 197
-An invalid line label has been encountered.
-.IP 200
-An expression involves an unidentified variable.
-.IP 240
-An attempt has been made to give an array a dimension of zero.
-.IP 241
-Invalid dimensioning information was supplied in defining or using
-an array.
-.IP 275
-A 32-bit value has been assigned to a 16-bit variable.
-.IP 436
-A retrieval has been attempted for an unSTASHed value.
-.IP 533
-A WRITE IN statement or interleave (\(ct) operation has produced a
-value requiring over 32 bits to represent.
-.IP 562
-Insufficient data.
-.IP 579
-Input data is invalid.
-.IP 621
-The expression of a RESUME statement evaluated to #0.
-.IP 632
-Program execution was terminated via a RESUME statement instead of
-GIVE UP.
-.IP 633
-Execution has passed beyond the last statement of the program.
-.IP 774
-A compiler error has occurred (see section 8.1).
-.IP 778
-An unexplainable compiler error has occurred (see J. Lyon or D. Woods).
-.NH 1
-JCL
-.LP
-The information contained in the following section applies
-only to the Princeton compiler, run under OS/360.
-.NH 2
-The Princeton Compiler
-.LP
-The Princeton compiler, written in SPITBOL (a variant of
-SNOBOL), performs the compilation in two stages. First the
-INTERCAL source is converted into SPITBOL source, then the
-latter is compiled and executed.
-.LP
-It should be noted that the Princeton compiler fails to
-properly interpret certain multiply-subscripted expressions,
-such as:
-.sp
-.IP
-",1SUB",2SUB#1"#2"
-.sp
-.LP
-This is not a "bug". Being documented, it is merely a
-"restriction". Such cases may be resolved by alternating
-sparks and ears in various levels of expression nesting:
-.sp
-.IP
-",1SUB',2SUB#1'#2"
-.sp
-.LP
-which is advisable in any case, since INTERCAL expressions
-are unreadable enough as is.
-.LP
-Since there is currently no catalogued procedure for
-invoking the compiler, the user must include the in-line
-procedure shown on the following page in his job before the
-compilation step. Copies of this in-line procedure may be
-obtained at any keypunch if the proper keys are struck.
-.LP
-The compiler is then executed in the usual manner:
-.LP
-.nf
-
- // EXEC INTERCAL[,PARM='parameters']
- //COMPILE.SYSIN DD *
- {INTERCAL source deck}
- /*
- //EXECUTE.SYSWRITE DD *
- {input data}
- /*
-
-.fi
-.LP
-The various parameters are described following the in-line
-procedure. At most one parameter from each set may apply to
-a given compilation; if more than one are specified, the
-results are undefined, and may vary depending upon the
-particular set of options. The default parameters are
-underlined.
-.bp
-.nf
- //INTERCAL PROC
- //COMPILE EXEC PGM=INTERCAL
- //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
- // DD DSN=SYS1.FORTLIB,DISP=SHR
- //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
- //SYSPUNCH DD DUMMY
- //SCRATCH DD DSN=&COMPSET,UNIT=SYSDA,SPACE=(CYL,(3,1)),DISP=(,PASS)
- //EXECUTE EXEC PGM=EXECUTE,COND=(4,LT) \**
- //SOURCES DD DSN=U.INTERCAL.SOURCES,DISP=SHR
- //STEPLIB DD DSN=U.INTERCAL.LIBRARY,DISP=SHR
- // DD DSN=SYS5.SPITLIB,DISP=SHR
- // DD DSN=SYS1.FORTLIB,DISP=SHR
- //SYSIN DD DSN=&COMPSET,DISP=(OLD,DELETE)
- //SYSOBJ DD SYSOUT=B,DCB=(BLKSIZE=80,LRECL=80,RECFM=F)
- //SYSPRINT DD SYSOUT=A,DCB=(BLKSIZE=992,LRECL=137,RECFM=VBA)
- //SYSPUNCH DD DUMMY
- // PEND
-.fi
-.FS
-Pending acquisition of SPITBOL release 3.0, the SOURCES
-DD card must be replaced by the five cards:
-.nf
- //NOOPTPFX DD DSN=U.INTERCAL.SOURCES(NOOPTPFX),DISP=SHR
- //NOOPTSUB DD DSN=U.INTERCAL.SOURCES(NOOPTSUB),DISP=SHR
- //OPTPFX DD DSN=U.INTERCAL.SOURCES(OPTPFX),DISP=SHR
- //OPTSUB DD DSN=U.INTERCAL.SOURCES(OPTSUB),DISP=SHR
- //PRELIM DD DSN=U.INTERCAL.SOURCES(PRELIM),DISP=SHR
-.fi
-.FE
-.ce 1
-Figure 3. Inline procedure for using INTERCAL.
-.LP
-.B OPT
-.br
-NOOPT
-.IP
-In the default mode, the compiler will print a
-list of all options in effect, including the
-defaults for unspecified parameter groups and the
-effective option for those sets where one was
-specified. If NOOPT is requested, it causes the
-default mode to be assumed.
-.LP
-.B OPTSUB
-.br
-NOOPTSUB
-.br
-NOSUB
-.IP
-Unless 'NOOPTSUB' is requested, the System Library
-is optimized, resulting in much more rapid
-NOSUB processing of function calls. Specifying NOOPTSUB
-causes the non-optimized INTERCAL code shown in
-section 6.3 to be used, whereas NOSUB requests
-that the System Library be omitted altogether.
-.LP
-IAMBIC
-.br
-.B PROSE
-.IP
-The IAMBIC parameter permits the programmer to use
-poetic license and thus write in verse. If the
-reader does not believe it possible to write verse
-in INTERCAL, he should send the authors a stamped,
-self-addressed envelope, along with any INTERCAL
-program, and they will provide one which is verse.
-.LP
-.B FORMAT
-.br
-NOFORMAT
-.IP
-In FORMAT mode, each statement printed is put on a
-separate line (or lines). In NOFORMAT mode, the
-free-format source is printed exactly as input.
-In this latter case, statement numbers are
-provided only for the first statement on a card,
-and they may be only approximate. Also,
-unrecognizable statements are not flagged.
-.LP
-SEQ
-.br
-.B NOSEQ
-.IP
-If the source deck has sequence numbers in columns
-73 through 80, specifying 'SEQ' will cause them to
-be ignored.
-.LP
-.B SOURCE
-.br
-NOSOURCE
-.IP
-If NOSOURCE is selected, all source listing is
-suppressed.
-.LP
-LIST
-.br
-.B NOLIST
-.IP
-If LIST is specified, the compiler will provide a
-list of statement numbers catalogued according to
-type of statement. The compiler uses this table
-to perform abstentions by gerund.
-.IP "WIDTH=nn"
-This sets the width (in number of characters) of
-the output line for FORMAT mode output. The
-default is
-.B 132.
-.LP
-CODE
-.br
-.B NOCODE
-.IP
-Include 'CODE' in the parameter list to obtain a
-listing of the SPITBOL code produced for each
-INTERCAL statement.
-.IP "LINES=nn"
-This determines the number of lines per page,
-during both compilation and execution. The
-default is
-.B 60.
-.LP
-DECK
-.br
-.B NODECK
-.IP
-Selecting 'DECK' will cause the compiler to punch
-out a SPITBOL object deck which may then be run
-without reinvoking the INTERCAL (or SPITBOL)
-compiler.
-.LP
-.B KIDDING
-.br
-NOKIDDING
-.IP
-Select NOKIDDING to eliminate the snide remarks
-which ordinarily accompany INTERCAL error
-messages.
-.LP
-.B GO
-.br
-NOGO
-.IP
-Specifying 'NOGO' will cause the program to be
-compiled but not executed. EXECUTE/NOEXECUTE may
-be substituted for GO/NOGO, but this will result
-in an error, and GO will be assumed.
-.LP
-.B BUG
-.br
-NOBUG
-.IP
-Under the default, there is a fixed probability of
-a fatal compiler bug being worked at random into
-the program being compiled. Encountering this bug
-during execution results in error message 774 (see
-section 7.2). This probability is reduced to zero
-under 'NOBUG'. This does not affect the
-probability (presumably negligible) of error
-message 778.
-.NH 2
-Other INTERCAL Compilers
-.LP
-There are no other INTERCAL compilers. \**
-.FS
-Note that this document pre-dates Eric Raymond's C-INTERCAL compiler, and
-an Atari implementation mentioned on the final page of this document.
-.FE
-.ds CH TONSIL A\**
-.bp
-.LP
-The Official INTERCAL Character Set
-.FS
-Since all other reference manuals have Appendices, it was decided that
-the INTERCAL manual should contain some other type of removable organ.
-.FE
-.nr * \n*+1
-.nr PG \n%+1
-.LP
-Tabulated on page \n(PG are all the characters used in INTERCAL, excepting
-letters and digits, along with their names and interpretations. Also
-included are several characters not used in INTERCAL, which are presented
-for completeness and to allow for future expansion.
-.FS
-This footnote intentionally unreferenced.
-.FE
-.ds CH - % -
-.bp
-.nr * \n*-1
-.TS
-box;
-c c c
-l l l.
-Character Name Use (if any)
-=
-\. spot identify 16-bit variable
-: two-spot identify 32-bit variable
-, tail identify 16-bit array
-; hybrid identify 32-bit array
-# mesh identify constant
-\&= half-mesh
-' spark grouper
-` backspark
-! wow equivalent to spark-spot
-? what \fIunary exlusive OR (ASCII)\fR
-" rabbit-ears grouper
-\o'".' rabbit equivalent to ears-spot
-| spike
-% double-oh-seven percentage qualifier
-\- worm used with angles
-< angle used with worms
-> right angle
-( wax precedes line label
-) wane follows line label
-[ U turn
-] U turn back
-{ embrace
-} bracelet
-* splat flags invalid statements
-& ampersand\** unary logical AND
-V V (or book) unary logical OR
-\*(vb bookworm (or universal qualifier) unary exclusive OR
-$ big money \fIbinary mingle (ASCII)\fR
-\(ct change binary mingle
-~ sqiggle binary select
-\&_ flat worm
-\(rn overline indicates "times 1000"
-+ intersection separates list items
-/ slat
-\e backslat
-@ whirlpool
-\(no hookworm
-^ shark (or simply sharkfin)
-\o"#*\(sq" blotch
-.TE
-.ce 1
-Table 2 (top view). INTERCAL character set.
-.FS
-Got any better ideas?
-.FE
-.ds CH NOTES ON THE ATARI IMPLEMENTATION
-.bp
-.LP
-The Atari implementation of INTERCAL differs from the original Princeton
-.ds CH INTERCAL
-version primarily in the use of ASCII rather than EBCDIC. Since there is no
-"change" sign (\(ct) in ASCII, we have substituted the "big money" ($) as the
-mingle operator. We feel that this correctly represents the increasing cost
-of software in relation to hardware. (Consider that in 1970 one could get
-RUNOFF for free, to run on a $20K machine, whereas today a not quite as
-powerful formatter costs $99 and runs on a $75 machine.) We also feel that
-there should be no defensible contention that INTERCAL has any sense.
-Also, since overpunches are difficult to read on the average VDT, the
-exclusive-or operator may be written ?. This correctly expresses the
-average person's reaction on first encountering exclusive-or, especially on
-a PDP-11. Note that in both of these cases, the over-punched symbol may
-also be used if one is masochistic, or concerned with portability to the
-Princeton compiler. The correct over-punch for "change" is "c<backspace>/"
-and the correct over-punch for \*(vb is "V<backspace>-". These codes will be
-properly printed if you have a proper printer, and the corresponding EBCDIC
-code will be produced by the /IBM option on the LIST command.
+++ /dev/null
-% -*- Mode: TeX -*-
-% for LaTeX
-
-% This is the file ick.sty: macros for typesetting the INTERCAL Manual.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% TO DO
-%
-
-% Document this thing.
-
-% Make ASCII->EBCDIC translation settable by a switch.
-
-% Is this how the rabbit is really supposed to look?
-
-% ``lines 192 and 193'' is wrong
-
-% ICverbatim environment
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% PAGE SIZE
-%
-
-\setlength{\textwidth}{6.5in}
-\setlength{\oddsidemargin}{0in}
-\setlength{\evensidemargin}{0in}
-\setlength{\textheight}{9in}
-\setlength{\topmargin}{0in}
-\setlength{\headsep}{0in}
-\setlength{\headheight}{0in}
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% TONSILS
-%
-
-\def\tonsil#1#2{\section*{Tonsil #1: #2}%
- \addtonsilline{#1}{#2}}
-
-\def\addtonsilline#1#2{\addcontentsline{toc}{section}{\protect\numberline{#1}#2}}
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% SPECIAL INTERCAL CHARACTERS
-%
-
-% Save ``regular'' characters.
-\def\backslat{\backslash}
-\def\embrace{\verb|{|}
-\def\bracelet{\verb|}|}
-\def\doubleohseven{\%}
-\def\ampersand{\&}
-\def\sqiggle{\~{}}
-\def\bigmoney{\$}
-\def\shark{\verb|^|}
-\def\flatworm{\verb|_|}
-\def\mesh{\#}
-\def\spot{.}
-\def\what{?}
-
-% \newcommand{\mathify}[1]{\ifmmode{#1}\else\mbox{$#1$}\fi}
-% \def\bookworm{\mathify{\forall}}
-\def\bookworm{\rlap V-}
-\def\change{\rlap c/}
-\def\Change{\change}
-%\def\altchange{\rlap /c}
-\def\zero{\={}}
-\def\spike{\verb+|+}
-\def\althookworm{-\llap '}
-\def\hookworm{'\llap -}
-\def\blotch{\#\llap I\llap [\llap ]}
-\def\blotCh{\blotch}
-\def\rabbit{\rlap".}
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% INTERCAL CODE ENVIRONMENT
-%
-
-% Just surround the code with vertical bars.
-
-\catcode`|=\active % The `|' is active from now on.
-\def|{\ifmmode\vert%
- \else\bgroup\tt\usespecials\def|{\null\egroup}%
- \fi}
-
-% True if $ and c should become \change, and ? should become \bookworm
-\newif\ifasciitoebcdic
-
-\def\activateebcdicspecials{%
- \catcode`$=\active
- \catcode`?=\active
- \catcode`c=\active}
-
-% I think these need to be global
-\def\Change{\change}
-\def\ativateebdispeials{\activateebcdicspecials}
-{% Now blow away the lowercase c.
- \activateebcdicspecials
- \gdef\useebdispeials{%
- \def${\Change}%
- \defc{\Change}%
- \def?{\bookworm}%
- \ativateebdispeials}}
-
-\def\useebcdicspecials{\useebdispeials}
-\def\useebcdicspecialsmaybe{\ifasciitoebcdic\useebcdicspecials\fi}
-
-
-% To get backslat, embrace, or bracelet in a | | environment, use the
-% respective macros.
-\def\activatespecials{%
- \catcode`\%=\active
- \catcode`\&=\active
- \catcode`\~=\active
- \catcode`\$=\active
- \catcode`\^=\active
- \catcode`\_=\active
- \catcode`\#=\active}
-
-{% Add new comment character
- \catcode`+=14
- \activatespecials
- \gdef\usespecials{+
- \activatespecials
- \def%{\doubleohseven}+
- \def&{\ampersand}+
- \def~{\sqiggle}+
- \def${\bigmoney}+
- \def^{\shark}+
- \def_{\flatworm}+
- \def#{\mesh}+
- \useebcdicspecialsmaybe}}
-
-
-% Typeset a one-line INTERCAL example. This is pretty gross.
-\def\IConeline#1{\vspace\topsep\par\noindent{\tt\ \ \ \ \ \ \ \ }#1\vspace\topsep}
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% VERBATIM FILE LISTING
-%
-
-% --- The macros are based on those distributed with Sunil Podar's
-% --- `EPIC.STY' macro package, attributed to Tim Morgan,
-% --- modified to keep internal macros internal by Adrian F. Clark,
-% --- alien@uk.ac.essex.ese
-% --- ---and further latexification by Chris Rowley,
-% --- ca_rowley@uk.ac.open.acs.vax.
-% And finally, ever-so-slightly modified for INTERCAL by Michael Ernst.
-
-\def\verbatimfile#1{\begingroup
- \@verbatim \frenchspacing \@vobeyspaces
- \input#1 \endgroup
-}
-
-\newcounter{lineno}
-
-\newif\ifcontinuationchar
-% Say \continuationchartrue if the ends of continued program lines are
-% flagged by slash-newline.
-% This implementation doesn't allow backslashes elsewhere; it would be
-% better to make \, clobbered by \@verbatim, the escape character again,
-% and then define a whole wad of escape sequences, with \^^M being one.
-
-\newif\ifnonumber % True if the next line shouldn't be numbered.
-
-%\def\activateverbspecials{%
-% \catcode`$=\active
-% \catcode`?=\active}
-
-{%\activateverbspecials
- \catcode`|=0
- \catcode`\\=\active
- |gdef|useverbspecials{%
- |def\{|nonumbertrue}%
- |useebcdicspecialsmaybe}}
-% |def${|change}%
-% |def?{|bookworm}%
-% |activateverbspecials}}
-
-\def\ICverbatimlisting#1{\setcounter{lineno}{0}%
- \begingroup \@verbatim \frenchspacing \@vobeyspaces \parindent=20pt
- \everypar{\ifnonumber\nonumberfalse
- \else\stepcounter{lineno}%
- \llap{{\footnotesize\rm\thelineno\ \ \ }}%
- \fi}%
- \ifcontinuationchar\catcode`\\=\active\fi
- \useverbspecials
- \input#1
- \endgroup
-}
+++ /dev/null
-% -*- Mode: TeX -*-
-% for LaTeX
-\documentstyle[intercal]{article}
-
-\title{ The INTERCAL Programming Language \\
- Reference Manual}
-\author{ Donald R. Woods \& James M. Lyon}
-\date{ Copyright Donald R. Woods \& James M. Lyon 1973}
-
-% Online version provided by Ken Johnson (ken@aiai.ed.ac.uk)
-% Corrected and typeset by Michael Ernst (mernst@theory.lcs.mit.edu), with
-% help from the global INTERCAL community.
-% Please send corrections to Michael Ernst (mernst@theory.lcs.mit.edu).
-% If you don't have TeX, and so can't format this manual, I will send you
-% the postscript version. If you have neither TeX nor Postscript, I'm
-% afraid I can't help you.
-
-% sample.i and syslib.i use the continuation character convention
-\continuationchartrue
-% Convert c,$ => \change and ? => \bookworm
-\asciitoebcdictrue
-
-
-\begin{document}
-
-\maketitle
-\thispagestyle{empty}
-\newpage
-
-\tableofcontents
-\thispagestyle{empty}
-\newpage
-\setcounter{page}{1}
-
-\section{Introduction}
-
-The names you are about to ignore are true. However, the story has been
-changed significantly. Any resemblance of the programming language
-portrayed here to other programming languages, living or dead, is purely
-coincidental.
-
-\subsection{Origin and Purpose}
-
-The INTERCAL programming language was designed the morning of May 26, 1972
-by Donald R. Woods and James M. Lyon, at Princeton University. Exactly
-when in the morning will become apparent in the course of this manual. It
-was inspired by one ambition; to have a compiler language which has nothing
-at all in common with any other major language. By ``major'' was meant
-anything with which the authors were at all familiar, e.g., FORTRAN, BASIC,
-COBOL, ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PL/I.
-For the most part, INTERCAL has remained true to this goal, sharing only
-the basic elements such as variables, arrays, and the ability to do I/O,
-and eschewing all conventional operations other than the assignment
-statement (FORTRAN ``|=|'').
-
-\subsection{Acronym}
-
-The full name of the compiler is ``Compiler Language With No Pronounceable
-Acronym,'' which is, for obvious reasons, abbreviated ``INTERCAL.''
-
-\subsection{Acknowledgments}
-
-The authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,
-without whose unwitting assistance this manual would still have been
-possible.
-
-
-\f
-
-
-
-
-
-\section{Fundamental Concepts}
-
-In this section an attempt is made to describe how and why INTERCAL may be
-used; i.e., what it is like and what it is good for.
-
-\subsection{Sample Program}
-
-Shown below is a relatively simple INTERCAL program which will read in
-32-bit unsigned integers, treat them as signed, 2's-complement numbers, and
-print out their absolute values. The program exits if the absolute value
-is zero. Note in particular the inversion routine (statements 6 through
-14), which could be greatly simplified if the subroutine library (see
-section 5) were used.
-
-A more detailed analysis of a program is made in section 6 of this manual.
-
-\ICverbatimlisting{sample.i}
-
-
-\subsection{Uses For INTERCAL}
-
-INTERCAL's main advantage over other programming languages is its strict
-simplicity. It has few capabilities, and thus there are few restrictions
-to be kept in mind. Since it is an exceedingly easy language to learn, one
-might expect it would be a good language for initiating novice programmers.
-Perhaps surprising, than, is the fact that it would be more likely to
-initiate a novice into a search for another line of work. As it turns out,
-INTERCAL is more useful (which isn't saying much) as a challenge to
-professional programmers. Those who doubt this need only refer back to the
-sample program in section 2.1. This 22-statement program took somewhere
-from 15 to 30 minutes to write, whereas the same objectives can be achieved
-by single-statement programs in either SNOBOL;
-
-\begin{verbatim}
- PLEASE INPUT POS(0) ('-' ! '')
- + (SPAN('0123456789') $ OUTPUT)
- + *NE(OUTPUT) :S(PLEASE)F(END)
-\end{verbatim}
-\noindent or APL;
-
-\IConeline{|[1] >\llap -0=\llap /?<\llap -?|}
-
-Admittedly, neither of these is likely to appear more intelligible to
-anyone unfamiliar with the languages involved, but they took roughly 60
-seconds and 15 seconds, respectively, to write. Such is the overwhelming
-power of INTERCAL!
-
-The other major importance of INTERCAL lies in its seemingly inexhaustible
-capacity for amazing one's fellow programmers, confounding programming shop
-managers, winning friends, and influencing people. It is a well-known and
-oft-demonstrated fact that a person whose work is incomprehensible is held
-in high esteem. For example, if one were to state that the simplest way to
-store a value of 65536 in a 32-bit INTERCAL variable is:
-
-\begin{verbatim}
- DO :1 <- #0$#256
-\end{verbatim}
-any sensible programmer would say that that was absurd. Since this is
-indeed the simplest method, the programmer would be made to look foolish in
-front of his boss, who would of course happened to turn up, as bosses are
-wont to do. The effect would be no less devastating for the programmer
-having been correct.
-
-\f
-
-
-
-
-
-\section{Description}
-
-The examples of INTERCAL programming which have appeared in the preceding
-sections of this manual have probably seemed highly esoteric to the reader
-unfamiliar with the language. With the aim of making them more so, we
-present here a description of INTERCAL.
-
-
-\subsection{Variables}
-
-INTERCAL allows only 2 different types of variables, the 16-bit integer
-and the 32-bit integer. These are represented by a spot (|.|) or two-spot
-(|:|), respectively, followed by any number between 1 and 65535, inclusive.
-These variables may contain only non-negative numbers; thus they have the
-respective ranges of values: 0 to 65535 and 0 to 4294967295. Note: |.123|
-and |:123| are two distinct variables. On the other hand, |.1| and |.0001|
-are identical. Furthermore, the latter may {\em not} be written as |1E-3|.
-
-\subsection{Constants}
-
-Constants are 16-bit values only and may range from 0 to 65535. They are
-prefixed by a mesh (|#|). Caution! Under no circumstances confuse the mesh
-with the interleave operator, except under confusing circumstances!
-
-\subsection{Arrays}
-
-Arrays are represented by a tail (|,|) for 16-bit values, or a hybrid (|;|)
-for 32-bit values, followed by a number between 1 and 65535, inclusive.
-The number is suffixed by the word |SUB|, followed by the subscripts,
-separated optionally by spaces. Subscripts may be any expressions,
-including those involving subscripted variables. This occasionally leads
-to ambiguous constructions, which are resolved as discussed in section
-3.4.3. Definition of array dimensions will be discussed later in greater
-detail, since discussing it in less detail would be difficult. As before,
-|,123| and |;123| are distinct. In summary, |.123|, |:123|, |#123|,
-|,123|, and |:123| are all distinct.
-
-\subsection{Operators}
-
-INTERCAL recognizes 5 operators---2 binary and 3 unary. Please be kind to
-our operators: they may not be very intelligent, but they're all we've got.
-In a sense, all 5 operators are binary, as they are all bit-oriented, but
-it is not our purpose here to quibble about bits of trivia.
-
-
-\f
-% ******* proofread versus the paper copy only this far !!!! ************
-
-
-
-
-\subsubsection{Binary Operators}
-
-The binary operators are {\sl interleave} (also called {\sl mingle}) and
-{\sl select}, which are represented by a change (|$|) and a sqiggle
-(|~|), respectively.
-
-The interleave operator takes two 16-bit values and produces a 32-bit
-result by alternating the bits of the operands. Thus, |#65535c#0| has the
-32-bit binary form 101010....10 or 2863311530 decimal, while |#0c#65535| =
-0101....01 binary = 1431655765 decimal, and |#255c#255| is equivalent to
-|#65535|.
-
-The select operator takes from the first operand whichever bits correspond
-to 1's in the second operand, and packs these bits to the right in the
-result. Both operands are automatically padded on the left with zeros to
-32 bits before the selection takes place, so the variable types are
-unrestricted. If more than 16 bits are selected, the result is a 32-bit
-value, otherwise it is a 16-bit value. For example, |#179~#201| (binary
-value 10110011|~|11001001) selects from the first argument the 8th, 7th,
-4th, and 1st from last bits, namely, 1001, which = 9. But |#201~#179|
-selects from binary 11001001 the 8th, 6th, 5th, 2nd, and 1st from last
-bits, giving 10001 = 17. |#179~#179| has the value 31, while |#201~#201|
-has the value 15.
-
-Perhaps a simpler way of understanding the operation of the select operator
-would be to examine the logic diagram on the following page (Figure 1),
-which performs the select operation upon two 8-bit values, A and B. The
-gates used are Warmenhovian logic gates, which means the outputs have four
-possible values: low, high, undefined (value of an uninitialized
-flip-flop), and oscillating (output of a NOR gate with one input low and
-the other input connected to the output). These values are represented
-symbolically by '|0|', '|1|', '{\tt ?}', and '|F|'. Note in particular that,
-while NOT-|0| is |1| and NOT-|1| is |0| as in two-valued logic, NOT-{\tt ?} is
-{\tt ?} and NOT-|F| is |F|. The functions of the various gates are listed in
-Table 1.
-\stepcounter{table}
-
-
-\f
-
-
-
-
-
-\subsubsection{Unary Operators}
-
-The unary operators are |&| (logical AND), |V| (logical OR), and
-|\bookworm| (logical XOR). This last character is obtained by overpunching
-a worm (|-|) on a V (|V|). The operator is inserted between the spot,
-two-spot, mesh, or what-have-you, and the integer, thus: |.&123|, |#V123|.
-Multiple unary operators may not be concatenated, thus the form |#V&123| is
-invalid. This will be covered later when precedence is discussed. These
-operators perform their respective logical operations on all pairs of
-adjacent bits, the result from the first and last bits going into the first
-(most significant) bit of the result. The effect is that of rotating the
-operand one place to the right and ANDing, ORing, or XORing with its
-initial value. Thus, |#&77| (|#77| = binary 1001101) is binary 0000000000000100
-= 4, |#V77| is binary 1000000001101111 = 32879, and |#?77| is binary
-1000000001101011 = 32875.
-
-\subsubsection{Precedence}
-
-Precedence of operators is as follows:\footnote{Keep in mind that the aim in designing INTERCAL was to have no
-precedents.}
-\stepcounter{footnote}
-
-
-% \vspace{2 in}
-% \hspace{4 in}
-% \footnote{Keep in mind that the aim in designing INTERCAL was to have no
-% precedents.}
-% \stepcounter{footnote}
-% \vspace{1 in}
-% (The remainder of this page intentionally left blank.)
-
-\vfill
-(The remainder of this page intentionally left blank.)
-\newpage
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-\f
-
-
-
-%% This manual only strictly checked up to (but not including) the 34815.
-
-This precedence (or lack thereof) may be overruled by grouping expressions
-between pairs of sparks (|'|) or rabbit-ears (|"|). Thus
-|'#165c#203'~#358| (binary value |'|10100101|c|11001011|'~|101100110) has
-the value 15, but |#165c'#203~#358'| has the value 34815, and
-|#165c#203~#358| is invalid syntax and is completely valueless (except
-perhaps as an educational tool to the programmer). A unary operator is
-applied to a sparked or rabbit-eared expression by inserting the operator
-immediately following the opening spark or ears. Thus, the invalid
-expression |#V&123|, which was described earlier, could be coded as
-|'V#&123'| or |'V"{"'|. Note: In the interests of simplifying the
-sometimes overly-complex form of expressions, INTERCAL allows a spark-spot
-combination (|'.|) to be replaced with a wow (|!|). Thus |'.1~.2'| is
-equivalent to |!1~.2'|, and |'V.1c.2'| is equivalent to |"V!1c.2'"|.
-%\typeout{Note that unary ops must go INSIDE delimiters!}
-
-Combining a rabbit-ears with a spot to form a rabbit (|\rabbit|)
-is not permitted, although the programmer is free to use it should he find
-an EBCDIC reader which will properly translate a 12-3-7-8 punch.
-
-Sparks and/or rabbit-ears must also be used to distinguish among such
-otherwise ambiguous subscripted and multiply-subscripted expressions as:
-
-\begin{verbatim}
- ,1 SUB #1 ~ #2
- ,1 SUB ,2 SUB #1 #2 #3
- ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "
-\end{verbatim}
-
-The third case may be isolated into either of its possible interpretations
-by simply changing some pairs of rabbit-ears to sparks, instead of adding
-more ears (which would only confuse the issue further). Ambiguous cases
-are defined as those for which the compiler being used finds a legitimate
-interpretation which is different from that which the user had in mind.
-See also section 8.1.
-
-
-
-
-
-
-\section{Statements}
-
-In this section is described the format of INTERCAL statements.
-
-\subsection{General Format}
-
-Statements may be entered in ``free format.'' That is, more than one
-statement may occur on a single card, and a statement may begin on one card
-and end on a later one. Note that if this is done, all intervening cards
-and portions thereof must be part of the same statement. That this
-restriction is necessary is immediately apparent from the following example
-of what might occur if statements could be interlaced.
-
-\begin{verbatim}
- DO .1 <- ".1c'&:51~"#V1c!12~;&75SUB"V'V.1~
- DO .2 <- '"!1c"&';V79SUB",&7SUB:173"'~!V9c
- .2'c,&1SUB:5~#33578"'"'"~'#65535c"V'V#&85'"'
- #8196'"'~.1"c.2'~'#&5c"'#1279c#4351'~#65535"'
-\end{verbatim}
-The above statements are obviously meaningless. (For that matter, so are
-the statements
-
-\begin{verbatim}
- DO .1 <- ".1c"&:51~"#V1c!12~;&75SUB"V'V.1~
- .2'C,&1SUB:5~/333578"'"'"~#65535c"V'V#&85'"'
- DO .2 <- '"!1c"&';V79SUB",&7SUB:173"'~!V9c
- #8196'"'~.1"c.2'~'#&5c"'#1279c!4351'~#65535"'
-\end{verbatim}
-but this is not of interest here.)
-
-Spaces may be used freely to enhance program legibility (or at least reduce
-program illegibility), with the restriction that no word of a statement
-identifier (see section 4.3) may contain any spaces.
-
-\subsection{Labels}
-
-A statement may begin with a {\sl logical line label} enclosed in wax-wane pairs
-(|()|). A statement may not have more than one label, although it is
-possible to omit the label entirely. A line label is any integer from 1 to
-65535, which must be unique within each program. The user is cautioned,
-however, that many line labels between 1000 and 1999 are used in the
-INTERCAL System Library functions.
-
-\subsection{Identifiers and Qualifiers}
-
-After the line label (if any), must follow one of the following statement
-identifiers: |DO|, |PLEASE|, or |PLEASE DO|. These may be used
-interchangeably to improve the aesthetics of the program. The identifier
-is then followed by either, neither, or both of the following optional
-parameters (qualifiers):
-\begin{enumerate}
-\item either of the character strings |NOT| or |N'T|, which causes the statement
-to be automatically abstained from (see section 4.4.9) when execution
-begins, and
-\item a number between 0 and 100, preceded by a double-oh-seven
-(|%|), which causes the statement to have only the specified percent chance
-of being executed each time it is encountered in the course of execution.
-\end{enumerate}
-
-\f
-
-
-
-
-
-\subsection{Statements}
-
-Following the qualifiers (or, if none are used, the identifier) must occur
-one of the 13 valid operations. (Exception: see section 4.5.) These are
-described individually in sections 4.4.1 through 4.4.13.
-
-\subsubsection{Calculate}
-
-The INTERCAL equivalent of the half-mesh (|=|) in FORTRAN, BASIC, PL/I, and
-others, is represented by an angle (|<|) followed by a worm (|-|). This
-combination is read ``gets.'' 32-bit variables may be assigned 16-bit
-values, which are padded on the left with 16 zero bits. 16-bit variables
-may be assigned 32-bit values only if the value is less than 65535. Thus,
-to invert the least significant bit of the first element of 16-bit
-2-dimensional array number 1, one could write:
-
-\begin{verbatim}
- ,1SUB#1#1 <- 'V,1SUB#1#1c#1'~'#0c#65535'
-\end{verbatim}
-
-Similarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define the
-dimensions of arrays. An example will probably best describe the format.
-To define 32-bit array number 7 as 3-dimensional, the first dimension being
-seven, the second being the current value of 16-bit variable number seven,
-and the third being the current value of the seventh element of 16-bit
-array number seven (which is one-dimensional) mingled with the last three
-bits of 32-bit variable number seven, one would write (just before they
-came to take him away):
-
-\begin{verbatim}
- ;7 <- #7 BY .7 BY ",7SUB#7"c':7~#7'
-\end{verbatim}
-This is, of course, different from the statement:
-
-\begin{verbatim}
- ;7 <- #7 BY .7 BY ,7SUB"#7c':7~#7'"
-\end{verbatim}
-
-INTERCAL also permits the redefining of array dimensioning, which is done
-the same way as is the initial dimensioning. All values of items in an
-array are lost upon redimensioning, unless they have been |STASH|ed (see
-section 4.4.5), in which case restoring them also restores the old
-dimensions.
-
-\f
-
-
-
-
-
-\subsubsection{Next}
-
-The |NEXT| statement is used both for subroutine calls and for
-unconditional transfers. This statement takes the form:
-
-\IConeline{|DO ({\em label}) NEXT|}
-
-\noindent
-(or, of course,
-\IConeline{|PLEASE DO ({\em label}) NEXT|}
-
-\noindent
-etc.), where |({\em label})| represents any logical line label which
-appears in the program. The effect of such a statement is to transfer
-control to the statement specified, and to store in a push down list (which
-is initially empty) the location from which the transfer takes place.
-Items may be removed from this list and may be discarded or used to return
-to the statement immediately following the |NEXT| statement. These
-operations are described in sections 4.4.3 and 4.4.4 respectively. The
-programmer is generally advised to discard any stack entries which he does
-not intend to utilize, since the stack has a maximum depth of 79 entries.
-A program's attempting to initiate an 80th level of |NEXT|ing will result
-on the fatal error message, ``PROGRAM HAS DISAPPEARED INTO THE BLACK
-LAGOON.''
-
-\subsubsection{Forget}
-
-The statement |PLEASE FORGET| {\em exp}, where {\em exp} represents any
-expression (except colloquial and facial expressions), causes the
-expression to be evaluated, and the specified number of entries to be
-removed from the |NEXT|ing stack and discarded. An attempt to |FORGET|
-more levels of |NEXT|ing than are currently stacked will cause the stack to
-be emptied, and no error condition is indicated. This is because the
-condition is not considered to be an error. As described in section 4.4.2,
-it is good programming practice to execute a |DO FORGET #1| after using a
-|NEXT| statement as an unconditional transfer, so that the stack does not
-get cluttered up with unused entries:
-
-\begin{verbatim}
- DO (123) NEXT
- .
- .
- (123) DO FORGET #1
-\end{verbatim}
-
-\subsubsection{Resume}
-
-The statement |PLEASE RESUME| {\em exp} has the same effect as |FORGET|,
-except that program control is returned to the statement immediately
-following the |NEXT| statement which stored in the stack the last entry to
-be removed. Note that a rough equivalent of the FORTRAN computed |GO TO|
-and BASIC |ON| {\em exp} |GO TO| is performed by a sequence of the form:
-
-\begin{verbatim}
- DO (1) NEXT
- .
- .
- (1) DO (2) NEXT
- PLEASE FORGET #1
- .
- .
- (2) DO RESUME .1
-\end{verbatim}
-
-Unlike the |FORGET| statement, an attempt to |RESUME| more levels of
-|NEXT|ing than been stacked will cause program termination. See also
-section 4.4.11.
-
-
-\subsubsection{Stash}
-
-Since subroutines are not explicitly implemented in INTERCAL, the |NEXT|
-and |RESUME| statements must be used to execute common routines. However,
-as these routines might use the same variables as the main program, it is
-necessary for them to save the values of any variables whose values they
-alter, and later restore them. This process is simplified by the |STASH|
-state ment, which has the form |DO STASH| {\em list}, where {\em list}
-represents a string of one or more variable or array names, separated by
-intersections (|+|). Thus
-
-\begin{verbatim}
- PLEASE STASH .123+:123+,123
-\end{verbatim}
-stashes the values of two variables and one entire array. The values are
-left intact, and copies thereof are saved for later retrieval by (what
-else?) the |RETRIEVE| statement (see section 4.4.6). It is not possible
-to |STASH| single array items.
-
-\subsubsection{Retrieve}
-
-|PLEASE RETRIEVE| {\em list} restores the previously |STASH|ed values of
-the variables and arrays named in the list. If a value has been
-stashed more than once, the most recently |STASH|ed values are |RETRIEVE|d,
-and a second |RETRIEVE| will restore the second most recent values
-|STASH|ed. Attempting to |RETRIEVE| a value which has not been |STASH|ed
-will result in the error message, ``THROW STICK BEFORE RETRIEVING.''
-
-\subsubsection{Ignore}
-
-The statement |DO IGNORE| {\em list} causes all subsequent statements to
-have no effect upon variables and/or arrays named in the list. Thus, for
-example, after the sequence
-
-\begin{verbatim}
- DO .1 <- #1
- PLEASE IGNORE .1
- DO .1 <- #0
-\end{verbatim}
-16-bit variable number 1 would have the value 1, not 0. Inputting (see
-section 4.4.12) into an |IGNORE|d variable also has no effect. The
-condition is annulled via the |REMEMBER| statement (see section 4.4.8).
-Note that, when a variable is being |IGNORE|d, its value, though immutable,
-is still available for use in expressions and the like.
-
-\subsubsection{Remember}
-
-|PLEASE REMEMBER| {\em list} terminates the effect of the |IGNORE|
-statement for all variables and/or arrays named in the list. It does not
-matter if a variable has been |IGNORE|d more than once, nor is it an error
-if the variable has not been |IGNORE|d at all.
-
-\subsubsection{Abstain}
-
-INTERCAL contains no simple equivalent to an |IF| statement or computed |GO
-TO|, making it difficult to combine similar sections of code into a single
-routine which occasionally skips around certain statements. The |IGNORE|
-statement (see section 4.4.7) is helpful in some cases, but a more viable
-method is often required. In keeping with the goal of INTERCAL having
-nothing in common with any other language, this is made possible via the
-|ABSTAIN| statement.
-
-This statement takes on one of two forms. It may not take on both at any
-one time. |DO ABSTAIN FROM ({\em label})| causes the statement whose
-logical line label is |({\em label})| to be abstained form. |PLEASE
-ABSTAIN FROM| {\em gerund list} causes all statements of the specified
-type(s) to be abstained from, as in
-
-\begin{verbatim}
- PLEASE ABSTAIN FROM STASHING
- PLEASE ABSTAIN FROM IGNORING + FORGETTING
- PLEASE ABSTAIN FROM NEXTING
- PLEASE ABSTAIN FROM CALCULATING
-\end{verbatim}
-
-
-Statements may also be automatically abstained from at the start of
-execution via the |NOT| or |N'T| parameter (see section 4.3).
-
-
-If, in the course of execution, a statement is encountered which is being
-abstained from, it is ignored and control passes to the next statement in
-the program (unless it, too, is being abstained from).
-
-The statement |DO ABSTAIN FROM ABSTAINING| is perfectly valid, as is |DO
-ABSTAIN FROM REINSTATING| (although this latter is not usually
-recommended). However, the statement |DO ABSTAIN FROM GIVING UP| is not
-accepted, even though |DON'T GIVE UP| is.
-
-\subsubsection{Reinstate}
-\newlength{\QEDlen}\settowidth{\QEDlen}{Q.E.D.}\newlength{\lastlinelen}
-\settowidth{\lastlinelen}{Since $x+y$ cannot equal anything but 0, $x+y=0$.}
-\addtolength{\lastlinelen}{-1\QEDlen}
-
-The |REINSTATE| statement, like the |ABSTAIN|, takes as an argument either
-a line label or a gerund list. No other form of argument is permitted.
-For example, the following is an invalid argument:
-\begin{quote}
- Given: $x\neq0$, $y\neq0$, Prove: $x+y=0$. \\
- Since $x\neq0$, then $x+1\neq1$, $x+a\neq a$, $x+y\neq y$. \\
- Thus $x+y \neq$ anything but 0. \\
- Since $x+y$ cannot equal anything but 0, $x+y=0$. \\
- \hspace*{\lastlinelen} Q.E.D.
-\end{quote}
-
-|REINSTATE|ment nullifies the effects of an abstention. Either form of
-|REINSTATE|ment can be used to ``free'' a statement, regardless of whether
-the statement was abstained from by gerund list, line label, or |NOT|.
-Thus, |PLEASE REINSTATE REINSTATING| is not necessarily an irrelevant
-statement, since it might free a |DON'T REINSTATE| command or a |REINSTATE|
-the line label of which was abstained from. However, |DO REINSTATE GIVING
-UP| is invalid, and attempting to |REINSTATE| a |GIVE UP| statement by line
-label will have no effect. Note that this insures that |DON'T GIVE UP|
-will always be a ``do-nothing'' statement.
-
-\subsubsection{Give Up}
-
-|PLEASE GIVE UP| is used to exit from a program. It has the effect of a
-|PLEASE RESUME #80|. |DON'T GIVE UP|, as noted in section 4.4.10, is
-effectively a null statement.
-
-\subsubsection{Input}
-
-Input is accomplished with the statement |DO WRITE IN| {\em list}, where
-{\em list} represents a string of variables and/or elements or arrays,
-separated by intersections. Numbers are represented on cards, each number
-on a separate card, by spelling out each digit (in English) and separating
-the digits with one or more spaces. A zero (0) may be spelled as either
-|ZERO| or |OH|. Thus the range of (32-bit) input values permissible
-extends from |ZERO| (or |OH|) through |FOUR TWO NINE FOUR NINE SIX SEVEN
-TWO NINE FIVE|.
-
-Attempting to write in a value greater than or equal to |SIX FIVE FIVE
-THREE SIX| for a 16-bit variable will result in the error message, ``DON'T
-BYTE OFF MORE THAN YOU CAN CHEW.''
-
-\subsubsection{Output}
-
-Values may be output to the printer, one value per line, via the statement
-|DO READ OUT| {\em list}, where the list contains variables, array
-elements, and/or constants. Output is in the form of ``extended'' Roman
-numerals (also called ``butchered'' Roman numerals), with an overline
-(\zero) indicating the value below is ``times 1000,'' and lower-case
-letters indicating ``times 1000000.'' Zero is indicated by an overline
-with no character underneath. Thus, the range of (32-bit) output values
-possible is from \zero\ through \=i\=vccxciv\=C\=M\=L\=X\=V\=I\=ICCXCV.
-Note: For values whose residues modulo 1000000 are less than 4000, M is
-used to represent 1000; for values whose residues are 4000 or greater, \=I
-is used. Thus |#3999| would read out as MMMIM while |#4000| would read out
-as \=I\=V. Similar rules apply to the use of \=M and i for 1000000, and to
-that of \=m and \=i for 1000000000.
-
-% \typeout{Do they mean MMMIM and not MMMCMXCIX??}
-
-\f
-
-
-
-
-
-\subsection{Comments}
-
-Unrecognizable statements, as noted in section 7, are flagged with a splat
-(|*|) during compilation, and are not considered fatal errors unless they
-are encountered during execution, at which time the statement (as input at
-compilation time) is printed and execution is terminated. This allows for
-an interesting (and, by necessity, unique) means of including comments in
-an INTERCAL listing. For example, the statement:
-
-\begin{verbatim}
-* PLEASE NOTE THAT THIS LINE HAS NO EFFECT
-\end{verbatim}
-will be ignored during execution due to the inclusion of the NOT qualifier.
-User-supplied error messages are also easy to implement:
-
-\begin{verbatim}
-* DO SOMETHING ABOUT OVERFLOW IN ;3
-\end{verbatim}
-as are certain simple conditional errors:
-
-\begin{verbatim}
-* (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED
- ONCE?
- PLEASE REINSTATE (123)
-\end{verbatim}
-This pair of statements will cause an error exit the second time they are
-encountered. Caution!! The appearance of a statement identifier in an
-intended comment will be taken as the beginning of a new statement. Thus,
-the first example on the preceding page could not have been:
-
-\begin{verbatim}
-* PLEASE NOTE THAT THIS LINE DOES NOTHING
-\end{verbatim}
-The third example, however, is valid, despite the appearance of two cases
-of |D|-space-|O|, since INTERCAL does not ignore extraneous spaces in
-statement identifiers.
-\f
-
-
-
-
-
-\section{Subroutine Library}
-
-INTERCAL provides several built-in subroutines to which control can be
-transferred to perform various operations. These operations include many
-useful functions which are not easily representable in INTERCAL, such as
-addition, subtraction, etc.
-
-\subsection{Usage}
-
-In general, the operands are |.1|, |.2|, etc., or |:1|, |:2|, etc., and the
-result(s) are stored in what would have been the next operand(s). For
-instance, one routine adds |.1| to |.2| and store the sum in |.3|, with
-|.4| being used to indicate overflow. All variables not used for results
-are left unchanged.
-
-\subsection{Available Functions}
-
-At the time of this writing, only the most fundamental operations are
-offered in the library, as a more complete selection would require
-prohibitive time and coree to implement. These functions, along with their
-corresponding entry points (entered via |DO ({\em entry}) NEXT|) are listed
-below.
-
-\begin{verbatim}
- (1000) .3 <- .1 plus .2, error exit on overflow
- (1009) .3 <- .1 plus .2
- .4 <- #1 if no overflow, else .4 <- #2
- (1010) .3 <- .1 minus .2, no action on overflow
- (1020) .1 <- .1 plus #1, no action on overflow
- (1030) .3 <- .1 times .2, error exit on overflow
- (1039) .3 <- .1 times .2
- .4 <- #1 if no overflow, else .4 <- #2
- (1040) .3 <- .1 divided by .2
- .3 <- #0 if .2 is #0
- (1050) .2 <- :1 divided by .1, error exit on overflow
- .2 <- #0 if .1 is #0
-
- (1500) :3 <- :1 plus :2, error exit on overflow
- (1509) :3 <- :1 plus :2
- :4 <- #1 if no overflow, else :4 <- #2
- (1510) :3 <- :1 minus :2, no action on overflow
- (1520) :1 <- .1 concatenated with .2
- (1525) This subroutine is intended solely for internal
- use within the subroutine library and is therefore
- not described here. Its effect is to shift .3
- logically 8 bits to the left.
- (1530) :1 <- .1 times .2
- (1540) :3 <- :1 times :2, error exit on overflow
- (1549) :3 <- :1 times :2
- :4 <- #1 if no overflow, else :4 <- #2
- (1550) :3 <- :1 divided by :2
- :3 <- #0 if :2 is #0
-
- (1900) .1 <- uniform random no. from #1 to #65535
- (1910) .2 <- normal random no. from #0 to .1, with
- standard deviation .1 divided by #12
-\end{verbatim}
-
-\f
-
-
-
-
-
-\section{Programming Hints}
-
-For the user looking to become more familiar with the INTERCAL language, we
-present in this section an analysis of a complex program, as well as some
-suggested projects for the ambitious programmer.
-
-Considering the effort involved in writing an INTERCAL program, it was
-decided in putting together this manual to use an already existing program
-for instructive analysis. Since there was only one such program available,
-we have proceeded to use it. It is known as the ``INTERCAL System Library.''
-
-\subsection{Description}
-
-The program listing begins on the second page following. It is in the same
-format as would be produced by the Princeton INTERCAL compiler in FORMAT
-mode with WIDTH=62 (see section 8). For a description of the functions
-performed by the Library, see section 5.2.
-
-\subsection{Analysis}
-
-We shall not attempt to discuss here the algorithms used, but rather we
-shall point out some of the general techniques applicable to a wide range
-of problems.
-
-Statements 10, 14, 15, and 26 make up a virtual ``computed |GO TO|.'' When
-statement 10 is executed, control passes eventually to statement 16 or 11,
-depending on whether |.5| contains |#1| or |#2|, respectively. The value
-of |.5| is determined in statement 9, which demonstrates another handy
-technique. To turn an expression, {\em exp}, with value |#0| or |#1|, into
-|#1| or |#2| (for use in a ``|GO TO|''), use |"?'{\em exp}'c#1"~#3|. To
-reverse the condition (i.e., convert |#0| to |#2| and leave |#1| alone) use
-|"?'{\em exp}'c#2"~#3|.
-
-Certain conditions are easily checked. For example, to test for zero,
-select the value from itself and select the bottom bit (see statement 54).
-To test for all bits being 1's, select the value from itself and select the
-top bit (see statement 261). The test for greater than, performed in
-statements 192 and 193 on 32-bit values, employs binary logical operations,
-which are performed as follows:
-
-\begin{verbatim}
- 'V.1c.2'~'#0c#65535'
-\end{verbatim}
-for 16-bit values or, for 32-bit values:
-
-\begin{verbatim}
- "'V":1~'#65535c30'"c":2~'#65535c#0'"'~'#0
- c#65535'"c"'V":1~'#0c#65535'"c":2~'#0
- c#65535'"'~'#0c#65535'"
-\end{verbatim}
-(The proofs are left as an exercise to the reader.)
-
-Testing for greater-than with 16-bit values is somewhat simpler and is done
-with the pair of statements:
-
-\begin{verbatim}
- DO .C <- 'V.Ac.B'~'#0c#65535'
- DO .C <- '&"'.A~.C'~'"V'V.C~.C'c#32768"
- ~"#0c#65535"'"c".C~.CZ''ZZZ`#1
-\end{verbatim}
-This sets |.C| (a dummy variable) to |#1| if |.A| $>$ |.B|, and |#0|
-otherwise. The expression may be expanded as described above to instead
-set |.C| to |#1| or |#2|.
-
-Note also in statement 220 the occurrence of |~"#65535c65535"|. Although
-these operations select the entire value, they are not extraneous, as they
-ensure that the forthcoming |V|s will be operating on 32-bit values.
-
-In several virtual computed |GO TO|s the |DO FORGET #1| (statement 15 in the
-earlier example) has been omitted, since the next transfer of control would
-be a |DO RESUME #1|. By making this a |DO RESUME #2| instead, the |FORGET| may
-be forgotten.
-
-In statement 64, note that .2 is |STASH|ed twice by a single statement. This
-is perfectly legal.
-
-Lastly, note in statements 243 and 214 respectively, expressions for
-shifting 16- and 32-bit variables logically one place to the left.
-Statement 231 demonstrates right-shifting for 32-bit variables.
-
-% MIKE GETS TO INSERT THE PROGRAM HERE!
-\f
-\subsection{Program Listing}
-
-% Thanks to David Moews (moews@math.berkeley.edu) for help debugging this.
-% There is still much to be done!
-\ICverbatimlisting{syslib.i}
-%\typeout{Where's line 1551? 1900? 1910?}
-\f
-
-
-
-
-
-\subsection{Programming Suggestions}
-
-For the novice INTERCAL programmer, we provide here a list of suggested
-INTERCAL programming projects:
-
-Write an integer exponentiation subroutine. |:1 <- .1| raised to the |.2| power.
-
-Write a double-precision sorting subroutine. Given 32-bit array |;1| of
-size |:1|, sort the contents into numerically increasing order, leaving the
-results in |;1|.
-
-Generate a table of prime numbers.
-
-Put together a floating-point library, using 32-bit variables to represent
-floating-point numbers (let the upper half be the mantissa and the lower
-half be the characteristic). The library should be capable of performing
-floating-point addition, subtraction, multiplication, and division, as well
-as the natural logarithm function.
-
-Program a Fast Fourier Transform (FFT). This project would probably entail
-the writing of the floating-point library as well as sine and cosine functions.
-
-Calculate, to |:1| places, the value of pi.
-
-\f
-
-
-
-
-
-\section{Error Messages}
-
-Due to INTERCAL's implementation of comment lines (see section 4.5), most
-error messages are produced during execution instead of during compilation.
-All errors except those not causing immediate termination of program execution
-are treated as fatal.
-
-\subsection{Format}
-
-All error messages appear in the following form:
-
-\begin{verbatim}
- ICLnnnI (error message)
- ON THE WAY TO STATEMENT nnnn
- CORRECT SOURCE AND RESUBMIT
-\end{verbatim}
-
-The message varies depending upon the error involved. For undecodable
-statements the message is the statement itself. The second line tells
-which statement would have been executed next had the error not occurred.
-Note that if the error is due to 80 attempted levels of |NEXT|ing, the
-statement which would have been executed next need not be anywhere near the
-statement causing the error.
-
-\subsection{Messages}
-
-Brief descriptions of the different error types are listed below according
-to message number.
-
-\begin{description}
-\def\ttitem#1{\item[{\tt #1}]}
-
-\ttitem{000} An undecodable statement has been encountered in the course of
- execution. Note that keypunching errors can be slightly disastrous,
- since if `|FORGET|' were misspelled F-O-R-G-E-R, the results would
- probably not be those desired. Extreme misspellings may have even
- more surprising consequences. For example, misspelling `|FORGET|'
- R-E-S-U-M-E could have drastic results.
-
-\ttitem{017} An expression contains a syntax error.
-
-\ttitem{079} Improper use has been made of statement identifiers.
-
-\ttitem{099} Improper use has been made of statement identifiers.
-
-\ttitem{123} Program has attempted 80 levels of |NEXT|ing.
-
-\ttitem{129} Program has attempted to transfer to a non-existent line label.
-
-\ttitem{139} An |ABSTAIN| or |REINSTATE| statement references a non-existent line label.
-
-\ttitem{182} A line label has been multiply defined.
-
-\ttitem{197} An invalid line label has been encountered.
-
-\ttitem{200} An expression involves an unidentified variable.
-
-\ttitem{240} An attempt has been made to give an array a dimension of zero.
-
-\ttitem{241} Invalid dimensioning information was supplied in defining or using
- an array.
-
-\ttitem{275} A 32-bit value has been assigned to a 16-bit variable.
-
-\ttitem{436} A retrieval has been attempted for an un|STASH|ed value.
-
-\ttitem{533} A |WRITE IN| statement or interleave (|$|) operation has
-produced a value requiring over 32 bits to represent.
-
-\ttitem{562} Insufficient data.
-
-\ttitem{579} Input data is invalid.
-
-\ttitem{621} The expression of a |RESUME| statement evaluated to |#0|.
-
-\ttitem{632} Program execution was terminated via a |RESUME| statement instead of
- |GIVE UP|.
-
-\ttitem{633} Execution has passed beyond the last statement of the program.
-
-\ttitem{774} A compiler error has occurred (see section 8.1).
-
-\ttitem{778} An unexplainable compiler error has occurred (see J. Lyon or B. Woods).
-\end{description}
-
-\f
-
-
-\section*{Tonsil\footnote{Since all other reference manuals
-have Appendices, it was decided that the INTERCAL manual should contain
-some other type of removable organ.} A: The Official INTERCAL Character Set}
-\addtonsilline{A}{The Official INTERCAL Character Set}
-%\addcontentsline{toc}{section}{\protect\numberline{A}The Official INTERCAL Character Set}
-
-Tabulated on page~\pageref{Tonsil-A-table} are all the characters used in
-INTERCAL, excepting letters and digits, along with their names and
-interpretations. Also included are several characters not used in
-INTERCAL, which are presented for completeness and to allow for future
-expansion.
-\stepcounter{footnote}
-\footnotetext{This footnote intentionally unreferenced.}
-
-{\catcode`.=\active \catcode`|=12 % Use . instead of | for code mode
-\def.{\bgroup\tt\usespecials\def.{\null\egroup}}
-\begin{table}
-\label{Tonsil-A-table}
-\begin{minipage}{\textwidth} % use a minipage so the footnote works
-\begin{tabular}{|r|l|p{3in}|}
-\hline
-Character & Name & Use (if any) \\
-\hline
-.\spot. & spot & identify 16-bit variable \\
-.:. & two-spot & identify 32-bit variable \\
-.,. & tail & identify 16-bit array \\
-.;. & hybrid & identify 32-bit array \\
-.\#. & mesh & identify constant \\
-.=. & half-mesh & \\
-.'. & spark & grouper \\
-.`. & backspark & \\
-.!. & wow & equivalent to spark-spot \\
-\verb|?|& what & unary exlusive OR (ASCII) \\
-.". & rabbit-ears & grouper \\
-.\rabbit.& rabbit & equivalent to ears-spot \\
-{\verb+|+}& spike & \\
-.\%. & double-oh-seven & percentage qualifier \\
-.-. & worm & used with angles \\
-.<. & angle & used with worms \\
-.>. & right angle & \\
-.(. & wax & precedes line label \\
-.). & wane & follows line label \\
-.[. & U turn & \\
-.]. & U turn back & \\
-.\{. & embrace & \\
-.\}. & bracelet & \\
-.*. & splat & flags invalid statements \\
-.\&. & ampersand\footnotemark & unary logical AND \\
-.V. & V (or book) & unary logical OR \\
-.\bookworm. & bookworm (or universal qualifier) & unary exclusive OR \\
-.\$. & big money & binary mingle (ASCII) \\
-.\Change.& change & binary mingle \\
-.\~{}. & sqiggle & binary select \\
-.\_. & flat worm & \\
-.\zero. & overline & indicates ``times 1000'' \\
-.+. & intersection & separates list items \\
-./. & slat & \\
-{\verb|\|}& backslat & \\
-.@. & whirlpool & \\
-.\hookworm.& hookworm & \\
-{\verb|^|}& shark (or simply sharkfin) & \\
-.\blotCh.& blotch \\
-\hline
-\end{tabular}
-\catcode`.=12
-\caption{ INTERCAL character set (top view).}
-\def\thempfootnote{\arabic{mpfootnote}}
-\footnotetext[\thefootnote]{Got any better ideas?}
-\label{character-set}
-\end{minipage}
-\end{table}
-}
-
-\f
-\tonsil{B}{Notes On The Atari Implementation}
-% \section*{Tonsil B:
-% Notes On The Atari Implementation}
-% \addtonsilline{B}{Notes On The Atari Implementation}
-%\addcontentsline{toc}{section}{\protect\numberline{B}{Notes On The Atari Implementation}}
-
-The Atari implementation of INTERCAL differs from the original Princeton
-version primarily in the use of ASCII rather than EBCDIC. Since there is
-no ``change'' sign ({\tt\change}) in ASCII, we have substituted the ``big
-money'' ({\tt\bigmoney}) as the mingle operator. We feel that this
-correctly represents the increasing cost of software in relation to
-hardware. (Consider that in 1970 one could get RUNOFF for free, to run on
-a \$20K machine, whereas today a not quite as powerful formatter costs \$99
-and runs on a \$75 machine.) We also feel that there should be no
-defensible contention that INTERCAL has any sense. Also, since overpunches
-are difficult to read on the average VDT, the exclusive-or operator may be
-written {\tt ?}. This correctly expresses the average person's reaction on
-first encountering exclusive-or, especially on a PDP-11. Note that in both
-of these cases, the over-punched symbol may also be used if one is
-masochistic, or concerned with portability to the Princeton compiler. The
-correct over-punch for ``change'' is ``c{\sc
-$\langle$backspace$\rangle$}/'' and the correct over-punch for |\bookworm|
-is "V{\sc $\langle$backspace$\rangle$}-". These codes will be properly
-printed if you have a proper printer, and the corresponding EBCDIC code
-will be produced by the |/IBM| option on the |LIST| command.
-
-\end{document}
+++ /dev/null
-
-
-
-
-
-
- THE INTERCAL PROGRAMMING LANGUAGE
- REFERENCE MANUAL
-
-
- Donald R. Woods & James M. Lyon
-
- Copyright Donald R. Woods & James M. Lyon 1973
-
-\f
-
-
-
-
-
- INTERCAL
-
-1. INTRODUCTION
-
-The names you are about to ignore are true. However, the story has been changed
-significantly. Any resemblance of the programming language portrayed here
-to other programming languages, living or dead, is purely coincidental.
-
-1.1 ORIGIN AND PURPOSE
-
-The INTERCAL programming language was designed the morning of May 26, 1972
-by Donald R. Woods and James M. Lyon, at Princeton University. Exactly when
-in the morning will become apparent in the course of this manual. It was
-inspired by one ambition; to have a compiler language which has nothing at
-all in common with any other major language. By 'major' was meant anything
-with which the authors were at all familiar, e.g., FORTRAN, BASIC, COBOL,
-ALGOL, SNOBOL, SPITBOL, FOCAL, SOLVE, TEACH, APL, LISP, and PL/I. For the
-most part, INTERCAL has remained true to this goal, sharing only the basic
-elements such as variables, arrays, and the ability to do I/O, and eschewing
-all conventional operations other than the assignment statement (FORTRAN
-"=").
-
-1.2 ACRONYM
-
-The full name of the compiler is "Compiler Language With No Pronounceable
-Acronym", which is, for obvious reasons, abbreviated "INTERCAL".
-
-1.3 ACKNOWLEDGMENTS
-
-The authors are deeply indebted to Eric M. Van and Daniel J. Warmenhoven,
-without whose unwitting assistance this manual would still have been
-possible.
-
-
-\f
-
-
-
-
-
-2. FUNDAMENTAL CONCEPTS
-
-In this section an attempt is made to describe how and why INTERCAL may be
-used; i.e., what it is like and what it is good for.
-
-2.1 SAMPLE PROGRAM
-
-Shown below is a relatively simple INTERCAL program which will read in 32-bit
-unsigned integers, treat them as signed, 2's-complement numbers, and print out
-their absolute values. The program exits if the absolute value is zero. Note
-in particular the inversion routine (statements 6 through 14), which could
-be greatly simplified if the subroutine library (see section 5) were used.
-
-A more detailed analysis of a program is made in section 6 of this manual.
-
- DO (5) NEXT
- (5) DO FORGET #1
- PLEASE WRITE IN :1
- DO .1 <- 'V":1~'#32768$#0'"$#1'~#3
- DO (1) NEXT
- DO :1 <- "'V":1~'#65535$#0'"$#65535'
- ~'#0$#65535'"$"'V":1~'#0$#65535'"
- $#65535'~'#0$#65535'"
- DO :2 <- #1
- PLEASE DO (4) NEXT
- (4) DO FORGET #1
- DO .1 <- "'V":1~'#65535$#0'"$":2~'#65535
- $#0'"'~'#0$#65535'"$"'V":1~'#0
- $#65535'"$":2~'#65535$#0'"'~'#0$#65535'"
- DO (1) NEXT
- DO :2 <- ":2~'#0$#65535'"
- $"'":2~'#65535$#0'"$#0'~'#32767$#1'"
- DO (4) NEXT
- (2) DO RESUME .1
- (1) PLEASE DO (2) NEXT
- PLEASE FORGET #1
- DO READ OUT :1
- PLEASE DO .1 <- 'V"':1~:1'~#1"$#1'~#3
- DO (3) NEXT
- PLEASE DO (5) NEXT
- (3) DO (2) NEXT
- PLEASE GIVE UP
-
-2.2 USES FOR INTERCAL
-
-INTERCAL's main advantage over other programming languages is its strict
-simplicity. It has few capabilities, and thus there are few restrictions to
-be kept in mind. Since it is an exceedingly easy language to learn, one
-might expect it would be a good language for initiating novice programmers.
-Perhaps surprising, than, is the fact that it would be more likely to
-initiate a novice into a search for another line of work. As it turns out,
-INTERCAL is more useful (which isn't saying much) as a challenge to
-professional programmers. Those who doubt this need only refer back to the
-sample program in section 2.1. This 22-statement program took somewhere
-from 15 to 30 minutes to write, whereas the same objectives can be achieved
-by single-statement programs in either SNOBOL;
-
- PLEASE INPUT POS(0) ('-' ! '')
- + (SPAN('0123456789') $ OUTPUT)
- + *NE(OUTPUT) :S(PLEASE)F(END)
-
-or APL;
-
- [1] >\b-0=\b/?<\b-?
-
-Admittedly, neither of these is likely to appear more intelligible to
-anyone unfamiliar with the languages involved, but they took roughly 60
-seconds and 15 seconds, respectively, to write. Such is the overwhelming
-power of INTERCAL!
-
-The other major importance of INTERCAL lies in its seemingly inexhaustible
-capacity for amazing one's fellow programmers, confounding programming shop
-managers, winning friends, and influencing people. It is a well-known and
-oft-demonstrated fact that a person whose work is incomprehensible is held
-in high esteem. For example, if one were to state that the simplest way to
-store a value of 65536 in a 32-bit INTERCAL variable is:
-
- DO :1 <- #0$#256
-
-any sensible programmer would say that that was absurd. Since this is
-indeed the simplest method, the programmer would be made to look foolish in
-front of his boss, who would of course happened to turn up, as bosses are
-wont to do. The effect would be no less devastating for the programmer
-having been correct.
-
-\f
-
-
-
-
-
-3. DESCRIPTION
-
-The examples of INTERCAL programming which have appeared in the preceding
-sections of this manual have probably seemed highly esoteric to the reader
-unfamiliar with the language. With the aim of making them more so, we
-present here a description of INTERCAL.
-
-
-3.1 VARIABLES
-
-INTERCAL allows only 2 different types of variables, the 16-bit integer
-and the 32-bit integer. These are represented by a spot (.) or two-spot
-(:), respectively, followed by any number between 1 and 65535, inclusive.
-These variables may contain only non-negative numbers; thus they have the
-respective ranges of values: 0 to 65535 and 0 to 4294967295. Note: .123 and
-:123 are two distinct variables. On the other hand, .1 and .0001 are
-identical. Furthermore, the latter may NOT be written as 1E-3.
-
-3.2 CONSTANTS
-
-Constants are 16-bit values only and may range from 0 to 65535. They are
-prefixed by a mesh (#). Caution! Under no circumstances confuse the mesh
-with the interleave operator, except under confusing circumstances!
-
-3.3 ARRAYS
-
-Arrays are represented by a tail (,) for 16-bit values, or a hybrid (;) for
-32-bit values, followed by a number between 1 and 65535, inclusive. The
-number is suffixed by the word SUB, followed by the subscripts, separated
-optionally by spaces. Subscripts may be any expressions, including those
-involving subscripted variables. This occasionally leads to ambiguous
-constructions, which are resolved as discussed in section 3.4.3. Definition
-of array dimensions will be discussed later in greater detail, since
-discussing it in less detail would be difficult. As before, ,123 and ;123
-are distinct. In summary, .123, :123, #123, ,123, and :123 are all
-distinct.
-
-3.4 OPERATORS
-
-INTERCAL recognizes 5 operators--2 binary and 3 unary. Please be kind to
-our operators: they may not be very intelligent, but they're all we've got.
-In a sense, all 5 operators are binary, as they are all bit-oriented, but
-it is not our purpose here to quibble about bits of trivia.
-
-
-\f
-******* proofread versus the paper copy only this far !!!! ************
-
-
-
-
-3.4.1 BINARY OPERATORS
-
-The binary operators are INTERLEAVE (also called MINGLE) and SELECT, which
-are represented by a change (c\b/) and a sqiggle [sic] (~), respectively.
-
-The interleave operator takes two 16-bit values and produces a 32-bit result
-by alternating the bits of the operands. Thus, #65535c\b/#0 has the 32-bit
-binary form 101010....10 or 2863311530 decimal, while #0c\b/#65535 =
-0101....01 binary = 1431655765 decimal, and #255c\b/#255 is equivalent to
-#65535.
-
-The select operator takes from the first operand whichever bits correspond
-to 1's in the second operand, and packs these bits to the right in the result.
-Both operands are automatically padded on the left with zeros to 32 bits
-before the selection takes place, so the variable types are unrestricted.
-If more than 16 bits are selected, the result is a 32-bit value, otherwise
-it is a 16-bit value. For example, #179~#201 (binary value 10110011~11001001)
-selects from the first argument the 8th, 7th, 4th, and 1st from last bits,
-namely, 1001, which = 9. But #201~#179 selects from binary 11001001 the 8th,
-6th, 5th, 2nd, and 1st from last bits, giving 10001 = 17. #179~#179 has the
-value 31, while #201~#201 has the value 15.
-
-Perhaps a simpler way of understanding the operation of the select operator
-would be to examine the logic diagram on the following page (Figure 1), which
-performs the select operation upon two 8-bit values, A and B. The gates used
-are Warmenhovian logic gates, which means the outputs have four possible
-values: low, high, undefined (value of an uninitialized flip-flop), and
-oscillating (output of a NOR gate with one input low and the other input
-connected to the output). These values are represented symbolically by '0',
-'1', '?', and 'F'. Note in particular that, while NOT-0 is 1 and NOT-1
-is 0 as in two-valued logic, NOT-? is ? and NOT-F is F. The functions
-of the various gates are listed in Table 1.
-
-\f
-
-
-
-
-
-3.4.2 UNARY OPERATORS
-
-The unary operators are & (logical AND), V (logical OR), and V\b- (logical
-XOR). This last character is obtained by overpunching a worm (-) on a V
-(V). The operator is inserted between the spot, two-spot, mesh, or
-what-have-you, and the integer, thus: .&123, #V123. Multiple unary
-operators may not be concatenated, thus the form #V&123 is invalid. This
-will be covered later when precedence is discussed. These operators perform
-their respective logical operations on all pairs of adjacent bits, the
-result from the first and last bits going into the first bit of the result.
-The effect is that of rotating the operand one place to the right and
-ANDing, ORing, or XORing with its initial value. Thus, #&77 (binary =
-1001101) is binary 0000000000000100 = 4, #V77 is binary 1000000001101111 =
-32879, and #?77 is binary 1000000001101011 = 32875.
-
-3.4.3 PRECEDENCE
-
-Precedence of operators is as follows:
-
-
-
-
-
-
-
-
-
-
-
- [1]
-(The remainder of this page intentionally left blank)
-
-
-
-
-
-
-
-
-
-
-
-
-
-_________________
-1) Keep in mind that the aim in designing INTERCAL was to have no
- precedents.
-
-\f
-
-
-
-
-
-This precedence (or lack thereof) may be overruled by grouping expressions
-between pairs of sparks (') or rabbit-ears ("). Thus '#165c\b/#203'~#358
-(binary value '10100101c11001011'~101100110) has the value 15, but
-#165c\b/'#203~#358' has the value 34815, and #165c\b/#203~#358 is invalid
-syntax and is completely valueless (except perhaps as an educational tool
-to the programmer). A unary operator is applied to a sparked or rabbit-eared
-expression by inserting the operator immediately following the opening spark
-or ears. Thus, the invalid expression #V&123, which was described earlier,
-could be coded as 'V#&123' or 'V"{"'. Note: In the interests of
-simplifying the sometimes overly-complex form of expressions, INTERCAL allows
-a spark-spot combination ('.) to be replaced with a wow (!). Thus '.1~.2'
-is equivalent to !1~.2', and 'V.1c.2' is equivalent to "V!1c.2'".
-
-Combining a rabbit-ears with a spot to form a rabbit ("\b.) is not permitted,
-although the programmer is free to use it should he find an EBCDIC reader
-which will properly translate a 12-3-7-8 punch.
-
-Sparks and/or rabbit-ears must also be used to distinguish among such
-otherwise ambiguous subscripted and multiply-subscripted expressions as:
-
- ,1 SUB #1 ~ #2
- ,1 SUB ,2 SUB #1 #2 #3
- ,1 SUB " ,2 SUB " ,3 SUB #1 " #2 " " #3 "
-
-The third case may be isolated into either of its possible interpretations
-by simply changing some pairs of rabbit-ears to sparks, instead of adding
-more ears (which would only confuse the issue further). Ambiguous cases are
-defined as those for which the compiler being used finds a legitimate
-interpretation which is different from that which the user had in mind. See
-also section 8.1.
-
-
-
-
-
-
-4. STATEMENTS
-
-In this section is described the format of INTERCAL statements.
-
-4.1 GENERAL FORMAT
-
-Statements may be entered in 'free format'. That is, more than one statement
-may occur on a single card, and a statement may begin on one card and end
-on a later one. Note that if this is done, all intervening cards and portions
-thereof must be part of the same statement. That this restriction is necessary
-is immediately apparent from the following example of what might occur if
-statements could be interlaced.
-
- DO .1 <- ".1c\b/'&:51~"#V1c!12~;&75SUB"V'V.1~
- DO .2 <- '"!1c\b/"&';V79SUB",&7SUB:173"'~!V9c
- .2'c,&1SUB:5~#33578"'"'"~'#65535c\b/"V'V#&85'"'
- #8196'"'~.1"c.2'~'#&5c\b/"'#1279c\b/#4351'~#65535"'
-
-The above statements are obviously meaningless. (For that matter, so are
-the statements
-
- DO .1 <- ".1c\b/"&:51~"#V1c!12~;&75SUB"V'V.1~
- .2'C,&1SUB:5~/333578"'"'"~#65535c\b/"V'V#&85'"'
- DO .2 <- '"!1c\b/"&';V79SUB",&7SUB:173"'~!V9c
- #8196'"'~.1"c.2'~'#&5c\b/"'#1279c!4351'~#65535"'
-
-but this is not of interest here.)
-
-Spaces may be used freely to enhance program legibility (or at least reduce
-program illegibility), with the restriction that no word of a statement
-identifier (see section 4.3) may contain any spaces.
-
-4.2 LABELS
-
-A statement may begin with a LOGICAL LINE LABEL enclosed in wax-wane pairs
-(()). A statement may not have more than one label, although it is possible
-to omit the label entirely. A line label is any integer from 1 to 65535,
-which must be unique within each program. The user is cautioned, however,
-that many line labels between 1000 and 1999 are used in the INTERCAL System
-Library functions.
-
-4.3 IDENTIFIERS AND QUALIFIERS
-
-After the line label (if any), must follow one of the following statement
-identifiers: DO, PLEASE, or PLEASE DO. These may be used interchangeably to
-improve the aesthetics of the program. The identifier is then followed by
-either, neither, or both of the following optional parameters (qualifiers):
-(1) either of the character strings NOT or N'T, which causes the statement
-to be automatically abstained from (see section 4.4.9) when execution
-begins, and (2) a number between 0 and 100, preceded by a double-oh-seven
-(%), which causes the statement to have only the specified percent chance
-of being executed each time it is encountered in the course of execution.
-
-\f
-
-
-
-
-
-4.4 STATEMENTS
-
-Following the qualifiers (or, if none are used, the identifier) must occur
-one of the 13 valid operations. (Exception: see section 4.5.) These are
-described individually in sections 4.4.1 through 4.4.13.
-
-4.4.1 CALCULATE
-
-The INTERCAL equivalent of the half-mesh (=) in FORTRAN, BASIC, PL/I, and
-others, is represented by an angle (<) followed by a worm (-). This
-combination is read 'gets'. 32-bit variables may be assigned 16-bit values,
-which are padded on the left with 16 zero bits. 16-bit variables may be
-assigned 32-bit values only if the value is less than 65535. Thus, to
-invert the least significant bit of the first element of 16-bit
-2-dimensional array number 1, one could write:
-
- ,1SUB#1#1 <- 'V,1SUB#1#1c\b/#1'~'#0c\b/#65535'
-
-Similarly to SNOBOL and SPITBOL, INTERCAL uses the angle-worm to define the
-dimensions of arrays. An example will probably best describe the format.
-To define 32-bit array number 7 as 3-dimensional, the first dimension being
-seven, the second being the current value of 16-bit variable number seven,
-and the third being the current value of the seventh element of 16-bit array
-number seven (which is one-dimensional) mingled with the last three bits of
-32-bit variable number seven, one would write (just before they came to take
-him away):
-
- ;7 <- #7 BY .7 BY ",7SUB#7"c\b/':7~#7'
-
-This is, of course, different from the statement:
-
- ;7 <- #7 BY .7 BY ,7SUB"#7c\b/':7~#7'"
-
-INTERCAL also permits the redefining of array dimensioning, which is done
-the same way as is the initial dimensioning. All values of items in an array
-are lost upon redimensioning, unless they have been STASHed (see section
-4.4.5), in which case restoring them also restores the old dimensions.
-
-\f
-
-
-
-
-
-4.4.2 NEXT
-
-The NEXT statement is used both for subroutine calls and for unconditional
-transfers. This statement takes the form:
-
- DO (label) NEXT
-
-(or, of course,
-
- PLEASE DO (label) NEXT
-
-etc.), where (label) represents any logical line label which appears in the
-program. The effect of such a statement is to transfer control to the
-statement specified, and to store in a push down list (which is initially
-empty) the location from which the transfer takes place. Items may be
-removed from this list and may be discarded or used to return to the
-statement immediately following the NEXT statement. These operations are
-described in sections 4.4.3 and 4.4.4 respectively. The programmer is
-generally advised to discard any stack entries which he does not intend to
-utilize, since the stack has a maximum depth of 79 entries. A program's
-attempting to initiate an 80th level of NEXTing will result on the fatal
-error message, "PROGRAM HAS DISAPPEARED INTO THE BLACK LAGOON."
-
-4.4.3 FORGET
-
-The statement PLEASE FORGET exp, where exp represents any expression
-(except colloquial and facial expressions), causes the expression to be
-evaluated, and the specified number of entries to be removed from the
-NEXTing stack and discarded. An attempt to FORGET more levels of NEXTing
-than are currently stacked will cause the stack to be emptied, and no error
-condition is indicated. This is because the condition is not considered to
-be an error. As described in section 4.4.2, it is good programming practice
-to execute a DO FORGET #1 after using a NEXT statement as an unconditional
-transfer, so that the stack does not get cluttered up with unused entries:
-
- DO (123) NEXT
- .
- .
- (123) DO FORGET #1
-
-4.4.4 RESUME
-
-The statement PLEASE RESUME exp has the same effect as FORGET, except that
-program control is returned to the statement immediately following the NEXT
-statement which stored in the stack the last entry to be removed. Note that
-a rough equivalent of the FORTRAN computed GO TO and BASIC ON exp GO TO is
-performed by a sequence of the form:
-
- DO (1) NEXT
- .
- .
- (1) DO (2) NEXT
- PLEASE FORGET #1
- .
- .
- (2) DO RESUME .1
-
-Unlike the FORGET statement, an attempt to RESUME more levels of NEXTing than
-been stacked will cause program termination. See also section 4.4.11.
-
-
-4.4.5 STASH
-
-Since subroutines are not explicitly implemented in INTERCAL, the NEXT and
-RESUME statements must be used to execute common routines. However, as
-these routines might use the same variables as the main program, it is
-necessary for them to save the values of any variables whose values they
-alter, and later restore them. This process is simplified by the STASH
-state ment, which has the form DO STASH list, where list represents a
-string of one or more variable or array names, separated by intersections
-(+). Thus
-
- PLEASE STASH .123+:123+,123
-
-stashes the values of two variables and one entire array. The values are
-left intact, and copies thereof are saved for later retrieval by (what else?)
-the RETRIEVE statement (see section 4.4.6). It is not possible to STASH
-single array items.
-
-4.4.6 RETRIEVE
-
-PLEASE RETRIEVE list restores the previously STASHed values of the variables
-and arrays named in the list. If a value has been stashed more than once,
-the most recently STASHed values are RETRIEVEd, and a second RETRIEVE will
-restore the second most recent values STASHed. Attempting to RETRIEVE a
-value which has not been STASHed will result in the error message, "THROW
-STICK BEFORE RETRIEVING."
-
-4.4.7 IGNORE
-
-The statement DO IGNORE list causes all subsequent statements to have no
-effect upon variables and/or arrays named in the list. Thus, for example,
-after the sequence
-
- DO .1 <- #1
- PLEASE IGNORE .1
- DO .1 <- #0
-
-16-bit variable number 1 would have the value 1, not 0. Inputting (see
-section 4.4.12) into an IGNOREd variable also has no effect. The condition
-is annulled via the REMEMBER statement (see section 4.4.8). Note that, when
-a variable is being IGNOREd, its value, though immutable, is still
-available for use in expressions and the like.
-
-4.4.8 REMEMBER
-
-PLEASE REMEMBER list terminates the effect of the IGNORE statement for all
-variables and/or arrays named in the list. It does not matter if a variable
-has been IGNOREd more than once, nor is it an error if the variable has not
-been IGNOREd at all.
-
-4.4.9 ABSTAIN
-
-INTERCAL contains no simple equivalent to an IF statement or computed GO
-TO, making it difficult to combine similar sections of code into a single
-routine which occasionally skips around certain statements. The IGNORE
-statement (see section 4.4.7) is helpful in some cases, but a more viable
-method is often required. In keeping with the goal of INTERCAL having
-nothing in common with any other language, this is made possible via the
-ABSTAIN statement.
-
-This statement takes on one of two forms. It may not take on both at any one
-time. DO ABSTAIN FROM (label) causes the statement whose logical line label
-is (label) to be abstained form. PLEASE ABSTAIN FROM gerund list causes all
-statements of the specified type(s) to be abstained from, as in
-
- PLEASE ABSTAIN FROM STASHING
- PLEASE ABSTAIN FROM IGNORING + FORGETTING
- PLEASE ABSTAIN FROM NEXTING
- or PLEASE ABSTAIN FROM CALCULATING
-
-Statements may also be automatically abstained from at the start of
-execution via the NOT or N'T parameter (see section 4.3).
-
-
-If, in the course of execution, a statement is encountered which is being
-abstained from, it is ignored and control passes to the next statement in
-the program (unless it, too, is being abstained from).
-
-The statement DO ABSTAIN FROM ABSTAINING is perfectly valid, as is DO ABSTAIN
-FROM REINSTATING (although this latter is not usually recommended). However,
-the statement DO ABSTAIN FROM GIVING UP is not accepted, even though DON'T
-GIVE UP is.
-
-4.4.10 REINSTATE
-
-The REINSTATE statement, like the ABSTAIN, takes as an argument either a
-line label or a gerund list. No other form of argument is permitted. For
-example, the following is an invalid argument:
-
- Given: x=\b/0, y=\b/0, Prove: x+y=0
- Since x=\b/0, then x+1=\b/1, x+a=\b/a, x+y=\b/y.
- Thus x+y =\b/ anything but 0.
- Since x+y cannot equal anything but 0, x+y=0.
-
- Q.E.D.
-
-REINSTATEment nullifies the effects of an abstention. Either form of
-REINSTATEment can be used to "free" a statement, regardless of whether the
-statement was abstained from by gerund list, line label, or NOT. Thus,
-PLEASE REINSTATE REINSTATING is not necessarily an irrelevant statement,
-since it might free a DON'T REINSTATE command or a REINSTATE the line label
-of which was abstained from. However, DO REINSTATE GIVING UP is invalid,
-and attempting to REINSTATE a GIVE UP statement by line label will have no
-effect. Note that this insures that DON'T GIVE UP will always be a
-"do-nothing" statement.
-
-4.4.11 GIVE UP
-
-PLEASE GIVE UP is used to exit from a program. It has the effect of a PLEASE
-RESUME #80. DON'T GIVE UP, as noted in section 4.4.10, is effectively a null
-statement.
-
-4.4.12 Input
-
-Input is accomplished with the statement DO WRITE IN list, where list
-represents a string of variables and/or elements or arrays, separated by
-intersections. Numbers are represented on cards, each number on a separate
-card, by spelling out each digit (in English) and separating the digits
-with one or more spaces. A zero (0) may be spelled as either ZERO or OH.
-Thus the range of (32-bit) input values permissible extends from ZERO (or
-OH) through FOUR TWO NINE FOUR NINE SIX SEVEN TWO NINE FIVE.
-
-Attempting to write in a value greater than or equal to SIX FIVE FIVE THREE
-SIX for a 16-bit variable will result in the error message, "DON'T BYTE OFF
-MORE THAN YOU CAN CHEW."
-
-4.4.13 Output
-
-Values may be output to the printer, one value per line, via the statement
-DO READ OUT list, where the list contains variables, array elements, and/or
-constants. Output is in the form of "extended" Roman numerals (also called
- _
-"butchered" Roman numerals), with an overline ( ) indicating the value below
-is "times 1000", and lower-case letters indicating "times 1000000". Zero
-is indicated by an overline with no character underneath. Thus, the range
- _ __ _______
-of (32-bit) output values possible is from through ivccxcivCMLXVIICCXCV.
-Note: For values whose residues modulo 1000000 are less than 4000, M is
-used to represent 1000; for values whose residues are 4000 or greater, I is
- __
-used. Thus #3999 would read out as MMMIM while #4000 would read out as IV.
- _ _ _
-Similar rules apply to the use of M and i for 1000000, and to that of m and i
-for 1000000000.
-
-\f
-
-
-
-
-
-4.5 Comments
-
-Unrecognizable statements, as noted in section 7, are flagged with a splat
-(*) during compilation, and are not considered fatal errors unless they
-are encountered during execution, at which time the statement (as input at
-compilation time) is printed and execution is terminated. This allows for
-an interesting (and, by necessity, unique) means of including comments in
-an INTERCAL listing. For example, the statement:
-
-* PLEASE NOTE THAT THIS LINE HAS NO EFFECT
-
-will be ignored during execution due to the inclusion of the NOT qualifier.
-User-supplied error messages are also easy to implement:
-
-* DO SOMETHING ABOUT OVERFLOW IN ;3
-
-as are certain simple conditional errors:
-
-* (123) DON'T YOU REALIZE THIS STATEMENT SHOULD ONLY BE ENCOUNTERED
- ONCE?
- PLEASE REINSTATE (123)
-
-This pair of statements will cause an error exit the second time they are
-encountered. Caution!! The appearance of a statement identifier in an
-intended comment will be taken as the beginning of a new statement. Thus,
-the first example on the preceding page could not have been:
-
-* PLEASE NOTE THAT THIS LINE DOES NOTHING
-
-The third example, however, is valid, despite the appearance of two cases
-of D-space-O, since INTERCAL does not ignore extraneous spaces in statement
-identifiers.
-\f
-
-
-
-
-
-5. SUBROUTINE LIBRARY
-
-INTERCAL provides several built-in subroutines to which control can be
-transferred to perform various operations. These operations include many
-useful functions which are not easily representable in INTERCAL, such as
-addition, subtraction, etc.
-
-5.1 Usage
-
-In general, the operands are .1, .2, etc., or :1, :2, etc., and the result(s)
-are stored in what would have been the next operand(s). For instance, one
-routine adds .1 to .2 and store the sum in .3, with .4 being used to indicate
-overflow. All variables not used for results are left unchanged.
-
-5.2 Available Functions
-
-At the time of this writing, only the most fundamental operations are offered
-in the library, as a more complete selection would require prohibitive time
-and coree to implement. These functions, along with their corresponding entry
-points (entered via DO (entry) NEXT) are listed below.
-
- (1000) .3 <- .1 plus .2, error exit on overflow
- (1009) .3 <- .1 plus .2
- .4 <- #1 if no overflow, else .4 <- #2
- (1010) .3 <- .1 minus .2, no action on overflow
- (1020) .1 <- .1 plus #1, no action on overflow
- (1030) .3 <- .1 times .2, error exit on overflow
- (1039) .3 <- .1 times .2
- .4 <- #1 if no overflow, else .4 <- #2
- (1040) .3 <- .1 divided by .2
- .3 <- #0 if .2 is #0
- (1050) .2 <- :1 divided by .1, error exit on overflow
- .2 <- #0 if .1 is #0
-
- (1500) :3 <- :1 plus :2, error exit on overflow
- (1509) :3 <- :1 plus :2
- :4 <- #1 if no overflow, else :4 <- #2
- (1510) :3 <- :1 minus :2, no action on overflow
- (1520) :1 <- .1 concatenated with .2
- (1525) This subroutine is intended solely for internal
- use within the subroutine library and is therefore
- not described here. Its effect is to shift .3
- logically 8 bits to the left.
- (1530) :1 <- .1 times .2
- (1540) :3 <- :1 times :2, error exit on overflow
- (1549) :3 <- :1 times :2
- :4 <- #1 if no overflow, else :4 <- #2
- (1550) :3 <- :1 divided by :2
- :3 <- #0 if :2 is #0
-
- (1900) .1 <- uniform random no. from #1 to #65535
- (1910) .2 <- normal random no. from #0 to .1, with
- standard deviation .1 divided by #12
-
-\f
-
-
-
-
-
-6. PROGRAMMING HINTS
-
-For the user looking to become more familiar with the INTERCAL language, we
-present in this section an analysis of a complex program, as well as some
-suggested projects for the ambitious programmer.
-
-Considering the effort involved in writing an INTERCAL program, it was
-decided in putting together this manual to use an already existing program
-for instructive analysis. Since there was only one such program available,
-we have proceeded to use it. It is known as the "INTERCAL System Library."
-
-6.1 Description
-
-The program listing begins on the second page following. It is in the same
-format as would be produced by the Princeton INTERCAL compiler in FORMAT
-mode with WIDTH=62 (see section 8). For a description of the functions
-performed by the Library, see section 5.2.
-
-6.2 Analysis
-
-We shall not attempt to discuss here the algorithms used, but rather we
-shall point out some of the general techniques applicable to a wide range
-of problems.
-
-Statements 10, 14, 15, and 26 make up a virtual "computed GO TO". When
-statement 10 is executed, control passes eventually to statement 16 or 11,
-depending on whether .5 contains #1 or #2, respectively. The value of .5
-is determined in statement 9, which demonstrates another handy technique.
-To turn an expression, exp, with value #0 or #1, into #1 or #2 (for use in
-a "GO TO"), use "V\b-'exp'c\b/#1"~#3. To reverse the condition (i.e., convert #0
-to #2 and leave #1 alone) use "V\b-'exp'c\b/#2"~#3.
-
-Certain conditions are easily checked. For example, to test for zero,
-select the value from itself and select the bottom bit (see statement 54).
-To test for all bits being 1's, select the value from itself and select the
-top bit (see statement 261). The test for greater than, performed in
-statements 192 and 193 on 32-bit values, employs binary logical operations,
-which are performed as follows:
-
- 'V.1c.2'~'#0c\b/#65535'
-
-for 16-bit values or, for 32-bit values:
-
- "'V":1~'#65535c30'"c\b/":2~'#65535c\b/#0'"'~'#0
- c\b/#65535'"c\b/"'V":1~'#0c\b/#65535'"c\b/":2~'#0
- c\b/#65535'"'~'#0c\b/#65535'"
-
-(The proofs are left as an exercise to the reader.)
-
-Testing for greater-than with 16-bit values is somewhat simpler and is done
-with the pair of statements:
-
- DO .C <- 'V.Ac.B'~'#0c\b/#65535'
- DO .C <- '&"'.A~.C'~'"V'V.C~.C'c\b/#32768"
- ~"#0c\b/#65535"'"c\b/".C~.CZ''ZZZ`#1
-
-This sets .C (a dummy variable) to #1 if .A > .B, and #0 otherwise. The
-expression may be expanded as described above to instead set .C to #1 or
-#2.
-
-Note also in statement 220 the occurrence of ~"#65535c65535". Although
-these operations select the entire value, they are not extraneous, as they
-ensure that the forthcoming Vs will be operating on 32-bit values.
-
-In several virtual computed GO TOs the DO FORGET #1 (statement 15 in the
-earlier example) has been omitted, since the next transfer of control would
-be a DO RESUME #1. By making this a DO RESUME #2 instead, the FORGET may
-be forgotten.
-
-In statement 64, note that .2 is STASHed twice by a single statement. This
-is perfectly legal.
-
-Lastly, note in statements 243 and 214 respectively, expressions for
-shifting 16- and 32-bit variables logically one place to the left.
-Statement 231 demonstrates right-shifting for 32-bit variables.
-
-MIKE GETS TO INSERT THE PROGRAM HERE!
-\f
-6.3 Program Listing
-
- 1 (1000) PLEASE IGNORE .4
- 2 PLEASE ABSTAIN FROM (1005)
- 3 (1009) DO STASH .1 + .2 + .5 + .6
- 4 DO .4 <- #1
- 5 DO (1004) NEXT
- 6 (1004) PLEASE FORGET #1
- 7 DO .3 <- 'V.1c.2'~'#0c\b/#65535'
- 8 DO .6 <- '&.1c.2'~'#0c\b/#65535'
- 9 PLEASE DO .5 <- "V!6~#32768'c\b/#1"~#3
- 10 DO (1002) NEXT
- 11 DO .4 <- #2
- 12 (1005) DO (1006) NEXT
-* 13 (1999) DOUBLE OR SINGLE PRECISION OVERFLOW
- 14 (1002) DO (1001) NEXT
- 15 (1006) PLEASE FORGET #1
- 16 DO .5 <- 'V"!6~.6'~#1"c\b/#1'~#3
- 17 DO (1003) NEXT
- 18 DO .1 <- .3
- 19 DO .2 <- !6c\b/#0'~'#32767c\b/#1'
- 20 DO (1004) NEXT
- 21 (1003) DO (1001) NEXT
- 22 DO REINSTATE (1005)
- 23 (1007) PLEASE RETRIEVE .1 + .2 + .5 + .6
- 24 DO REMEMBER .4
- 25 PLEASE RESUME #2
- 26 (1001) DO RESUME .5
- 27 (1010) DO STASH .1 + .2 + .4
- 28 DO .4 <- .1
- 29 DO .1 <- 'V.2c\b/#65535'~'#0c\b/#65535'
- 30 DO (1020) NEXT
- 31 PLEASE DO .2 <- .4
- 32 PLEASE DO (1009) NEXT
- 33 DO RETRIEVE .1 + .2 + .4
- 34 PLEASE RESUME #1
- 35 (1020) DO STASH .2 + .3
- 36 DO .2 <- #1
- 37 PLEASE DO (1021) NEXT
- 38 (1021) DO FORGET #1
- 39 DO .3 <- "V!1~.2'c\b/#1"~#3
- 40 PLEASE DO .1 <- 'V.1c.2'~'#0c\b/#65535'
- 41 DO (1022) NEXT
- 42 DO .2 <- !2c\b/#0'~'#32767c\b/#1'
- 43 DO (1021) NEXT
- 44 (1023) PLEASE RESUME .3
- 45 (1022) DO (1023) NEXT
- 46 PLEASE RETRIEVE .2 + .3
- 47 PLEASE RESUME #2
- 48 (1030) DO ABSTAIN FROM (1033)
- 49 PLEASE ABSTAIN FROM (1032)
- 50 (1039) DO STASH :1 + .5
- 51 DO (1530) NEXT
- 52 DO .3 <- :1~#65535
- 53 PLEASE DO .5 <- :1~'#65280c\b/#65280'
- 54 DO .5 <- 'V"!5~.5'~#1"c\b/#1'~#3
- 55 DO (1031) NEXT
- 56 (1032) DO (1033) NEXT
- 57 DO (1999) NEXT
- 58 (1031) DO (1001) NEXT
- 59 (1033) DO .4 <- .5
- 60 DO REINSTATE (1032)
- 61 PLEASE REINSTATE (1033)
- 62 DO RETRIEVE :1 + .5
- 63 PLEASE RESUME #2
- 64 (1040) PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3
- 65 DO .2 <- #0
- 66 DO (1520) NEXT
- 67 DO STASH :1
- 68 PLEASE RETRIEVE .2
- 69 DO .1 <- .2
- 70 DO .2 <- #0
- 71 PLEASE DO (1520) NEXT
- 72 DO :2 <- :1
- 73 DO RETRIEVE .1 + .2 + :1
- 74 DO (1550) NEXT
- 75 PLEASE DO .3 <- :3
- 76 DO RETRIEVE :1 + :2 + :3
- 77 DO RESUME #1
- 78 (1050) PLEASE STASH :2 + :3 + .5
- 79 DO :2 <- .1
- 80 PLEASE DO (1550) NEXT
- 81 DO .5 <- :3~'#65280c\b/#65280'
- 82 DO .5 <- 'V"!5~.5'~#1"c\b/#1'~#3
- 83 DO (1051) NEXT
- 84 DO (1999) NEXT
- 85 (1051) DO (1001) NEXT
- 86 DO .2 <- :3
- 87 PLEASE RETRIEVE :2 + :3 + .5
- 88 DO RESUME #2
- 89 (1500) PLEASE ABSTAIN FROM (1502)
- 90 PLEASE ABSTAIN FROM (1506)
- 91 (1509) PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6
- 92 DO .1 <- :1~#65535
- 93 PLEASE DO .2 <- :2~#65535
- 94 DO (1009) NEXT
- 95 DO .5 <- .3
- 96 PLEASE DO .6 <- .4
- 97 DO .1 <- :1~'#65280c\b/#65280'
- 98 DO .2 <- :2~'#65280c\b/#65280'
- 99 DO (1009) NEXT
- 100 DO .1 <- .3
- 101 PLEASE DO (1503) NEXT
- 102 DO .6 <- .4
- 103 DO .2 <- #1
- 104 DO (1009) NEXT
- 105 DO .1 <- .3
- 106 DO (1501) NEXT
- 107 (1504) PLEASE RESUME .6
- 108 (1503) DO (1504) NEXT
- 109 (1501) DO .2 <- .5
- 110 DO .5 <- 'V"'&.6c.4'~#1"c\b/#2'~#3
- 111 DO (1505) NEXT
- 112 (1506) DO (1502) NEXT
- 113 PLEASE DO (1999) NEXT
- 114 (1505) DO (1001) NEXT
- 115 (1502) DO :4 <- .5
- 116 DO (1520) NEXT
- 117 DO :3 <- :1
- 118 PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6
- 119 DO REINSTATE (1502)
- 120 DO REINSTATE (1506)
- 121 PLEASE RESUME #3
- 122 (1510) DO STASH :1 + :2 + :4
- 123 DO :1 <- "'V\b/":2~'#65535c\b/#0'"c\b/#65535'~'#0c\b/#6553
- 5'"c\b/"'V":2~'#0c\b/#65535'"c\b/#65535'~'#0c65535
- '"
- 124 DO :2 <- #1
- 125 DO (1509) NEXT
- 126 PLEASE RETRIEVE :1
- 127 DO :2 <- :3
- 128 PLEASE DO (1509) NEXT
- 129 DO RETRIEVE :2 + :4
- 130 PLEASE RESUME #1
- 131 (1520) PLEASE STASH .3 + .4
- 132 DO .3 <- .1~#43690
- 133 DO (1525) NEXT
- 134 PLEASE DO .4 <- 'V.3c\b/".2~#43690"'~'#0c\b/#65535'
- 135 DO .3 <- .1~#21845
- 136 PLEASE DO (1525) NEXT
- 137 DO :1 <- .4c\b/"'V.3c\b/".2~#21845"'~'#0c\b/#65535'"
- 138 PLEASE RETRIEVE .3 + .4
- 139 DO RESUME #1
- 140 (1525) DO .3 <- '"'"'"!3c\b/#0'~'#32767c\b/#1'"c\b/#0'~'#32767
- c\b/#1'"c\b/#0'~'#16383c\b/#3'"c\b/#0'~'#4095c\b/#15'
- 141 PLEASE RESUME #1
- 142 (1530) DO STASH :2 + :3 + .3 + .5
- 143 DO :1 <- #0
- 144 DO :2 <- .2
- 145 DO .3 <- #1
- 146 DO (1535) NEXT
- 147 (1535) PLEASE FORGET #1
- 148 DO .5 <- "V!1~.3'c\b/#1"~#3
- 149 DO (1531) NEXT
- 150 DO (1500) NEXT
- 151 DO :1 <- :3
- 152 PLEASE DO (1533) NEXT
- 153 (1531) PLEASE DO (1001) NEXT
- 154 (1533) DO FORGET #1
- 155 DO .3 <- !3c\b/#0'~'#32767c\b/#1'
- 156 DO :2 <- ":2~'#0c\b/#65535'"c\b/"'":2~'#32767c\b/#0'"c\b/#
- 0'~'#32767c\b/#1'"
- 157 PLEASE DO .5 <- "V!3~.3'c\b/#1"~#3
- 158 DO (1532) NEXT
- 159 DO (1535) NEXT
- 160 (1532) DO (1001) NEXT
- 161 PLEASE RETRIEVE :2 + :3 + .3 + .5
- 162 DO RESUME #2
- 163 (1540) PLEASE ABSTAIN FROM (1541)
- 164 DO ABSTAIN FROM (1542)
- 165 (1549) PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5
- 166 DO .1 <- :1~#65535
- 167 PLEASE DO .2 <- :2~'#65280c\b/#65280'
- 168 DO .5 <- :1~'#65280c\b/#65280'
- 169 DO (1530) NEXT
- 170 DO :3 <- :1
- 171 DO .2 <- :2~#65535
- 172 PLEASE DO (1530) NEXT
- 173 DO :5 <- :1
- 174 DO .1 <- .5
- 175 DO (1530) NEXT
- 176 DO :4 <- :1
- 177 PLEASE DO :1 <- ":3~'#65280c\b/#65280'"c\b/":5~'652
- 80c\b/#65280'"
- 178 DO .5 <- ':1~:1'~#1
- 179 DO .2 <- :2~'#65280c\b/#65280'
- 180 DO (1530) NEXT
- 181 PLEASE DO .5 <- '"':1~:1'~#1"c.5'~#3
- 182 DO .1 <- :3~#65535
- 183 DO .2 <- #0
- 184 DO (1520) NEXT
- 185 PLEASE DO :2 <- :1
- 186 PLEASE DO .1 <- :4~#65535
- 187 DO (1520) NEXT
- 188 DO (1509) NEXT
- 189 DO .5 <- !5c\b/":4~#3"'~#15
- 190 DO :1 <- :3
- 191 DO :2 <- :5
- 192 DO (1509) NEXT
- 193 PLEASE DO .5 <- !5c\b/"4~#3"'~#63
- 194 DO .5 <- 'V"!5~.5'~#1"c\b/#1'~#3
- 195 PLEASE RETRIEVE :4
- 196 (1541) DO :4 <- .5
- 197 DO (1543) NEXT
- 198 (1542) DO (1544) NEXT
- 199 PLEASE DO (1999) NEXT
- 200 (1543) DO (1001) NEXT
- 201 (1544) DO REINSTATE (1541)
- 202 PLEASE REINSTATE (1542)
- 203 PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5
- 204 DO RESUME #2
- 205 (1550) DO STASH :1 + :4 + :5 + .5
- 206 DO :3 <- #0
- 207 DO .5 <- 'V"':2~:2'~#1"c\b/#1'~#3
- 208 PLEASE DO (1551) NEXT
-\f
-
-
-
-
-
-6.4 Programming Suggestions
-
-For the novice INTERCAL programmer, we provide here a list of suggested
-INTERCAL programming projects:
-
-Write an integer exponentiation subroutine. :1 <- .1 raised to the .2 power.
-
-Write a double-precision sorting subroutine. Given 32-bit array ;1 of size
-:1, sort the contents into numerically increasing order, leaving the results
-in ;1.
-
-Generate a table of prime numbers.
-
-Put together a floating-point library, using 32-bit variables to represent
-floating-point numbers (let the upper half be the mantissa and the lower
-half be the characteristic). The library should be capable of performing
-floating-point addition, subtraction, multiplication, and division, as well
-as the natural logarithm function.
-
-Program a Fast Fourier Transform (FFT). This project would probably entail
-the writing of the floating-point library as well as sine and cosine functions.
-
-Calculate, to :1 places, the value of pi.
-
-\f
-
-
-
-
-
-7. ERROR MESSAGES
-
-Due to INTERCAL's implementation of comment lines (see section 4.5), most
-error messages are produced during execution instead of during compilation.
-All errors except those not causing immediate termination of program execution
-are treated as fatal.
-
-7.1 Format
-
-All error messages appear in the following form:
-
- ICLnnnI (error message)
- ON THE WAY TO STATEMENT nnnn
- CORRECT SOURCE AND RESUBMIT
-
-The message varies depending upon the error involved. For undecodable
-statements the message is the statement itself. The second line tells
-which statement would have been executed next had the error not occurred.
-Note that if the error is due to 80 attempted levels of NEXTing, the
-statement which would have been executed next need not be anywhere near the
-statement causing the error.
-
-7.2 Messages
-
-Brief descriptions of the different error types are listed below according
-to message number.
-
- 000 An undecodable statement has been encountered in the course of
- execution. Note that keypunching errors can be slightly disastrous,
- since if 'FORGET' were misspelled F-O-R-G-E-R, the results would
- probably not be those desired. Extreme misspellings may have even
- more surprising consequences. For example, misspelling 'FORGET'
- R-E-S-U-M-E could have drastic results.
-
- 017 An expression contains a syntax error.
-
- 079 Improper use has been made of statement identifiers.
-
- 099 Improper use has been made of statement identifiers.
-
- 123 Program has attempted 80 levels of NEXTing.
-
- 129 Program has attempted to transfer to a non-existent line label.
-
- 139 An ABSTAIN or REINSTATE statement references a non-existent line label.
-
- 182 A line label has been multiply defined.
-
- 197 An invalid line label has been encountered.
-
- 200 An expression involves an unidentified variable.
-
- 240 An attempt has been made to give an array a dimension of zero.
-
- 241 Invalid dimensioning information was supplied in defining or using
- an array.
-
- 275 A 32-bit value has been assigned to a 16-bit variable.
-
- 436 A retrieval has been attempted for an unSTASHed value.
-
- 533 A WRITE IN statement or interleave (c) operation has produced a
- value requiring over 32 bits to represent.
-
- 562 Insufficient data.
-
- 579 Input data is invalid.
-
- 621 The expression of a RESUME statement evaluated to #0.
-
- 632 Program execution was terminated via a RESUME statement instead of
- GIVE UP.
-
- 633 Execution has passed beyond the last statement of the program.
-
- 774 A compiler error has occurred (see section 8.1).
-
- 778 An unexplainable compiler error has occurred (see J. Lyon or B. Woods).
-
-\f
-
-
-
-
- [3]
- TONSIL A
-
-
-
-The Official INTERCAL Character Set
-
-Tabulated on page XX are all the characters used in INTERCAL, excepting
-letters and digits, along with their names and interpretations. Also
-included are several characters not used in INTERCAL, which are presented
-for completeness and to allow for future expansion.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-_____________________
-3) Since all other reference manuals have Appendices, it was decided that
-the INTERCAL manual should contain some other type of removable organ.
-
-4) This footnote intentionally unreferenced.
-
-
-
-
-
-
-_______________________________________________________________________
-| |
-|Character Name Use (if any) |
-| |
-| . spot identify 16-bit variable |
-| : two-spot identify 32-bit variable |
-| , tail identify 16-bit array |
-| ; hybrid identify 32-bit array |
-| # mesh identify constant |
-| = half-mesh |
-| ' spark grouper |
-| ` backspark |
-| ! wow equivalent to spark-spot |
-| ? what unary exlusive OR (ASCII) |
-| " rabbit-ears grouper |
-| "\b. rabbit equivalent to ears-spot |
-| | spike |
-| % double-oh-seven percentage qualifier |
-| - worm used with angles |
-| < angle used with worms |
-| > right angle |
-| ( wax precedes line label |
-| ) wane follows line label |
-| [ U turn |
-| ] U turn back |
-| { embrace |
-| } bracelet |
-| * splat flags invalid statements |
-| & ampersand[5] unary logical AND |
-| V V unary logical OR |
-| (or book) |
-| V\b- bookworm unary exclusive OR |
-| (or universal qualifier) |
-| $ big money unary exclusive OR (ASCII) | |
-| c\b| change binary mingle |
-| ~ sqiggle binary select |
-| _ flat worm |
-| overline indicates "times 1000" |
-| + intersection separates list items |
-| / slat |
-| \ backslat |
-| @ whirlpool |
-| -\b' hookworm |
-| ^ shark |
-| (or simply sharkfin) |
-| #\bI\b[\b] blotch |
-|_____________________________________________________________________|
-
-
- Table 2 (top view). INTERCAL character set.
-
-__________________________________
-
-5) Got any better ideas?
-
-\f
-NOTES ON THE ATARI IMPLEMENTATION
-
-The Atari implementation of INTERCAL differs from the original Princeton
-version primarily in the use of ASCII rather than EBCDIC. Since there is no
-"change" sign (c) in ASCII, we have substituted the "big money" ($) as the
-mingle operator. We feel that this correctly represents the increasing cost
-of software in relation to hardware. (Consider that in 1970 one could get
-RUNOFF for free, to run on a $20K machine, whereas today a not quite as
-powerful formatter costs $99 and runs on a $75 machine.) We also feel that
-there should be no defensible contention that INTERCAL has any sense.
-Also, since overpunches are difficult to read on the average VDT, the
-exclusive-or operator may be written ?. This correctly expresses the
-average person's reaction on first encountering exclusive-or, especially on
-a PDP-11. Note that in both of these cases, the over-punched symbol may
-also be used if one is masochistic, or concerned with portability to the
-Princeton compiler. The correct over-punch for "change" is "c<backspace>/"
-and the correct over-punch for V is "V<backspace>-". These codes will be
-properly printed if you have a proper printer, and the corresponding EBCDIC
-code will be produced by the /IBM option on the LIST command.
Begin3
Title: intercal
-Version: 0.12
-Entered-date: Tue Mar 22 12:42:31 EST 1995
+Version: 0.15
+Entered-date: Thu Jun 20 17:42:36 EDT 1996
Description: An implementation of the language INTERCAL, legendary for
its perversity and horribleness (this version adds COME FROM
- for extra flavor). Includes language manual and examples
+ for extra flavor). Comes with language manual and examples
including possibly the entire extant body of INTERCAL code.
-Keywords: language, compiler, retrocomputing
+Keywords: language, compiler, retrocomputing, geek humor
Author: esr@snark.thyrsus.com (Eric S. Raymond)
Maintained-by: esr@snark.thyrsus.com (Eric S. Raymond)
Primary-site: locke.ccil.org /pub/esr
- intercal-0.12
+ intercal-0.15
Platform: All
-Copying-policy: BSD-like
+Copying-policy: GPL
End
Contents:
from original manual:
- sample.i Returns absolute value of a 16-bit 2s-complement number
- lib/syslib.i Standard library
+ sample.i Returns absolute value of a 16-bit 2s-complement number
+ lib/syslib-orig.i Standard library (original buggy version)
by Jon Blow <blojo@ocf.berkeley.edu>
sink.i Simple test program
lib/lib2.i Currently contains only a decrement routine, see life.doc
pi.i Calculate pi
primes.i Find prime numbers
+ pow.i prints a list of nth powers (test of exponentiation routine)
+ lib/syslib.i Corrected version of system library.
+
+by Matt Dimeo, via http://www.ionet.net/~timtroyr/funhouse/beer.html
+ beer.i Print out the lyrics to "99 Bottles of Beer On The Wall"
+
+by Stinglai Ka'abi <stinglai@bureau.World.GOV>:
+ random2.i Another random-number generator
+
+by Jacob Mandelson <jlm@cco.caltech.edu>
+ rot13.i a ROT13 filter in INTERCAL
+
+by Jan-Pieter Cornet <johnpc@xs4all.nl>
+ hail_mary.3i print 1,000,000 Hail Marys
+ count.3i count from 1 to 10 in TriINTERCAL
+
+By Brian Raiter <breadbox@muppetlabs.com>
+ lib/numio.i I/O routines
+ lib/numio.doc description of the I/O routines
The subdirectory tests contains some programs written only to test the
compiler.
SOURCES = \
./sample.i \
+ ./beer.i \
./bubble.i \
+ ./count.3i \
+ ./hail_mary.3i \
./icat.i \
./tests/limits.i \
./tests/test1.i \
./tests/test2.i \
./tests/testlimits.i \
./tests/testsplat.i \
+ ./pow.i \
./random.i \
+ ./random2.i \
+ ./rot13.i \
./iogerunds.i \
./pi.i \
./lib/lib2.i \
+ ./lib/numio.i \
./lib/syslib.i \
./lib/plus.i \
./primes.i \
TARGETS = \
./sample \
+ ./beer \
./bubble \
+ ./count \
+ ./hail_mary \
./icat \
./tests/limits \
./tests/test1 \
./tests/test2 \
./tests/testlimits \
./tests/testsplat \
+ ./pow \
./random \
+ ./random2 \
+ ./rot13 \
./iogerunds \
./pi \
./lib/lib2 \
+ ./lib/numio \
./lib/syslib \
./lib/plus \
./primes \
./sink
test:
- for x in $(SOURCES); do echo "Test-compiling $$x"; ../src/ick $$x; done
+ for x in $(SOURCES); do echo "Test-compiling $$x"; ../src/ick -b $$x; done
lines:
wc -l $(SOURCES)
--- /dev/null
+PLEASE DO ,10 <- #1
+PLEASE DO ,10SUB#1 <- #176
+PLEASE DO ,11 <- #30
+PLEASE DO ,11SUB#1 <- #76
+ DO ,11SUB#2 <- #190
+ DO ,11SUB#3 <- #80
+ DO ,11SUB#4 <- #200
+PLEASE DO ,11SUB#5 <- #256
+ DO ,11SUB#6 <- #248
+ DO ,11SUB#7 <- #144
+ DO ,11SUB#8 <- #216
+PLEASE DO ,11SUB#9 <- #202
+ DO ,11SUB#10 <- #14
+ DO ,11SUB#11 <- #144
+ DO ,11SUB#12 <- #98
+PLEASE DO ,11SUB#13 <- #190
+ DO ,11SUB#14 <- #160
+ DO ,11SUB#15 <- #256
+ DO ,11SUB#16 <- #88
+PLEASE DO ,11SUB#17 <- #74
+ DO ,11SUB#18 <- #14
+ DO ,11SUB#19 <- #128
+ DO ,11SUB#20 <- #114
+PLEASE DO ,11SUB#21 <- #214
+ DO ,11SUB#22 <- #24
+ DO ,11SUB#23 <- #112
+ DO ,11SUB#24 <- #162
+PLEASE DO ,11SUB#25 <- #22
+ DO ,11SUB#26 <- #104
+ DO ,11SUB#27 <- #80
+ DO ,11SUB#28 <- #256
+PLEASE DO ,11SUB#29 <- #2
+ DO ,11SUB#30 <- #228
+PLEASE DO ,12 <- #49
+PLEASE DO ,12SUB#1 <- #76
+ DO ,12SUB#2 <- #190
+ DO ,12SUB#3 <- #80
+ DO ,12SUB#4 <- #200
+PLEASE DO ,12SUB#5 <- #256
+ DO ,12SUB#6 <- #248
+ DO ,12SUB#7 <- #144
+ DO ,12SUB#8 <- #216
+PLEASE DO ,12SUB#9 <- #202
+ DO ,12SUB#10 <- #14
+ DO ,12SUB#11 <- #144
+ DO ,12SUB#12 <- #98
+PLEASE DO ,12SUB#13 <- #190
+ DO ,12SUB#14 <- #160
+ DO ,12SUB#15 <- #256
+ DO ,12SUB#16 <- #88
+PLEASE DO ,12SUB#17 <- #218
+ DO ,12SUB#18 <- #36
+ DO ,12SUB#19 <- #38
+ DO ,12SUB#20 <- #164
+PLEASE DO ,12SUB#21 <- #176
+ DO ,12SUB#22 <- #48
+ DO ,12SUB#23 <- #162
+ DO ,12SUB#24 <- #14
+PLEASE DO ,12SUB#25 <- #128
+ DO ,12SUB#26 <- #208
+ DO ,12SUB#27 <- #162
+ DO ,12SUB#28 <- #222
+PLEASE DO ,12SUB#29 <- #48
+ DO ,12SUB#30 <- #8
+ DO ,12SUB#31 <- #120
+ DO ,12SUB#32 <- #66
+PLEASE DO ,12SUB#33 <- #48
+ DO ,12SUB#34 <- #246
+ DO ,12SUB#35 <- #136
+ DO ,12SUB#36 <- #184
+PLEASE DO ,12SUB#37 <- #256
+ DO ,12SUB#38 <- #202
+ DO ,12SUB#39 <- #110
+ DO ,12SUB#40 <- #104
+PLEASE DO ,12SUB#41 <- #42
+ DO ,12SUB#42 <- #126
+ DO ,12SUB#43 <- #56
+ DO ,12SUB#44 <- #88
+PLEASE DO ,12SUB#45 <- #72
+ DO ,12SUB#46 <- #56
+ DO ,12SUB#47 <- #80
+ DO ,12SUB#48 <- #242
+PLEASE DO ,12SUB#49 <- #228
+PLEASE DO ,13 <- #31
+PLEASE DO ,13SUB#1 <- #76
+ DO ,13SUB#2 <- #190
+ DO ,13SUB#3 <- #80
+ DO ,13SUB#4 <- #200
+PLEASE DO ,13SUB#5 <- #256
+ DO ,13SUB#6 <- #248
+ DO ,13SUB#7 <- #144
+ DO ,13SUB#8 <- #216
+PLEASE DO ,13SUB#9 <- #202
+ DO ,13SUB#10 <- #14
+ DO ,13SUB#11 <- #144
+ DO ,13SUB#12 <- #98
+PLEASE DO ,13SUB#13 <- #190
+ DO ,13SUB#14 <- #160
+ DO ,13SUB#15 <- #256
+ DO ,13SUB#16 <- #88
+PLEASE DO ,13SUB#17 <- #74
+ DO ,13SUB#18 <- #14
+ DO ,13SUB#19 <- #128
+ DO ,13SUB#20 <- #114
+PLEASE DO ,13SUB#21 <- #214
+ DO ,13SUB#22 <- #24
+ DO ,13SUB#23 <- #112
+ DO ,13SUB#24 <- #162
+PLEASE DO ,13SUB#25 <- #22
+ DO ,13SUB#26 <- #104
+ DO ,13SUB#27 <- #80
+ DO ,13SUB#28 <- #256
+PLEASE DO ,13SUB#29 <- #194
+ DO ,13SUB#30 <- #36
+ DO ,13SUB#31 <- #256
+PLEASE DO ,20 <- #10
+PLEASE DO ,20 SUB #1 <- #76
+ DO ,20 SUB #2 <- #196
+ DO ,20 SUB #3 <- #4
+ DO ,20 SUB #4 <- #132
+PLEASE DO ,20 SUB #5 <- #36
+ DO ,20 SUB #6 <- #164
+ DO ,20 SUB #7 <- #228
+ DO ,20 SUB #8 <- #100
+PLEASE DO ,20 SUB #9 <- #52
+ DO ,20 SUB #10 <- #180
+PLEASE DO ,21 <- #10 BY #10
+PLEASE DO ,21SUB#1#1 <- #248
+PLEASE DO ,21SUB#1#2 <- #120
+PLEASE DO ,21SUB#1#3 <- #184
+PLEASE DO ,21SUB#1#4 <- #56
+PLEASE DO ,21SUB#1#5 <- #216
+PLEASE DO ,21SUB#1#6 <- #88
+PLEASE DO ,21SUB#1#7 <- #152
+PLEASE DO ,21SUB#1#8 <- #24
+PLEASE DO ,21SUB#1#9 <- #232
+PLEASE DO ,21SUB#1#10 <- #104
+ DO ,21SUB#2#1 <- #128
+ DO ,21SUB#2#2 <- #256
+ DO ,21SUB#2#3 <- #64
+ DO ,21SUB#2#4 <- #192
+ DO ,21SUB#2#5 <- #96
+ DO ,21SUB#2#6 <- #224
+ DO ,21SUB#2#7 <- #32
+ DO ,21SUB#2#8 <- #160
+ DO ,21SUB#2#9 <- #112
+ DO ,21SUB#2#10 <- #240
+ DO ,21SUB#3#1 <- #64
+ DO ,21SUB#3#2 <- #192
+ DO ,21SUB#3#3 <- #256
+ DO ,21SUB#3#4 <- #128
+ DO ,21SUB#3#5 <- #32
+ DO ,21SUB#3#6 <- #160
+ DO ,21SUB#3#7 <- #224
+ DO ,21SUB#3#8 <- #96
+ DO ,21SUB#3#9 <- #48
+ DO ,21SUB#3#10 <- #176
+ DO ,21SUB#4#1 <- #192
+ DO ,21SUB#4#2 <- #64
+ DO ,21SUB#4#3 <- #128
+ DO ,21SUB#4#4 <- #256
+ DO ,21SUB#4#5 <- #160
+ DO ,21SUB#4#6 <- #32
+ DO ,21SUB#4#7 <- #96
+ DO ,21SUB#4#8 <- #224
+ DO ,21SUB#4#9 <- #176
+ DO ,21SUB#4#10 <- #48
+PLEASE DO ,21SUB#5#1 <- #32
+PLEASE DO ,21SUB#5#2 <- #160
+PLEASE DO ,21SUB#5#3 <- #224
+PLEASE DO ,21SUB#5#4 <- #96
+PLEASE DO ,21SUB#5#5 <- #256
+PLEASE DO ,21SUB#5#6 <- #128
+PLEASE DO ,21SUB#5#7 <- #192
+PLEASE DO ,21SUB#5#8 <- #64
+PLEASE DO ,21SUB#5#9 <- #16
+PLEASE DO ,21SUB#5#10 <- #144
+ DO ,21SUB#6#1 <- #160
+ DO ,21SUB#6#2 <- #32
+ DO ,21SUB#6#3 <- #96
+ DO ,21SUB#6#4 <- #224
+ DO ,21SUB#6#5 <- #128
+ DO ,21SUB#6#6 <- #256
+ DO ,21SUB#6#7 <- #64
+ DO ,21SUB#6#8 <- #192
+ DO ,21SUB#6#9 <- #144
+ DO ,21SUB#6#10 <- #16
+ DO ,21SUB#7#1 <- #96
+ DO ,21SUB#7#2 <- #224
+ DO ,21SUB#7#3 <- #32
+ DO ,21SUB#7#4 <- #160
+ DO ,21SUB#7#5 <- #64
+ DO ,21SUB#7#6 <- #192
+ DO ,21SUB#7#7 <- #256
+ DO ,21SUB#7#8 <- #128
+ DO ,21SUB#7#9 <- #80
+ DO ,21SUB#7#10 <- #208
+ DO ,21SUB#8#1 <- #224
+ DO ,21SUB#8#2 <- #96
+ DO ,21SUB#8#3 <- #160
+ DO ,21SUB#8#4 <- #32
+ DO ,21SUB#8#5 <- #192
+ DO ,21SUB#8#6 <- #64
+ DO ,21SUB#8#7 <- #128
+ DO ,21SUB#8#8 <- #256
+ DO ,21SUB#8#9 <- #208
+ DO ,21SUB#8#10 <- #80
+PLEASE DO ,21SUB#9#1 <- #16
+PLEASE DO ,21SUB#9#2 <- #144
+PLEASE DO ,21SUB#9#3 <- #208
+PLEASE DO ,21SUB#9#4 <- #80
+PLEASE DO ,21SUB#9#5 <- #240
+PLEASE DO ,21SUB#9#6 <- #112
+PLEASE DO ,21SUB#9#7 <- #176
+PLEASE DO ,21SUB#9#8 <- #48
+PLEASE DO ,21SUB#9#9 <- #256
+PLEASE DO ,21SUB#9#10 <- #128
+ DO ,21SUB#10#1 <- #144
+ DO ,21SUB#10#2 <- #16
+ DO ,21SUB#10#3 <- #80
+ DO ,21SUB#10#4 <- #208
+ DO ,21SUB#10#5 <- #112
+ DO ,21SUB#10#6 <- #240
+ DO ,21SUB#10#7 <- #48
+ DO ,21SUB#10#8 <- #176
+ DO ,21SUB#10#9 <- #128
+ DO ,21SUB#10#10 <- #256
+PLEASE DO ,22 <- #10
+PLEASE DO ,22 SUB #1 <- #8
+ DO ,22 SUB #2 <- #136
+ DO ,22 SUB #3 <- #72
+ DO ,22 SUB #4 <- #200
+PLEASE DO ,22 SUB #5 <- #40
+ DO ,22 SUB #6 <- #168
+ DO ,22 SUB #7 <- #104
+ DO ,22 SUB #8 <- #232
+PLEASE DO ,22 SUB #9 <- #24
+ DO ,22 SUB #10 <- #152
+ DO .10 <- #9
+ DO .11 <- #9
+PLEASE DO ,10 <- #1
+PLEASE DO ,10SUB#1 <- #176
+ DO READ OUT ,10
+ DO COME FROM (999)
+ DO (500) NEXT
+PLEASE DO ,11SUB#1 <- .5
+ DO READ OUT ,11
+ DO (500) NEXT
+ DO ,12SUB#1 <- .5
+PLEASE DO READ OUT ,12
+PLEASE DO .6 <- '?"!10~.10'~#1"$#1'~#3
+ DO (50) NEXT
+PLEASE DO .7 <- '?"!11~.11'~#1"$#1'~#3
+ DO (70) NEXT
+ DO .2 <- #1
+ DO .1 <- .11
+PLEASE DO (1010) NEXT
+ DO .11 <- .3
+ DO (600) NEXT
+ DO (101) NEXT
+(70) DO (71) NEXT
+ DO .11 <- #9
+ DO .2 <- #1
+PLEASE DO .1 <- .10
+ DO (1010) NEXT
+ DO .10 <- .3
+ DO (600) NEXT
+ DO (101) NEXT
+(71) DO RESUME .7
+(50) DO (51) NEXT
+PLEASE DO FORGET #1
+ DO .2 <- #1
+ DO .1 <- .11
+PLEASE DO (1010) NEXT
+ DO .11 <- .3
+ DO (600) NEXT
+PLEASE DO .7 <- '?"!11~.11'~#1"$#1'~#3
+ DO (80) NEXT
+ DO (101) NEXT
+(80) DO (81) NEXT
+ DO GIVE UP
+(81) DO RESUME .7
+(51) DO RESUME .6
+(101) DO FORGET #1
+(999) DO FORGET #1
+(600) DO (500) NEXT
+ DO ,13SUB#1 <- .5
+ DO READ OUT ,13
+ DO RESUME #1
+(500) DO ,30 <- #1
+ DO .1 <- .10
+ DO (1020) NEXT
+PLEASE DO ,30SUB#1 <- ,20SUB.1
+ DO READ OUT ,30
+ DO .3 <- .1
+ DO .1 <- .11
+ DO (1020) NEXT
+PLEASE DO ,30SUB#1 <- ,21SUB .3 .1
+ DO READ OUT ,30
+ DO .5 <- ,22SUB.1
+PLEASE DO RESUME #1
PLEASE NOTE INITIAL SEQUENCE INPUT
DO .1 <- .2
DO (110) NEXT
-(110) PLEASE FORGET #1
+(110) DO FORGET #1
DO WRITE IN ,1 SUB .1
DO (111) NEXT
(112) DO (2010) NEXT
- PLEASE FORGET #2
+ DO FORGET #2
DO (110) NEXT
(111) DO (112) NEXT
- PLEASE FORGET #1
+ DO FORGET #1
PLEASE NOTE CALLING SORT ROUTINE INDIRECTLY
DO .1 <- .2
PLEASE NOTE SORTED SEQUENCE OUTPUT
DO .1 <- .2
DO (210) NEXT
-(210) PLEASE FORGET #1
+(210) DO FORGET #1
DO READ OUT ,1 SUB .1
DO (211) NEXT
(212) DO (2010) NEXT
- PLEASE FORGET #2
+ DO FORGET #2
DO (210) NEXT
(211) DO (212) NEXT
- PLEASE FORGET #1
+ DO FORGET #1
PLEASE GIVE UP
(500) PLEASE ABSTAIN FROM (502)
DO (3000) NEXT
DO (501) NEXT
-(501) PLEASE FORGET #1
+(501) DO FORGET #1
(502) DO (3010) NEXT
PLEASE REINSTATE (502)
DO .3 <- '?",1SUB.1"$,1SUB.2'~'#0$#65535'
DO (501) NEXT
(504) PLEASE RESUME .3
(503) DO (504) NEXT
- PLEASE FORGET #1
+ DO FORGET #1
DO (501) NEXT
DO .2 <- .1
DO (2000) NEXT
DO (3001) NEXT
-(3001) PLEASE FORGET #1
+(3001) DO FORGET #1
DO RESUME #1
(3011) DO (2010) NEXT
- PLEASE FORGET #1
+ DO FORGET #1
DO (3001) NEXT
(3010) DO (3011) NEXT
DO (3012) NEXT
(3013) DO .1 <- .2
DO (2010) NEXT
- PLEASE FORGET #2
+ DO FORGET #2
DO .2 <- .1
DO (3010) NEXT
DO RESUME #1
(2000) PLEASE STASH .2
DO .2 <- #1
DO (2001) NEXT
-(2001) PLEASE FORGET #1
+(2001) DO FORGET #1
DO .1 <- '?.1$.2'~'#0$#65535'
DO (2002) NEXT
DO .2 <- !2$#0'~'#32767$#1'
--- /dev/null
+ DO ,1 <- #16
+ DO :2 <- #6490$#55022
+ PLEASE DO (44) NEXT
+ DO :2 <- #5631$#54733
+ PLEASE DO (44) NEXT
+ DO :2 <- #14637$#40039
+ PLEASE DO (44) NEXT
+ DO :2 <- #58550$#53112
+ PLEASE DO (44) NEXT
+ DO .1 <- #1
+ PLEASE DO (99) NEXT
+ DO GIVE UP
+(44) DO REINSTATE COMING FROM
+(19) DO COME FROM (68)
+ DO ABSTAIN FROM (19)
+(31) DO COME FROM (34)
+ DO ABSTAIN FROM (31)
+(88) DO COME FROM (65)
+ PLEASE ABSTAIN FROM (88)
+ DO COME FROM (44)
+ PLEASE DO (123) NEXT
+ DO .3 <- ':2~"#4$#13"'
+ DO :2 <- ':2~"#29520$#29511"'
+ DO ,1 SUB .1 <- .3
+(65) DON'T GIVE UP
+(34) PLEASE DON'T GIVE UP
+(68) DO NOTE THAT THIS FUNNY CODE ACTUALLY WORKS
+ PLEASE RESUME #1
+(99) DO COME FROM (69)
+ DO READ OUT ,1
+ DO ,1 SUB #1 <- #180
+ DO READ OUT .1
+ DO .2 <- "?.1$#10"~"#0$#29524"
+ PLEASE DO (15) NEXT
+(69) PLEASE DO (123) NEXT
+(42) DO RESUME .9
+(123) PLEASE .8 <- #1
+ DO COME FROM (81)
+ DO .9 <- '?"V!1~.8'$#1"~#1'~#1
+ DO .1 <- "^.1$.8"~"#0$#29524"
+ PLEASE DO (42) NEXT
+(81) DO .8 <- !8$#0'~"#9841$#1"
+(15) PLEASE RESUME '?"!2~.2'~#2"$#1'~#1
--- /dev/null
+
+ DO ,1 <- #10
+ DO ,1 SUB #1 <- #238
+ PLEASE ABSTAIN FROM (11)
+ DO ,1 SUB #2 <- #140
+ PLEASE DO ,1 SUB #3 <- #240
+ DO ,1 SUB #4 <- #96
+ DO ,1 SUB #5 <- #132
+ DO ,1 SUB #6 <- #44
+ DO ,1 SUB #7 <- #56
+ DO ,1 SUB #8 <- #176
+ DO ,1 SUB #9 <- #238
+ DO ,1 SUB #10 <- #96
+ DO .1 <- #400
+ DO (19) NEXT
+ DO GIVE UP
+(19) DO COME FROM (55)
+ PLEASE DO STASH .1
+ DO .1 <- #2500
+ PLEASE (31) NEXT
+ DO RETRIEVE .1
+ DO (123) NEXT
+(55) PLEASE DO (15) NEXT
+(31) DO COME FROM (69)
+ PLEASE DON'T FORGET TO INSERT A BETTER HAIL-MARY ROUTINE
+(11) DO ,1 SUB #1 <- #62
+ PLEASE REINSTATE CALCULATING
+ DO READ OUT ,1
+ PLEASE DO (123) NEXT
+(69) DO (15) NEXT
+(42) DO RESUME .9
+(123) PLEASE .8 <- #1
+ PLEASE COME FROM (81)
+ DO .1 <- "?.1$.8"~"#0$#29524"
+ DO .9 <- '?"V!1~.8'$#1"~#1'~#1
+ PLEASE DO (42) NEXT
+(81) DO .8 <- !8$#0'~"#9841$#1"
+(15) PLEASE RESUME '?"!1~.1'~#2"$#1'~#1
PLEASE DO ,1 <- #1
DO .4 <- #0
DO .5 <- #0
- PLEASE DO COME FROM (30)
+ DO COME FROM (30)
DO WRITE IN ,1
DO .1 <- ,1SUB#1
DO (10) NEXT
(2000) PLEASE STASH .2
DO .2 <- #1
DO (2001) NEXT
-(2001) PLEASE FORGET #1
+(2001) DO FORGET #1
DO .1 <- '?.1$.2'~'#0$#65535'
DO (2002) NEXT
DO .2 <- !2$#0'~'#32767$#1'
PLEASE DO .4 <- !4$#0'~'#32767$#1'
DO (2033) NEXT
(2032) DO (1001) NEXT
-(2036) PLEASE FORGET #1
+(2036) DO FORGET #1
DO .5 <- '?.1$.2'~'#0$#65535'
DO .5 <- '?"'&"!2~.5'~'"?'?.5~.5'$#32768"~"#0$#65535"'"$
".5~.5"'~#1"$#2'~#3
--- /dev/null
+Summary of routines in numio.i:
+
+(3000) .1 <- character from input
+(3001) Prints .2 as a character
+(3080) .1 <- a 16-bit number from the user
+(3089) .1 <- a 16-bit number from the user, with an error message if
+ non-digits are encountered
+(3090) Displays the value in .1
+(3099) Displays the value in .1 and prints a newline
+(3080) :1 <- a 32-bit number from the user
+(3089) :1 <- a 32-bit number from the user, with an error message if
+ non-digits are encountered
+(3090) Displays the value in :1
+(3099) Displays the value in :1 and prints a newline
+(3990) Initializes internal arrays.
+
+The file numio.i contains routines for doing "wimpmode"-style I/O - or
+in other words, the C-INTERCAL equivalent of atoi and itoa. (3080) and
+(3090) translate the ASCII input as a number (yes, a number as in
+[0-9]*), and (3090) and (3190) do the same for displaying numbers in
+ASCII. (By the way, the routines can also be made to support EBCDIC:
+simply replace #3 with #15 on lines 41, 81, and 107.)
+
+Each routine also has a "niner" variation. For itoa, (3099) and (3190)
+print a newline at the end of the number. In the case of atoi, (3089)
+and (3189) make sure that the number ends with a newline. In other
+words, they ensure there are no other non-numeric characters in the
+input line. If there are, a typically snide INTERCAL error message is
+displayed. (The regular versions work like C's atoi in that they
+return as soon as they see any non-digit.)
+
+There's not too much to note about these routines. The atoi versions
+use the shift-and-add trick to avoid multiplying by 10, so they should
+be pretty efficient (snort). itoa has no such shortcuts, and the
+routines use the modified division routine which also returns the
+remainder. The 16-bit version is at (2030), and is the familiar one
+created by Louis Howell, copied from syslib2.i. The 32-bit version is
+at (2530), and is just a copy of the standard library routine without
+the lines that throw away the remainder at the end.
+
+The library reserves the use of two arrays - ,3000 and ,3001 - for
+input and output respectively. Each array has one dimension of one
+element, and they are used to provide a getchar and putchar: routines
+(3000) and (3001).
+
+The arrays are initialized by routine (3990); this should be called
+before using any other routines in this file.
+
+Note also that for these routines to work properly, they must be used
+more or less exclusively in regards to other array I/O. Otherwise, the
+getchar and putchar subroutines will get out of synch with the
+Turing-text character loop. If you do want to do other I/O while using
+these routines, you can use (3000) and (3001) as a getchar and putchar
+(note that the latter expects that the character values have already
+been reversed). Or, you can simply re-initialize the ,3000 and/or
+,3001 values after you are done, by storing in them the ASCII value of
+the last character that you wrote in and/or read out. For example,
+if you have displayed some strings and the last thing to be printed
+was a newline, then:
+
+ DO ,3001SUB#1 <- #80
+
+would allow you to safely call the itoa routines, since 80 is the
+bit-reversal of 10.
+
+
+It is my earnest hope that C-INTERCAL programmers everywhere will
+flock to these handy routines, and C-INTERCAL users will thus no
+longer need to fear that they might succumb to the foul and awful
+temptation to use the dastardly +wimpmode option.
--- /dev/null
+ PLEASE USE THE AUTHORIZED CHANNELS
+
+(3000) DO STASH .2 + .3
+ DO .1 <- ,3000SUB#1
+ PLEASE WRITE IN ,3000
+ DO .2 <- ,3000SUB#1
+ DO (1000) NEXT
+ DO .1 <- .3~#255
+ DO ,3000SUB#1 <- .1
+ DO RETRIEVE .2 + .3
+ PLEASE RESUME #1
+
+(3001) DO STASH .1 + .3
+ DO .1 <- ,3001SUB#1
+ DO (1010) NEXT
+ DO ,3001SUB#1 <- .3~#255
+ PLEASE READ OUT ,3001
+ DO ,3001SUB#1 <- .2
+ DO .1 <- .2
+ DO RETRIEVE .1 + .3
+ PLEASE RESUME #1
+
+(3089) PLEASE ABSTAIN FROM (3087)
+(3080) PLEASE STASH .2 + .3 + .4
+ DO .3 <- #0
+ DO (3081) NEXT
+(3087) DO (3088) NEXT
+ PLEASE REINSTATE (3087)
+ DO .4 <- '?.1$#10'~'#0$#65535'
+ DO .4 <- .4~.4
+ DO (3085) NEXT
+(3998) DOES "ENTER A NUMBER" MEAN SOMETHING DIFFERENT WHERE YOU COME FROM?
+(3085) DO (3086) NEXT
+(3088) PLEASE FORGET #1
+ DO .1 <- .3
+ PLEASE RETRIEVE .2 + .3 + .4
+ PLEASE RESUME #1
+(3086) PLEASE RESUME '?.V4$#1'~#3
+(3081) DO COME FROM (3082)
+ DO (3000) NEXT
+ DO .4 <- '?".1~#240"$#3'~#85
+ DO .4 <- '".4~.4"~#1'$'&".1~#8"$".V1~#2"'
+ DO (3086) NEXT
+ DO .4 <- .3~#57344
+ DO .4 <- .4~.4
+ DO (3083) NEXT
+ DO (1999) NEXT
+(3083) DO (3086) NEXT
+ PLEASE FORGET #1
+ DO .4 <- .1
+ DO .2 <- !3$#0'~'#32767$#1'
+ DO .1 <- !2$#0'~'#16383$#3'
+ DO (1000) NEXT
+ DO .1 <- .3
+ DO .2 <- .4~#15
+(3082) DO (1000) NEXT
+
+(3090) PLEASE ABSTAIN FROM (3097)
+(3099) PLEASE STASH .1 + .2 + .3 + .4
+ DO .2 <- #256
+ PLEASE STASH .2
+ DO (3091) NEXT
+ DO (3095) NEXT
+ DO .2 <- #80
+(3097) DO (3001) NEXT
+ PLEASE REINSTATE (3097)
+ PLEASE RETRIEVE .1 + .2 + .3 + .4
+ PLEASE RESUME #1
+(3098) PLEASE RESUME '?"!1~.1'~#1"$#2'~#3
+(3091) DO COME FROM (3092)
+ DO .2 <- #10
+ DO (2030) NEXT
+ DO .2 <- .4
+ PLEASE STASH .2
+ DO .1 <- .3
+(3092) DO (3098) NEXT
+
+(3095) DO COME FROM (3094)
+ PLEASE RETRIEVE .2
+ DO (3093) NEXT
+ DO .2 <- .2$#3
+ DO .2 <- !2~#15'$!2~#240'
+ DO .2 <- !2~#15'$!2~#240'
+(3094) DO (3001) NEXT
+(3093) PLEASE RESUME '?".2~#256"$#1'~#3
+
+(3189) PLEASE ABSTAIN FROM (3187)
+(3180) PLEASE STASH :2 + :3 + .1 + .4
+ DO :3 <- #0
+ PLEASE STASH :4
+ DO (3181) NEXT
+ PLEASE RETRIEVE :4
+(3187) DO (3188) NEXT
+ PLEASE REINSTATE (3187)
+ DO .4 <- '?.1$#10'~'#0$#65535'
+ DO .4 <- .4~.4
+ DO (3185) NEXT
+ DO (3998) NEXT
+(3185) DO (3186) NEXT
+(3188) PLEASE FORGET #1
+ DO :1 <- :3
+ PLEASE RETRIEVE :2 + :3 + .1 + .4
+ PLEASE RESUME #1
+(3186) PLEASE RESUME '?.V4$#1'~#3
+(3181) DO COME FROM (3182)
+ DO (3000) NEXT
+ DO .4 <- '?".1~#240"$#3'~#85
+ DO .4 <- '".4~.4"~#1'$'&".1~#8"$".V1~#2"'
+ DO (3186) NEXT
+ DO .4 <- :3~'#49152$#32768'
+ DO .4 <- .4~.4
+ DO (3183) NEXT
+ DO (1999) NEXT
+(3183) DO (3186) NEXT
+ PLEASE FORGET #1
+ DO :2 <- ':3~"#0$#65535"'$'"':3~"#32767$#0"'$#0"~"#32767$#1"'
+ DO :1 <- ':2~"#32767$#1"'$'"':2~"#0$#32767"'$#0"~"#32767$#1"'
+ DO (1500) NEXT
+ DO :1 <- :3
+ DO :2 <- .1~#15
+(3182) DO (1500) NEXT
+
+(3190) PLEASE ABSTAIN FROM (3197)
+(3199) PLEASE STASH :1 + :2 + :3 + .2 + .4
+ DO :2 <- #10
+ DO .2 <- #256
+ PLEASE STASH .2
+ DO (3191) NEXT
+ DO (3095) NEXT
+ DO .2 <- #80
+(3197) DO (3001) NEXT
+ PLEASE REINSTATE (3197)
+ PLEASE RETRIEVE :1 + :2 + :3 + .2 + .4
+ PLEASE RESUME #1
+(3198) PLEASE RESUME '?"':1~:1'~#1"$#2'~#3
+(3191) DO COME FROM (3192)
+ DO (2530) NEXT
+ DO .2 <- :4
+ PLEASE STASH .2
+ DO :1 <- :3
+(3192) DO (3198) NEXT
+
+(3990) DO ,3000 <- #1
+ DO ,3000SUB#1 <- #0
+ DO ,3001 <- #1
+ DO ,3001SUB#1 <- #0
+ PLEASE RESUME #1
+
+
+(2030) DO STASH .1 + .5
+ DO .3 <- #0
+ DO .5 <- '?"!2~.2'~#1"$#1'~#3
+ PLEASE DO (2031) NEXT
+ DO .4 <- #1
+ PLEASE DO (2033) NEXT
+(2033) DO FORGET #1
+ DO .5 <- '?".2~#32768"$#2'~#3
+ DO (2032) NEXT
+ DO .2 <- !2$#0'~'#32767$#1'
+ PLEASE DO .4 <- !4$#0'~'#32767$#1'
+ DO (2033) NEXT
+(2032) DO (1001) NEXT
+(2036) PLEASE FORGET #1
+ DO .5 <- '?.1$.2'~'#0$#65535'
+ DO .5 <- '?"'&"!2~.5'~'"?'?.5~.5'$#32768"~"#0$#65535"'"$
+ ".5~.5"'~#1"$#2'~#3
+ DO (2034) NEXT
+ DO .5 <- .3
+ DO (1010) NEXT
+ PLEASE DO .1 <- .3
+ DO .3 <- 'V.4$.5'~'#0$#65535'
+ DO (2035) NEXT
+(2034) PLEASE DO (1001) NEXT
+(2035) DO FORGET #1
+ DO .5 <- "?'.4~#1'$#2"~#3
+ DO (2031) NEXT
+ DO .2 <- .2~#65534
+ DO .4 <- .4~#65534
+ PLEASE DO (2036) NEXT
+(2031) DO (1001) NEXT
+ PLEASE DO .4 <- .1
+ PLEASE RETRIEVE .1 + .5
+ PLEASE RESUME #2
+
+(2530) DO STASH :1 + :5 + .5
+ DO :3 <- #0
+ DO .5 <- '?"':2~:2'~#1"$#1'~#3
+ PLEASE DO (2531) NEXT
+ DO :4 <- #1
+ PLEASE DO (2533) NEXT
+(2533) DO FORGET #1
+ DO .5 <- '?":2~'#32768$#0'"$#2'~#3
+ DO (2532) NEXT
+ DO :2 <- ":2~'#0$#65535'"$"'":2~'#32767$#0'"$#
+ 0'~'#32767$#1'"
+ PLEASE DO :4 <- ":4~'#0$#65535'"$"'":4~'#32767
+ $#0'"$#0'~'#32767$#1'"
+ DO (2533) NEXT
+(2532) DO (1001) NEXT
+(2536) PLEASE FORGET #1
+ DO :5 <- "'?":1~'#65535$#0'"$":2~'#65535$#0'"'
+ ~'#0$#65535'"$"'?":1~'#0$#65535'"$":2~'#0$
+ #65535'"'~'#0$#65535'"
+ DO .5 <- '?"'&"':2~:5'~'"'?"'?":5~:5"~"#65535$
+ #65535"'~'#65535$#0'"$#32768'~'#0$#65535'"
+ $"'?":5~:5"~"#65535$#65535"'~'#0$#65535'"'
+ "$"':5~:5'~#1"'~#1"$#2'~#3
+ DO (2534) NEXT
+ DO :5 <- :3
+ DO (1510) NEXT
+ PLEASE DO :1 <- :3
+ DO :3 <- "'V":4~'#65535$#0'"$":5~'#65535$#0'"'
+ ~'#0$#65535'"$"'V":4~'#0$#65535'"$":5~'#0$
+ #65535'"'~'#0$#65535'"
+ DO (2535) NEXT
+(2534) PLEASE DO (1001) NEXT
+(2535) DO FORGET #1
+ DO .5 <- "?':4~#1'$#2"~#3
+ DO (2531) NEXT
+ DO :2 <- ":2~'#0$#65534'"$":2~'#65535$#0'"
+ DO :4 <- ":4~'#0$#65534'"$":4~'#65535$#0'"
+ PLEASE DO (2536) NEXT
+(2531) DO (1001) NEXT
+ DO :4 <- :1
+ PLEASE RETRIEVE :1 + :5 + .5
+ PLEASE RESUME #2
--- /dev/null
+ PLEASE KNOCK BEFORE ENTERING
+
+ (1000) PLEASE IGNORE .4
+ PLEASE ABSTAIN FROM (1005)
+ (1009) DO STASH .1 + .2 + .5 + .6
+ DO .4 <- #1
+ DO (1004) NEXT
+ (1004) PLEASE FORGET #1
+ DO .3 <- '?.1$.2'~'#0$#65535'
+ DO .6 <- '&.1$.2'~'#0$#65535'
+ PLEASE DO .5 <- "?!6~#32768'$#1"~#3
+ DO (1002) NEXT
+ DO .4 <- #2
+ (1005) DO (1006) NEXT
+ (1999) DOUBLE OR SINGLE PRECISION OVERFLOW
+ (1002) DO (1001) NEXT
+ (1006) PLEASE FORGET #1
+ DO .5 <- '?"!6~.6'~#1"$#1'~#3
+ DO (1003) NEXT
+ DO .1 <- .3
+ DO .2 <- !6$#0'~'#32767$#1'
+ DO (1004) NEXT
+ (1003) DO (1001) NEXT
+ DO REINSTATE (1005)
+ (1007) PLEASE RETRIEVE .1 + .2 + .5 + .6
+ DO REMEMBER .4
+ PLEASE RESUME #2
+ (1001) DO RESUME .5
+ (1010) DO STASH .1 + .2 + .4
+ DO .4 <- .1
+ DO .1 <- '?.2$#65535'~'#0$#65535'
+ DO (1020) NEXT
+ PLEASE DO .2 <- .4
+ PLEASE DO (1009) NEXT
+ DO RETRIEVE .1 + .2 + .4
+ PLEASE RESUME #1
+ (1020) DO STASH .2 + .3
+ DO .2 <- #1
+ PLEASE DO (1021) NEXT
+ (1021) DO FORGET #1
+ DO .3 <- "?!1~.2'$#1"~#3
+ PLEASE DO .1 <- '?.1$.2'~'#0$#65535'
+ DO (1022) NEXT
+ DO .2 <- !2$#0'~'#32767$#1'
+ DO (1021) NEXT
+ (1023) PLEASE RESUME .3
+ (1022) DO (1023) NEXT
+ PLEASE RETRIEVE .2 + .3
+ PLEASE RESUME #2
+ (1030) DO ABSTAIN FROM (1033)
+ PLEASE ABSTAIN FROM (1032)
+ (1039) DO STASH :1 + .5
+ DO (1530) NEXT
+ DO .3 <- :1~#65535
+ PLEASE DO .5 <- :1~'#65280$#65280'
+ DO .5 <- '?"!5~.5'~#1"$#1'~#3
+ DO (1031) NEXT
+ (1032) DO (1033) NEXT
+ DO (1999) NEXT
+ (1031) DO (1001) NEXT
+ (1033) DO .4 <- .5
+ DO REINSTATE (1032)
+ PLEASE REINSTATE (1033)
+ DO RETRIEVE :1 + .5
+ PLEASE RESUME #2
+ (1040) PLEASE STASH .1 + .2 + .2 + :1 + :2 + :3
+ DO .2 <- #0
+ DO (1520) NEXT
+ DO STASH :1
+ PLEASE RETRIEVE .2
+ DO .1 <- .2
+ DO .2 <- #0
+ PLEASE DO (1520) NEXT
+ DO :2 <- :1
+ DO RETRIEVE .1 + .2 + :1
+ DO (1550) NEXT
+ PLEASE DO .3 <- :3
+ DO RETRIEVE :1 + :2 + :3
+ DO RESUME #1
+ (1050) PLEASE STASH :2 + :3 + .5
+ DO :2 <- .1
+ PLEASE DO (1550) NEXT
+ DO .5 <- :3~'#65280$#65280'
+ DO .5 <- '?"!5~.5'~#1"$#1'~#3
+ DO (1051) NEXT
+ DO (1999) NEXT
+ (1051) DO (1001) NEXT
+ DO .2 <- :3
+ PLEASE RETRIEVE :2 + :3 + .5
+ DO RESUME #2
+ (1500) PLEASE ABSTAIN FROM (1502)
+ PLEASE ABSTAIN FROM (1506)
+ (1509) PLEASE STASH :1 + .1 + .2 + .3 + .4 + .5 + .6
+ DO .1 <- :1~#65535
+ PLEASE DO .2 <- :2~#65535
+ DO (1009) NEXT
+ DO .5 <- .3
+ PLEASE DO .6 <- .4
+ DO .1 <- :1~'#65280$#65280'
+ DO .2 <- :2~'#65280$#65280'
+ DO (1009) NEXT
+ DO .1 <- .3
+ PLEASE DO (1503) NEXT
+ DO .6 <- .4
+ DO .2 <- #1
+ DO (1009) NEXT
+ DO .1 <- .3
+ DO (1501) NEXT
+ (1504) PLEASE RESUME .6
+ (1503) DO (1504) NEXT
+ (1501) DO .2 <- .5
+ DO .5 <- '?"'&.6$.4'~#1"$#2'~#3
+ DO (1505) NEXT
+ (1506) DO (1502) NEXT
+ PLEASE DO (1999) NEXT
+ (1505) DO (1001) NEXT
+ (1502) DO :4 <- .5
+ DO (1520) NEXT
+ DO :3 <- :1
+ PLEASE RETRIEVE :1 + .1 + .2 + .3 + .4 + .5 + .6
+ DO REINSTATE (1502)
+ DO REINSTATE (1506)
+ PLEASE RESUME #3
+ (1510) DO STASH :1 + :2 + :4
+ DO :1 <- "'?":2~'#65535$#0'"$#65535'~'#0$#6553
+ 5'"$"'?":2~'#0$#65535'"$#65535'~'#0$#65535
+ '"
+ DO :2 <- #1
+ DO (1509) NEXT
+ PLEASE RETRIEVE :1
+ DO :2 <- :3
+ PLEASE DO (1509) NEXT
+ DO RETRIEVE :2 + :4
+ PLEASE RESUME #1
+ (1520) PLEASE STASH .3 + .4
+ DO .3 <- .1~#43690
+ DO (1525) NEXT
+ PLEASE DO .4 <- 'V.3$".2~#43690"'~'#0$#65535'
+ DO .3 <- .1~#21845
+ PLEASE DO (1525) NEXT
+ DO :1 <- .4$"'V.3$".2~#21845"'~'#0$#65535'"
+ PLEASE RETRIEVE .3 + .4
+ DO RESUME #1
+ (1525) DO .3 <- '"'"'"!3$#0'~'#32767$#1'"$#0'~'#32767
+ $#1'"$#0'~'#16383$#3'"$#0'~'#4095$#15'
+ PLEASE RESUME #1
+ (1530) DO STASH :2 + :3 + .3 + .5
+ DO :1 <- #0
+ DO :2 <- .2
+ DO .3 <- #1
+ DO (1535) NEXT
+ (1535) PLEASE FORGET #1
+ DO .5 <- "?!1~.3'$#1"~#3
+ DO (1531) NEXT
+ DO (1500) NEXT
+ DO :1 <- :3
+ PLEASE DO (1533) NEXT
+ (1531) PLEASE DO (1001) NEXT
+ (1533) DO FORGET #1
+ DO .3 <- !3$#0'~'#32767$#1'
+ DO :2 <- ":2~'#0$#65535'"$"'":2~'#32767$#0'"$#
+ 0'~'#32767$#1'"
+ PLEASE DO .5 <- "?!3~.3'$#1"~#3
+ DO (1532) NEXT
+ DO (1535) NEXT
+ (1532) DO (1001) NEXT
+ PLEASE RETRIEVE :2 + :3 + .3 + .5
+ DO RESUME #2
+ (1540) PLEASE ABSTAIN FROM (1541)
+ DO ABSTAIN FROM (1542)
+ (1549) PLEASE STASH :1 + :2 + :4 + :5 + .1 + .2 + .5
+ DO .1 <- :1~#65535
+ PLEASE DO .2 <- :2~'#65280$#65280'
+ DO .5 <- :1~'#65280$#65280'
+ DO (1530) NEXT
+ DO :3 <- :1
+ DO .2 <- :2~#65535
+ PLEASE DO (1530) NEXT
+ DO :5 <- :1
+ DO .1 <- .5
+ DO (1530) NEXT
+ DO :4 <- :1
+ PLEASE DO :1 <- ":3~'#65280$#65280'"$":5~'#652
+ 80$#65280'"
+ DO .5 <- ':1~:1'~#1
+ DO .2 <- :2~'#65280$#65280'
+ DO (1530) NEXT
+ PLEASE DO .5 <- '"':1~:1'~#1"$.5'~#3
+ DO .1 <- :3~#65535
+ DO .2 <- #0
+ DO (1520) NEXT
+ PLEASE DO :2 <- :1
+ PLEASE DO .1 <- :4~#65535
+ DO (1520) NEXT
+ DO (1509) NEXT
+ DO .5 <- !5$":4~#3"'~#15
+ DO :1 <- :3
+ DO :2 <- :5
+ DO (1509) NEXT
+ PLEASE DO .5 <- !5$":4~#3"'~#63
+ DO .5 <- '?"!5~.5'~#1"$#1'~#3
+ PLEASE RETRIEVE :4
+ (1541) DO :4 <- .5
+ DO (1543) NEXT
+ (1542) DO (1544) NEXT
+ PLEASE DO (1999) NEXT
+ (1543) DO (1001) NEXT
+ (1544) DO REINSTATE (1541)
+ PLEASE REINSTATE (1542)
+ PLEASE RETRIEVE :1 + :2 + :5 + .1 + .2 + .5
+ DO RESUME #2
+ (1550) DO STASH :1 + :4 + :5 + .5
+ DO :3 <- #0
+ DO .5 <- '?"':2~:2'~#1"$#1'~#3
+ PLEASE DO (1551) NEXT
+ DO :4 <- #1
+ PLEASE DO (1553) NEXT
+ (1553) DO FORGET #1
+ DO .5 <- '?":2~'#32768$#0'"$#2'~#3
+ DO (1552) NEXT
+ DO :2 <- ":2~'#0$#65535'"$"'":2~'#32767$#0'"$#
+ 0'~'#32767$#1'"
+ PLEASE DO :4 <- ":4~'#0$#65535'"$"'":4~'#32767
+ $#0'"$#0'~'#32767$#1'"
+ DO (1553) NEXT
+ (1552) DO (1001) NEXT
+ (1556) PLEASE FORGET #1
+ DO :5 <- "'?":1~'#65535$#0'"$":2~'#65535$#0'"'
+ ~'#0$#65535'"$"'?":1~'#0$#65535'"$":2~'#0$
+ #65535'"'~'#0$#65535'"
+ DO .5 <- '?"'&"':2~:5'~'"'?"'?":5~:5"~"#65535~
+ #65535"'~'#65535$#0'"$#32768'~'#0$#65535'"
+ $"'?":5~:5"~"#65535$#65535"'~'#0$#65535'"'
+ "$"':5~:5'~#1"'~#1"$#2'~#3
+ DO (1554) NEXT
+ DO :5 <- :3
+ DO (1510) NEXT
+ PLEASE DO :1 <- :3
+ DO :3 <- "'V":4~'#65535$#0'"$":5~'#65535$#0'"'
+ ~'#0$#65535'"$"'V":4~'#0$#65535'"$":5~'#0$
+ #65535'"'~'#0$#65535'"
+ DO (1555) NEXT
+ (1554) PLEASE DO (1001) NEXT
+ (1555) DO FORGET #1
+ DO .5 <- "?':4~#1'$#2"~#3
+ DO (1551) NEXT
+ DO :2 <- ":2~'#0$#65534'"$":2~'#65535$#0'"
+ DO :4 <- ":4~'#0$#65534'"$":4~'#65535$#0'"
+ PLEASE DO (1556) NEXT
+ (1551) DO (1001) NEXT
+ PLEASE RETRIEVE :1 + :4 + :5 + .5
+ PLEASE RESUME #2
+ (1900) DO STASH .2 + .3 + .5
+ DO .1 <- #0
+ DO .2 <- #1
+ PLEASE DO (1901) NEXT
+ (1901) DO FORGET #1
+ DO %50 .1 <- 'V.1$.2'~'#0$#65535'
+ DO .2 <- !2$#0'~'#32767$#1'
+ PLEASE DO .5 <- "?!2~.2'$#1"~#3
+ DO (1902) NEXT
+ DO (1901) NEXT
+ (1902) DO (1001) NEXT
+ DO RETRIEVE .2 + .3 + .5
+ PLEASE RESUME #2
+ (1910) PLEASE STASH .1 + .3 + .5 + :1 + :2 + :3
+ DO .3 <- #65524
+ DO :1 <- #6
+ DO (1911) NEXT
+ PLEASE NOTE THAT YOU CAN'T GET THERE FROM HERE
+ (1912) DO (1001) NEXT
+ (1911) DO FORGET #1
+ PLEASE DO (1900) NEXT
+ DO :2 <- .1
+ DO (1500) NEXT
+ PLEASE DO :1 <- :3
+ DO .1 <- .3
+ DO (1020) NEXT
+ PLEASE DO .3 <- .1
+ DO .5 <- '?"!3~.3'~#1"$#2'~#3
+ DO (1912) NEXT
+ DO .1 <- #12
+ PLEASE DO (1050) NEXT
+ DO RETRIEVE .1
+ DO (1530) NEXT
+ DO :2 <- #32768
+ DO (1500) NEXT
+ PLEASE DO .2 <- :3~'#65280$#65280'
+ PLEASE RETRIEVE .3 + .5 + :1 + :2 + :3
+ DO RESUME #1
DO .1 <- .5
DO (1530) NEXT
DO :4 <- :1
- PLEASE DO :1 <- ":3~'#65280$#65280'"$":5~'#652
+ PLEASE DO :1 <- ":3~'#65280$#65280'"$":4~'#652
80$#65280'"
DO .5 <- ':1~:1'~#1
DO .2 <- :2~'#65280$#65280'
DO :1 <- :3
DO :2 <- :5
DO (1509) NEXT
- PLEASE DO .5 <- !5$":4~#3"'~#63
+ PLEASE DO .5 <- !5$":4~#3"'~#172
DO .5 <- '?"!5~.5'~#1"$#1'~#3
PLEASE RETRIEVE :4
(1541) DO :4 <- .5
DO :5 <- "'?":1~'#65535$#0'"$":2~'#65535$#0'"'
~'#0$#65535'"$"'?":1~'#0$#65535'"$":2~'#0$
#65535'"'~'#0$#65535'"
- DO .5 <- '?"'&"':2~:5'~'"'?"'?":5~:5"~"#65535~
+ DO .5 <- '?"'&"':2~:5'~'"'?"'?":5~:5"~"#65535$
#65535"'~'#65535$#0'"$#32768'~'#0$#65535'"
$"'?":5~:5"~"#65535$#65535"'~'#0$#65535'"'
"$"':5~:5'~#1"'~#1"$#2'~#3
--- /dev/null
+ PLEASE WRITE IN .2
+ DO .1 <- #0
+ PLEASE COME FROM (1)
+ DO (2040) NEXT
+ DO NOT (2049) NEXT
+ DO READ OUT :1
+ DO NOT READ OUT .4
+(1) DO (1020) NEXT
+ PLEASE GIVE UP
+
+
+(2040) PLEASE STASH .4
+ DO ABSTAIN FROM (2047)
+(2049) DO STASH .1 + .2 + :2 + :3 + :4 + :5 + :6
+ PLEASE DO .4 <- #1
+ DO :5 <- .1
+ DO :6 <- #1
+ DO (2044) NEXT
+(2047) DO (2048) NEXT
+ DO .1 <- .4
+ DO (2046) NEXT
+ DO (1999) NEXT
+(2046) DO (2042) NEXT
+ PLEASE REINSTATE (2047)
+ PLEASE RETRIEVE .4
+(2048) DO :1 <- :6
+ DO RETRIEVE .1 + .2 + :2 + :3 + :4 + :5 + :6
+ PLEASE RESUME #2
+(2044) DO (2045) NEXT
+(2045) PLEASE FORGET #1
+ DO .1 <- "?!2~#1'$#1"~#3
+ DO (2041) NEXT
+ PLEASE DO :1 <- :6
+ PLEASE DO :2 <- :5
+ DO (1549) NEXT
+ DO :6 <- :3
+ DO .4 <- '?"'V.4$":4~#3"'~#4"$#1'~#3
+ DO (2043) NEXT
+(2042) PLEASE RESUME .1
+(2041) DO (2042) NEXT
+(2043) PLEASE FORGET #1
+ DO .2 <- .2~#65534
+ DO .1 <- '?"!2~.2'~#1"$#2'~#3
+ DO (2042) NEXT
+ PLEASE DO :1 <- :5
+ PLEASE DO :2 <- :5
+ DO (1549) NEXT
+ DO :5 <- :3
+ DO .4 <- '?"'V.4$":4~#3"'~#4"$#1'~#3
+ DO (2045) NEXT
--- /dev/null
+(1900) DO STASH .2 + .3
+ DO .3 <- #65535
+ DO (1903) NEXT
+(1903) PLEASE FORGET #1
+ DO .2 <- #0
+ PLEASE %50 IGNORE .2
+ DO .2 <- #1
+ PLEASE REMEMBER .2
+ DO .1 <- !1$.2'~"#65535$#1"
+ DO .3 <- .3~#65534
+ DO (1902) NEXT
+ DO (1903) NEXT
+(1902) DO (1904) NEXT
+ DO RETRIEVE .2 + .3
+ DO FORGET #1
+ PLEASE RESUME #1
+(1904) PLEASE RESUME '?"!3~.3'~#1"$#1'~#3
--- /dev/null
+(10) PLEASE DON'T GIVE UP
+(1) DO .2 <- '?.1$#64'~'#0$#65535'
+ DO .2 <- '&"'.1~.2'~'"?'?.2~.2'$#32768"~"#0$#65535"'"$".2~.2"'~#1
+ DO .3 <- '?#91$.1'~'#0$#65535'
+ DO .3 <- '&"'#91~.3'~'"?'?.3~.3'$#32768"~"#0$#65535"'"$".3~.3"'~#1
+ PLEASE DO (11) NEXT
+ PLEASE DO (2) NEXT
+ PLEASE DO (12) NEXT
+(11) PLEASE DO (13) NEXT
+ PLEASE FORGET #1
+ PLEASE DO (12) NEXT
+(13) PLEASE DO (14) NEXT
+ PLEASE FORGET #2
+ PLEASE DO (12) NEXT
+(14) DO STASH .1
+ DO .1 <- .3
+ PLEASE DO (1000) NEXT
+ DO .1 <- .3
+ DO .2 <- #1
+ PLEASE DO (1000) NEXT
+ DO RETRIEVE .1
+ DO RESUME .3
+(12) PLEASE FORGET #1
+ DO .2 <- '?.1$#96'~'#0$#65535'
+ DO .2 <- '&"'.1~.2'~'"?'?.2~.2'$#32768"~"#0$#65535"'"$".2~.2"'~#1
+ DO .3 <- '?#123$.1'~'#0$#65535'
+ DO .3 <- '&"'#123~.3'~'"?'?.3~.3'$#32768"~"#0$#65535"'"$".3~.3"'~#1
+ PLEASE DO (15) NEXT
+ PLEASE DO (3) NEXT
+ PLEASE DO (16) NEXT
+(15) PLEASE DO (17) NEXT
+ PLEASE FORGET #1
+ DO (16) NEXT
+(17) DO (18) NEXT
+ DO FORGET #2
+ DO (16) NEXT
+(18) DO STASH .1
+ DO .1 <- .3
+ DO (1000) NEXT
+ DO .1 <- .3
+ DO .2 <- #1
+ DO (1000) NEXT
+ DO RETRIEVE .1
+ DO RESUME .3
+(16) DO FORGET #1
+ DO RESUME #1
+(2) DO .2 <- #65
+ DO (1010) NEXT
+ DO .1 <- .3
+ DO .2 <- #13
+ DO (1000) NEXT
+ DO STASH .3
+ DO .1 <- .3
+ DO .2 <- #26
+ DO (1040) NEXT
+ DO .1 <- .3
+ DO (1030) NEXT
+ DO .2 <- .3
+ DO RETRIEVE .3
+ DO .1 <- .3
+ DO (1010) NEXT
+ DO .1 <- .3
+ DO .2 <- #65
+ DO (1000) NEXT
+ DO .1 <- .3
+ DO RESUME #1
+(3) DO .2 <- #97
+ DO (1010) NEXT
+ DO .1 <- .3
+ DO .2 <- #13
+ DO (1000) NEXT
+ DO STASH .3
+ DO .1 <- .3
+ DO .2 <- #26
+ DO (1040) NEXT
+ DO .1 <- .3
+ DO (1030) NEXT
+ DO .2 <- .3
+ DO RETRIEVE .3
+ DO .1 <- .3
+ DO (1010) NEXT
+ DO .1 <- .3
+ DO .2 <- #97
+ DO (1000) NEXT
+ DO .1 <- .3
+ DO RESUME #1
+ DO COME FROM (10)
+ DO .4 <- #0
+ DO .5 <- #0
+ DO STASH .4 + .5
+ DO ,1 <- #1
+ DO COME FROM (33)
+ DO WRITE IN ,1
+ DO .1 <- ,1 SUB #1
+ DO (31) NEXT
+ PLEASE DO .6 <- #1
+ PLEASE DO (34) NEXT
+(32) PLEASE RESUME '?.1$#256'~'#256$#256'
+(31) DO (32) NEXT
+ DO FORGET #1
+ DO .6 <- #0
+ PLEASE DO (34) NEXT
+(33) DON'T GIVE UP
+(34) DO .6 <- "?!6'$#1"~#3
+ DO (40) NEXT
+ DO GIVE UP
+(40) DO (41) NEXT
+ PLEASE FORGET #1
+ DO (42) NEXT
+(41) DO RESUME .6
+(42) DO FORGET #1
+ DO RETRIEVE .4
+ DO .2 <- .4
+ DO (1000) NEXT
+ DO .4 <- .3~#255
+ DO .3 <- .4
+ DO STASH .4
+ DO .1 <- .3
+ DO (1) NEXT
+ DO .3 <- !1~#15'$!1~#240'
+ DO .3 <- !3~#15'$!3~#240'
+ DO .2 <- !3~#15'$!3~#240'
+ DO .1 <- .5
+ DO (1010) NEXT
+ DO .5 <- .2
+ DO ,1 SUB #1 <- .3
+ PLEASE READ OUT ,1
+ PLEASE RESUME #1
- PLEASE DO .1 <- #65535
+ DO .1 <- #65535
DO :1 <- #65535
DO WRITE IN .1 + :1
DO READ OUT .1 + :1
DO .1 <- "?',1 SUB .2.1'$#1"~#3
DO .2 <- ,1 SUB #1 ;2 SUB #5
DO .1 <- .2~,1 SUB #1 #1
- PLEASE STASH .1 + ,2 + ;2 + ,1 + ,3
+ DO STASH .1 + ,2 + ;2 + ,1 + ,3
DO ,1 <- #500
DO ,1 SUB #1 <- #112
PLEASE DO READ OUT ,1 SUB .2
(2010) PLEASE ABSTAIN FROM (2004)
-(2000) PLEASE STASH .2
+(2000) DO STASH .2
DO .2 <- #1
DO (2001) NEXT
(2001) PLEASE FORGET #1
# all over creation behind your back.
# (/dev/null may be another good choice :-))
-DVMT=/home2/esr/WWW/intercal-0.13
+DVMT=/home2/esr/WWW/intercal-0.15
BINDIR = $(DVMT)/bin
INCDIR = $(DVMT)/lib
-DICKLIBDIR=\"$(LIBDIR)\" -DYYDEBUG
LDFLAGS =
-# Warning: using flex does not work yet!
+CC = gcc -Wall -W
+
+# You can use lex or flex
#LEX = lex
LEX = flex
-# However, you can use either yacc or bison
+# You can use either yacc or bison
#YACC = yacc
YACC = bison -y
ick: ick.o lexer.o feh.o lose.o fiddle.o perpetrate.o
$(CC) perpetrate.o ick.o lexer.o feh.o lose.o fiddle.o $(LDFLAGS) -o ick
-y.tab.h ick.c: ick.y
+y.tab.h ick.c: ick.y ick.h sizes.h feh.h lose.h
$(YACC) -d $(YDEBUG) ick.y
mv y.tab.c ick.c
-lexer.c: lexer.l ick.h
+lexer.c: lexer.l ick.h lose.h
$(LEX) $(LFLAGS) lexer.l
mv lex.yy.c lexer.c
-ranlib libick.a
install: all
+ -mkdir $(BINDIR); rm -f $(BINDIR)/*
cp ick $(BINDIR)
+ -mkdir $(INCDIR)
+ (cd $(INCDIR); rm -f lose.h abcess.h fiddle.h ick-wrap.c)
cp lose.h abcess.h fiddle.h ick-wrap.c $(INCDIR)
+ -mkdir $(LIBDIR)
+ (cd $(LIBDIR); rm -f libick.a syslib.i)
cp libick.a ../pit/lib/syslib.i $(LIBDIR)
-ranlib $(LIBDIR)/libick.a
* AUTHOR : Steve Swales
* DATE: October 7, 1990
* PURPOSE: Parse arguments for INTERCAL programs.
+ *
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
-/* cesspool.c -- storage management and runtime support for INTERCAL */
+/*****************************************************************************
+
+NAME
+ cesspool.c -- storage management and runtime support for INTERCAL
+
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+***************************************************************************/
/* LINTLIBRARY */
#include <stdio.h>
#include <stdlib.h>
/**********************************************************************
*
- * The following function is used for random error generation
+ * The following function is used for random decision making
*
*********************************************************************/
This module provides storage manglement, code degeneration,
and optimizations of dubious value for the INTERCAL compiler.
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
****************************************************************************/
/*LINTLIBRARY */
#include <stdio.h>
#include "lose.h"
#include "feh.h"
+static int emitlineno; /* line number for errors encountered during emit */
+
/*************************************************************************
*
* Node allocation functions.
{
atom *x;
+ if (index < 1 || index > 65535)
+ lose(E200, yylineno, (char *)NULL);
+
/* if it's already on the oblist, return its intindex */
for (x = oblist; x < obdex; x++)
if (x->type == type && x->extindex == index)
return(obdex[-1].intindex);
}
+/*************************************************************************
+ *
+ * This function insures a label is valid.
+ *
+ **************************************************************************/
+
+void checklabel(int label)
+{
+ if (label < 1 || label > 65535)
+ lose(E197, yylineno, (char *)NULL);
+}
+
/*************************************************************************
*
* Tuple allocation functions.
void optimize(node *np)
{
+ node *mingleop, *op;
+
/* recurse so we simplify each node after all its subnodes */
if (np == (node *)NULL)
return;
if (np->rval != (node *)NULL)
optimize(np->rval);
- /* check for non-zeroness test */
- if (np->opcode == SELECT && ISCONSTANT(np->rval, 1) && requal(np->lval->rval, np->lval->lval))
- {
- rfree(np->rval);
- np->rval = np->lval->rval;
- rfree(np->lval->lval);
- np->lval = (node *)NULL;
- np->opcode = TESTNZ;
- np->width = 16;
- }
-
- /* equality test by XOR */
- if (np->opcode == TESTNZ && np->rval->opcode == XOR)
- {
- node *tp = np->rval;
-
- np->opcode = EQUALS;
- np->lval = tp->lval;
- np->rval = tp->rval;
- free(np->rval);
- }
+ /*
+ * OK, now do complete folding of constant expressions.
+ */
/* fold MINGLE operations on constants */
if (np->opcode==MINGLE && (np->lval->opcode==MESH&&np->rval->opcode==MESH))
}
/* fold SELECT operations on constants */
- if (np->opcode == SELECT && (np->lval->opcode==MESH && np->rval->opcode==MESH))
+ if (np->opcode == SELECT
+ && ((np->lval->opcode==MESH || np->lval->opcode==MESH32)
+ && (np->rval->opcode==MESH || np->rval->opcode==MESH32)))
{
- np->opcode = MESH;
+ np->opcode = np->rval->opcode;
np->constant = iselect(np->lval->constant, np->rval->constant);
free(np->lval);
free(np->rval);
}
- /* fold AND operations on constants */
+ /* fold AND operations on 16-bit constants */
if (np->opcode == AND && np->rval->opcode == MESH)
{
np->opcode = MESH;
- np->constant = and16(np->lval->constant);
+ np->constant = and16(np->rval->constant);
+ free(np->rval);
+ }
+
+ /* fold AND operations on 32-bit constants */
+ if (np->opcode == AND && np->rval->opcode == MESH32)
+ {
+ np->opcode = MESH32;
+ np->constant = and32(np->rval->constant);
free(np->rval);
}
- /* fold OR operations on constants */
+ /* fold OR operations on 16-bit constants */
if (np->opcode == OR && np->rval->opcode == MESH)
{
np->opcode = MESH;
- np->constant = or16(np->lval->constant);
+ np->constant = or16(np->rval->constant);
free(np->rval);
}
- /* fold XOR operations on constants */
+ /* fold OR operations on 32-bit constants */
+ if (np->opcode == OR && np->rval->opcode == MESH32)
+ {
+ np->opcode = MESH32;
+ np->constant = or32(np->rval->constant);
+ free(np->rval);
+ }
+
+ /* fold XOR operations on 16-bit constants */
if (np->opcode == XOR && np->rval->opcode == MESH)
{
np->opcode = MESH;
- np->constant = xor16(np->lval->constant);
+ np->constant = xor16(np->rval->constant);
free(np->rval);
}
+
+ /* fold XOR operations on 32-bit constants */
+ if (np->opcode == XOR && np->rval->opcode == MESH32)
+ {
+ np->opcode = MESH32;
+ np->constant = xor32(np->rval->constant);
+ free(np->rval);
+ }
+
+ /*
+ * Less trivial stuff begins here
+ */
+
+ /* equality test by XOR */
+ if (np->opcode == TESTNZ && np->rval->opcode == XOR)
+ {
+ node *tp = np->rval;
+
+ np->opcode = EQUALS;
+ np->lval = tp->lval;
+ np->rval = tp->rval;
+ free(np->rval);
+ }
+
+ /* check for non-zeroness test */
+ if (np->opcode == SELECT && ISCONSTANT(np->rval, 1) && requal(np->lval->rval, np->lval->lval))
+ {
+ rfree(np->rval);
+ np->rval = np->lval->rval;
+ rfree(np->lval->lval);
+ np->lval = (node *)NULL;
+ np->opcode = TESTNZ;
+ np->width = 16;
+ }
+
+ /* following optimizations only work in binary */
+ if (Base != 2)
+ return;
+
+ /* recognize the idioms for various C binary logical operations */
+ if (np->opcode == SELECT
+ && np->rval->opcode == MESH32 && np->rval->constant == 0x55555555
+ && (op = np->lval)
+ && (op->opcode == AND || op->opcode == OR || op->opcode == XOR)
+ && (mingleop = op->rval) && mingleop->opcode == MINGLE
+ && mingleop->rval->width == 16
+ && mingleop->lval->width == 16)
+ {
+ np->lval = mingleop->lval;
+ np->rval = mingleop->rval;
+
+ switch(op->opcode)
+ {
+ case AND: np->opcode = C_AND; break;
+ case OR: np->opcode = C_OR; break;
+ case XOR: np->opcode = C_XOR; break;
+ default: lose(E778, yylineno, (char *)NULL);
+ }
+
+ free(mingleop); free(op);
+ }
+
+ /* recognize idioms for ~ */
+ if (np->opcode == XOR)
+ {
+ if (np->rval->width == 16
+ && np->lval->opcode == MESH &&np->lval->constant == 0xffff)
+ {
+ np->opcode = C_NOT;
+ free(np->lval);
+ }
+
+ if (np->lval->width == 16
+ && np->rval->opcode == MESH && np->rval->constant == 0xffff)
+ {
+ np->opcode = C_NOT;
+ np->rval = np->lval;
+ free(np->rval);
+ }
+
+ if (np->rval->width == 32
+ && np->lval->opcode == MESH32 && np->lval->constant == 0xffffffffL)
+ {
+ np->opcode = C_NOT;
+ free(np->lval);
+ }
+
+ if (np->lval->width == 32
+ && np->rval->opcode == MESH32 && np->rval->constant == 0xffffffffL)
+ {
+ np->opcode = C_NOT;
+ np->rval = np->lval;
+ free(np->rval);
+ }
+ }
}
/*************************************************************************
case FIN:
if (Base < 3)
- lose(E997, lineno, (char *)NULL);
+ lose(E997, emitlineno, (char *)NULL);
(void) fprintf(fp, "fin%d(", np->width);
prexpr(np->rval, fp);
(void) fprintf(fp, ")");
case WHIRL4:
case WHIRL5:
if (np->opcode - WHIRL + 3 > Base)
- lose(E997, lineno, (char *)NULL);
+ lose(E997, emitlineno, (char *)NULL);
(void) fprintf(fp, "whirl%d(%d, ", np->width, np->opcode - WHIRL + 1);
prexpr(np->rval, fp);
(void) fprintf(fp, ")");
prexpr(np->rval, fp);
(void) fprintf(fp, " != 0)");
break;
+
+ case C_AND:
+ (void) fprintf(fp, "(");
+ prexpr(np->lval, fp);
+ (void) fprintf(fp, " & ");
+ prexpr(np->rval, fp);
+ (void) fprintf(fp, ")");
+ break;
+
+ case C_OR:
+ (void) fprintf(fp, "(");
+ prexpr(np->lval, fp);
+ (void) fprintf(fp, " | ");
+ prexpr(np->rval, fp);
+ (void) fprintf(fp, ")");
+ break;
+
+ case C_XOR:
+ (void) fprintf(fp, "(");
+ prexpr(np->lval, fp);
+ (void) fprintf(fp, " ^ ");
+ prexpr(np->rval, fp);
+ (void) fprintf(fp, ")");
+ break;
+
+ case C_NOT:
+ (void) fprintf(fp, "(~");
+ prexpr(np->rval, fp);
+ (void) fprintf(fp, ")");
+ break;
}
(void) free(np);
}
-static char *nice_text(char *text)
+static char *nice_text(char *texts[], int lines)
{
#define MAXNICEBUF 512
static char buf[MAXNICEBUF];
- char *cp;
-
- for(cp = buf;*text;cp++,text++) {
+ char *cp, *text;
+ int i;
+
+ if (lines < 1)
+ lines = 1;
+ for (cp = buf, i = 0 ; i < lines ; ++i) {
+ if (i) {
+ (*cp++) = '\n';
+ (*cp++) = '\t';
+ }
+ for (text = texts[i] ; *text ; cp++, text++) {
if(*text == '"' || *text == '\\') {
- (*cp++) = '\\';
+ (*cp++) = '\\';
}
*cp = *text;
+ }
}
*cp = '\0';
return buf;
}
+static void emit_guard(tuple *tn, FILE *fp)
+/* emit execution guard for giiven tuple (note the unbalanced trailing {!) */
+{
+ (void) fprintf(fp, " if (");
+ if (tn->exechance < 100)
+ (void) fprintf(fp, "roll(%d) && ", tn->exechance);
+ (void) fprintf(fp, "!abstained[%d]) {\n", tn - tuples);
+}
+
void emit(tuple *tn, FILE *fp)
/* emit code for the given tuple */
{
node *np, *sp;
int dim;
- static int make_cf_target = 0;
+ /* grind out label and source dump */
if (yydebug || compile_only)
- (void) fprintf(fp, " /* line %03d: %s */\n",
- tn - tuples + 1,
- textlines[tn-tuples+1]);
-
- /* don't make a label if we are emitting the jump to a COME FROM */
- if (make_cf_target)
- tn->label = 0;
+ (void) fprintf(fp, " /* line %03d */\n", tn->lineno);
if (tn->label)
- (void) fprintf(fp, "L%d:\n", tn->label);
+ (void) fprintf(fp, "L%d:", tn->label);
+ if (yydebug || compile_only)
+ (void) fprintf(fp, "\t/* %s */", textlines[tn->lineno]);
+ (void) fputc('\n', fp);
+
+ /* set up the "next" lexical line number for error messages */
+ if (tn->type == NEXT) {
+ tuple *up;
+ for (up = tuples; up < tuples + lineno; up++)
+ if (tn->u.target == up->label) {
+ emitlineno = up->lineno;
+ break;
+ }
+ } else if (tn->comefrom)
+ emitlineno = tuples[tn->comefrom-1].lineno;
+ else if (tn < tuples + lineno - 1)
+ emitlineno = tn[1].lineno;
+ else
+ emitlineno = yylineno;
+ (void) fprintf(fp, " lineno = %d;\n", emitlineno);
- /* if this is a COME FROM statement, just make a label and jump to end */
- if (tn->type == COME_FROM && !make_cf_target)
+ /* emit random compiler bug */
+ if (!nocompilerbug)
{
- (void) fprintf(fp, "C%d:\n", tn->u.target);
- goto comefrom;
+#ifdef USG
+ if ((lrand48() & 127) == 127)
+#else
+ if ((rand() & 127) == 127)
+#endif
+ (void) fprintf(fp, " lose(E774, lineno, (char *)0);\n");
}
/* emit conditional-execution prefixes */
- (void) fprintf(fp, " if (");
- if (tn->exechance < 100)
- (void) fprintf(fp, "roll(%d) && ", tn->exechance);
- (void) fprintf(fp, "!abstained[(lineno = %d)-1])\n", tn - tuples + 1);
- (void) fprintf(fp, " {\n");
+ if (tn->type != COME_FROM)
+ emit_guard(tn, fp);
/* now emit the code for the statement body */
switch(tn->type)
break;
case ABSTAIN:
- (void) fprintf(fp, "\tabstained[%d-1] = TRUE;\n", tn->u.target);
+ (void) fprintf(fp, "\tabstained[%d] = TRUE;\n", tn->u.target - 1);
break;
case REINSTATE:
- (void) fprintf(fp, "\tabstained[%d-1] = FALSE;\n", tn->u.target);
+ (void) fprintf(fp, "\tabstained[%d] = FALSE;\n", tn->u.target - 1);
break;
case ENABLE:
}
break;
- case COME_FROM:
- (void) fprintf(fp,"\tgoto C%d;\n", tn->u.target);
+ case SPLATTERED:
+ dim = emitlineno - tn->lineno;
+ if (tn->sharedline)
+ ++dim;
+ (void) fprintf(fp, "\tlose(E000, %d, \"%s\");\n",
+ emitlineno, nice_text(textlines + tn->lineno, dim));
break;
- case SPLATTERED:
- /*
- fprintf(stderr,"compiling a splat... line = %d (%s)\n",
- tn->lineno,textlines[tn->lineno]);
- */
- (void) fprintf(fp,"\t(void) puts(\"*%s\");\n",
- nice_text(textlines[tn->lineno]));
- (void) fprintf(fp,
- "\texit(%d);\n", tn->lineno);
+ case COME_FROM:
+ (void) fprintf(fp, "C%d:\n", tn->u.target);
break;
default:
- lose(E778, tn - tuples + 1, (char *)NULL);
+ lose(E778, emitlineno, (char *)NULL);
break;
}
- (void) fprintf(fp, " }\n");
-
- comefrom:
-
- /* if the statement that was just degenerated was a COME FROM target,
- emit the code for the jump to the COME FROM. */
+ if (tn->type != COME_FROM)
+ (void) fprintf(fp, " }\n");
- if (tn->comefrom && !make_cf_target) {
- make_cf_target = 1;
- emit(tuples + tn->comefrom - 1, fp);
- make_cf_target = 0;
+ /*
+ * If the statement that was just degenerated was a COME FROM target,
+ * emit the code for the jump to the COME FROM.
+ */
+ if (tn->comefrom) {
+ if (yydebug || compile_only)
+ (void) fprintf(fp,
+ " /* line %03d is a suck point for the COME FROM at line %03d */\n",
+ tn->lineno, tuples[tn->comefrom-1].lineno);
+ emit_guard(tuples + tn->comefrom - 1, fp);
+ (void) fprintf(fp,
+ "\tgoto C%d;\n }\n",
+ tuples[tn->comefrom-1].u.target);
}
}
extern node *newnode(void);
extern node *cons(int type, node *car, node *cdr);
extern unsigned int intern(int type, int index);
+extern void checklabel(int label);
extern void treset(void);
extern tuple *newtuple(void);
extern void typecast(node *np);
* fiddle.c -- functions that implement the five INTERCAL operators
*
* We link these to the compiler, too, in order to do constant folding
+ *
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "fiddle.h"
/* $A.c -- generated C-code file for INTERCAL program $A.i */
+/* This code is explicitly *not* GPLed. Use, abuse, and redistribute freely */
+
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
stashinit();
$F
-
/* degenerated code */
$G
- lose(E633, $B+1, (char *)0);
-
- /* generated switch for resumes */
- top:
- switch(skipto)
- {
- $H
- }
+ lose(E633, $J, (char *)0);
+$H
return 0;
}
unsigned int target; /* for NEXT statements */
node *node; /* attached expression node(s) */
} u;
- int lineno; /* for splatters*/
+ int lineno; /* source line for error messages */
+ bool sharedline; /* if NZ, two statements on a line */
} tuple;
/* this maps the `external' name of a variable to an internal array index */
extern int yylineno;
/* compilation options */
-extern bool compile_only; /* just compile into C, don't run the linker */
-extern int yydebug; /* print debugging information while parsing */
-extern int traditional; /* compile as INTERCAL-72 */
+extern bool compile_only; /* just compile into C, don't run the linker */
+extern bool nocompilerbug; /* set possibility of E774 to zero */
+extern int traditional; /* compile as INTERCAL-72 */
+extern int yydebug; /* print debugging information while parsing */
extern int politesse;
INTERCAL-72 language; the COME FROM statement, and the prefixed forms of the
WHIRL operator.
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
*****************************************************************************/
%{
#define yylex() lexer()
static node *rlist; /* pointer to current right-hand node list */
-/* static node *llist; */ /* pointer to current left-hand node list */
+/*static node *llist;*/ /* pointer to current left-hand node list */
static node *np; /* variable for building node lists */
-#define ACTION(x, nt, nn) {x = newtuple(); x->type = nt; x->u.node=nn;}
-#define TARGET(x, nt, nn) {x = newtuple(); x->type = nt; x->u.target=nn;}
-#define NEWFANGLED if (traditional) lose(E111,yylineno,(char*)NULL); else
-
+extern int stbeginline; /* line number of last seen preamble */
+static int thisline; /* line number of beginning of current statement */
static tuple *splat(void);
+#define GETLINENO \
+ {if (stbeginline < 0) thisline = -stbeginline; \
+ else {thisline = stbeginline; stbeginline = 0;}}
+
+#define ACTION(x, nt, nn) \
+ {x = newtuple(); x->type = nt; x->lineno = thisline; x->u.node = nn;}
+#define TARGET(x, nt, nn) \
+ {x = newtuple(); x->type = nt; x->lineno = thisline; x->u.target = nn;}
+#define NEWFANGLED if (traditional) lose(E111,yylineno,(char*)NULL); else
+
%}
%start program
* will not conflict with the other tokens. It is important that
* WHIRL through WHIRL5 be a continuous sequence.
*/
-%token SPLATTERED TESTNZ EQUALS AND OR XOR FIN MESH32
+%token SPLATTERED TESTNZ C_AND C_OR C_XOR C_NOT EQUALS AND OR XOR FIN MESH32
%token WHIRL WHIRL2 WHIRL3 WHIRL4 WHIRL5
%type <node> expr varlist variable constant lvalue inlist outlist
| please OHOHSEVEN perform
{$3->label = 0; $3->exechance = $1 * $2;}
| LABEL please perform
- {$3->label = $1; $3->exechance = $2 * 100;}
+ {checklabel($1); $3->label = $1; $3->exechance = $2 * 100;}
| LABEL please OHOHSEVEN perform
- {$4->label = $1; $4->exechance = $2 * $3;}
+ {checklabel($1); $4->label = $1; $4->exechance = $2 * $3;}
| error
{lose(E017, yylineno, (char *)NULL);}
;
/* There are two forms of preamble returned by the lexer */
-please : DO {$$ = 1;}
- | DO NOT {$$ = -1;}
+please : DO {GETLINENO; $$ = 1;}
+ | DO NOT {GETLINENO; $$ = -1;}
;
/* Here's how to parse statement bodies */
{$$ = $1; $$->rval = cons(SUB, $$->rval, $3);}
;
-/* here goes the general expession syntax */
+/* here goes the general expression syntax */
expr : unambig {$$ = $1;}
| unambig SELECT unambig {$$ = cons(SELECT, $1, $3);}
| unambig SELECT subscr {$$ = cons(SELECT, $1, $3);}
/* try to recover from an invalid statement. */
{
tuple *sp;
- int tok, i, lineno;
+ int tok, i;
extern bool re_send_token;
/*
* here is to skip to the next DO, PLEASE or label, then unget that token.
* which we can do with a tricky flag on the lexer (re_send_token).
*/
- lineno = yylineno;
- /* fprintf(stderr,"attempting to splat at line %d....\n",lineno); */
+ /* fprintf(stderr,"attempting to splat at line %d....\n",yylineno); */
for(i = 0,re_send_token = FALSE;;i++) {
tok = lexer();
if (!tok)
/* generate a placeholder tuple for the text line */
TARGET(sp, SPLATTERED, 0);
- sp->lineno = lineno;
+
return(sp);
}
%{
+/*
+ * NAME
+ * lexer.l -- source for the C-INTERCAL lexical analyzer.
+ *
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char *textlines[MAXLINES];
int politesse = 0;
+int stbeginline = 0;
#ifdef FLEX_SCANNER
static char linebuf[YY_BUF_SIZE];
int lexer(void);
static int myatoi(char *text);
-
+
+#define SETLINENO \
+ {if (stbeginline == 0) stbeginline = yylineno; \
+ else if (stbeginline < 0) stbeginline = 0;}
+
/*
* The spectacular ugliness of INTERCAL syntax requires that the lexical
* analyzer have two levels. One, embedded in the getc() function, handles
\; {return(HYBRID);}
\# {return(MESH);}
-"C^H/" |
\$ {return(MINGLE);}
\~ {return(SELECT);}
\' {return(SPARK);}
\" {return(EARS);}
-\({W}{D}\) {yylval.numval = myatoi(yytext); return(LABEL);}
+\({W}{D}\) {SETLINENO; yylval.numval = myatoi(yytext); return(LABEL);}
-DO {return(DO);}
-PLEASE {politesse++; return(DO);}
-DO{W}PLEASE {politesse++; return(DO);}
-PLEASE{W}DO {politesse++; return(DO);}
+DO {SETLINENO; return(DO);}
+PLEASE {SETLINENO; politesse++; return(DO);}
+DO{W}PLEASE {SETLINENO; politesse++; return(DO);}
+PLEASE{W}DO {SETLINENO; politesse++; return(DO);}
NOT {return(NOT);}
N\'T {return(NOT);}
\<- {return(GETS);}
CALCULATING {yylval.numval = GETS; return(GERUND);}
-NEXT {return(NEXT);}
+NEXT {stbeginline = 0; return(NEXT);}
NEXTING {yylval.numval = NEXT; return(GERUND);}
FORGET {return(FORGET);}
FORGETTING {yylval.numval = FORGET; return(GERUND);}
READING{W}OUT {yylval.numval = READ_OUT; return(GERUND);}
WRITE{W}IN {return(WRITE_IN);}
WRITING{W}IN {yylval.numval = WRITE_IN; return(GERUND);}
-COME{W}FROM {return(COME_FROM);}
+COME{W}FROM {stbeginline = -stbeginline; return(COME_FROM);}
COMING{W}FROM {yylval.numval = COME_FROM; return(GERUND);}
GIVE{W}UP {return(GIVE_UP);}
/*
- * lose.c -- report INTERCAL compile- or run-time error
+ *
+ * NAME
+ * lose.c -- report INTERCAL compile- or run-time error
+ *
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*LINTLIBRARY*/
#include <stdio.h>
#define E632 "632 THE NEXT STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!\n\
ON THE WAY TO %d\n"
/* Execution has passed beyond the last statement of the program. */
-#define E633 "633 PROGRAM FELL OFF THE EDGE\n\n\
+#define E633 "633 PROGRAM FELL OFF THE EDGE\n\
ON THE WAY TO THE NEW WORLD\n"
/* A compiler error has occurred (see section 8.1). */
#define E774 "774 RANDOM COMPILER BUG\n\
ON THE WAY TO %d\n"
/*
- * These errors are unique to C-INTERCAL. They ought to be documented in
- * the revised manual.
+ * These errors are unique to C-INTERCAL.
*/
/* You tried to use a C-INTERCAL extension with the `traditional' flag on */
#define E111 "111 COMMUNIST PLOT DETECTED, COMPILER IS SUICIDING\n\
* and Volap\"uk. I've left out Albanian (didn't want to keep track
* of the dipthong diacritical) and Ojibwe (no zero digit). So:
* Nahuatl, Tagalog, Sanskrit, Basque, Georgian, Kwakiutl, and
- * Volap\"uk are now supported in addition to English. */
+ * Volap\"uk are now supported in addition to English.
+ *
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
typedef struct
{
DESCRIPTION
This is where all the dirty work begins and ends.
+LICENSE TERMS
+ Copyright (C) 1996 Eric S. Raymond
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
****************************************************************************/
/*LINTLIBRARY */
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
+#include <time.h>
#include "ick.h"
#include "feh.h"
#include "y.tab.h"
/* compilation options */
bool compile_only; /* just compile into C, don't run the linker */
bool traditional; /* insist on strict INTERCAL-72 conformance */
+bool nocompilerbug; /* disable error E774 */
static bool dooptimize; /* do optimizations? (controlled by -O) */
static bool clockface; /* set up output to do IIII for IV */
unsigned int Max_small = 0xffff;
unsigned int Max_large = 0xffffffff;
-int lineno; /* current source line number; lose() uses it */
+int lineno; /* after yyparse, this is the total number of statements */
/* currently supported numeric bases, not exported */
static int maxbase = 7;
static void print_usage(char *prog, char *options)
{
fprintf(stderr,"Usage: %s [-%s] <file> [<file> ... ]\n",prog,options);
+ fprintf(stderr,"\t-b\t:reduce the probability of E774 to zero\n");
fprintf(stderr,"\t-c\t:compile INTERCAL to C, but don't compile C\n");
fprintf(stderr,"\t-d\t:print debugging information (implies -c)\n");
fprintf(stderr,"\t-t\t:traditional mode, accept only INTERCAL-72\n");
int c;
char *includedir, *libdir, *getenv();
FILE *ifp, *ofp;
- int maxabstain;
+ int maxabstain, nextcount;
bool needsyslib;
if (!(includedir = getenv("ICKINCLUDEDIR")))
if (!(compiler = getenv("CC")))
compiler = CC;
- while ((c = getopt(argc, argv, "cdtOC@")) != EOF)
+ while ((c = getopt(argc, argv, "bcdtOC@")) != EOF)
{
switch (c)
{
+ case 'b':
+ nocompilerbug = TRUE;
+ break;
+
case 'c':
compile_only = TRUE;
break;
case '?':
default:
case '@':
- print_usage(argv[0],"cdtCO");
+ print_usage(argv[0],"bcdtCO");
exit(1);
break;
}
(void) signal(SIGBUS, abend);
#endif /* SIGBUS */
+ if (!nocompilerbug) {
+#ifdef USG
+ srand48(time(NULL) + getpid());
+#else
+ srand(time(NULL));
+#endif /* UNIX */
+ }
+
(void) sprintf(buf2,"%s/%s",includedir,SKELETON);
/* now substitute in tokens in the skeleton */
if ((ifp = fopen(buf2, "r")) == (FILE *)NULL)
- lose(E999, 0, (char *)NULL);
+ lose(E999, 1, (char *)NULL);
buf[strlen(buf) - 2] = '\0';
for (; optind < argc; optind++)
{
if (freopen(argv[optind], "r", stdin) == (FILE *)NULL)
- lose(E777, 0, (char *)NULL);
+ lose(E777, 1, (char *)NULL);
else
{
/* strip off the file extension */
if(!(chp = strrchr(argv[optind],'.')))
{
- lose(E998, 0, (char *)NULL);
+ lose(E998, 1, (char *)NULL);
}
*chp++ = '\0';
long strtol();
Base = strtol(chp,&chp,10);
if (Base < 2 || Base > maxbase)
- lose(E998, 0, (char *)NULL);
+ lose(E998, 1, (char *)NULL);
else if (traditional && Base != 2)
- lose(E111, 0, (char *)NULL);
+ lose(E111, 1, (char *)NULL);
Small_digits = smallsizes[Base];
Large_digits = 2 * Small_digits;
Max_small = maxsmalls[Base];
/*
* Miss Manners lives.
*/
- if (yylineno > 2)
- if (politesse == 0 || yylineno / politesse > 5)
+ if (lineno > 2)
+ if (politesse == 0 || lineno / politesse > 5)
lose(E079, yylineno, (char *)NULL);
- else if (yylineno / politesse < 3)
+ else if (lineno / politesse < 3)
lose(E099, yylineno, (char *)NULL);
/*
* check if we need to magically include the system library
*/
needsyslib = FALSE;
- for (tp = tuples; tp < tuples + lineno; tp++) {
+ for (tp = tuples; tp->type; tp++) {
/*
* If some label in the (1000)-(2000) range is defined,
* then clearly the syslib is already there, so we
* called, we might need the system library.
*/
if (tp->type == NEXT && tp->u.target >= 1000 &&
- tp->u.target <= 1999 )
+ tp->u.target <= 1999)
needsyslib = TRUE;
}
if ( needsyslib ) {
(void) sprintf(buf2, "%s/%s", ICKLIBDIR, SYSLIB);
if ( freopen(buf2, "r", stdin) == (FILE*) NULL ) {
- lose(E127, 0, (char*) NULL);
+ lose(E127, 1, (char*) NULL);
}
#ifdef USE_YYRESTART
yyrestart(stdin);
* we have to generate different code depending on the
* deducible type of the operand.
*/
- for (tp = tuples; tp < tuples + lineno; tp++)
+ for (tp = tuples; tp->type; tp++)
if (tp->type == GETS || tp->type == RESIZE
|| tp->type == FORGET || tp->type == RESUME)
typecast(tp->u.node);
/* perform optimizations */
if (dooptimize)
- for (tp = tuples; tp < tuples + lineno; tp++)
+ for (tp = tuples; tp->type; tp++)
if (tp->type == GETS || tp->type == RESIZE
|| tp->type == FORGET || tp->type == RESUME)
optimize(tp->u.node);
(void) strcpy(buf, argv[optind]);
(void) strcat(buf, ".c");
if ((ofp = fopen(buf, "w")) == (FILE *)NULL)
- lose(E888, 0, (char *)NULL);
+ lose(E888, 1, (char *)NULL);
fseek(ifp,0L,0); /* rewind skeleton file */
(void) fputs(argv[optind], ofp);
break;
- case 'B': /* # of source lines */
+ case 'B': /* # of statements */
(void) fprintf(ofp, "%d", lineno);
break;
case 'C': /* initial abstentions */
maxabstain = 0;
- for (tp = tuples; tp < tuples + lineno; tp++)
+ for (tp = tuples; tp->type; tp++)
if (tp->exechance <= 0 && tp - tuples + 1 > maxabstain)
maxabstain = tp - tuples + 1;
if (maxabstain)
case 'D': /* linetypes array for abstention handling */
maxabstain = 0;
- for (tp = tuples; tp < tuples + lineno; tp++)
+ for (tp = tuples; tp->type; tp++)
if (tp->type == ENABLE || tp->type == DISABLE)
maxabstain++;
if (maxabstain)
enablers[i], i+1);
(void) fprintf(ofp, "int linetype[] = {\n");
- for (tp = tuples; tp < tuples + lineno; tp++)
+ for (tp = tuples; tp->type; tp++)
if (tp->type >= GETS && tp->type <= COME_FROM)
(void) fprintf(ofp,
" %s,\n",
op->intindex);
break;
- case 'F':
+ case 'F': /* set clockface option? */
if (clockface)
(void) fprintf(ofp, "clockface(TRUE);");
break;
case 'G': /* degenerated code */
- for (tp = tuples; tp < tuples + lineno; tp++)
+ for (tp = tuples; tp->type; tp++)
emit(tp, ofp);
break;
- case 'H':
- for (tp = tuples; tp < tuples + lineno; tp++)
+ case 'H': /* dispatching for resumes */
+ nextcount = 0;
+ for (tp = tuples; tp->type; tp++)
if (tp->type == NEXT)
- (void) fprintf(ofp,
- "\tcase %d: goto N%d; break;\n",
- tp - tuples + 1, tp - tuples + 1);
+ nextcount++;
+ if (nextcount)
+ {
+ (void) fputs("/* generated switch for resumes */",ofp);
+ (void) fputs("top:\n switch(skipto)\n {\n", ofp);
+ for (tp = tuples; tp->type; tp++)
+ if (tp->type == NEXT)
+ (void) fprintf(ofp,
+ "\tcase %d: goto N%d; break;\n",
+ tp-tuples+1, tp-tuples+1);
+ (void) fprintf(ofp, " }");
+ }
+ break;
+
+ case 'J': /* # of source file lines */
+ (void) fprintf(ofp, "%d", yylineno);
break;
}
--- /dev/null
+<!doctype HTML public "-//W3O//DTD W3 HTML 2.0//EN">
+<HTML>
+<HEAD>
+<link rev=made href=mailto:esr@snark.thyrsus.com>
+<TITLE>INTERCAL Resource Page</TITLE>
+</HEAD>
+<BODY BGCOLOR="fffffh">
+<H1><CENTER>This is the INTERCAL Resources Page.</CENTER></H1>
+
+Beware! If you aren't a hard-core hacker, you'd best surf right back
+where you came from <EM>now</EM>. Nothing but twisted technical yuks
+and an inexorable descent into brain-sucking obsession awaits beyond
+this point. <B>You have been warned.</B>
+
+<H1><CENTER>Abandon All Sanity, Ye Who Enter Here</CENTER></H1>
+
+So, you think you've seen it all, eh? <P>
+
+OK. You've coded in C. You've hacked in LISP. Fortran and BASIC
+hold no terrors for you. You write Emacs modes for fun. You eat
+assemblers for breakfast. You're fluent in half a dozen languages
+nobody but a handful of übergeeks have ever heard of. You grok TECO.
+Possibly you even know <I><shudder></I> COBOL. <P>
+
+Maybe you're ready for the ultimate challenge...INTERCAL. <P>
+
+INTERCAL. The language designed to be Turing-complete but as
+fundamentally unlike any existing language as possible. Expressions
+that look like line noise. Control constracts that will make you
+gasp, make you laugh, and possibly make you hurl. Data structures?
+We don't need no steenking data structures! <P>
+
+INTERCAL. Designed very early one May morning in 1972 by by two
+hackers who are still trying to live it down. Initially implemented
+on an IBM 360 running batch SPITBOL. Described by a manual that
+circulated for years after the short life of the first implementation,
+reducing strong men to tears (of laughter). Revived in 1990 by the
+C-INTERCAL compiler, and now the center of an international community
+of technomasochists. <P>
+
+INTERCAL. Now you, too, can be a part of the madness. <P>
+
+<H1><CENTER>Intercal Resources</CENTER></H1>
+
+You can download either a <A HREF="intercal.ps">Postscript</A> or
+<A HREF="intercal.ms">flat text</A> version of the Revised INTERCAL
+Manual here. Postscript is recommended, as the manual now includes
+figures and diagrams until recently unseen by any but the small
+handful with paper copies. <P>
+
+You can download the latest version of the <A
+HREF="http:../esr-freeware/intercal-0.14.tar.gz"> C-INTERCAL
+distribution</A> here (includes the manual and sample programs).
+Requires either bison or yacc and flex or lex. Builds and runs nicely
+under any ANSI/POSIX platform, including Linux and the free BSD
+versions.<P>
+
+There is an <A HREF="news:alt.lang.intercal">alt.lang.intercal</A>
+Usenet newsgroup. <P>
+
+Louis Howell, possibly the most accomplished C-INTERCAL hacker not yet
+permanently institutionalized, has his own INTERCAL page, <A
+HREF="http://www.webcom.com/nazgul/intercal.html"> The Pit</A>. Jacob
+Mandelson also has an <A
+HREF="http://www.ugcs.caltech.edu/~jlm/intercal.html">INTERCAL
+Page</A>. (The code from both these pages has been folded into the
+INTERCAL distribution.)
+
+<H1><CENTER>Related Links</CENTER></H1>
+
+If INTERCAL interests you, you may want to check out the <A
+HREF="http://www.ccil.org/jargon">Jargon File</A> and the <A
+HREF="http://www.ccil.org/retro">Retrocomputing Museum</A>. Both these
+pages and this one are maintained by <A
+HREF="http://www.ccil.org/~esr"> Eric S. Raymond</A>, who also
+maintains a large collection of freeware you may find stimulating. <P>
+
+<HR>
+<ADDRESS>Eric S. Raymond <esr@snark.thyrsus.com></ADDRESS>
+</BODY>
+</HTML>