Grammar¶
Todo
jashankj: transition to something like EBNF
Todo
jashankj: use productionlist
Here we use a grammar notation which is similar to that used in the Java language specifications. The meta constructs have the following meaning:
- Brackets, [], make their content optional.
- Braces, {}, make their content repeatable (and optional).
Nonterminals are denoted in italics. Literal code is denoted in typewriter font.
Productions are structured by indenting the right-hand side, every single line is one alternative. There are special forms of productions for selecting among a set of terminals and for specifying the syntax of a nonterminal informally.
- Program:
TopLevelUnit { TopLevelUnit }- TopLevelUnit:
IncludeDefinition- Include:
includeStringLiteralincludeSystemFile- Systemfile: informally,
A file pathname enclosed in<and>.- Definition:
TypeDefinitionValueDefinitionFunctionDefinitionAbstractDefinition- TypeDefinition:
typeTypeConstructor { TypeVariable }=MonoTypeAbstractTypeDefinition- TypeConstructor:
CapitalizedID- TypeVariable:
LowercaseId- AbstractTypeDefinition:
typeTypeConstructor { TypeVariable }- MonoType:
TypeA1FunctionType- FunctionType:
TypeA1->TypeA1- TypeA1:
TypeA2ParameterizedTypePartialRecordType- ParameterizedType:
TypeConstructor { TypeA2 }- PartialRecordType:
TypeA2 TakePut TakePutFields- TakePut:
takeput- TakePutFields:
FieldName([ FieldName {,FieldName } ])( .. )- FieldName:
LowercaseID- TypeA2:
AtomType#AtomTypeAtomType!- AtomType:
(MonoType)TypeConstructorTupleTypeRecordTypeVariantTypeTypeVariable- TupleType:
()(MonoType,MonoType {,MonoType })- RecordType:
{FieldName:MonoType {,FieldName:MonoType }}- VariantType:
<DataConstructor { TypeA2 } {|DataConstructor { TypeA2 } }>- DataConstructor:
CapitalizedID- ValueDefinition:
Signature Variable=Expression- Signature:
Variable:PolyType- PolyType:
MonoTypeallPermSignatures.MonoType- PermSignatures:
PermSignature(PermSignature {,PermSignature })- PermSignature:
TypeVariableTypeVariable:<Permissions- Permissions:
Permission { Permission }- Permission: one of
DSE- FunctionDefinition:
Signature Variable IrrefutablePattern=ExpressionSignature Variable Alternative { Alternative }- AbstractDefinition:
Signature- Pattern:
(Pattern)IrrefutablePatternLiteralPatternVariantPattern- LiteralPattern:
BooleanLiteralIntegerLiteralCharacterLiteral- IrrefutablePattern:
VariableWildcardPatternTuplePatternRecordPattern- WildcardPattern:
_- TuplePattern:
()(IrrefutablePattern,IrrefutablePattern {,IrrefutablePattern })- RecordPattern:
Variable{RecordMatchings}#{RecordMatchings}- RecordMatchings:
RecordMatching {,RecordMatching }- RecordMatching:
FieldName [=IrrefutablePattern ]- VariantPattern:
DataConstructor { IrrefutablePattern }- Expression:
BasicExpressionMatchingExpressionLetExpressionConditionalExpression- BasicExpression:
BasExprBasExpr;Expression- MatchingExpression:
ObservableBasicExpression Alternative { Alternative }- ObservableBasicExpression:
BasicExpressionBasicExpression {!Variable }- Alternative:
|Pattern PArr Expression- PArr: one of
->=>~>- LetExpression:
letBinding {andBinding }inExpression- Binding:
IrrefutablePattern [:MonoType ]=ObservableExpression- ObservableExpression:
ExpressionExpression {!Variable }- ConditionalExpression:
ifObservableExpressionthenExpressionelseExpression- BasExpr:
TermFunctionalApplicationOperatorApplicationPutExpressionMemberAccess- FunctionApplication:
BasExpr BasExpr- OperatorApplication:
UnaryOp BasExprBasExpr BinaryOp BasExpr- UnaryOp: one of
upcastcomplementnot- BinaryOp: one of
o*/%+-><>=<===/=.&..^..|.>><<&&||$- PutExpression:
BasExpr { RecordAssignments }- RecordAssignments:
RecordAssignments {,RecordAssignment }- RecordAssignment:
FieldName [=Expression ]- MemberAccess:
BasExpr.FieldName- Term:
(Expression)VariableLiteralTermTupleTermRecordTermVariantTermLambdaTermPolyVariable- LiteralTerm:
BooleanLiteralIntegerLiteralCharacterLiteralStringLiteral- BooleanLiteral: one of
TrueFalse- IntegerLiteral: one of
DecDigits0xHexDigits0XHexDigits0oOctDigits0OOctDigits- DecDigits: informally,
a sequence of decimal digits 0-9.- HexDigits: informally,
a sequence of hexadecimal digits 0-9, A-F.- OctDigits: informally,
a sequence of octal digits 0-7.- CharacterLiteral: informally,
a character enclosed in single quotes.- StringLiteral: informally,
a sequence of characters enclosed in double quotes.- TupleTerm:
()(Expression,Expression {,Expression })- RecordTerm:
#{RecordAssignments}- VariantTerm:
DataConstructor { Term }- LambdaTerm:
\IrrefutablePattern [:MonoType ]=>Expression- PolyVariable:
Variable[OptMonoType {,OptMonoType }]- OptMonoType:
MonoType_- LowercaseID: informally,
a sequence of letters, digits, underscore symbols, and single quotesstarting with a lowercase letter- CapitalizedID: informally,
a sequence of letters, digits, underscore symbols, and single quotesstarting with an uppercase letter