Sather Home Page

Section 6.8:
Expressions

Concrete Syntax

expression = literal expression
| parenthesised expression
| self expression
| local expression
| call expression
| void test expression
| post-condition expression
| method closure creation expression
| creation expression
| array expression
| logical expression
| infix expression
| exception expression
| at expression ;
qualified ident = (expression, Fullstop_SY)
| (type specifier, Colon_SY, Colon_SY) ;

Abstract Syntax

The abstract form of expression syntax is quite different from the concrete syntax expressions defined above and in the other pages of this section of the specification.

The detail given in the following is expanded on other expression pages as necessary using invariants and well-formedness functions.
Expression =
Store_Expression
| Value_Expression ;
Store_Expression

An expression which returns a handle to some storage location may provide this in one of three ways :-

  1. A reference to some entity in the environment in which the program is executing. This is provided by that environment and is merely a token as far as the executing program is concerned.
  2. Some local memory or port address to which the program may (or may not, of course!) have some form of access. This address forms part of the computer in which the program is executing.
  3. Some non-local memory or port address to which the program has some access by virtue of being a distributed program.
Store_Expression =
Reference_Value
| Eval_Near
| Eval_Far ;
Reference_Value

This type models an uninterpretable token provided to a program from its external environment.

Reference_Value = token ;
Eval_Near

This type models a location which is on the computer system which created the location.

Eval_Near = Address ;
Eval_Far

This type models a location which is not on the computer system which created the location.

Eval_Far = Address ;
Address

An Address models a computer location which may be derived by an implementation as the result of using programming expressions. It refers to a location which is defined by the Sather language. The actual location (or indeed address token) indicated during any program execution is implementation dependent.

Address = token ;
Value_Expression

A value expression yields a value of some program type the semantics of which are defined by the defining class. The way in which such values may be manipulated is not defined by the Sather language.

Value_Expression =
Bit_Pattern
| Literal_Value
| Built_in_Value
| Eval_Expression ;
Bit_Pattern

The bit pattern is the fundamental way of expressing values of any kind. Any semantics attributed to it are defined by the appropriate class definition. The length of the sequence for any given class is implementation defined.

Bit_Pattern = seq of Bit ;
Value_Domain

The Sather language definition requires that numeric and textual values may be expressed when writing programs. The form in which such values appear is necessarily implementation defined.

NOTE It is important to note that the language specifies no operations on such values unless they are converted into a required library (or other) numeric or text class which defines those pre-defined operations such as add, minus, times, etc.
Value_Domain = token
inv vdom ==
(vdom = Numeric)
or (vdom = Text) ;
Literal_Value

Sather defines two general forms of user-specifiable literal values - numbers and text (including individual characters). This type models both the token value and the kind of literal it represents.

Literal_Value ::
code : Bit_Pattern
kind : Value_Domain ;
Language defined literal values

Sather defines a small number of literal values which are modelled by the following small group of types.

Built_in_Value =
Bit
| Boolean
| Void ;


Bit = token
inv bitval ==
(bitval = Set_Bit)
or (bitval = Clear_Bit) ;


Boolean = token
inv bval ==
(bval = True)
or (bval = False) ;
Eval_Expression

Those values which need to be evaluated from some form of expression are treated as routines - either predefined or programmer written.

Eval_Expression =
Call_Expression
| Predefined_Call_Expression ;
Call_Expression

This model type describes routines which have been written in the language and which return a value. They thus form a strict subset of Feature_Applications (for which a return value is optional).

Call_Expression ::
id : Defined_Feature_Name
body : Feature ;
Predefined_Call_Expression

The Predefined Call expression consists of those individual concrete syntax statements such as exception, self, is_void, etc. They are thus a strict subset of Predefined Applications, having a mandatory return value.

Predefined_Call_Expression ::
id : Built_In_Exp_Name
args : Feature
impl : Feature
rval : Value_Expression ;

Static Semantics

Dynamic Semantics


Specification Index Language Index Section 6 Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Tuesday, 23 May 2000.
Produced with Amaya