Abstract This document describes AsmL, a specification language based on abstract state machines. Foundations of Software Engineering Microsoft Research (c) Microsoft Corporation. All rights reserved. Contents 1 Introduction 6



Download 0.93 Mb.
Page24/25
Date28.01.2017
Size0.93 Mb.
#9776
1   ...   17   18   19   20   21   22   23   24   25

1.74String operations


The AsmL2 library provides a String datatype that is compatible with the .NET Framework System.String. However, in addition, future versions of the compiler will support all of the sequence operations, as if String were a subtype of the AsmL type Seq of Char.

12List of Examples


Example 1 In-place sorting 7

Example 2 Indentation as block structure 18

Example 3 Indentation as block structure 19

Example 4 Declarations 19

Example 5 Continuation of declarations 22

Example 6 Literal constructors 24

Example 7 Constructing instances 24

Example 8 Constructing compound values 25

Example 9 Constructing enumerated values 25

Example 10 Constructing tuples 26

Example 11 Constructing sets 27

Example 12 Constructing sequences 27

Example 13 Constructing maps 28

Example 14 Symmetry of construction and pattern matching 28

Example 15 Pattern matching without binding 29

Example 16 Single-name patterns 29

Example 17 Type patterns 30

Example 18 Tuple pattern 30

Example 19 Destructing patterns for structures 31

Example 20 Maplet patterns 32

Example 21 Simple, iterated and nondeterministic bindings 33

Example 22 Type expressions 34

Example 23 Disjunctive type 35

Example 24 Type families 37

Example 25 Type operations 38

Example 26 Interface declaration 41

Example 27 Datatype variants 43

Example 28 Structure case as subtypes 43

Example 29 Enumeration with user-provided values 44

Example 30 Enum Ranges 44

Example 31 Constrained type 46

Example 32 Constraints on type parameters 47

Example 33 Field containing a compound value 51

Example 34 Indexing parameters vs. indexing field names 52

Example 35 Kinds of methods 53

Example 36 Example: Operator declaration 54

Example 37 Example: Conversion methods 55

Example 38 Static method selection 57

Example 39 Dynamic method selection 58

Example 40 User-provided constructor 59

Example 41 User-provided constructor with inheritance 60

Example 42 Disambiguation of method names 60

Example 43 Constraint declaration 61

Example 44 Local fields 64

Example 45 Runtime assertion checking 65

Example 46 Use of a resulting expression 66

Example 47 Statement-level nondetermism 67

Example 48 Quantifying expressions 72

Example 49 Value-level nondeterministic choice 73

Example 50 Selection expressions 73

Example 51 Type conversions of built-in types 75

Example 52 Invocation syntax 76

Example 53 Enumerated types 77

Example 54 Enumerable disjunctive types 77

Example 55 Enumerable structure type 78

Example 56 Enumerated class 78

Example 57 Enumeration of enum values 78

Example 58 Enumeration of constrained type 79

Example 59 Update statement 81

Example 60 Update statements 81

Example 61 Parallel update 83

Example 62 Sequential and parallel steps 85

Example 63 Skip statement 86

Example 64 Select expressions 87

Example 65 Namespaces 88

Example 66 Use of qualified names 88

Example 67 Import Directives 89

Example 68 Explicit qualification required 89



Example 69 Delegate 94

2 Grammar


This section provides a summary of the AsmL grammar.

2.1Lexical level

2.1.1Identifiers


id ::= initIdChar { idChar } { '' }
initIdChar
::= letter | ideographic | '@' | '_'
idChar
::= letter | combining | ideographic
| digit | extender | underscore
letter ::= // per Unicode section 4.5, letter,
excluding combining characters
combining
::= \u20DD | \u20DE | \u20DF | \u20E0
digit
::= // per Unicode section 4.6, digit char
ideographic
::= \u2FF0..\u2FFF
extender
::= \u00B7 | \u02D0 | \u02D1 | \u0387 | \u0640
| \u0E46 | \u0EC6 | \u3005 | \u3031..\u3035
| \u309B..\u309D | \u309E | \u30FC..\u30FE
| \uFF70 | \uFF9E | \uFF9F
underscore
::= \u005F | \uFF3F

2.1.2Literals


literal ::= null | boolean | integer | real | string | char

2.1.3Boolean literals


boolean ::= true | false

2.1.4Integer literals


integer ::= (decimal | hexadecimal) [ integerSuffix ]
decimal
::= digits
hexadecimal
::= '0' ('x' | 'X') hexDigit { hexDigit }
integerSuffix
::= 'l' | 'L' | 's' | 'S' | 'b' | 'B'
digits
::= digit { digit }
hexDigit
::= digit | 'a' .. 'f' | 'A' .. 'F'

2.1.5Literals for real numbers


real ::= digits '.' digits [ exponent ] [ realSuffix ]
exponent
::= ('e' | 'E') [ '+' | '-' ] digits
realSuffix
::= 'f' | 'F'

2.1.6String literals


string ::= quote { strChar } quote
strChar
::= readable | whiteChar | sQuote | '\' esc
readable
::= (see text)
quote
::= '"'
esc
::= 'b' | 'f' | 'n' | 't' | 'r'
| ('u' hexDigit hexDigit hexDigit hexDigit)

2.1.7Character literals


char ::= sQuote (readable | quote | '\' esc) sQuote sQuote ::= "'"

2.1.8Keywords


->

_

eq

initially

operator

step

..

{

error

inout

or

structure

:=

|

event

interface

otherwise

subset

<=

}

exists

internal

out

subseteq

<>

abstract

explore

intersect

override

sum

>=

add

extends

is

primitive

the

(

and

fixpoint

let

private

then

)

any

for

lt

procedure

throw

*

as

forall

lte

process

to

+

case

foreach

match

property

try

,

catch

from

max

protected

type

-

choose

function

me

public

union

.

class

get

merge

ref

unique

/

const

gt

min

remove

until

:

constraint

gte

mod

require

value

;

delegate

holds

mybase

resulting

values

<

do

if

namespace

return

var

=

else

ifnone

ne

sealed

virtual

>

elseif

implements

new

search

where

?

ensure

implies

not

set

while

[

enum

import

notin

shared

 

]

enumerated

in

of

skip

 

+=

*=















Download 0.93 Mb.

Share with your friends:
1   ...   17   18   19   20   21   22   23   24   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page