Ocean Parse Tree

ocean::= { ocean-elem step }
ocean-elem::= ( interface | mixin | concrete | concept | delegate | deputy | library | monitor | module | program )

Module

Modules are the generic way to group both data and code. They create their own namespace, but have no further overhead.

module::= module name { AND module-contract } module-details ? END ( ITS module same-name ? ) ?
module-contract::= ( call-model | switch | exception )
module-details::= SPEC { module-elem step }

Library

A Library module like a program module declares the contract with the nvironment, only in the case of a library the environment are other programs which use this as a dynamic loading library.

A library has an automatic 'switch forbidden'

library::= library name { AND library-contract } ***TODO'*** END ( ITS library same-name ? ) ?
library-contract::= ( call-model | exception | ***TODO*** )

Monitor

A monitor is a module with added support for entrance and use protection for all code with its scope.

A monitor has an implicit 'call threaded'.

monitor::= monitor name { AND monitor-contract } monitor-details ? END ( ITS monitor same-name ? ) ?
monitor-contract::= ( switch | exception | ***TODO*** )
monitor-details::= SPEC { module-elem step }

Program

There is either one program module per program (sic) or a 'library'. The program module declares the contract to the environment.

program::= program name { AND program-contract } program-details ? END ( ITS program same-name ? ) ?
program-contract::= ( call-model | switch | exception | environment IDENTIFIER )
program-details::= SPEC { module-elem step }

Memory Model

Static (qv 'Fortran') is not an option as it is the minimal supported set: no calling stack is used; recursive (qv 'C') adds calling stack functionality although most programs running under an OS get this automaticaly; threaded OS support and are a condition for monitors

call-model::= call ( recursive | static | threaded )

Exception

Ugly way of telling it... Rethink.

exception::= exceptions yes

Switch

Routines are co-routines with named switch targets, fibres are user-x cooperative multi-tasking. NB routines and fibres are mutual exclusive. If none of these is selected the local code cannot use either, but other modules might, if it is forbidden the program cannot use it.

Note: routines and fibres are mutual exclusive and a 'library' has an automatic 'forbidden'

switch::= switch ( fibres | forbidden | routines )

Module Elements

Modules...

module-elem::= alias visibility ? alias
 | assert visibility ? assert
 | augment visibility ? augment
 | define visibility ? define
 | our visibility ? changability ? our
 | the visibility ? changability ? the
visibility::= private
 | public
 | restricted
changability::= alterable
 | constant
 | read_volatile
 | volatile
 | write_volatile

Alias

alias::= dyadic SYMBOL priority ( in | lr | rl ) alias-name
 | monadic SYMBOL alias-name
 | name name alias-name
 | unit name ( OR IDENTIFIER ) ? ( = | ) LABEL derive-factor-1 ?

Assert

assert::= unit ( LIT_INTEGER | LIT_REAL ) ( LIT_INTEGER ) ? LABEL ( = | ) ( LIT_INTEGER | LIT_REAL ) ( LIT_INTEGER ) ? LABEL

Augment

augment::= TODO ***TODO***

Define

define::= ( define-unit | define-type | code )

Our

our::= IDENTIFIER array ? IDENTIFIER

The

the::= IDENTIFIER array ? IDENTIFIER

Define Type

define-type::= enum name { AND enum-contract } ( SPEC enum-elem ) ? END ( ITS enum same-name ? ) ?
 | range name { AND range-contract } ( SPEC expression RANGE expression ( LABEL ) ? ) ? END ( ITS range same-name ? ) ?
 | structure name { AND structure-contract } ( SPEC { structure-elem ( SEP | SYM_TXT_CONCAT ) } ) ? END ( ITS structure same-name ? ) ?
 | union opt-name { AND align ( LIT_INTEGER | LIT_REAL ) } SPEC { structure-elem SEP } END ( ITS union ( ITS ( DUMMY | IDENTIFIER ) ) ? ) ?
 | variant name { AND ( SWITCHER ***TODO*** | align ( LIT_INTEGER | LIT_REAL ) ) } SPEC { variant-elem step } END ( ITS variant same-name ? ) ?
enum-elem::= ENUM ( LIST_START expression LIST_END ) ? ( OR enum-elem ) ?
variant-elem::= TODO ***TODO***
enum-contract::= align ( LIT_INTEGER | LIT_REAL )
 | endian ( big | little )
 | extend IDENTIFIER
range-contract::= align ( LIT_INTEGER | LIT_REAL )
 | endian ( big | little )
structure-contract::= access ***TODO***
 | align ( LIT_INTEGER | LIT_REAL )
 | counted ***TODO***
 | invariant ***TODO***
 | owner ***TODO***
 | pointer ***TODO***

Define Unit

define-unit::= unit name ( OR IDENTIFIER ) ?

Define Type

structure-elem::= IDENTIFIER array ? IDENTIFIER
 | define visibility ? define
 | enum name { AND enum-contract } ( SPEC enum-elem ) ? END ( ITS enum same-name ? ) ?
 | range name { AND range-contract } ( SPEC expression RANGE expression ( LABEL ) ? ) ? END ( ITS range same-name ? ) ?
 | structure name { AND structure-contract } ( SPEC { structure-elem ( SEP | SYM_TXT_CONCAT ) } ) ? END ( ITS structure same-name ? ) ?
 | union opt-name { AND align ( LIT_INTEGER | LIT_REAL ) } SPEC { structure-elem SEP } END ( ITS union ( ITS ( DUMMY | IDENTIFIER ) ) ? ) ?
 | variant name { AND ( SWITCHER ***TODO*** | align ( LIT_INTEGER | LIT_REAL ) ) } SPEC { variant-elem step } END ( ITS variant same-name ? ) ?
array::= INDEX_START { expression SEP } INDEX_END

Classes

Concepts

concept::= concept name { AND concept-contract } class-details ? END ( ITS concept same-name ? ) ?

Contracts

concept-contract::= TODO ***TODO***
concrete::= concrete name { AND concrete-contract } class-details ? END ( ITS concrete same-name ? ) ?
concrete-contract::= TODO ***TODO***
delegate::= delegate name { AND delegate-contract } class-details ? END ( ITS delegate same-name ? ) ?
delegate-contract::= TODO ***TODO***
deputy::= deputy name { AND deputy-contract } class-details ? END ( ITS deputy same-name ? ) ?
deputy-contract::= TODO ***TODO***
interface::= interface name { AND interface-contract } class-details ? END ( ITS interface same-name ? ) ?
interface-contract::= TODO ***TODO***
mixin::= mixin name { AND mixin-contract } class-details ? END ( ITS mixin same-name ? ) ?
mixin-contract::= TODO ***TODO***

Details

class-details::= SPEC { class-elem step }
class-elem::= defers ***TODO***
 | delegates ***TODO***
 | has ***TODO***
 | implements ***TODO***
 | is ***TODO***
 | represents ***TODO***
 | wraps ***TODO***

Code blocks

...

code::= ( function | procedure | terminal | generator | method | thread )
function::= function name params { AND code-contract } code-body ? END ( ITS function same-name ? ) ?
generator::= generator name params { AND code-contract } code-body ? END ( ITS generator same-name ? ) ?
method::= method name params { AND method-contract } code-body ? END ( ITS method same-name ? ) ?
procedure::= procedure name params { AND code-contract } code-body ? END ( ITS procedure same-name ? ) ?
terminal::= terminal name params { AND code-contract } code-body ? END ( ITS terminal same-name ? ) ?
thread::= thread name { AND thread-contract } thread-details ? END ( ITS thread same-name ? ) ?
params::= LIST_START { params-elem SEP } LIST_END
params-elem::= code-param-presence ? code-param-passing code-param-type array ? IDENTIFIER
thread-contract::= TODO ***TODO***
thread-details::= SPEC { statement step }

Code contract

...

code-contract::= ensure expression
 | invariant expression
 | link IDENTIFIER
 | place ( generic | inline | normal )
 | require expression
 | volatile ***TODO***
 | weak ***TODO***
code-param-type::= IDENTIFIER ( ITS code-param-type ) ?
 | IDENT_GENERIC ( ITS code-param-type ) ?

Parameter passing

...

code-param-passing::= borrow
 | copy
 | give
 | present
 | share
 | take
 | their
 | use

Parameter presence

...

code-param-presence::= automatic
 | mandatory
 | repeated
code-body::= SPEC { statement step }
method-contract::= TODO ***TODO***

Statements

...

statement::= statement-simpel statement-qualifier ?
statement-qualifier::= else expression
 | if expression
 | unless expression
 | until expression
 | while expression
statement-simpel::= expression
 | assume expression SPEC { statement step } statement-else ? END ( ITS assume ) ?
 | bounce ( LABEL ) ?
 | for ***TODO***
 | foreach ***TODO(next,leave,bounce,redo) [else] [finally] end***
 | if expression SPEC { statement step } statement-elsif ? statement-else ? END ( ITS if ) ?
 | leave ( LABEL ) ?
 | next ( LABEL ) ?
 | redo ( LABEL ) ?
 | release
 | resume name
 | return expression ?
 | unless expression SPEC { statement step } statement-elsif ? statement-else ? END ( ITS unless ) ?
 | until expression SPEC { statement step } statement-continue ? statement-else ? statement-finally ? END ( ITS until ) ?
 | while expression SPEC { statement step } statement-continue ? statement-else ? statement-finally ? END ( ITS while ) ?
 | with SPEC { statement step } do { statement step } statement-continue ? statement-else ? statement-finally ? END ( ITS with ) ?
 | yield expression
statement-continue::= continue SPEC { statement step }
statement-else::= else SPEC { statement step }
statement-elsif::= elsif expression SPEC { statement step } statement-elsif ?
statement-finally::= finally SPEC { statement step }

Expressions

...

expression::= ASPECT IDENTIFIER ( TODO ) ? expr-aspect expr-dyadic ?
 | IDENTIFIER expr-sub ? expr-dyadic ?
 | LIST_START { expression step } LIST_END expr-sub ? expr-dyadic ?
 | LIT_FRACTION ( LABEL ) ? expr-dyadic ?
 | LIT_INTEGER ( LABEL ) ? expr-dyadic ?
 | LIT_REAL ( LABEL ) ? expr-dyadic ?
 | LIT_TEXT ( LABEL ) ? expr-dyadic ?
 | SYMBOL expression
expr-aspect::= ASPECT IDENTIFIER expr-aspect-n ?
expr-aspect-n::= ASPECT IDENTIFIER expr-aspect-n ?
expr-dyadic::= SYMBOL expression
expr-sub::= INDEX_START { expression step } INDEX_END expr-sub ?
 | ITS expr-its expr-sub ?
 | LIST_START { expression step } LIST_END expr-sub ?
 | WITH_ITS IDENTIFIER expr-sub ?
expr-its::= IDENTIFIER
 | LIST_START { expression step } LIST_END
derive-factor-1::= SYM_ARM_ADD ( LIT_INTEGER | LIT_REAL ) ( LIT_INTEGER ) ?
 | SYM_ARM_DIVIDE ( LIT_INTEGER | LIT_REAL ) ( LIT_INTEGER ) ? derive-factor-2 ?
 | SYM_ARM_MULTIPLY ( LIT_INTEGER | LIT_REAL ) ( LIT_INTEGER ) ? derive-factor-2 ?
 | SYM_ARM_SUBTRACT ( LIT_INTEGER | LIT_REAL ) ( LIT_INTEGER ) ?
derive-factor-2::= SYM_ARM_ADD lit-number
 | SYM_ARM_SUBTRACT lit-number

terminals

alias-name::= IDENTIFIER
lit-number::= LIT_INTEGER ( SYM_ARM_DIVIDE ***LIT_INTEGER*** ) ?
 | LIT_RATIONAL
 | LIT_REAL
name::= IDENTIFIER
opt-name::= DUMMY
 | IDENTIFIER
priority::= LIT_INTEGER
same-name::= ITS IDENTIFIER
step::= SEP
 | THEN