/*{{{}}}*/
/*{{{  Copyright*/
Copyright (c) Michael Haardt, 1995.

You may use and modify this program or derived works without charge for
personal use under the condition that no copyright notices are removed
or changed.  Any commercial use, especially charging for copying or
selling it or derived works, needs to be permitted by me.  My address
is:

   Snail mail:
   Michael Haardt
   Rtscherstrae 155/1703
   52072 Aachen
   Germany

   Email:
   michael@cantor.informatik.rwth-aachen.de

I am in no way responsible for anything caused by using this program,
so if your computer or house blows up, that's your problem.  :)
/*}}}  */
/*{{{  Cells*/
/*{{{  Introduction*/
A spread sheet consists of cells formed by rows and columns. 
Additionally, you have a third dimension, which you can imagine as
various sheets laying on top of each other.  The third dimension allows
you to hide intermediate results, show you additional results you do
not want to appear in the ``official'' tables, keep sheets per time
period (like 12 sheets for each month in a year) while allowing you to
make calculations over the entire time interval.
/*}}}  */
/*{{{  Cell contents*/
Each cell contains an expression, which result is shown in the spread
sheet.  The following result value types are available:

-  empty.  Empty cells have this as value.
-  string.  A string is a sequence of characters.
-  floating point.  Floating point values are inexact, their precision
   and range depends on the implementation of the C type "double" on your
   system.
-  integer.  Integer values are exact, their range depends on the C type
   "long" on your system.
-  location.  Cell labels have this type.
-  error.  Syntax and semantical errors cause this value, as well as
   division by 0 and the function \fBerror()\fP.  An error always has an
   assigned error message.

Expressions consist of constants of the above types, operators applied
to subexpressions and functions which may have zero or more argument
expressions and which return one value.
/*}}}  */
/*{{{  Operators*/
The following operators are available:

x+y evaluates to the sum if x and y are numbers.  If x and y are
strings, the result is the concatenated string.  If x or y is empty,
the result is the other element.

x\-y evaluates to the difference if x and y are numbers.  If x is
empty, the result is \-y.  If y is empty, the result is x.

x*y evaluates to the product if x and y are numbers.  If x or y is
empty, the result is 0.

x/y evaluates to the quotient if x and y are numbers.  If x is empty,
the result is 0.  If y is empty, the result is the error ``division by 0''.

\-x evaluates to \-x if x is a number.  If x is empty, the result will
be empty, too.

(expression) evaluates to the expression.

label evaluates to the location it is set at.

function(arg1,..,argn) first evaluates to the value of the function applied
to the values resulting from evaluating the argument expressions.
/*}}}  */
/*{{{  Functions*/
The followinf functions exist:

@(integer x, integer y[, integer z]) or @(location) returns the value of
the cell at location x, y, z.  If z is omitted, the current z is used.

&(integer x, integer y[, integer z]) returns a pointer to the cell at
location x, y, z.  If z is omitted, the current z is used.

error(string message) evalutes to an error with the specified message.

here.x([location]), here.y([location]), here.z([location]) evaluate to
the x, y and z position of the given location, of the currently updated
cell if none is given.  These functions are usually used in combination
with the @ function for relative relations to other cells.

ctos(integer x, integer y[, integer z]) or ctos(location) evaluates to a
string containing the current value of the given cell.  If z is
omitted, the current z is used.

sum(location1,location2) evaluates to the sum of all values in the block
marked by the corners pointed to by location1 and location2.

n(location1,location2) evaluates to the number of non-empty cells in
the block marked by the corners pointed to by location1 and location2.
/*}}}  */
/*{{{  Attributes*/
Further, cells have a set of attributes.  The following attributes can be
set:

-  A cell label, which is useful because it avoids to directly address
   cells by their position.
-  The cell adjustment.  The cell contents can be printed left adjusted,
   right adjusted or centered.
-  The precision of printed floating point numbers.  This only changes
   what is printed,
   the spread sheet always uses the maximum precision for calculations.
-  If floating point numbers should be printed in scientific notation
   (0.123e1) or as decimal number (1.23).
-  If the cell is shadowed by its left neighbour.  This means that the
   left neighbour additionally uses the room of the shadowed cell.
-  If the cell is locked which prevents to accidentally editing it or
   erasing it.  Note that block operations override this attribute,
   because when you deal with blocks, you usually know what you are
   doing.
/*}}}  */
/*}}}  */
/*{{{  Function key usage*/
Some terminals do not have certain function keys, which are needed to
move around or perform other functions.  For that and other reasons,
the following control keys are also recognised:

-  Next line: Cursor down or control n
-  Previous line: Cursor up or control p
-  Backward character: Cursor left or control b
-  Forward character: Cursor right or control f
-  Cancel: Cancel key or control g
-  Backspace: Backspace key or control h
-  Delete: Delete key, control ? (dec. 127) or control d
-  Enter: Enter key or control j or control m
-  Beginning: Begin key or control a
-  End: End key or control e
-  Insert: Ins key or control i
-  Kill line: Delete line key or control k
-  Transpose character: Control t, only used in line editor
-  Goto matching paren: Control \, only used in line editor
/*}}}  */
/*{{{  Menu usage*/
Most functions are used through menues.  The menues are used in the
following way:

-  Cursor right, tab and space go to the next menu item
-  Cursor left or backspace goes to the previous item
-  Return selects the current item
-  Cancel does not select any item and aborts the function
/*}}}  */
/*{{{  Hotkeys*/
The cursor keys move the cell cursor in x and y direction of the current
z position.  + and - move the cell cursor forward/backward in z
direction.  Beg and End move it to the first/last column (x direction);
< and > move it to the first/last line (y direction); _ and * move it
to the first/last sheet (z direction).

? gets you into the main menu.

A cell is edited using e.  . (dot) marks blocks: The first time it marks
the beginning of a block, which is then extended by moving the cell cursor.
The next time, it marks the end of the block which lets you move the cell
cursor after without changing the block.  The third time, it removes the
block marks again.

q is a quick way to leave the spread sheet.
/*}}}  */
/*{{{  Grammar of cell contents*/
Grammar of cell contents

digit                    ::= '0'|..|'9'
hex_digit                ::= '0'|..|'9'|'a'|..|'f'
octal_digit              ::= '0'|..|'7'
decimal_unsigned_integer ::= digit {digit}
hex_unsigned_integer     ::= '0x' hex_digit {hexdigit}
octal_unsigned_integer   ::= '0' octal_digit {octdigit}
integer                  ::= decimal_unsigned_integer |
                             hex_unsigned_integer |
                             octal_unsigned_integer
float                    ::= digit {digit} [.] {digit} 
                             [e|E [+|-] digit {digit}]
quoted_character         ::= '\' any_character
character                ::= any_character | quoted_character
string                   ::= '"' character '"'
identifier_character     ::= '_' | '@' | '&' | '.' | alpha_character
identifier               ::= identifier_character 
                             {identifier_character | digit}
function                 ::= identifier '(' [term {',' term}] ')'
label                    ::= identifier
parenterm                ::= '(' term ')'
negterm                  ::= '-' term
primary                  ::= function | label | parenterm | negterm
powterm                  ::= primary {'^' primary}
mathterm                 ::= powterm {'/' | '*' powterm}
factor                   ::= mathterm {'+' | '-' mathterm}
term                     ::= factor 
                             {'<' | '<=' | '>=' | '>' | '==' | '!=' mathterm}
/*}}}  */
