FileMap | |||
::= | (UnitSpec FileName ;)* | ||
UnitSpec | |||
::= | module Identifier | ||
| | signature Identifier |
ASDL
give a list of different entry kindsFor example, consider the following small Moby module:
module M { datatype T { C of Int } val x : T = C(5) }It can be represented by the following MBI file:
Stamp | Name | Kind | Contents | |||
0 | M | DK_MODULE | decls: [1, 5, 6] | |||
1 | T | DK_TYPE |
|
|||
2 | Int | DK_XTYPE | owner: 3 | |||
3 | Int | DK_XMODULE | owner: 4 | |||
4 | moby-basis | DK_LIBRARY | guid: "..." | |||
5 | C | DK_CON |
|
|||
6 | x | DK_VAL |
|
|||
BOL
Overloading
MBXFile | |||
::= | (MBXUnit)+ | ||
MBXUnit | |||
::= | %module ModuleId Guid { Decl* } | ||
| | %pervasive Guidopt { PervDecl* } | ||
Decl | |||
::= | TypeDecl | ||
PervDecl | |||
::= | OverloadDecl |
OverloadDecl | |||
::= | %overload ValId : TyScheme | ||
| | %bind ValId : TyScheme = ValSpec |
TypeDecl | |||
::= | %type TypeId TyParamsopt = %prim BOLType | ||
| | %type TypeId TyParamsopt = Type | ||
| | %enumtype TypeId { NullaryDataCons } | ||
| | %datatype TypeId TyParamsopt { DataCons } | ||
| | %objtype TypeId TyParamsopt { ObjMemberList } | ||
| | %tagtype TypeId TyParamsopt | ||
| | %tagtype TypeId TyParamsopt %of OneOrMoreTys | ||
| | %tagtype TypeId TyParamsopt %extends NamedTy | ||
| | %tagtype TypeId TyParamsopt %of OneOrMoreTys %extends NamedTy |
BOLType | |||
::= | %any | ||
| | %unit | ||
| | %bool | ||
| | %int8 | ||
| | %int16 | ||
| | %int32 | ||
| | %int64 | ||
| | %integer | ||
| | %enum ( Num , Num ) | ||
| | %float | ||
| | %double | ||
| | %extended | ||
| | %ptr BOLHeapType | ||
| | %seq BOLHeapType | ||
BOLHeapType | |||
::= | %object | ||
| | %closure | ||
| | %struct Num ( BOLFieldType (, BOLFieldType)* ) | ||
BOLFieldType | |||
::= | Num : BOLType ([ Num ])opt |
ValueDecl | |||
::= | %val ValId : TyScheme (= PrimValue)opt | ||
| | %val ValId : TyScheme = ValSpec | ||
PrimValue | |||
::= | %prim PrimOp | ||
| | %prim BOLFunction | ||
ValSpec | |||
::= | Pathopt ValId |
%val add : (Int, Int) -> Int = %prim I32Add %val div : (Int, Int) -> Int = %prim I32Divare expanded into the following:
%val add : (Int, Int) -> Int = %prim add (a : %int32, b : %int32, ex) { %let c : %int32 = I32Add(a, b) %return (c) } %val div : (Int, Int) -> Int = %prim div (a : %int32, b : %int32, ex) { %let c : %int32 = I32Div(a, b, ex) %return (c) }Note that in the case of the add function, the exception handler continuation is ignored, whereas it is passed as an argument to the I32Div operator in the case of the div function. This specialization is supported by comparing the arity of the Moby type on the lhs with the arity and signature of the operator on the rhs.
BOLFunction | |||
::= | Var Params BOLBlock | ||
BOLBlock | |||
::= | { BOLStmt } | ||
BOLExpr | |||
::= | BOLBlock | ||
| | TailExpr | ||
BOLStmt | |||
::= | TailExpr | ||
| | %let Binding BOLStmt | ||
| | %fun BOLFunction (%and BOLFunction)* BOLStmt | ||
| | %cont BOLFunction BOLStmt | ||
| | %stack Var ( Int , Int ) : BOLType BOLStmt | ||
TailExpr | |||
::= | %if Var %then BOLExpr %else BOLExpr | ||
| | %switch Var Case+ (%default : BOLExpr)opt | ||
| | %call Var ( Var (, Var)* ) | ||
| | %ccall CFun Convention ( Var (, Var)* ) | ||
| | %throw Var ( Var (, Var)* ) | ||
| | %return Terms | ||
Case | |||
::= | %case Num : BOLExpr | ||
Binding | |||
::= | Params = BOLExpr | ||
| | Param = # Num Var | ||
| | Param = %alloc ( BOLField (, BOLField)* ) | ||
| | Param = BOLTerm | ||
| | Param = %meth Var . Label | ||
| | Param = %field Var . Label | ||
| | Param = %meth Var | ||
| | Param = %field Var | ||
| | Param = %meth Var @ Var | ||
| | Param = %field Var @ Var | ||
| | _ = %field Var @ Var := Var | ||
BOLTerm | |||
::= | PrimOp BOLTerms | ||
| | Var | ||
| | Constant | ||
BOLTerms | |||
::= | ( (BOLTerm (, BOLTerm)*)opt ) | ||
BOLField | |||
::= | Num : Var | ||
Params | |||
::= | _ | ||
| | ParamList | ||
ParamList | |||
::= | Param | ||
| | ( Param (, Param)* ) | ||
Param | |||
::= | Var (: BOLType)opt |