\documentstyle[makeidx]{mybook}
%\input{slovak.tex}
%
%\vsize     29.7cm 
%\hsize     21.0cm
%\textheight 22cm
%\textwidth  15.5cm
%\topmargin  -0.5cm
%\oddsidemargin  0.5cm
%\evensidemargin 0.5cm
%\renewcommand{\chaptername}{Kapitola}
%\renewcommand{\appendixname}{Dodatok}
%\renewcommand{\bibname}{Preh"lad literat`ury}
%\renewcommand{\contentsname}{Obsah}
%\renewcommand{\figurename}{Obr}
%\renewcommand{\listfigurename}{Zoznam obr`azkov}

%% doktorat
%\addtolength{\topmargin}{-68pt}
%\addtolength{\textheight}{102pt}
%\renewcommand{\baselinestretch}{1.3}
%\textheight 20.0cm
%\textwidth  12.cm
%\topmargin -1.5cm
%\oddsidemargin 0.45cm
%\evensidemargin 0cm
%%%%%%%%%%%%%%%%%%%%%%%%

\textheight       24.7cm
\textwidth        17cm
%
%
\oddsidemargin    -0.40cm
\topmargin       -1.90cm

\newcommand{\CiF}{\sf Clif}
\newcommand{\mybasel}{\baselineskip 9pt}
\newcommand{\myver}{0.8.1.beta
}
\makeindex

%%
\title{The Interpreter \CiF \\ User's Guide}
\author{\v{L}. Kore\v{n}%\thanks{
%\protect \input{adr0.tex}}
\\
For version \myver
}
\date{Last updated 30 July 1996}
%%
\begin{document}
\maketitle
\pagenumbering{roman}
\chapter{Preface}

The syntax of the \CiF\ is based on the C language. The handbook is
sequenced very close to the \cite{ritchie} or other computer
programming language books.

The syntax structures are described in the following chapters. These
structures are described using examples. All examples are simply
stated programs and therefore they should be understandable for users
knowing a C-language.

\tableofcontents
\listoffigures
\chapter{Introduction to the interpreter \CiF}

Our goal is to show main structures of the language via
examples. We want to explain all structures in the way of
writing simply stated programs.

%This kind of explanation has disadvantages. The most
%important are the explanation of a feature is not placed at
%one part and simplicity could be strange.

\section{Start of the interpreter} 

The interpreter\index{interpreter!session} session can begin by
writing just \CiF\ on the command interpreter line.  The interpreter
framework is started (another way of starting the interpreter session
is explained later). On the standard output is written:

\begin{verbatim}
This is interpreter Clif 
\end{verbatim}

The simplest command is:\index{function!cprintf@{\sf cprintf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf();
cprintf(1,"%s\n","hello");
\end{verbatim}}

On the standard output is written:

\begin{verbatim}
hello
\end{verbatim}

If you make a mistake in the statement, the interpreter announces
it. The argument 1 means {\it stdout}\index{stdout@{\it stdout}}.

\section{Variables and arithmetic operations}

The following program adds two numbers:\index{function!cprintf@{\sf
cprintf()}}\index{function!cscanf@{\sf cscanf()}}

{\mybasel
\begin{verbatim}
/* program for input and output of the text */

export_type extern int cprintf();
extern int cscanf();

int a,b,c; 
cprintf(1,"%s\n","input value a"); 
cscanf(0,"%d",a);
cprintf(1,"%s\n","input value b"); 
cscanf(0,"%d",b); 
c=a+b;
cprintf(1,"the sum is %d\n",c); 
exit; 
\end{verbatim}}

The comment\index{comment} lines are embedded between the $\slash
\ast$ and $\ast \slash$. They are unimportant during the run-time. 

Variables\index{variable!declaration} have to be declared before they
are used first time. If you forget the declaration statement the
interpreter announces the mistake. The declaration contents of a name
of the type and list of variables separated by commas:\\

\begin{verbatim}
int a,b,c;
\end{verbatim}

The argument 0 in {\sf cscanf} statement means {\it
stdin}\index{stdin@{\it stdin}}. The rest of the statements is
described in the following sections.

\pagenumbering{arabic}
\chapter{Data types, operators and expressions} 

\section{Names of the variables}

Names of the variables\index{variable!name} are sequences of
characters. The first character must be a letter. The character "\_"
is assumed like a letter as well. The names of the variables are
restricted. The names can not be keywords (e.g.  {\sf if, else,
int}). The keywords are dedicated.

\section{Data types}

The interpreter \CiF\ as well as the C-language, has only few
fundamental data types: \label{`types'}

\begin{tabular}{ll}
{\sf char} & one byte, it is possible to store one
character from the set \\
{\sf int} & integer, it is depending on a size of the
integer of the host \\
{\sf float} & single precision real number \\
{\sf double} & double precision real number \\
\end{tabular}

\section{Constants}\index{constant}

There are different types of constants. The
integer\index{constant!int@{\sf int}} constant has usual notation for
example 134 e.g. it is any sequence of digits. The {\sf
float}\index{constant!float@{\sf float}} and {\sf
double}\index{constant!double@{\sf double}} constants have the
following notations: 134.435 or 12.56e-3 or 0.2345E3

The character\index{constant!char@{\sf char}} constant is a character
cited in single quotas\index{quotas!single}, for example 'a'. The
value of the character constant is integer value from the set of
characters of the host computer (for example ASCII).

There are special character constant\index{constant!special!char@{\sf
char}} comprised of sequence of characters, for example: $\backslash$n
(newline), $\backslash$t (tab), $\backslash \backslash$ (backslash),
etc.

The string constant\index{constant!string} is embedded by double
quotas\index{quotas!double}, e.g.  "I am a string". The quotas are not
included in string constants. The string is an array\index{array} of
characters. At the end of the string constant an empty character
$\backslash$0 is appended. Therefore it is necessary to bear into mind
that 'x' is different from "x".

\section{Declaration}\index{variable!declaration}

All variables must have been declared before they are used. The
declaration contents of type specifier followed by a list of one or
more variables of the type. For example:\\

{\mybasel
\begin{verbatim} 
int a,b,c; 
double d,e,f; 
int g;
double h; 
\end{verbatim}}

The declaration is a little bit larger but it can be completed by a
comment.

\section{Arithmetic operators} 

The arithmetic operators\index{operator!arithmetic} are
$+,-,\ast,\slash$ and the modulus operator \%. There is a
operator\index{operator!unary} of unary $-$ but not unary $+$. The
rest is truncated in the integer division.  The expression $x$\%$y$ is
the operation $x$ divided by $y$. The result is zero, if $y$ is the
divisor of the $x$.

The operators $+$ and $-$ have the same
precedence\index{operator!precedence}. The precedence is lower then
the (equal) precedence of the operators $\ast, \slash$ and \%. The
arithmetic operators are left
associative\index{operator!associativity}.

%The order of evaluation of the
%associative and commutative operators (e.g. $\ast$ and
%$+$) is left associative too.

\section{Relational and logical
operators}\index{operator!relational}\index{operator!logical}

The relational operators are\\
\hspace{0.5cm}$>$\hspace{0.5cm}$>\,=$\hspace{0.5cm}$<$\hspace{0.5cm}$<\,=$\\
Each of them has the same precedence\index{operator!precedence}. The
operators of equality are behind them in the precedence\\
\hspace{0.5cm}$==$\hspace{0.5cm}$!=$\\ (both have the same
precedence). The relational operators have the lower precedence than
the arithmetic ones.

The logical operators\index{operator!logical} \&\& and $||$ are left
associative\index{operator!associativity}. The logical expressions
are evaluated from left to right.
  
%These behaviors are important for the writing good programs.

The precedence of the operator \&\& is higher than the operator
$||$. Both of them have the lower precedence than the relational and
equality operators.

\section{Type conversion}

In an expression, the operands can differ in types. The
coercions\index{coercion} take place in the expressions which have a
sense. For example, using a variable which has type double as an array
subscript has no sense; therefore the coercion is not processed. In
this case the interpreter announces an error.

If one of the operands is a double, all operands become
double. Always, types of both processed operands are compared. Then
the coercion is made to the type of operand which is "wider". The
order of the implemented types from the "narrowest" to the "widest" is
as follows: {\it char, int, float, double}. Another type of
coercion\index{coercion} is in an assignment. The right side value of
the expression is converted to the type of the variable on the left
side. The type of result is the same as type of the variable on the
left side of the expression.

The type of the result can be forced by cast operator which
causes an explicit conversion. In a statement\\ {\em
(name\_of\_type) expression}\\ the {\em expression} is
converted to the {\em name\_of\_type}.

\section{Increment and decrement
operators}\index{operator!increment}\index{operator!decrement}

The language of the interpreter has operators for the increment and
decrement of the
variables\index{variable!increment}\index{variable!decrement}. The
increment operator ($++$) adds one to the operand. The decrement
operator ($--$) subtracts one from the operand. The operators can be
used only in the prefix notation\index{notation!prefix}. E.g. let n
is 5, the expression\\

\begin{verbatim}
   x = ++n;
\end{verbatim}

assigns to the variable n the value 6. Then the value 6
is assigned to the variable x.

\section{Bitwise logical operators}\index{operator!bitwise logical}

The \CiF\ has operators for bit manipulating\\

\begin{tabbing}
\&\hspace{3cm} \=the bitwise AND operator\\
$|$            \>the bitwise inclusive OR operator\\
$\hat{}$       \>the bitwise exclusive OR operator\\
$<<$           \>the left shift operator\\
$>>$           \>the right shift operator\\
$\tilde{}$     \>the unary one's complement
operator\\\index{operator!one's complement}\index{operator!unary}
\end{tabbing}

The bitwise AND operator\index{operator!AND} (\&) is often used as a
mask of the bits. The bitwise inclusive OR operator\index{operator!OR}
($|$) is used in a setting of bits.

An user should bear in mind the big difference between the bitwise
logical operators \&, $|$ and logical operators \&\&, $||$. For
example if $x$ is 1 and $y$ is 2 then expression $x$\&$y$ is equal
zero, while $x$\&\&$y$ is equal one. The result of bitwise logical AND
and bitwise logical OR is always {\it int}.

The shift operators\index{operator!shift} $<<$ and $>>$ cause the
shift of the left operand to the left or right. The number of shifted
bits is in the right operand. The result of these operations is
undefined if the right operand is negative or greater than or equal to
the length of object in this bits.

The unary one's complement operator\index{operator!unary} $\tilde{}$
changes each bit, ones to zeros and vice versa. The type of the
operand must be integer.  

\section{Conditional expression}

There is a short form for the conditional statement using only
expressions instead of statements, i.e.:

{\mybasel
\begin{tabbing}
\sf expr1 ? expr2 : expr3; 
\end{tabbing}}

The {\sf expr1} is evaluated. If it is true, the {\sf expr2} is
executed. If the {\sf expr1} is false, {\sf expr3} is executed.

\section{Assignment operators}
\label{sec:ao}

There are the following compound assign operators:\\ \newline

{\mybasel
\begin{center}
\begin{tabular}{|c|}\hline
$*=$ \\ \hline
$/=$ \\ \hline
$\%=$ \\ \hline
$+=$ \\ \hline
$-=$ \\ \hline
$<<=$ \\ \hline
$>>=$ \\ \hline
$\&=$ \\ \hline
$\hat{}=$ \\ \hline
$|=$ \\ \hline
\end{tabular}
\end{center}}

\section{The precedence and the order of the
evaluation}\index{operator!precedence}

The following table offers the survey of the operators.  The operators
in the same line have the same precedence. The precedence increases
line by line.\\ \newline

{\mybasel
\begin{center}
\begin{tabular}{|l|c|} \hline 
{\bf Operator} & {\bf Associativity}\\ \hline \hline 
$=$ $+=$ $-=$ $*=$ $/=$ $\%=$ $\&=$ $\hat{}=$ $|=$ $<<=$ $>>=$ & right
to left\\ \hline 
$?:$ & right to left \\ \hline
$||$ & left to right\\ \hline 
$\&\&$ & left to right\\ \hline 
$|$ & left to right\\ \hline
$\hat{}$ & left to right\\ \hline 
$\&$ & left to right\\ \hline 
$==$ $!=$ & left to right\\ \hline 
$<$ $<=$ $>$ $>=$& left to right\\ \hline 
$<<$ $>>$ & left to right\\ \hline 
$+$ $-$ & left to right\\ \hline 
$*$ $/$ $\%$ & left to right\\ \hline 
$\tilde{}$ $!$ $++$ $--$ $-$ ({\it name\_of\_type})& right to left\\
\hline $($ $)$ $[$ $]$ & left to right\\ \hline 
\end{tabular} 
\end{center}}
\vspace{1cm} 

The table must be born in mind to write correct program without
complications.

\chapter{Control flow}
\section{Conditional statement}

The conditional statement\index{statement!if@{\sf if}} {\sf if-else}
has the following syntax:

{\mybasel
\begin{tabbing}
\sf if \sf ( \sf expr \sf ) \=                           \\
                            \> \sf \{ \sf stat1 \sf \}   \\
\sf else                                                 \\
                            \> \sf \{ \sf stat2 \sf \}   \\
\end{tabbing}}

The {\sf else }part is not compulsory. The {\sf expr} is evaluated and
if it is nonzero, the first substatement is executed.  If the {\sf
expr} is equal zero and if the {\sf else} part exists, the second
substatement is executed ({\sf stat2}).

\section{Statement {\sf switch-case}}

If more conditional statements have to be used in a sequence, a {\sf
  switch}\index{statement!switch@{\sf switch}} can be used. Then the
different branches can be followed using {\sf
  case}\index{statement!case@{\sf case}} statement. I.e.,

{\mybasel
\begin{tabbing}
  \sf switch \sf ( \sf expr \sf ) \=                                \\
                                  \> \sf \{                         \\
                                  \> \sf case \sf expr1 : \sf stat1 \\
                                  \> \sf case \sf expr2 : \sf stat2 \\
                                  \> \sf default : \sf stat3        \\
                                  \> \}                             \\
\end{tabbing}}

The {\sf expr} is evaluated. Then it is compared to {\sf expr1}. If
they are equal then the {\sf stat1} is executed. If they are not equal
the execution continues at the next label ({\sf expr2} in this case).
The expressions in labels have to be constant expressions. {\sf
  default} is executed only if no expression in label statements is
equal to the {\sf expr}. The {\sf default} statement can be
omitted. A usage is in the following
example:\index{function!cprintf@{\sf
    cprintf()}}\index{function!cscanf@{\sf cscanf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf();
extern int cscanf();
int a;
cprintf(1,"%s\n","input a");
cscanf(0,"%d",a);
switch (a)
{
default:
        cprintf(1,"%s\n","default");
case 1:
        cprintf(1,"%s\n","1");
        break;
case 2|5:
        cprintf(1,"%s\n","2|5");
        break;
case 3:
        cprintf(1,"%s\n","3");
        cprintf(1,"%s\n","no break");
case 4:
        cprintf(1,"%s\n","4");
        break;
}
exit;
\end{verbatim}}

 \section{{\sf while}, {\sf do while} and {\sf for}
   loops}\index{statement!while@{\sf while}}\index{statement!for@{\sf for}}\index{statement!do@{\sf do}}

 In 
 {\mybasel
 \begin{tabbing}
 \sf while \sf ( \sf expr \sf )\=                           \\
                               \> \sf \{ \sf stat \sf \}    \\
 \end{tabbing}}

 the {\sf expr} is evaluated. If its value is nonzero, the {\sf stat}
 is executed and the {\sf expr} is evaluated again.  The
 loop\index{loop} continues until the {\sf expr} becomes 0. After loop
 finishing, it is proceeded below the {\sf stat}.

 The sequence of statements\index{statement!do@{\sf do}}
 {\mybasel
 \begin{tabbing}
 \sf do \sf \=                                                   \\
                               \> \sf \{ \sf stat \sf \}         \\
                               \> \sf while \sf ( \sf expr \sf ) \\ 
 \end{tabbing}}

 is executed at least once. The {\sf while expr} is evaluated at the
 end of the loop sequence. If the {\sf expr} is true the sequence of
 statements in the loop is repeated.

 The statement {\sf for}\\

 {\mybasel
 \begin{tabbing}
 \sf for \sf ( \sf expr1; \sf expr2; \sf expr3) \=                              \\ 
                                                      \> \sf \{ \sf stat \sf \} \\
 \end{tabbing}}
 is equal with the sequence of the following commands\\
 {\mybasel
 \begin{tabbing}
 \sf expr1;\\
 \sf while \sf ( \sf expr2 \sf ) \=                    \\
                                   \> \sf \{ \sf stat  \\
                                   \> \sf expr3; \sf \}\\
 \end{tabbing}}

 All three parts of the statement {\sf for} are
 expressions\index{expression}. The expressions {\sf expr1} and {\sf
 expr3} are usually assignments. The {\sf expr2} is a relational
 expression.  Thus the first expression specifies initialization for
 the loop\index{loop!initialization}; the second specifies a test, made
 before each iteration, such that the loop is exited when expression
 becomes 0. The third expression often specifies an
 incrementing\index{operation!increment} that is performed after each
 iteration.

 If all three parts are dropped, the {\sf expr2} is
 considered true and\\

 {\mybasel
 \begin{tabbing}
 \sf for \sf( \sf ; \sf ; \sf ) \sf \{ \=         \\
                                       \> $\dots$ \\
                                       \> \sf \}  \\
 \end{tabbing}}

 is an infinite loop\index{loop!infinite}. It is assumed another
 termination of the loop. For example by the
 statements\index{statement!break@{\sf break}} {\sf break} or {\sf
 return}\index{statement!return@{\sf return}}.

 Everyone should consider which loop statement\index{loop!statement} to
 use. If we need not to initialize or to reinitialize the loop
 variable\index{loop!initialize}, we can take an advantage of the
 statement {\sf while}.

 The loop statement\index{statement!for@{\sf for}} {\sf for} is useful
 if we need to initialize and reinitialize the loop variable. The
 control statements are concentrated at the beginning of the loop.

 \section{Statement {\sf break}}\index{statement!break@{\sf break}}
 
 It is useful to break processing of the loop at arbitrary place. The
 statement\index{statement!break@{\sf break}} {\sf break} causes
 termination of the most inner {\sf while}\index{statement!while@{\sf while}} or {\sf for}\index{statement!for@{\sf for}}. The
 following program shows function of the {\sf
   break}\index{statement!break@{\sf break}}:\index{function!cprintf@{\sf cprintf()}}

 {\mybasel
 \begin{verbatim}
 export_type extern int cprintf();

 int x;
 x=1;
 while (x<=10)
         {
         cprintf(1,"%s\n","now in while");
                 if(x == 5)
                         {
                         cprintf(1,"%s\n","now in IF");
                         cprintf(1,"%s\n","*********************************");
                         x++;
                         break;
                         }
                 cprintf(1,"x=%d\n",x);
                 x++;
         }
 exit;
 \end{verbatim}}

 Control passes to the statement following the terminated compound
 statement.

 \section{Statement {\sf continue}}\index{statement!continue@{\sf continue}}

 Statement {\sf continue} is related to the statement {\sf break}. It
 causes control to pass to the loop-continuation part of the most inner
 loop ({\sf for, while})\index{statement!while@{\sf while}}\index{statement!for@{\sf for}}, i.e. to the end of the loop.
 The {\sf while} loop proceeds at the expression. The {\sf for} loop
 proceeds at the reinitialization. The program with the statement {\sf
 continue} follows:\index{function!cprintf@{\sf cprintf()}}

 {\mybasel
 \begin{verbatim}
 export_type extern int cprintf();

 int x;
 for (x=1;x<=10;x++)
         {
         cprintf(1,"%s\n","now in for");
                 if(x == 5)
                         {
                         cprintf(1,"%s\n","now in IF");
                         print(1,"%s\n","*********************************");
                         continue;
                         }
                 cprintf(1,"x=%d\n",x);
         }
 exit;
 \end{verbatim}}

 and more complex example:\index{function!cprintf@{\sf cprintf()}}

 {\mybasel
 \begin{verbatim}
 /* test program for nested loop */
 export_type extern int cprintf();

 int x,y;
 y=1;
 for(x=1;x<15;x++)
         {
          cprintf(1,"%s\n","now in for");
          cprintf(1,"x=%d\n",x);
          while(x>5 && x<10)
                 {
                  cprintf(1,"%s\n","now in while");
                  cprintf(1,"x=%d\n",x);
                  if(x==9)
                         {
                          cprintf(1,"%s\n","now in the body of the first condition");
                          cprintf(1,"x=%d\n",x);
                          continue;
                         }
                  if(x==8)
                         {
                          cprintf(1,"%s\n","now in the body of the second condition");
                          break;
                         }
                  x=x+y;
                  cprintf(1,"x=%d\n",x);
                 }
         if(x==14)
                 {
                  cprintf(1,"%s\n","now in the body of the third condition");
                  cprintf(1,"x=%d\n",x);
                  break;
                 }
         }
 exit;
 \end{verbatim}}

 \section{Statement {\sf goto}}\index{statement!goto@{\sf goto}}

 Although the {\sf goto} statement is a part of unstructured
 programming the \CiF environment supports this syntactic construction
 as well. The {\sf goto} statement is used for unconditional branching
 of programs. The jump is possible only in the level one. There is no
 possibility to jump with {\sf goto} statement across
 functions. Typical usage is in the following example:
 \index{function!cprintf@{\sf cprintf()}}

 {\mybasel
\begin{verbatim}
 export_type extern int cprintf();

int i;

cprintf(1,"%s\n","in front");
  {
   a: cprintf(1,"%s ","a");

   if (10 == i)
     {
      cprintf(1,"%s ","in if"); ++i;
      goto b;
     }
   else
     {
      ++i;
     }
   goto a;
b:
  cprintf(1,"%s ","b");
  }
cprintf(1,"%s\n","after");
exit;

\end{verbatim}
}

\chapter{Functions and program structure}
Bigger tasks can be split by functions to the parts.
Programmer can use the parts which were designed by other
authors.

\section{Fundamentals}

Each function looks like

{\mybasel
\begin{tabbing}
\sf type \sf name \sf(type \sf argument, \sf \ldots \sf )\=                                       \\
                                                         \> \sf \{                                \\
                                                         \> \sf declarations \sf a \sf statements \\
                                                         \> \sf \}                                \\
\end{tabbing}}

(The types are mentioned on the page~\pageref{`types'}. In addition,
the type {\sf void}\index{type!void@{\sf void}} can be in a function
declaration). The {\sf void} type denotes an nonexistent return
value. Some parts of functions can be dropped out; minimal function
is\\ {\sf type dummy() \{ \}\\}.  (The function can be useful in
filling place in program design).

{\sf return} statement\index{statement!return@{\sf return}} returns
value of the called function to the calling function. Syntax of the
statement {\sf return} is as follows:\\ {\sf return ( expr );\\}\\ The
calling function can ignore the return value.  

\section{Scope rules}

Global variables\index{variable!global} must have been declared before
they are used. Functions\index{function!declaration} must be declared
before the formal call as well. The functions must be
defined\index{function!definition} before the real call. The part of
program where the name is declared is a scope of the
name\index{variable!scope}. The global
variables\index{variable!global} are valid during whole interpreter
session\index{interpreter!session}. The local
variables\index{variable!local} are only valid during the processing
of the function. The interpreter searches the table of local variables
for the variable. If it is not successful, it proceeds searching the
table of global variables for the variable. If it is not successful
again it announces an error.

\section{Recursion} 

Functions\index{function!recursive} can be written in recursive form
(e.g. a function can call {\em itself}). The recursion can be direct
or indirect. An example of the recursion is n!
(factorial):\index{function!cprintf@{\sf
cprintf()}}\index{function!cscanf@{\sf cscanf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf(); 
extern int cscanf();

int n;
int fak(int n)
{
if(n==1)
        {return(1);}
return(fak(n-1)*n);
}
cprintf(1,"%s\n","input n");
cscanf(0,"%d",n);
n=fak(n);
cprintf(1,"factorial =%d\n",n);
exit;
\end{verbatim}}

Other examples follow:\\ Recursive function for Fibonacci
sequence\index{function!cprintf@{\sf
cprintf()}}\index{function!cscanf@{\sf cscanf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf();
extern int cscanf();

int n;
int fib(int n)
{
if(n<=1)
        {
        return(1);
        }
else
        {
        return(fib(n-1)+fib(n-2));
        }
}
cprintf(1,"%s\n","input n");
cscanf(0,"%d",n);
n=fib(n);
cprintf(1,"n=%d\n",n);
exit;
\end{verbatim}}

or for $n \choose k$\index{function!cprintf@{\sf
cprintf()}}\index{function!cscanf@{\sf cscanf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf();
extern int cscanf();

int n,k;
int komb(int n,int k)
{
if((n==k) || (k==0))
        {
        return(1);
        }
else
        {
        return(komb(n-1,k)+komb(n-1,k-1));
        }
}
cprintf(1,"%s\n","input n");
cscanf(0,"%d",n);
cprintf(1,"%s\n","input k");
cscanf(0,"%d",k);
n=komb(n,k);
cprintf(1,"n=%d\n",n);
exit;
\end{verbatim}}

and for ${n \choose k} \cdot \sum \limits_{i=1}^{l}i
$\index{function!cprintf@{\sf cprintf()}}\index{function!cscanf@{\sf
cscanf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf();
extern int cscanf();

int n,k,l;
int f(int n,int k)
{
if((k==0) || (n==k))
        {
        return(1);
        }
return(f(n-1,k)+f(n-1,k-1));
}
int komb(int n,int k,int l)
{
if((k==0) || (n==k))
        {
        return(1);
        }
if(l==1)
        {
        return(f(n,k));
        }
return(komb(n-1,k,l-1)+f(n-1,k)*l+komb(n-1,k-1,l-1)+f(n-1,k-1)*l);
}
cprintf(1,"%s\n","input n");
cscanf(0,"%d",n);
cprintf(1,"%s\n","input k");
cscanf(0,"%d",k);
cprintf(1,"%s\n","input l");
cscanf(0,"%d",l);
n=komb(n,k,l);
cprintf(1,"n=%d\n",n);
exit;
\end{verbatim}}

\section{Including files for interpretation during the
session}\index{interpreter!session}

Users can include a file into the interpreter by
statement\index{statement!load@{\sf load}}\\
{\sf load ( name\_of\_file);\\}
The file will be interpreted automatically.

\chapter{Derived variable types}\index{variable!type}

\section{Arrays}\index{array}

One and multidimensional type of
arrays\index{array!onedimensional}\index{array!multidimensional} are
available in the interpreter. They are used to group the sets of the
like variables. Example of one-dimensional array follows:

\begin{verbatim}
type name_of_array[number_of_elements];
\end{verbatim}

The size of an array\index{array!size of} must be an integer
constant\index{constant!int@{\sf int}}. An element of the
array\index{array!subscript} can be accessed through subscripting.
For example:\\

\begin{verbatim}
a[7]=56;
\end{verbatim}

In the interpreter, subscripting\index{array!subscript} begins with
zero. An integer expression\index{expression} can be between the
brackets; i.e. a subscripting variable\index{variable!subscripting},
an expression\index{expression}, or return value from a function call.

\subsection{Internal representation of arrays}\index{array!internal
representation of}

Arrays are containing certain data type. They are stored in a
contiguous set of these data types. See figure \ref{pole}

\begin{figure}
\begin{center}
\unitlength=1.00mm
%\special{em:linewidth 0.4pt}
\linethickness{0.4pt}
\begin{picture}(73.00,128.33)
\put(50.00,46.00){\framebox(23.00,81.00)[cc]{}}
\put(50.00,122.67){\line(1,0){23.00}}
\put(50.00,120.67){\line(1,0){23.00}}
\put(61.00,118.67){\makebox(0,0)[cc]{.}}
\put(61.00,114.67){\makebox(0,0)[cc]{.}}
\put(61.00,108.67){\makebox(0,0)[cc]{.}}
\put(50.00,99.00){\line(1,0){23.00}}
\put(46.00,109.00){\makebox(0,0)[cc]{0}}
\put(46.00,84.67){\makebox(0,0)[cc]{1}}
\put(61.00,36.00){\makebox(0,0)[cc]{.}}
\put(61.00,40.00){\makebox(0,0)[cc]{.}}
\put(61.00,44.00){\makebox(0,0)[cc]{.}}
\put(50.00,4.67){\framebox(23.00,18.67)[cc]{}}
\put(60.67,101.67){\makebox(0,0)[cc]{n}}
\put(25.67,127.00){\line(0,-1){122.33}}
\put(50.00,74.33){\line(1,0){23.00}}
\put(46.00,56.33){\makebox(0,0)[cc]{n}}
\put(0.67,41.00){\line(1,0){52.67}}
\put(16.34,91.00){\makebox(0,0)[cc]{0}}
\put(16.00,21.67){\makebox(0,0)[cc]{1}}
\put(36.33,127.00){\vector(1,0){13.67}}
\put(42.33,128.33){\makebox(0,0)[cc]{A}}
\put(45.67,18.00){\makebox(0,0)[cc]{.}}
\put(45.67,22.00){\makebox(0,0)[cc]{.}}
\put(45.67,26.00){\makebox(0,0)[cc]{.}}
\put(16.00,11.00){\makebox(0,0)[cc]{.}}
\put(16.00,15.00){\makebox(0,0)[cc]{.}}
\put(16.00,19.00){\makebox(0,0)[cc]{.}}
\end{picture}

\caption[Internal representation of arrays]{Internal
representation of arrays}\label{pole}
\end{center}
\end{figure}

\section{Multidimensional arrays}\index{array!multidimensional}

In the interpreter, arrays of arbitrary dimensions can also be
declared. The two-dimensional array with $m\times n$ elements is
declared as follows:

\begin{verbatim}
type name_of_array[m][n];
\end{verbatim}

An element of the array can again be accessed through
subscripting\index{array!subscripting}, e.g.

\begin{verbatim}
a[7][9]
\end{verbatim}

This will access the element in the 8-th row (row number 7)
and in the 10-th column (column number 9).

\section{Array names in expressions}

The element of the array\index{array!element of} in an expression can
only be accessed through subscripting\index{array!subscript}, but
there is an exception; the array can be passed as a parameter to a
function (without subscripting).  An example of the parameter
passing\index{parameter!passing} mechanism using an array as a
parameter\index{array!as parameter}
follows:\index{function!cprintf@{\sf cprintf()}}

{\mybasel
\begin{verbatim}
export_type extern int cprintf();

int a[5][5][5][5][5];
a[0][0][0][0][0]=1;
a[1][1][1][1][1]=1;
a[2][2][2][2][2]=1;
a[3][3][3][3][3]=1;
a[4][4][4][4][4]=a[3][3][3][3][3];
int z(int b[][5][5][5][5])
{
cprintf(1,"%d\n",b[0][0][0][0][0]);
cprintf(1,"%d\n",b[1][1][1][1][1]);
cprintf(1,"%d\n",b[2][2][2][2][2]);
cprintf(1,"%d\n",b[3][3][3][3][3]);
cprintf(1,"%d\n",b[4][4][4][4][4]);
}
z(a);
exit;
\end{verbatim}}

\chapter{Termination of the \CiF\ session}

Statement {\sf exit;}\index{statement!exit@{\sf exit}} terminates the
interpreter session\index{interpreter!session}. This statement
terminates correctly work of the interpreter environment.

\chapter{Run-string handling}

So far, the input was always standard input. But the interpreter can
have specified parameters\index{parameter!run-string}\index{command
line} in the run-string (command line) which are names of
programs. The input is redirected and a file\index{file@open} is
opened instead of the standard input.\index{input!standard}

Other parameters can appear in the command line. One of the
parameters is {\sf $\slash$help} evoking brief help.  Another
parameter is for resetting of the size of main memory\index{memory}
areas of the interpreter\index{interpreter!memory area of}. The size
is specified relatively. This parameter can be specified in the
run-string\index{parameter!run-string} as follows:

\begin{verbatim}
/bc=<number>
\end{verbatim}

As the {\sf $<$number$>$} can be specified a positive integer. The
default value is 10.

\chapter{The standard I/O routines}

So far, all our sample programs have written data to the standard
output\index{output!standard}\index{stdout@{\it stdout}} and read data
from standard input\index{input!standard}\index{stdin@{\it stdin}} (in
both cases the terminal). As long as we are
accessing\index{data!access} not large portions of data, thus data in
the simple form, this type of I/O routines is sufficient. However,
large amounts of data are generally stored in files\index{file}. To
perform I/O from and to files\index{file} I/O functions are included
in the interpreter.

Access to files generally requires four basic functions:
\begin{description}
\item[open] This enables access to a file and establishes
the file handle.

\item[close] This terminates access to the file. When the
access to a file is complete, it should be closed. The
number of files that the interpreter can simultaneously
manage is limited.  Therefore the files should be properly
closed.

\item[read] This function gets data from the file.

\item[write] This function adds information to the file or
replaces information already in the file.
\end{description}

\section{Opening a file}\index{file!open}

The standard I/O function used to open a file is named copen(). The
function returns a handle\index{handle} to the opened
file\index{file!open}. The function has to be declared as
follows:\index{function!copen@{\sf copen()}}

\begin{verbatim}
extern int copen();
\end{verbatim}

The function has two arguments\index{function!argument}:

\begin{itemize} 
\item {\sf file\_name} is the starting address of a character string
describing the name of the file. This can be a string constant or an
array name\index{array!as parameter}.

\item {\sf mode} which describes the action that should be
performing on the file. The modes are:

\begin{itemize}
\item {\sf r} The file\index{file!open} is opened for reading started
at the beginning of the file.

\item {\sf w} The file\index{file!open} is opened for writing; it is
assumed that the file is to be created. If the file does not exist, it
is created; if it exists, it is truncated (size of the file is reduced
to zero) and positioned at the beginning of the file.

\item {\sf a} The file\index{file!open} is opened for writing. The
mode is the same as mode for {\sf w} except that the initial position
is at the end of the file, i.e. the file is not truncated.

\item {\sf r+} The file\index{file!open} is opened for update,
i.e. the file is opened for reading and writing and is not
truncated. The initial position is at the beginning of the file.

\item {\sf w+} The file\index{file!open} is opened for update,
i.e. the file is opened for reading and writing and is truncated, if
the file already exists. If it does not exist, it is created. The
initial position is at the beginning of the file.

\item {\sf a+} The file\index{file!open} is opened for update,
i.e. the file is opened for reading and writing and is not truncated
and the initial position is at the end of the file.

\end{itemize} 
\end{itemize} 

The function returns\index{function!return} an handle\index{handle}
(integer number) if opening is successful. Otherwise the function
returns\index{function!return} {\it EOF}\index{EOF@{\it EOF}}.

\section{Closing a file}\index{file!close}

If the access to a file was completed, the file\index{file!close}
should be closed. The declaration\index{function!declaration} of the
function is as follows:\index{function!cclose@{\sf cclose()}}

\begin{verbatim}
extern int cclose(); 
\end{verbatim}

The argument of the {\sf cclose()}\index{function!cclose@{\sf
cclose()}} function\index{function!argument} is the return
value\index{function!return} from the {\sf
copen()}\index{function!copen@{\sf copen()}} function (the
handle\index{handle}). The handle is released. If the program exits
without closing a file\index{file!close}, the system closes
automatically the opened file.

The return\index{function!return} values are 0 that means a successful
file\index{file!close} closing or {\it EOF}\index{EOF@{\it EOF}} that
means an error was encountered during the closing of the file.

\section{Reading from a file}

As far, we have only used the {\sf
cscanf()}\index{function!cscanf@{\sf cscanf()}} function. Another
function that can be used is {\sf cgetc()}\index{function!cgetc@{\sf
cgetc()}} function. The parameter of the
function\index{function!parameter} is an integer number
(handle\index{handle}), which was returned by a {\sf
copen()}\index{function!copen@{\sf copen()}} function. The {\sf
cgetc()}\index{function!cgetc@{\sf cgetc()}} function reads a
character from the file\index{file} which is pointed by the
handle. The function {\sf cgetc()}\index{function!cgetc@{\sf cgetc()}}
is declared as follows:\index{function!cgetc@{\sf cgetc()}}

\begin{verbatim}
extern int cgetc();
\end{verbatim}

This function returns\index{function!return} an {\it
EOF}\index{EOF@{\it EOF}} character when an error occurred or at the
end-of-file.

\section{Writing to a file}\index{file!write}

In the previous sections we only write to the {\it
stdout}\index{stdout@{\it stdout}} via the {\sf cprintf()}
function. Analogous function to the {\sf
cgetc()}\index{function!cgetc@{\sf cgetc()}} is a function {\sf
cputc()}\index{function!cputc@{\sf cputc()}}. The function is
declared\index{function!declaration}:\index{function!cputc@{\sf
cputc()}}

\begin{verbatim} 
extern int cputc(); 
\end{verbatim} 

The function writes a character into the file\index{file!write}. On
failure, the function\index{function!return} returns an {\it
EOF}\index{EOF@{\it EOF}}.

\section{Functions {\sf cscanf()} and {\sf
cprintf()}}\index{function!cscanf@{\sf
cscanf()}}\index{function!cprintf@{\sf cprintf()}}

The functions used in previous section read from standard input and
wrote to standard output. Default handles for {\it
stdin}\index{stdin@{\it stdin}}, {\it stdout}\index{stdout@{\it
stdout}} and {\it stderr}\index{stderr@{\it stderr}} are 0,1,2
respectively. These functions can read\index{file!read} from or
write\index{file!write} to a file. As the first parameter of the
functions\index{function!parameter} is used a handle\index{handle} of
the file, for example:\index{function!cscanf@{\sf
cscanf()}}\index{function!cprintf@{\sf cprintf()}}

{\mybasel
\begin{verbatim}

float f; 
int a,b;

extern int cscanf ();
export_type extern int cprintf ();

extern int cclose ();
extern int copen ();

cscanf(0,"%f",f);
b=copen("test_file","w");
cprintf(1,"handle = %d\n",b);
cprintf(b," f=%f\n",f);
cscanf(0,"%d",a);
cprintf(b,"integer value = %d\n",a);
cclose(b);
cprintf(1,"%s\n","I am a string");
exit;
\end{verbatim}}

The second parameter in the {\sf cscanf()} function is a format string
and the third parameter is a variable name for storing the input. 

The second parameter of the {\sf cprintf()} function is a format
string and/or string constant and the third parameter is a variable
name for output.

The following list describes valid format strings\index{string!format}:

\begin{description}

\item[d] the input/output field is a decimal integer; the
corresponding variable name must point to the integer

\item[u] the input/output field is a decimal integer; the
corresponding variable name must point to the integer; value is
unsigned

\item[o] the input/output field is a octal integer; the corresponding
variable name must point to the integer

\item[x] the input/output field is a hexadecimal integer; the
corresponding variable name must point to the integer

\item[e,f,g] the input/output field is an optionally signed string of
digits. The field may contain a radix character and an exponent field
begins with a letter E or e, followed by an optional sign or space and
an integer. The variable must point to the floating point variable. If
you specify l, the variable must point to the double precision
variable. 

\item[s] the input/output field is a character string. The variable
must point to an array of characters large enough to contain the
string and a termination character ($\backslash 0$). The {\sf
cscanf()} function adds the termination character automatically. A
white-space character terminates the input string, so the input string
cannot contain spaces.

\item[c] the input/output field is a character or character
string. The variable must point to either a character variable or a
character array.

\end{description}
\chapter{Graphics interface}

So far, the sample programs have written data to the standard
output\index{output!standard} in the numerical form. The interpreter
also provides graphics outputs\index{output!graphics}. Certain type
of graphics functions\index{function!graphics} is included in the
interpreter. A call to the graphics functions results in establishment
of a channel\index{channel}. Access to channels generally requires
four basic operations: \\

\begin{description} 

\item[open] First channel\index{channel!open} should be opened which
allows access to the other graphics
functions\index{function!graphics}.

\item[close] This terminates access to the
channel\index{channel!close}. When the access to the channel is
complete, it should be closed.  The number of channels that can
simultaneously be opened is limited.

\item[write] This adds data to the channel\index{channel!write}.  

\item[flush] This flushes all data from the
channel\index{channel!flush} to the output device.

\end{description} 

\section{Opening a channel} 

The graphics interface function used to open a
channel\index{channel!open} is named {\sf
chopen()}\index{function!chopen@{\sf chopen()}}. It returns a integer
number - handle\index{handle}, if opening succeeds; otherwise it
returns -1. The handle must be saved; all other graphics functions
require the handle as an argument. The {\sf
chopen()}\index{function!chopen@{\sf chopen()}} function should be
declared as follows:

\begin{verbatim} 
extern int chopen("arguments");
\end{verbatim} 

This function creates a window for a graphics
output\index{output!graphics}. This must be done before attempts are
made to write in to the channel\index{channel!write}.

The {\sf chopen()}\index{function!chopen@{\sf chopen()}} has the
following arguments (arguments are in the form of
sublanguage):\index{drawn object}

\begin{description}

\item[fields]\label{`fields'}\index{fields} This record is compulsive.
This is an integer number which specifies number of records written to
the channel\index{channel!record}. The other arguments have their
default\index{default} values.

\item[style] This specifies the type and path (attributes) of the
drawn object. The {\sf style}\index{style} is a positive integer number.

\item[lower]\index{lower} This denotes lower boundary of the drawn
object.

\item[upper]\index{upper} This denotes upper boundary of the drawn
object.

\item[print\_format]\index{print\_format} The available values are
{\sf point}\index{point@{\sf point}} and {\sf line}\index{line@{\sf
line}}. Default\index{default} is {\sf line}.

\item[start\_time]\index{start\_time} Initial setup of the time. The
available values are {\sf automatic}\index{automatic@{\sf automatic}}
and an arbitrary real number. The {\sf automatic}\index{automatic@{\sf
automatic}} means that the window is cleared when the output reaches
the right end of the window. New initial time continues at the end
value of the time in previous window.  Default\index{default} value is
0.0.

\item[duration\_time]\index{duration\_time} This means a length of the
window, i.e.  the number of the records contained in the window in the
vertical direction. The available values are {\sf
automatic}\index{automatic@{\sf automatic}} and an arbitrary real
number. The {\sf automatic}\index{automatic@{\sf automatic}} means if
the output reaches the right end of the window then output is redrawn,
i. e. the {\sf duration\_time} size is changed. Default\index{default}
value is 1000.0.

\item[w\_resolution]\index{w\_resolution} This specifies the size of
the window.  The default \index{default}value is 256 by 256 pixels.

\item[type]\index{type} This specifies if the alphanumeric window
should be created as well. The available values are {\sf
alpha}\index{alpha} and {\sf
graphic}\index{graphic}. Default\index{default} value is the {\sf
graphic}.

\item[OnLeaveW]\index{OnLeaveW} The parameter specifies if the
interpreter should be stopped temporarily when enriches the right end
of the window. The available values are {\sf noevent}\index{noevent}
and {\sf suspend}\index{suspend}. The default\index{default} value is
the {\sf noevent}.

\end{description} 

The records\index{channel!record} are separated by a backslash
immediately followed by a newline. The first record should be the {\sf
fields}\index{fields}. The other records can be arbitrarily ordered.

\section{Closing a channel}\index{channel!close}

When the program has completed its use of a channel, the channel
should be closed using {\sf chclose()}\index{function!chclose@{\sf
chclose()}} function.  This function is declared as follows:

\begin{verbatim}
extern void chclose(); 
\end{verbatim} 

This function closes the specified channel and releases the {\sf
handle}\index{handle}. The {\sf handle} is the only parameter of the
{\sf chclose} function. If program exits without closing a channel,
the system will automatically close the channel.

\section{Writing to a channel}\index{channel!write}

The graphics interface function used for writing to a channel is
named {\sf chwrite}\index{function!chwrite@{\sf chwrite()}}. This
function is declared as follows:

\begin{verbatim} 
extern void chwrite(); 
\end{verbatim} 

The function has the following arguments: The first argument is the
{\sf handle}\index{handle} of the channel in to which data should be
written. The second argument is a datum. The data are collected in the
specified channel\index{data!collected in channel}. When number of
records is equal to the number specified in the record {\sf
fields}\index{fields} (see page~\pageref{`fields'} for more details),
the data are put into the window.  

\section{Flushing a channel}\index{channel!flush}

This function flushes a channel in which were collected data. The
function is declared:\index{function!chflush@{\sf chflush()}}

\begin{verbatim} 
extern void chflush();
\end{verbatim} 

The function has no arguments. It flushes all opened graphics
channels. This function is necessary at the end of putting image to
the window, when data are in the channel but in the window.

The following program shows a use of graphics interface
functions:\index{function!sin@{\sf sin()}}
{\mybasel
\begin{verbatim}
double x,y;

extern double sin();

/* declaration of graphics functions */
extern int chopen();
extern void chwrite();
extern void chclose();
extern void chflush();

int handle;

handle=chopen("fields=6\
lower(0)=-0.5\
upper (0) = 0.5\
style (0) = 10\
lower(1)=-1.5\
upper (1) = 1.5\
style (1) = 20\
lower(2)=-3.\
upper (2) = 3.\
style (2) = 15\
lower(3)=-3.5\
upper (3) = 3.5\
style (3) = 5\
lower(4)=-4.\
upper (4) = 4.\
style (4) = 17\
lower(5)=-4.5\
upper (5) = 4.5\
style (5) = 7\
start_time=automatic\
duration_time=256.\
w_resolution=600 400\
print_format=point\
type=alpha\
OnLeaveW=suspend");

for(x=0;x<6.5;x=x+0.01)
        {
        y=sin(x);
        chwrite(handle,y);
        chwrite(handle,y);
        chwrite(handle,y);
        chwrite(handle,y);
        chwrite(handle,y);
        chwrite(handle,y);
        }
chclose(handle);
exit;
\end{verbatim}}

\chapter{Interrupt handling}\index{interrupt!handling}

The run of the virtual machine of the interpreter can be
interrupted. The interpreter provides two kinds of the interrupts;
synchronous\index{interrupt!synchronous} and
asynchronous\index{interrupt!asynchronous}.

\section{Synchronous interrupt}

The synchronous interrupt is specified in the form of
statements\index{statement!csuspend@{\sf csuspend}} in a program. The
following statement can be placed where it is useful:

\begin{verbatim}
csuspend;
\end{verbatim}

When the interpreter reaches the statement it is stopped
and echoed:

\begin{verbatim}
clif interrupt level <number>
\end{verbatim}

Where the {\sf $<$number$>$} is a positive number. A user, at any
interrupt level\index{interrupt!level}, can do anything what is
available in the interpreter. To resume the run of the interpreter a
user should write the following statement\index{statement!resume@{\sf
resume}}:

\begin{verbatim}
resume;
\end{verbatim}

or press the key DC4 (Ctrl-t)\index{Ctrl-t}. The interpreter is then
echoed:

\begin{verbatim}
clif interrupt level <number>-1
\end{verbatim}

which means that the interrupt level is decreased. The lowest
interrupt level\index{interrupt!level} is zero.  An example of use of
the synchronous interrupt\index{interrupt!synchronous}
follows:\index{function!cprintf@{\sf
cprintf()}}\index{function!cscanf@{\sf cscanf()}}

{\mybasel
\begin{verbatim}
int a,n;
extern int cscanf();
export_type extern int cprintf();
int fakt(int n)
{
csuspend;
if(n==1)
        {
        return(1);
        }
else
        {
        return(fakt(n-1)*n);
        }
}
cprintf(1,"input n %d\n",n);
cscanf(0,"%d",n);
csuspend;
a=fakt(n);
cprintf(1,"factorial = %d\n",a);
exit;
\end{verbatim}}

\section{Asynchronous interrupt}\index{interrupt!asynchronous}

An asynchronous interrupt can be invoked by the user with pressing the
key {\sf Ctrl-t}\index{Ctrl-t} while the virtual machine\index{virtual
machine} of the interpreter is running. A dummy program in which a
user can follow the use of asynchronous interrupt
is:\index{function!cprintf@{\sf cprintf()}}

{\mybasel
\begin{verbatim}
extern int cscanf();
export_type extern int cprintf();

int i;
for(i=0;i<100000;++i)
        {
        cprintf(1,"%d",i);
        }
cprintf(1,"%s\n","loop is over");
exit;

\end{verbatim}}

After making statements requested by the user, the further processing
can be invoked as by the synchronous
interrupt\index{interrupt!synchronous} with pressing {\sf Ctrl-t} or
typing {\sf resume}\index{statement!resume@{\sf resume}}.

%\input{gu10a.tex}
\chapter{Errors}

\section{\CiF\ error messages}

In this chapter is a list of \CiF\ error messages. 

\subsection{Syntax error messages}

{\mybasel
\begin{verbatim}


    case 1000:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: variable `%s' isn't declared\n", 
		err_no, line_counter, text);
      break;
    case 1001:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: variable `%s' was already declared\n", 
		err_no, line_counter, text);
      break;
    case 1002:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: remote procedure %s is not declared\n", 
		err_no, line_counter, proc_name_text[proc]);
      break;
    case 1003:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: local variable `%s' was already declared\n", err_no, text);
      break;
    case 1004:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: at the %d-th char, near the \"%s\"\n", err_no, line_counter, char_counter, yytext);
      break;
    case 1005:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: Invalid type of the operand, %d-th character\n", err_no, line_counter, char_counter);
      break;
    case 1006:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: Remote function %s already declared\n", err_no, text);
      break;
    case 1007:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: Remote function isn't declared\n", err_no);
      break;
    case 1008:
      print_source_line ();
      fprintfx (stderr, "Error %d: Remote functions are not in the load table\n", err_no);
      break;
    case 1009:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: Void type in expression at line\n", err_no, line_counter);
      break;
    case 1010:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: Void type assigned to l_value\n", err_no, line_counter);
      break;
    case 1011:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: load can't open file `%s'\n", err_no, yytext);
      break;
    case 1012:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: variable or field `%s' declared void\n", err_no, line_counter, text);
      break;
    case 1013:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: switch quantity not an integer\n", err_no, line_counter);
      break;
    case 1014:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: case label does not reduce to an integer constant\n", err_no, line_counter);
      break;
    case 1015:
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: duplicate case value",
		err_no, tmp_c->line_number);
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: this is the first entry for that value\n", err_no, tmp_m->line_number);
      break;
    case 1016:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: case label not within a switch statement\n", err_no, line_counter);
      break;
    case 1017:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: struct tag `%s' was already declared\n", 
		err_no, line_counter, text);
      break;
    case 1018:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: union tag `%s' was already declared\n", 
		err_no, line_counter, text);
      break;
    case 1019:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: enum tag `%s' was already declared\n", 
		err_no, line_counter, text);
      break;

      
\end{verbatim}
}

\subsection{\CiF\ compilation error messages}

{\mybasel
\begin{verbatim}

    case 2000:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: invalid number of subscripts\n", err_no, line_counter);
      break;
    case 2001:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: `%s' is not an array variable\n", err_no, line_counter, text);
      break;
    case 2002:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: invalid type of array subscript\n", err_no, line_counter);
      break;
    case 2003:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: type of formal parameter does not match previous declaration\n", err_no, line_counter);
      break;
    case 2004:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: number of formal parameters does not match previous declaration\n", err_no, line_counter);
      break;
    case 2005:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: name of formal paramter does not match previous declaration\n", err_no, line_counter);
      break;
    case 2006:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: size of array subscript of formal parameter does not match previous declaration\n", err_no, line_counter);
      break;
    case 2007:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: number of array subscripts of formal parameter does not match previous declaration\n", err_no, line_counter);
      break;

      
\end{verbatim}
}

\subsection{\CiF\ }

{\mybasel
\begin{verbatim}

    case 3000:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: \"break\" outside loop or switch\n", err_no, line_counter);
      break;
    case 3001:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: bad used continue\n",
		err_no, line_counter);
      break;
    case 3002:
      print_source_line ();
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: default label not within a switch statement\n", err_no, line_counter);
      break;
    case 3003:
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: multiple default labels in one switch", err_no, line_counter);
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: this is the first default label\n",
		err_no, fixp->switch1.def_use.line_number);
      break;
    case 3004:
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: duplicate label `%s'\n",
		err_no, line_counter, text);
      break;
    case 3005:
      print_file_name ();
      fprintfx (stderr, "Error %d: line %d: label `%s' used but not defined\n", 
		err_no, error_line_number, text);
      break;
      
      
\end{verbatim}
}

\subsection{\CiF\ run-time error messages}

{\mybasel
\begin{verbatim}


    case 4000:
      fprintfx (stderr, "Error %d: interpreter: full memory\n", err_no);
      break;
    case 4001:
      fprintfx (stderr, "Error %d: interpreter: stack overflow\n", err_no);
      break;
    case 4002:
      fprintfx (stderr, "Error %d: Operating system out of memory\n", err_no);
      break;
      
\end{verbatim}
}

\subsection{\CiF\ fatal error messages}

{\mybasel
\begin{verbatim}


    case 5000:
      fprintfx (stderr, "Compile fatal error %d:\nInterpreter Internal Error\n(unknown operand type)\nin line %d\ne-mail: %s\n", err_no, line_counter, EMAIL);
      break;
    case 5001:
      fprintfx (stderr, "Run-time fatal error %d:\nInternal Interpreter Error\n(unknown instruction)\ne-mail: %s\n", err_no, EMAIL);
      break;
    case 5002:
      fprintfx (stderr, "Compile fatal error %d:\nInterpreter Internal Error\n(error in book-keeping)\nin line %d\ne-mail: %s\n", err_no, line_counter, EMAIL);
      break;

      
\end{verbatim}
}

\subsection{\CiF\ warning messages}

{\mybasel
\begin{verbatim}


    case 6000:
      if (warning_yes)
	{
	  fprintfx (stderr, "Warning %d: line %d: remote function %s already declared\n", err_no, line_counter, text);
	}
      return;
      break;
    case 6001:
      if (warning_yes)
	{
	  print_file_name ();
	  fprintfx (stderr, "Warning %d: line %d: `return' with no value, in function returning non-void\n", err_no, line_counter);
	}
      return;
      break;
    case 6002:
      if (warning_yes)
	{
	  print_file_name ();
	  fprintfx (stderr, "Warning %d: line %d: `return' with a value, in function returning void\n", err_no, line_counter);
	}
      return;
      break;
    case 6003:
      if (warning_yes)
	{
	  if (proc)
	    {
	      fprintfx (stderr, 
			"%s: In function `%s':\n%s: Warning %d: unused variable `%s'\n",
			argvv[argc_counter], proc_name_text[proc],
			argvv[argc_counter], err_no, text);
	    }
	  else
	    {
	      fprintfx (stderr, 
			"%s: In  block finishing at line %d:\n%s: Warning %d: unused variable `%s'\n",
			argvv[argc_counter], line_counter,
			argvv[argc_counter], err_no, text);
	    }
	}
      return;
      break;
    case 6004:
      if (warning_yes)
	{
	  fprintfx (stderr, "Warning %d: line %d: label `%s' defined but not used\n", 
		    err_no, error_line_number, text);
	}
      return;
      break;
    case 6005:
      if (warning_yes)
	{
	  fprintfx (stderr, "Warning %d: `/*' within comment\n",
		    err_no);
	}
      return;
      break;
    case 6006:
      if (warning_yes)
	{
	  if (proc)
	    {
	      fprintfx (stderr, 
			"%s: In function `%s':\n%s: Warning %d: `%s' might be used uninitialized in this function\n",
			argvv[argc_counter], proc_name_text[proc],
			argvv[argc_counter], err_no, text);
	    }
	  else
	    {
	      fprintfx (stderr, 
			"%s: In block finishing at line %d:\n%s: Warning %d: `%s' might be used uninitialized in the block\n",
			argvv[argc_counter], line_counter,
			argvv[argc_counter], err_no, text);
	    }
	}
      return;
      break;
    case 6007:
      if (warning_yes)
	{
	  print_file_name ();
	  fprintfx (stderr,
		    "In function `%s':\n%s: Warning %d: number of locals is greater than the ANSI allows\n",
		    proc_name_text[proc], argvv[argc_counter],
		    err_no);
	}
      return;
      break;
    case 6008:
      if (warning_yes)
	{
	  print_file_name ();
	  fprintfx (stderr,
		    "In function `%s':\n%s: Warning %d: number of params is greater than the ANSI allows\n",
		    proc_name_text[proc], argvv[argc_counter],
		    err_no);
	}
      return;
      break;
      
      
\end{verbatim}
}

\subsection{\CiF\ initialization error messages}

{\mybasel
\begin{verbatim}


    case 7000:
      fprintfx (stderr, "Error %d: in run-string and/or in `clif.ini' file\n", err_no);
      break;
    case 7001:
      fprintfx (stderr, "Error %d: interpreter: can't open file %s\n\n", err_no, argvv[argc_counter]);
      break;
    default:
      fprintfx (stderr, "Fatal error invalid error number (%d)\ne-mail: %s\n", err_no, EMAIL);
      break;

      
\end{verbatim}
}

\bibliographystyle{plain}
\bibliography{knia}
\printindex
\end{document}
