alice
manual.


Alice Project

the
language


________ Overview ____________________________________________________

Alice ML is based on the Standard ML programming language (SML), as defined in

However, Alice ML features a number of extensions relative to SML (including most current proposals for Successor ML).

You should also be aware of some


________ Syntax summary ______________________________________________

Line comments

Literals

Reserved words

Alice ML defines some additional identifiers as reserved words:

	any    assert    assertd   comp      constructor  exttype
	fct    finally   from      import    non          lazy
	pack   spawn     unpack    withfun   withval      _file_    _line_

The following grammar collects all other syntactic extensions of Alice ML relative to Standard ML. Derived forms are marked (*).

Long identifiers

longid ::= id
longid . id long identifiers

Expressions

atexp ::= ...
comp <ann in> spec with dec end component1
#[ exp1 , ... , expn ] vector (n≥0)
{ atexp where exprow } record update
( exp1 ; ... ; expn <;>) sequential (n≥2)
let dec in exp1 ; ... ; expn <;> end local declaration (n≥1)
_file_ source file (*)
_line_ source line (*)
exp ::= ...
exp handle <|> match handle exception
case exp of <|> match case analysis
fn <|> match function
if exp1 then exp2 <else exp3> conditional
lazy exp lazy
spawn exp concurrent
exp1 finally exp2 finalization (L) (*)
rec pat => exp recursion (*)
pack strexp : sigexp transparent packing
pack strexp :> sigexp opaque packing (*)
assert<d> exp boolean assertion (*)
assert<d> exp of pat pattern assertion (*)
assert<d> exp raise pat exception assertion (*)
assert<d> exp do exp boolean precondition (*)
assert<d> exp of pat do exp pattern precondition (*)
exprow ::= ...
vid <: ty> <, exprow> label as expression (*)
... = exp <, exprow> record extension

1) The syntax of import items in a first-class component is restricted to the syntactic subclass of the corresponding descriptions, as used in signatures.

Patterns

 
atpat ::= ...
#[ pat1 , ... , patn ] vector (n≥0)
( pat1 | ... | patn ) alternative (n≥2)
pat ::= ...
pat as pat layered (R)
pat if atexp guarded (L)
patrow ::= ...
... = pat <, patrow> record extension

Types

ty ::= ...
_ wildcard
tyrow ::= ...
... : ty <, tyrow> record extension

Declarations

dec ::= ... 1)
exttype extbind extensible datatype
constructor econbind generative constructor
open strexp generalised open (*)
do exp statement
fvalbind ::= <lazy | spawn> lazy/concurrent function (m,n≥1) (*)
  <|> <op> vid atpat11 ... atpat1n <: ty1> = exp1
    | <op> vid atpat21 ... atpat2n <: ty2> = exp2
    | ...
    | <op> vid atpatm1 ... atpatmn <: tym> = expm
    <and fvalbind>
datbind ::= tyvarseq tycon = <|> conbind <and datbind> datatype binding
extbind ::= tyvarseq tycon extensible datatype
econbind ::= <op> vid <of ty> : tyvarseq longtycon <and econbind> new constructor
<op> vid = <op> longvid <and econbind> synonym
strbind ::= ...
_ <: sigexp> = strexp <and strbind> anonymous structure (*)
funbind ::= <lazy | spawn> strid strpat1 ... strpatn: | :> sigexp> = strexp <and funbind> functor binding (n≥1) (*) 2

1) The extended phrase class dec contains all of Standard ML's dec, strdec and topdec.

2) See the module syntax summary for a more precise grammar of functor bindings.

Structures

strexp ::= ...
( strexp ) parentheses
( dec ) structure (*)
strexp strexp functor application 1
fct strpat => strexp functor
unpack infexp : sigexp unpacking
lazy strexp laziness
spawn strexp concurrency
strpat ::= strid : sigexp parameter
_ : sigexp anonymous parameter (*)
( strid : sigexp ) parameter (*)
( _ : sigexp ) anonymous parameter (*)
( spec ) signature as parameter (*)

1) See the module syntax summary for a more precise grammar of structure expressions and functor application.

Signatures

sigexp ::= ...
longsigid signature identifier
( sigexp ) parentheses
( spec ) signature (*)
fct strpat -> sigexp functor
sigexp1 -> sigexp2 non-dependent functor 1

1) See the module syntax summary for a more precise grammar of functor signatures.

Specifications

spec ::= ...
exttype extdesc extensible datatype
constructor econdesc generative constructor
functor fundesc functor specification (*)
signature sigdesc signature specification
datdesc ::= tyvarseq tycon = <|> condesc <and datdesc> datatype description
extdesc ::= tyvarseq tycon extensible datatype
econdesc ::= <op> vid <of ty> : tyvarseq longtycon <and econdesc> new constructor
fundesc ::= strid strpat1 ... strpatn : sigexp <and fundesc> functor description (n≥1) (*) 1
sigdesc ::= sigid <= sigexp> <and sigdesc> signature description

1) See the module syntax summary for a more precise grammar of functor specifications.

Components

component ::= ann <program> component
ann ::= import imp from string import announcement
import string import all (*)
empty
ann <;> ann
imp ::= val valitem
type typitem
datatype datitem
exttype extitem
constructor econitem
exception exitem (*)
structure stritem
functor funitem (*)
signature sigitem
infix <d> vid1 ... vidn (n≥1)
infixr <d> vid1 ... vidn (n≥1)
nonfix vid1 ... vidn (n≥1)
empty
imp <;> imp
valitem ::= <op> vid <and valitem>
<op> vid : ty <and valitem>
typitem ::= tycon <and typitem>
tyvarseq tycon <and typitem>
datitem ::= tycon <and datitem>
tyvarseq tycon = <|> conitem <and datitem>
conitem ::= <op> vid <of ty> <| conitem>
extitem ::= tycon <and extitem>
tyvarseq tycon <and extitem>
econitem ::= <op> vid <and econitem>
exitem ::= <op> vid <and exitem> (*)
<op> vid of ty <and exitem> (*)
stritem ::= strid <and stritem>
strid : sigexp <and stritem>
funitem ::= strid <and funitem> (*)
strid strpat1 ... strpatn : sigexp <and funitem> (n≥1) (*) 1
sigitem ::= sigid <and sigitem>

1) See the component syntax summary for a more precise grammar of functor items.



last modified 2007/04/10 15:26