feat: update EBNF with revised syntax

This commit is contained in:
2026-05-21 07:53:40 +02:00
parent 7477ec8d70
commit db8fe5d3ff

View File

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