DIPARTIMENTO   DI   INFORMATICA
Università di Torino

Rank 2 intersection for a simple language of modules (built on a subset of Caml)

Module syntax

module ::= [import {import-typedef}+]
[export {export-typedef}+]
[declare {declaration}+]
define simple-let-binding {and simple-let-binding}* ;;
     
import-typedef ::= type type-declaration ;;
| type import-type-definition {and import-type-definition}* ;;
import-type-definition ::= type-definition
| readonly type-definition
     
type-declaration ::= typeconstr-name
| 'ident typeconstr-name
| ( 'ident {, 'ident }+ ) typeconstr-name
type-definition ::= typeconstr-name = type-representation
| 'ident typeconstr-name = type-representation
| ( 'ident {, 'ident }+ ) typeconstr-name = type-representation
type-representation ::= constr-decl {| constr-decl }*
constr-decl ::= cconstr-name
| ncconstr-name of typexpr
     
export-typedef ::= type export-type-definition {and export-typedef}* ;;
export-type-definition ::= type-definition
| readonly type-definition
| opaque type-declaration
| hidden type-declaration
     
declaration ::= value-name : rank2-typexpr ;;
     
rank2-typexpr ::= conj -> rank2-typexpr
| typexpr -> rank2-typexpr
| typexpr
conj ::= ( typexpr {^ typexpr}+ )
typexpr ::= int | bool | unit | 'ident |
| typexpr -> typexpr | ( typexpr {* typexpr }+ )
| typeconstr-name | typexpr typeconstr-name
| ( typexpr {, typexpr }+ ) typeconstr-name
     
simple-let-binding ::= {value-name}+ = expr
     
expr ::= value-name | constant
| cconstr-name | ncconstr-name expr
| ( expr {, expr }+ ) | expr expr
| if expr then expr else expr
| match expr with pattern-matching
| fun {value-name}+ -> expr
| function pattern-matching
| let simple-let-binding in expr
| let rec simple-let-binding {and simple-let-binding }* in expr
| expr infix-op expr | prefix-symbol expr
| expr :: expr
     
pattern-matching ::= pattern -> expr {| pattern -> expr }+
pattern ::= _ | value-name | constant
| cconstr-name | ncconstr-name pattern
| ( pattern {, pattern }+ )
| pattern :: pattern
     
infix-op ::= + | - | * | /
| > | < | = | <>
| && | ||
prefix-symbol ::= not | hd | tl | null | fst | snd
constant ::= ... | -1 | 0 | 1 | ...
| true | false | ()


[Back]

Comments to: damiani[at]di[dot]unito[dot]it