.BG
.VE $Header: /usr3/s/current/s/.help/RCS/syntax,v 1.2 83/12/30 19:35:26 rab Exp $
.FN syntax
.FN for
.FN if
.FN else
.TL
Syntax: S Expressions
.PP
All user input to S is composed of expressions.
The simplest expressions are
.PP
NUMBER               1, 5.3, 1e17
.PP
CHARACTER STRING     "abc", 'def ghi'
.PP
NAME                 iris, city23
.PP
More complicated expressions can be made by combining expressions using
the following rules:
.PP
EXPR op EXPR           where op is one of 
                       +  \-  *  /  ^  ** 
                       ==  !=  <=  >=  <  >  &  :  %%
.PP
( EXPR )               parens specify order of evaluation
.PP
op EXPR                unary operators + \- !
.PP
NAME <- EXPR           assignment
.PP
EXPR $ NAME            selection of component
.PP
NAME [ EXPR, EXPR, ...]  subscripting
.PP
NAME ( NAME1 = EXPR1, NAME2 = EXPR2, ...)    function call
.PP
NAME $ [ EXPR ]        component by number
.PP
`for' ( NAME `in' EXPR ) EXPR      loop
.PP
`if' ( EXPR ) EXPR1 `else' EXPR2  conditional expression
.PP
{ EXPR1 ; EXPR2 ; ... }    compound expression
.PP
Notice that expressions can be arbitrarily complicated by repeated
uses of the above rules.
.PP
A typed expression may be continued on further lines by ending a
line at a place where the line is obviously incomplete with a trailing
comma, operator, or with more left parens than right parens (implying
more rights will follow).  Ordinarily the prompt character signifying
that more input is necessary is "> ", but when continuation is
expected the prompt is "+ ".
.PP
The NAME for subscripting may also be a parenthesized EXPR,
function call, or component selection.
.PP
Functions may be called without arguments, may have missing
arguments of the form NAME= or ,, and the keywords NAME= are
optional.
.PP
The value of the input expression is automatically printed if it
is not saved, producing a "desk calculator" mode.  The expression 
`A <- 1+2' is not printed because the result is saved in `A'.  Certain
functions (`save') do not automatically print their results.
.PP
A line consisting of only a name is first interpreted as a
function with no arguments, and if the function is not found, the line
is treated as a dataset name and automatically printed.
.PP
If the top-most EXPR is a function call, it is not necessary to
use parens to delimit its argument list, e.g. `plot x,y' is identical
to `plot(x,y)'.  All other functions must use parens, however.
.PP
A line whose first character is "!" is executed as a system command
with no changes.
.PP
The value of a compound expression is the value of the last
executed subexpression.
.SH SEE ALSO
`precedence'.
.KW builtin
.KW special
.WR
