From 7477ec8d70754b4ea0ade78719acee9184da547d Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 20 May 2026 15:47:34 +0200 Subject: [PATCH] fix: change syntax definition to W3C EBNF --- syntax/midas.ebnf | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/syntax/midas.ebnf b/syntax/midas.ebnf index 71b4740..f8c6dbe 100644 --- a/syntax/midas.ebnf +++ b/syntax/midas.ebnf @@ -1,26 +1,27 @@ -identifier ::= '[a-zA-Z][a-zA-Z_]*' +// W3C EBNF syntax definition for Midas +Identifier ::= [a-zA-Z] [a-zA-Z_]* -integer ::= '\d+' -number ::= integer ["." integer] -boolean ::= "False" | "True" -none ::= "None" +Integer ::= '\d+' +Number ::= Integer ("." Integer)? +Boolean ::= "False" | "True" +None ::= "None" -value ::= number | boolean | none -lambda-value ::= "_" | value -lambda-operator ::= ">" | "<" | ">=" | "<=" | "==" | "!=" -lambda ::= lambda-value lambda-operator lambda-value +Value ::= Number | Boolean | None +LambdaValue ::= "_" | Value +LambdaOperator ::= ">" | "<" | ">=" | "<=" | "==" | "!=" +Lambda ::= LambdaValue LambdaOperator LambdaValue -constraint ::= identifier | "(" lambda ")" -base-type ::= identifier -type ::= base-type { "+" constraint } +Constraint ::= Identifier | "(" Lambda ")" +BaseType ::= Identifier +Type ::= BaseType ("+" Constraint)* -type-property ::= 'identifier' ":" 'type' -type-body ::= "{" { 'type-property' } "}" +TypeProperty ::= Identifier ":" Type +TypeBody ::= "{" TypeProperty* "}" -operation-type ::= "<" 'type' ">" +OperationType ::= "<" Type ">" -type-statement ::= "type" 'identifier' "<" 'type' {"," 'type'} ">" ['type-body'] -operation-statement ::= "op" 'operation-type' 'operator' 'operation-type' "=" 'operation-type' -constraint-statement ::= "constraint" 'identifier' "=" 'lambda' +TypeStatement ::= "type" Identifier "<" Type ("," Type)* ">" TypeBody? +OperationStatement ::= "op" OperationType [^\s]+ OperationType "=" OperationType +ConstraintStatement ::= "constraint" Identifier "=" Lambda -statement ::= type-statement | operation-statement | constraint-statement \ No newline at end of file +Statement ::= TypeStatement | OperationStatement | ConstraintStatement \ No newline at end of file