| Annex B: Collected Concrete Syntax |

This Annex contains all of the concrete syntax of the Sather language as given in the various sections of the language specification.

The reference form of the xxx_SY tokens for the purposes of program example text is given in Annex D.

### B.1 Program Components

source text = class specification, {Semicolon_SY, class specification} ;

### B.2 Class Definitions

class specification = | [library signifier],
| (abstract class definition | class) ;

library signifier = | Library_SY, identifier ;

### B.2.1 Abstract Class Definition

abstract class definition = | Abstract_SY, Class_SY, abstract type name,
| [generic arguments],
| [subtyping clause],
| [supertyping clause], Is_SY,
| [abstract signature], {Semicolon_SY, [abstract signature]}, End_SY ;

### B.2.2 Implementation Class Definitions

class = | [class type], Class_SY, concrete type name, [generic arguments],
| [subtyping clause], Is_SY,
| [class element], {Semicolon_SY, [class element]}, End_SY ;

class type = Immutable_SY | Partial_SY | (External_SY, [identifier]) ;

generic arguments = | Left_Brace_SY, parameter declaration,
| {Comma_SY, parameter declaration}, Right_Brace_SY ;

subtyping clause = Left_Angle_Bracket_SY, type specifier list ;

supertyping clause = Right_Angle_Bracket_SY, type specifier list ;

parameter declaration = | type name, [Left_Angle_Bracket_SY, type specifier] ;

### B.3 Method Signatures

abstract signature = abstract routine signature | abstract iter signature ;

identifier list = identifier, {Comma_SY, identifier} ;

return signature = Colon_SY, type specifier ;

### 3.3.1 Routine Signatures

abstract routine signature = | identifier, [routine parameter pack], [return signature] ;

routine parameter pack = | Left_Parenthesis_SY,
| routine argument list, Right_Parenthesis_SY ;

routine argument list = routine argument, {Comma_Sy, routine argument} ;

routine argument = routine mode, identifier list, return signature ;

routine mode = [(Out_SY | Inout_SY)] ;

### B.3.2 Iter Signatures

abstract iter signature = | iter name, [iter parameter pack], [return signature] ;

iter parameter pack = | Left_Parenthesis_SY,
| iter argument list, Right_Parenthesis_SY ;

iter argument list = iter argument, {Comma_Sy, iter argument} ;

iter argument = iter mode, identifier list, return signature ;

iter mode = [(Out_SY | Inout_SY | Once_SY)] ;

### B.4 Type Definitions

type specifier list = type specifier, {Comma_SY, type specifier} ;

type specifier = | (type name, [{type specifier list}])
| | method closure type specifier
| | Same_Type_SY ;

method closure type specifier = | routine closure type specifier
| | iter closure type specifier ;

routine closure type specifier = | Routine_SY,
| [{routine mode, type specifier,
| {Comma_SY, routine mode, type specifier}}],
| [return signature] ;

iter closure type specifier = | Iter_SY,
| [{iter mode, type specifier,
| {Comma_SY, iter mode, type specifier}}],
| [return signature] ;

### B.6 Feature Definitions

class element = | constant definition
| | shared definition
| | attribute definition
| | routine definition
| | iter definition
| | include clause
| | stub ;

### B.6.1 Constant Definition

constant definition = | [Private_SY], Constant_SY,
| (simple value | enumerated constants) ;

simple value = identifier, return signature, initialise ;

enumerated constants = | identifier, [initialise],
| [Comma_SY,identifier list] ;

initialise = assign op, expression ;

### B.6.2 Shared Definition

shared definition = | [Private_SY | Readonly_SY], Shared_SY,
| (simple value | declaration) ;

### B.6.3 Attribute Definition

attribute definition = | [Private_SY | Readonly_SY], Attr_SY,
| declaration ;

### B.6.4 Routine Definition

routine definition = | [Private_SY], identifier, [routine parameter pack],
| [return signature],
| [pre-condition],
| [post-condition],
| [method body] ;

pre-condition = Pre_SY, expression ;

post-condition = Post_SY, expression ;

method body = Is_SY, statement list, End_SY ;

### B.6.5 Iter Definition

iter definition = | [Private_SY], iter name, [iter parameter pack],
| [return signature],
| [pre-condition],
| [post-condition],
| [method body] ;

### B.6.6 Include Clause

include clause = | [Private_SY], Include_SY,
| (library include | class include),
| [feature modifier list] ;

library include = Library_SY, identifier ;

class include = type specifier ;

feature modifier list = | feature modifier,
| {Comma_SY, feature modifier} ;

feature modifier = | (identifier | iter name), Rename_SY,
| [Private_SY | Readonly_SY],
| [(identifier | iter name)] ;

### B.6.7 Stub Definition

stub = Stub_SY, abstract signature ;

### B.7 Statements

statement list = [statement], {Semicolon_SY, [statement]} ;

statement = | declaration statement
| | assign statement
| | if statement
| | return statement
| | case statement
| | typecase statement
| | expression statement
| | loop statement
| | yield statement
| | quit statement
| | protect statement
| | raise statement
| | assert statement
-- Iters
| | while statement
| | until statement
| | break statement
-- Concurrent programming
| | parallel statement
| | fork statement
| | parallel loop statement
| | select statement
| | lock statement
| | unlock statement
| | attach statement
| | synchronise statement
| | with near statement ;

### B.7.1 Declaration Statement

declaration statement = declaration ;

declaration = identifier list, return signature ;

### B.7.2 Assign Statement

assign statement = | (expression | (identifier, Colon_SY, [type specifier])),
| initialise ;

### B.7.3 If Statement

if statement = | If_SY, expression, guarded clause,
| [Elsif_SY, expression, guarded clause},
| [default clause], End_SY ;

guarded clause = Then_SY, statement list ;

default clause = Else_SY, statement list ;

### B.7.4 Return Statement

return statement = Return_SY, [expression] ;

### B.7.5 Case Statement

case statement = | Case_SY, expression,
| value guard, guarded clause,
| [{value guard, guarded clause}],
| [default clause], End_SY ;

guard = value guard | type guard ;

value guard = When_SY, expression, {Comma_SY, expression} ;

type guard = When_SY, type specifier ;

### B.7.6 Typecase Statement

typecase statement = | Typecase_SY, identifier,
| type guard, guarded clause,
| [{type guard, guarded clause}],
| [default clause], End_SY ;

### B.6.7 Expression Statement

expression statement = expression ;

### B.7.8 Loop Statement

loop statement = Loop_SY, statement list, End_SY ;

### B.7.9 Yield Statement

yield statement = Yield_SY, [expression] ;

### B.7.10 Quit Statement

quit statement = Quit_SY ;

### B.7.11 Protect Statement

protect statement = | Protect_SY, statement list,
| [type guard, guarded clause],
| [{type guard, guarded clause}],
| [default clause], End_SY

### B.7.12 Raise Statement

raise statement = Raise_SY, expression ;

### B.7.13 Assert Statement

assert statement = Assert_SY, expression ;

### B.7.14 While Statement

while statement = While_SY, Iter_SY, parenthesised expression ;

### B.7.15 Until Statement

until statement = Until_SY, Iter_SY, parenthesised expression ;

### B.7.16 Break Statement

break statement = Break_SY, Iter_SY ;

### B.7.17 Parallel Statement

parallel statement = Parallel_SY, statement list, End_SY ;

### B.7.18 Fork Statement

fork statement = | Fork_SY, [At_SY, expression, Semicolon_SY],
| statement list, End_SY ;

### B.7.19 Parallel Loop Statement

parallel loop statement = | Parloop_SY, statement list, Do_SY,
| [At_SY, expression, Semicolon_SY],
| statement list, End_SY ;

### B.7.20 Select Statement

select statement = | Lock_SY,
| select guard, {select guard},
| [default clause], End_SY ;

select guard = lock guard, guarded clause ;

lock guard = [Guard_SY, expression], value guard ;

### B.7.21 Lock Statement

lock statement = | Lock_SY, expression,
| guarded clause,
| [default clause], End_SY ;

### B.7.22 Unlock Statement

unlock statement = Unlock_SY, expression ;

### B.7.23 Attach Statement

attach statement = expression, Do_Attach_SY, expression ;

### B.7.24 Synchronise Statement

synchronise statement = Synchronise_SY ;

### B.7.25 With Near Statement

with near statement = | With_SY, local feature list,
| Near_SY, statement list,
| [default clause], End_SY ;

local feature list = local feature, {Comma_SY, local feature} ;

local feature = identifier | self expression ;

### B.8 Expressions

expression = | literal expression
| | parenthesised expression
| | self expression
| | local expression
| | call expression
| | void test expression
| | post-condition expression
| | method closure expression
| | creation expression
| | array expression
| | logical expression
| | infix expression
| | exception expression
| | at expression ;

qualified ident = | (expression, Fullstop_SY)
| | (type specifier, Colon_SY, Colon_SY) ;

### B.8.1 Literal Expressions

literal expression = literal ;

### B.8.2 Parenthesised Expressions

parenthesised expression = | Left_Parenthesis_SY,
| expression,
| Right_Parenthesis_SY ;

### B.8.3 Self Expression

self expression = Self_SY ;

### B.8.4 Local Expression

local expression = identifier ;

### B.8.5 Call Expression

call expression = routine call | iter call ;

### B.8.5.1 Routine Call Expression

routine call = qualified ident, identifier, [routine call args] ;

routine call args = | Left_Parenthesis_SY,
| routine call arg list, Right_Parenthesis_SY ;

routine call arg list = | routine call argument,
| {Comma_Sy, routine call argument} ;

routine call argument = routine mode, expression ;

### B.8.5.2 Iter Call Expression

iter call = qualified ident, iter name, [iter call args] ;

iter call args = | Left_Parenthesis_SY,
| iter call arg list, Right_Parenthesis_SY ;

iter call arg list = | iter call argument,
| {Comma_Sy, iter call argument} ;

iter call argument = iter mode, expression ;

### B.8.6 Void Test Expression

void test expression = Is_Void_SY, parenthesised expression ;

### B.8.7 Post-condition Expression

postcondition expression = | initial expression
| | result expression ;

### B.8.7.1 Initial Expression

initial expression = Initial_SY, parenthesised expression ;

### B.8.7.2 Result Expression

result expression = Result_SY ;

### B.8.8 Method Closure Expression

method closure expression = | routine closure expression
| | iter closure expression ;

### B.8.8.1 Routine Closure Expression

routine closure expression = | Bind_SY, Left_Parenthesis_SY,
| routine bind expression, Right_Parenthesis_SY ;

routine bind expression = | [qualified ident], identifier,
| [routine closure argument expression] ;

routine closure argument expression = | Left_Parenthesis_SY,
| routine closure argument list, Right_Parenthsis_SY ;

routine closure argument list = | routine closure argument,
| {Comma_SY, routine closure argument} ;

routine closure argument = routine mode, closure argument ;

closure argument = expression | low line ;

### B.8.8.2 Iter Closure Expression

iter closure expression = | Bind_SY, Left_Parenthesis_SY,
| iter bind expression, Right_Parenthesis_SY ;

iter bind expression = | [qualified ident], iter name,
| [iter closure argument expression] ;

iter closure argument expression = | Left_Parenthesis_SY,
| iter closure argument list, Right_Parenthesis_SY ;

iter closure argument list = | iter closure argument,
| {Comma_SY, iter closure argument} ;

iter closure argument = iter mode, closure argument ;

### B.8.9 Creation Expression

creation expression = create expression | new expression ;

### B.8.9.1 Create Expression

create expression = create op, [type_specifier], routine call args ;

### B.8.9.2 New Expression

new expression = New_SY, [parenthesised expression] ;

### B.8.10 Array Expression

array expression = Bar_SY, expression list, Bar_SY ;

expression list = expression, {Comma_SY, expression} ;

### B.8.11 Logical Expression

logical expression = expression, binary logical op, expression ;

### B.8.12 Infix Expressions

infix expression = unary expression | binary expression ;

unary expression = unary operator, expression ;

binary expression = | (expression, binary operator, expression)
| | (expression, binary logical operator, expression) ;

### B.8.13 Exception Expression

exception expression = Exception_SY ;

### B.8.14 At Expression

at expression = expression, At_SY, expression ;

| Specification Index |  | Language Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Wednesday, 17 May 2000. |