996
|
1 <HTML>
|
|
2 <HEAD>
|
|
3 <TITLE>CLC-INTERCAL Reference</TITLE>
|
|
4 </HEAD>
|
|
5 <BODY>
|
|
6 <H1>CLC-INTERCAL Reference</H1>
|
|
7 <H2>... Fundamental Concepts</H2>
|
|
8
|
|
9 <P>
|
|
10 Table of contents:
|
|
11 <UL>
|
|
12 <LI><A HREF="index.html">Parent directory</A>
|
|
13 <LI><A HREF="#history">History of INTERCAL</A>
|
|
14 <LI><A HREF="#syntax">INTERCAL Syntax</A>
|
|
15 </UL>
|
|
16 </P>
|
|
17
|
|
18 <H2><A NAME="history">History of INTERCAL</A></H2>
|
|
19
|
|
20 <P>
|
|
21 This section will be left blank until somebody volunteers to write it.
|
|
22 </P>
|
|
23
|
|
24 <H2><A NAME="syntax">INTERCAL Syntax</A></H2>
|
|
25
|
|
26 <P>
|
|
27 INTERCAL enjoys a very simple and regular syntax. The input file is
|
|
28 completely free format. The whole program can bein one (very long) line,
|
|
29 or a newline can be inserted anywhere a space is permitted. There is
|
|
30 no need for a special statement termination symbol (like the hybrid
|
|
31 (<CODE>;</CODE>) used by C, Perl, Java, and other languages). Instead,
|
|
32 a statement simply ends when the next one starts.
|
|
33 </P>
|
|
34
|
|
35 <P>
|
|
36 Whitespace is allowed almost anywhere. The only exception is inside keywords
|
|
37 (so IGNORE cannot be written IG NORE) and numbers (so #65535 is not the
|
|
38 same as #655 35). However, if a keyword already contains a space (like
|
|
39 COME FROM), more can be added to keep it company, or the lone space can be
|
|
40 removed.
|
|
41 </P>
|
|
42
|
|
43 <P>
|
|
44 Note that a future version of CLC-INTERCAL plans to embed a
|
|
45 <A HREF="http://compsoc.dur.ac.uk/whitespace/">Whitespace</A>
|
|
46 compiler inside the standard compiler. When that is done, whitespace
|
|
47 will be still ignored by the standard compiler, but it will have a
|
|
48 new meaning. We'll change this chapter as necessary when we do that.
|
|
49 </P>
|
|
50
|
|
51 <P>
|
|
52 A statement consists of up to five fields; only the second and fifth are
|
|
53 required, the rest being optional. When the compiler is looking for the
|
|
54 start of a statement, it will look for anything which resembles the contents
|
|
55 of the first or the second field and take it from there. The five fields
|
|
56 are:
|
|
57 <UL>
|
|
58 <LI>Label - this is a number enclosed in parentheses, for example (1) or
|
|
59 (65535). The number must be a positive integer less than 65536. Recent
|
|
60 versions of CLC-INTERCAL allow computed labels if you specify the
|
|
61 <I>computed-labels</I> compiler option.
|
|
62
|
|
63 <LI>Statement identifier - this is one of the keywords "DO", "PLEASE", or
|
|
64 "PLEASE DO". The programmer should achieve a good balance between these
|
|
65 keywords, as otherwise the compiler will stop with an error. We
|
|
66 recommend approximately one "PLEASE" every four statements. Note that
|
|
67 CLC-INTERCAL does not currently check for a balance between politeness
|
|
68 and rudeness, although it will one day.
|
|
69
|
|
70 <LI>Initial ABSTAIN - this is one of the keywords "NOT" or "N'T", or
|
|
71 <CODE>¬</CODE> (this is the symbol for logical negation, if the
|
|
72 character set is ISO-8859-1). See the discussion on ABSTAIN FROM in
|
|
73 <A HREF="statements.html#abstain_from">the chapter about Statements</A>.
|
|
74
|
|
75 <LI>Execution probability - this is the symbol double-oh-seven
|
|
76 (<CODE>%</CODE>) followed by an expression. Before executing the statement,
|
|
77 the value is calculated: if it is 100 or over, the statement is executed.
|
|
78 Otherwise, the statement might or might not be executed, and the
|
|
79 probability of executing it is the value of the expression. For
|
|
80 compatibility with INTERCAL-72, which only accepted constant probabilities,
|
|
81 constants can be written without the leading "#", i.e. "%#50" can be
|
|
82 written simply "%50".
|
|
83
|
|
84 <LI>Statement - this is described in <A HREF="statements.html">the chapter
|
|
85 about Statements</A>, and can be composed of several subfields.
|
|
86 </UL>
|
|
87 </P>
|
|
88
|
|
89 <P>
|
|
90 For example, all the following statements are equivalent when executed:
|
|
91 <UL>
|
|
92 <LI><CODE>DON'T PANIC</CODE>
|
|
93 <LI><CODE>PLEASE DO NOT PANIC</CODE>
|
|
94 <LI><CODE>PLEASE ¬ PANIC</CODE>
|
|
95 <LI><CODE>DO¬PANIC</CODE>
|
|
96 <LI><CODE>DONOTPANIC</CODE>
|
|
97 </UL>
|
|
98 </P>
|
|
99
|
|
100 <P>
|
|
101 As an aside, the above is a useful "no operation" statement which you
|
|
102 might want to know about. It does nothing, so it can't do any more damage
|
|
103 than the rest of the program already does. It can be REINSTATEd, though,
|
|
104 so you might end up executing it which will print DON'T PANIC on the terminal
|
|
105 and exit - this might also be useful.
|
|
106 </P>
|
|
107
|
|
108 </BODY>
|
|
109 </HTML>
|
|
110
|