Files
midas/syntax/midas.ebnf

27 lines
835 B
EBNF

// W3C EBNF syntax definition for Midas
Identifier ::= [a-zA-Z] [a-zA-Z_]*
Integer ::= '\d+'
Number ::= Integer ("." Integer)?
Boolean ::= "False" | "True"
None ::= "None"
Value ::= Number | Boolean | None
LambdaValue ::= "_" | Value
LambdaOperator ::= ">" | "<" | ">=" | "<=" | "==" | "!="
Lambda ::= LambdaValue LambdaOperator LambdaValue
Constraint ::= Identifier | "(" Lambda ")"
BaseType ::= Identifier
Type ::= BaseType ("+" Constraint)*
TypeProperty ::= Identifier ":" Type
TypeBody ::= "{" TypeProperty* "}"
OperationType ::= "<" Type ">"
TypeStatement ::= "type" Identifier "<" Type ("," Type)* ">" TypeBody?
OperationStatement ::= "op" OperationType [^\s]+ OperationType "=" OperationType
ConstraintStatement ::= "constraint" Identifier "=" Lambda
Statement ::= TypeStatement | OperationStatement | ConstraintStatement