.BG
.FN Syntax
.FN for
.FN repeat
.FN while
.FN break
.FN next
.FN {
.FN return
.TL
S Expressions
.PP
Expressions in S are typed by the user, parsed,
and evaluated.
The following rules define the expressions considered legal by the parser,
and the mode of the corresponding object.
.sp
.in +.5i
.nf
.ta 3.5iR
.ce
Literals
\f6number\fP	"numeric"
\f6string\fP	"character"
\f6name\fP	"name"
\f6comment\fP	"comment"
\f6function\fP ( formals ) expr	"function"
.ce
Calls
expr \f6infix\fP expr	"call"
expr \f6%anything%\fP expr
\f6unary\fP expr
expr ( arglist )
expr [ arglist ]
expr [[ arglist ]]
expr $ fname
.ce
Assignment
expr \(<- expr	"<\-"
expr _ expr
expr -> expr
expr <<\- expr	"<<\-"
.ce
Conditional
\f6if\fP ( expr ) expr	"if"
\f6if\fP ( expr ) expr \f6else\fP expr
\f6for\fP ( \f6name\fP \f6in\fP expr ) expr	"for"
.ce
Iteration
\f6repeat\fP expr	"repeat"
\f6while\fP ( expr ) expr	"while"
.ce
Flow
\f6break\fP	"break"
\f6next\fP	"next"
\f6return\fP ( expr )	"return"
( expr )	"("
{ exprlist }	"{"
.sp
.ne 10
.in -.5i
.fi
The additional syntactic forms introduced in the above rules are defined
as follows:
.sp
.in +.5i
.nf
.ta .75i
exprlist:	expr
	exprlist ; expr
arglist:	arg
	arglist , arg
formals:	\f6empty\fP
	formal
	formals , formal
arg:	\f6empty\fP
	expr
	fname =
	fname = expr
formal:	\f6name\fP
	\f6name\fP = expr
fname:	\f6name\fP
	\f6string\fP
.sp
.in -.5i
.fi
.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).  The default prompt character is "> ";
when continuation is
expected the default prompt is "+ ".
.PP
Numeric literals (numbers) are defined by the following rules:
.ne 13
.sp
.in +.5i
.nf
.ta .75i
numeric:	integer
	float
complex:	numeric "i"
	numeric [+\-] numeric "i"
name:	(.|letter) (.|letter|digit)*
integer:	digit+
exponent:	"e" [+\-]? integer
float:	integer exponent
	integer "." digit* exponent?
	"." integer exponent?
.sp
.in -.5i
.fi
String literals are contained between matching apostrophes or matching
double quotes.  Characters inside can be escaped by preceding them by the
back-slash character: `\\n', `\\t', and `\\\\' represent a new-line, tab and
back-slash character.  In addition, a back-slash followed by 1 to 3 octal
digits represents the character with the corresponding octal representation.
.PP
.Ix operator
.Ix precedence
The following \f6infix\fP operators are recognized by the parser.
They are listed in decreasing precedence.
.sp
.in +.5i
.nf
.ta 1.5i,3.5iR
`$'	component selection	\fBHIGH\fP
`[ [['	subscripts, elements
`^'	exponentiation
`-'	unary minus
`:'	sequence operator
`%'\f2anything\fP`%'	special operator
`*   /'	multiply, divide
`+   -'	add, subtract
`<  >  <=  >='
`  ==  !='	comparison
`!'	not
`&   |  &&  ||'	and, or
`<<-'	assignment
`\(->'  
`\(<-'   _	\fBLOW\fP
.sp
.in -.5i
.fi
Any sequence of characters between matching "%" characters,
not including a new line, is recognized as an infix operator.
.PP
A line whose first character is "!" is executed as a system command
with no changes.
.KW programming
.WR
