The annotated grammar below is presented in three columns. The first column is the symbol being defined, the second column contains a list of the possibilities for that symbol, and the third column, when present, provides additional explanation.
INPUT
PROGRAM
STMT
EXPR ;
PROGRAM
program ID ; STMTS ; end ;
STMTS
``One or more instances of
STMT
LHS := EXPR ;
Examples:
a := 4; |
[a,b] := [1,2]; |
[x,y] := [y,x]; |
Swap
f(3) := 7; |
If
EXPR ;
for ITERATOR do STMTS end ;
while EXPR do STMTS end ;
take LHS frome LHS ;
take LHS fromb LHS ;
take LHS from LHS ;
read LHS_ LIST ;
read LHS_ LIST from EXPR ;
print EXPR_ LIST ;
print EXPR_ LIST to EXPR ;
return ;
return EXPR ;
IF_ STMT
if EXPR then STMTS ELSE_ IFS ELSE_ PART end
ELSE_ IFS
``zero or more repetitions of the following''
elseif EXPR then STMTS
ELSE_ PART
``may be omitted''
else STMTS
ITERATOR
ITER_ LIST
ITER_ LIST | EXPR
ITER_ LIST
``one or more
SIMPLE_ ITERATOR
BOUND_ LIST in EXPR
BOUND = ID ( BOUND_ LIST )
BOUND = ID { BOUND_ LIST }
BOUND_ LIST
``one or more
BOUND
˜
ID
[ BOUND_ LIST ]
SELECTOR
{ EXPR_ LIST }
( EXPR_ LIST )
( EXPR .. EXPR )
The value is the slice of the original tuple or string in the range specified by the two occurrences of
a≤b | value is the tuple or string with components |
defined only at the integers from 1 to b - a + 1, | |
inclusive. The value of the ith component is | |
the value of the (a + i - 1)st component of the | |
value of
EXPR
. |
|
a = b + 1 | value is the null tuple. |
a > b + 1 | run-time error. |
( .. EXPR )
( EXPR .. )
( )
FORMER
EXPR : ITERATOR
EXPR_ LIST
EXPR .. EXPR
EXPR , EXPR .. EXPR
LHS
ID
LHS SELECTOR
[ LHS_ LIST ]
LHS_ LIST
``One or more instances of
[A, B, C] := [1, 2, 3]; |
has the effect of replacing
``Any
[A, ˜ , C] := [1, 2, 3]; |
replaces
EXPR
ID
INTEGER
FLOATING_ POINT
STRING
true
false
OM
newat
FUNC_ CONST
( EXPR )
[ FORMER ]
{ FORMER }
# EXPR
EXPR SELECTOR
EXPR . ID EXPR
EXPR ? EXPR
EXPR ** EXPR
EXPR * EXPR
EXPR / EXPR
EXPR mod EXPR
EXPR div EXPR
(a |
EXPR + EXPR
EXPR - EXPR
EXPR with EXPR
EXPR less EXPR
EXPR = EXPR
EXPR /= EXPR
EXPR < EXPR
EXPR > EXPR
EXPR <= EXPR
EXPR >= EXPR
EXPR in EXPR
EXPR notin EXPR
EXPR subset EXPR
EXPR and EXPR
EXPR or EXPR
EXPR impl EXPR
not EXPR
+ EXPR
- EXPR
% BINOP EXPR
x1 BINOP x2 BINOP … BINOP xN |
If
EXPR % BINOP EXPR
a BINOP x1 BINOP x2 BINOP … BINOP xN |
exists ITER_ LIST | EXPR
forall ITER_ LIST | EXPR
EXPR where DEFNS end
DEFNS
``Zero or more instances of
DEFN
BOUND := EXPR ;
ID SELECTOR := EXPR ;
EXPR_ LIST
``One or more instances of
BINOP
``Any binary operator (
FUNC_ CONST
FUNC_ HEAD LOCALS VALUES STMTS end
FUNC_ HEAD
func ( ID_ LIST ) ;
func ( ) ;
LOCALS
local ID_ LIST ;
VALUES
value ID_ LIST ;
ID_ LIST
``One or more instances of