The syntax of the OUN language

Similar documents
The SPL Programming Language Reference Manual

RSL Reference Manual

The PCAT Programming Language Reference Manual

Mid-Term 2 Grades

Second release of the COMPASS Tool Tool Grammar Reference

CPSC 411, 2015W Term 2 Midterm Exam Date: February 25, 2016; Instructor: Ron Garcia

Lexical Considerations

1 Lexical Considerations

Lexical Considerations

Functional Programming. Pure Functional Programming

Principles of Programming Languages

Recap: Functions as first-class values

ication text. It is essential that already proven results are maintained when programs are changed, or guaranteed by additional verication conditions.

COMP520 - GoLite Type Checking Specification

IFAD. VDMTools Validated. Design through Modelling. Overview of VDM -SL/++ IFAD. IFAD A/S Forskerparken 10 DK-5230 Odense M Denmark.

CS 457/557: Functional Languages

The Decaf Language. 1 Lexical considerations

Decaf Language Reference

COMP520 - GoLite Type Checking Specification

Compilers. Compiler Construction Tutorial The Front-end

Reasoning about Asynchronous Method Calls and Inheritance

Decaf Language Reference Manual

COMP520 - GoLite Type Checking Specification

Scheme in Scheme: The Metacircular Evaluator Eval and Apply

Python in 10 (50) minutes

Datatype declarations

CMSC 330: Organization of Programming Languages. Operational Semantics

Racket: Modules, Contracts, Languages

A quick introduction to SML

Specifying Syntax. An English Grammar. Components of a Grammar. Language Specification. Types of Grammars. 1. Terminal symbols or terminals, Σ

Induction and Semantics in Dafny

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

IC Language Specification

COS 320. Compiling Techniques

Haskell 98 in short! CPSC 449 Principles of Programming Languages

Lazy Behavioral Subtyping

Solution sheet 1. Introduction. Exercise 1 - Types of values. Exercise 2 - Constructors

The S-Expression Design Language (SEDL) James C. Corbett. September 1, Introduction. 2 Origins of SEDL 2. 3 The Language SEDL 2.

Translating Scala to SIL

Copyright 2008 CS655 System Modeling and Analysis. Korea Advanced Institute of Science and Technology

Functions & First Class Function Values

Programming Languages Third Edition

More Assigned Reading and Exercises on Syntax (for Exam 2)

TEMPO RELEASE NOTES I O A. Recent Fixes (v0.1.4) 3. Known Issues (v0.1.4) 4. Language changes (v0.1.4) 4. v0.1.4 (BETA) 12/14/2006

SML A F unctional Functional Language Language Lecture 19

The Design Recipe Fall 2017

Chapter 3. Describing Syntax and Semantics

CA4003 Compiler Construction Assignment Language Definition

GNU ccscript Scripting Guide IV

Appendix A OCL 2.0 Grammar

G Programming Languages - Fall 2012

X Language Definition

InterprocStack analyzer for recursive programs with finite-type and numerical variables

Object Oriented Issues in VDM++

Incremental Reasoning for Multiple Inheritance

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

Exercises on ML. Programming Languages. Chanseok Oh

The Decaf language 1

A Third Look At ML. Chapter Nine Modern Programming Languages, 2nd ed. 1

(Not Quite) Minijava

TML Language Reference Manual

CMSC 330: Organization of Programming Languages

QUark Language Reference Manual

Lecture 11: Subprograms & their implementation. Subprograms. Parameters

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Reference C0.2. bool The type of booleans has just two elements, true and false. They are used for conditions, as well as contracts.

Module 10: Imperative Programming, Modularization, and The Future

Scheme Quick Reference

Ruby: Introduction, Basics

Object-Oriented Modeling. Sequence Diagram. Slides accompanying Version 1.0

Module 8: Local and functional abstraction

CSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc.

The Warhol Language Reference Manual

Principles of Programming Languages

Specification of Zinc and MiniZinc. Nicholas Nethercote Kim Marriott Reza Rafeh Mark Wallace María García de la Banda Version 0.8

The Formal Syntax and Semantics of Web-PDDL

CS143 Handout 03 Summer 2012 June 27, 2012 Decaf Specification

fjyswan Dr. Philip Cannata 1

Control Structures. Christopher Simpkins CS 3693, Fall Chris Simpkins (Georgia Tech) CS 3693 Scala / 1

Procedural abstraction SICP Data abstractions. The universe of procedures forsqrt. Procedural abstraction example: sqrt

SMURF Language Reference Manual Serial MUsic Represented as Functions

Testing, Debugging, and Verification

Defining Languages GMU

Scheme Quick Reference

A Verifying Compiler for a Multi-threaded Object-Oriented Language

Chapter 3 (part 3) Describing Syntax and Semantics

The Typed Racket Reference

GAWK Language Reference Manual

Program Design in PVS. Eindhoven University of Technology. Abstract. Hoare triples (precondition, program, postcondition) have

Formal Development with ABEL

Programming Languages 3. Definition and Proof by Induction

K Reference Card. Complete example

6.037 Lecture 4. Interpretation. What is an interpreter? Why do we need an interpreter? Stages of an interpreter. Role of each part of the interpreter

Languages and Compiler Design II IR Code Generation I

BinaryExpr.action Ints, all Ops

Chapter 2 SML, a Functional Programming Language

2.1. Expressions. Chapter 2 SML, a Functional Programming Language. Integers. Interacting with ML

Towards a Module System for K

Data types for mcrl2

Universe Type System for Eiffel. Annetta Schaad

Transcription:

The syntax of the OUN language Olaf Owe Department of Informatics, University of Oslo, Norway February 21, 2002 Contents 1 The OUN language 1 1.1 Interface and contract definition.................. 2 1.2 Class and subclass definition.................... 3 1.3 Dynamic class extension....................... 3 1.4 Basic elements: Lists and bindings................. 4 1.5 Names................................. 4 1.6 Type Declarations.......................... 5 1.7 Expressions.............................. 5 1.8 Communication events........................ 6 1.9 Basic types.............................. 6 1.10 Imperative code............................ 7 1.11 Executable expressions........................ 7 1.12 Reserved words............................ 7 1.13 ASCII symbols............................ 8 1.14 Transformation............................ 8 1 The OUN language This document defines the grammar of the OUN language ( Oslo University Notation ), using extended BNF. The language is designed for high-level programming and modeling of open distributed systems, with support of behavioral specification and modular program reasoning, and was developed in the context of the Adapt-FT project [1]. The language has similarities to the one suggested in [3] and is explained in more detail in [5]. Distributed units are represented by objects, each with its own (virtual) processor. Each object can handle a number of processes, corresponding to remaining parts of method activations. A method activation may be temporarily suspended by use of guards, with the syntax guard statement, allowing other enabled processes to continue. A suspended process is enabled when its initial guard is satisfied. A method call m(in; out) can have several in-parameters as well as out-parameters. A remote 1

call m(in; out) do s od will execute the statments s while waiting for the callee o to complete the call (if different from this object). Openness is supported by run-time class upgrades, called class extension, allowing a class to be changed at run-time without interrupting the execution. A class extension may modify an existing class by adding new fields and new methods, by redefining existing methods (as well as associated behavioral specification), and by providing support of additional interfaces. Specifications of classes and interfaces are given by invariants and pre- and post-conditions, using predicates that may refer to the communication history H, following [3, 6, 4]. In additon to class and interfaces specification, we allow contract specifications for subsystems invloving several objects. The language is object-oriented supporting single and multiple inheritance of classes as well as interfaces, late binding, overloading, dynamic generation of objects, and encapsulation. Remote access to fields are not allowed and inter-object communication is done by means of method interaction controlled by interfaces. Method interaction is represented by two-way asynchronous communication, letting each such communication event correspond to an event in the communication history. We use arrows to visualize the direction of the communication event. Objects are representing concurrent units in a distributed setting, while local data structure is defined by data types, using a syntax similar to [2, 4]. The language is strongly typed, using co-interfaces (specified by with clauses) in order to be able to write type-correct call-backs. We refer to [5] for further details of the language. Notational conventions Terminal symbols appear in bold, square brackets are used for optional parts; {something} means that something may be repeated n times, n N. We enclose terminal symbols in quotations marks when necessary to avoid confusion. 1.1 Interface and contract definition spec interface ::= interface interface name [ [ type bindings ] ][ ( object bindings ) ] [inherits interfaces] begin [types type decls] [with interface name {operation}] [asm expr] [inv expr] [auxiliary part] end spec contract ::= contract contract name begin with object bindings inv expr [auxiliary part] 2

end 1.2 Class and subclass definition spec class ::= class class name [ [ type bindings ] ][ ( bindings ) ] [implements inst interfaces] [inherits classes] begin [types type decls] [val constant declarations] [var var declarations] [init imperative code] {operation == imperative code} {with interface name {operation == imperative code} [asm expr]} [inv expr] [auxiliary part] end 1.3 Dynamic class extension spec class extension ::= class extension class name [implements inst interfaces] begin {operation == imperative code} {with object binding {operation == imperative code} [asm expr]} [inv expr] [auxiliary part] end auxiliary part ::= func function sigs [ def function defs] [ axiom exprs] [ lma exprs] 3

1.4 Basic elements: Lists and bindings type bindings ::= {type binding,} type binding object bindings ::= {object binding,} object binding bindings ::= {binding,} binding type binding ::= type name : type deter object binding ::= object name : interface name binding ::= identifier : type name var declarations ::= {var declaration,} var declaration var declaration ::= binding [:= expr] constant declarations ::= {var declaration,} var declaration type deter ::= Data Type Interface operation ::= opr operation name ( [in out parameters] ) in out parameters ::= [in] bindings [; out bindings] out bindings function sigs ::= {function sig,} function sig function sig ::= identifier ( func bindings ) : func type func bindings ::= {func binding,} func binding func binding ::= identifier : func type func type ::= type name event seq function defs ::= {function def,} function def function def ::= expr== expr exprs ::= {expr,} expr inst interfaces ::= {inst interface, } inst interface inst interface ::= interface name[ [ type names ] ] type names ::= {type name,} type name 1.5 Names interfaces ::= {interface name,} interface name classes ::= {class name,} class name interface name ::= identifier any class name ::= identifier contract name ::= identifier operation name ::= identifier object name ::= id type name ::= basic type identifier (class name interface name).identifier basic type ::= int nat bool string id ::= identifier id ( number ) id.id identifier ::= non num{alpha num} non num ::= a... z A... Z alpha num ::= digit non num - digit ::= 0... 9 4

1.6 Type Declarations type decls ::= {type decl,} type decl type decl ::= identifier: type = type expr type expr ::= identifier enumeration type tuple type record type seq type set type array type subtype enumeration type ::= { identifiers } tuple type ::= [ tuple members ] tuple members ::= {tuple member,} tuple member tuple member ::= identifier : type expr record type ::= [ #field decls# ] field decls ::= {field decl,} field decl field decl ::= identifiers : type expr seq type ::= seq [ type name ] set type ::= set [ type name ] array type ::= array [ number ] [ type name ] subtype ::= { binding mid expr } identifiers ::= {identifier,} identifier mid ::= 1.7 Expressions expr ::= litteral expr event sequence projection set rs id ( expr ) (class name interface name).identifier func arguments (seq pdf id) func arguments expr binop expr unaryop expr if expr quantified expr reused spec 5

litteral expr ::= number boolean string [ ex exprs ] { ex exprs } ( ex exprs ) (#ex exprs#) [ ] { } ( ) if expr ::= if expr then expr {elsif expr then expr} else expr endif quantified expr ::= binding op bindings : expr func arguments ::= ( {expr,} expr ) binop ::= xor andthen orelse ˆ + / % = < > head \ prs in sub unaryop ::= not <> binding op ::= forall exists reused spec ::= (class name interface name).inv (class name interface name).asm 1.8 Communication events rs ::= event sequence [ rs mid where bindings ] ( rs ) rs mid rs rs rs rs event sequence ::= empty {event} event projection set ::= init term id object binding event set operation set event set ::= { {event,}event } event operation set ::= { {operation name,}operation name } operation name init ::= object object term ::= object object init term ::= object object object ::= object name me event ::= init event term event init term event init event ::= init.operation name[ ( exprs ) ] term event ::= term.operation name[ ( exprs [; exprs] ) ] init term event ::= init term.operation name 1.9 Basic types number ::= [-]{digit}digit string ::= {ascii} boolean ::= true false 6

1.10 Imperative code imperative code ::= stms stms ::= {stm ;} stm stm ::= skip if stm nondet stm while stm assignm guarded stm ifany stm local call remote call local var mythical stm skip ::= skip if stm ::= if ex expr then stms [else stms] endif nondet stm ::= begin {guarded stm mid} guarded stm end while stm ::= while ex expr do stms enddo assignm ::= ids := ex expr guarded stm ::= ex expr stm ifany stm ::= if any Itest expr then stms [else stms] endif local call ::= operation name ( ex exprs ) operation name ( ex exprs ; ids ) remote call ::= identifier.local call [do stms enddo] local var ::= var identifier : type name = ex expr mythical stm ::= bool expr ids ::= {id,} id 1.11 Executable expressions ex exprs ::= {ex expr, }ex expr ex expr ::= numeric expr bool expr string expr seq expr litteral expr null id new expr ( ex expr ) bool expr ::= ex expr bool op ex expr not ex expr Itest expr id boolean Itest expr ::= object binding? numeric exp ::= ex expr num op ex expr string expr ::= ex expr + ex expr seq expr ::= ex expr seq op ex expr seq pdf ( ex expr ) new expr ::= new class name ( ex exprs ) bool op ::= < > = andthen orelse xor in head sub num op ::= + / % seq op ::= seq pdf ::= lr rr lt rt # 1.12 Reserved words andthen any asm axiom begin caller class contract Data Type empty def do else elsif end endif enddo exists false forall func H if implements in inherits init Interface interface inv lma me new null opr orelse out skip super then true type types val var where while with Types: array bool event seq int nat seq set string Functions and operators: head in lr lt not prs rr rt sub xor 7

1.13 ASCII symbols Latex ASCII <=> => \/ /\ <= >= / = 1.14 Transformation id ::= identifier [id ] id ::= ( number ) [id ].id [id ] expr ::= litteral expr [expr ] event sequence [expr ] projection set [expr ] rs [expr ] id [expr ] ( expr ) [expr ] (class name interface name).identifier func arguments [expr ] (seq pdf id) func arguments [expr ] unaryop expr [expr ] if expr [expr ] quantified expr [expr ] reused spec [expr ] expr ::= binop expr [expr ] rs ::= event sequence [rs ] [ rs mid where bindings ] [rs ] ( rs ) [rs ] rs ::= mid rs [rs ] * [rs ] rs [rs ] ex expr ::= litteral expr [ex ] null [ex ] id [ex ] new expr [ex ] ( ex expr ) [ex ] seq pdf ( ex expr ) [ex ] Itest expr [ex ] not ex expr [ex ] ex ::= num op ex expr [ex ] bool op ex expr [ex ] + ex expr [ex ] seq op ex expr [ex ] References [1] The ADPAT-FT project homepage. http://www.ifi.uio.no/ adapt/. [2] Dahl, O.-J. Verifiable Programming. Prentice-Hall, 1992. [3] Dahl, O.-J., and Owe, O. Formal methods and the RM-ODP. Tech. Rep. 261, Department of Informatics, University of Oslo, 1998. 8

[4] Dahl, O.-J., and Owe, O. Formal Development with ABEL. In Proceedings of Formal Software Development Methods (VDM 91) LNCS 552, pages 320 362, 1991. [5] Owe, O., and Ryl, I. OUN: A formalism for open, object-oriented, distributed sytems. Research Report 270, Department of Informatics, University of Oslo, Norway, 1999. http://www.ifi.uio.no/ adapt/. [6] Soundarajan, N., and Fridella, S. Inheritance: From code reuse to reasoning reuse. In Proc. 5th Conference on Software Reuse (ICSR5) (1998), P. Devanbu and J. Poulin, Eds., IEEE Computer Society Press, pp. 206 215. 9