35 lines
1.2 KiB
EBNF
35 lines
1.2 KiB
EBNF
// W3C EBNF syntax definition for Midas
|
|
Identifier ::= [a-zA-Z] [a-zA-Z_]*
|
|
OpIdentifier ::= Identifier | "__" Identifier "__"
|
|
|
|
Integer ::= '\d+'
|
|
Number ::= "-"? Integer ("." Integer)?
|
|
Boolean ::= "False" | "True"
|
|
None ::= "None"
|
|
|
|
Variable ::= Identifier ("." Identifier)*
|
|
Value ::= Number | Boolean | None
|
|
LambdaValue ::= "_" | Value | Variable
|
|
LambdaOperator ::= ">" | "<" | ">=" | "<=" | "==" | "!="
|
|
Lambda ::= LambdaValue (LambdaOperator LambdaValue)+
|
|
|
|
SimpleType ::= Identifier "?"?
|
|
Template ::= "[" SimpleType "]"
|
|
Type ::= Identifier Template? "?"?
|
|
Constraint ::= Identifier | Lambda
|
|
|
|
SimpleTypeBase ::= "(" Type ")"
|
|
WrappedConstraint ::= Constraint | "(" Constraint ")"
|
|
Constraints ::= WrappedConstraint ("&" WrappedConstraint)*
|
|
|
|
TypeProperty ::= Identifier ":" Type ("where" Constraints)?
|
|
ComplexTypeBody ::= "{" TypeProperty* "}"
|
|
OpDefinition ::= "op" OpIdentifier "(" Type ")" "->" Type
|
|
ExtendBody ::= "{" OpDefinition* "}"
|
|
|
|
TypeStatement ::= "type" Identifier Template? (SimpleTypeBase ("where" Constraints)? | ComplexTypeBody)
|
|
ExtendStatement ::= "extend" Type ExtendBody
|
|
PredicateStatement ::= "predicate" Identifier "(" Identifier ":" Type ")" "=" Constraints
|
|
|
|
Statement ::= TypeStatement | ExtendStatement | PredicateStatement
|