FYI, since I really need it, based on a couple of feedbacks I tried to push it a tad further, sharing it here in case it can be helpful to others!
Looking forward to the offical one!
# Enea's Very Unofficial EBNF Grammar for Verse - v33
# Basic Symbols
letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" |
"a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
# Identifiers
identifier = letter , { letter | digit | "_" } ;
# Types
type = "int" | "float" | "string" | "bool" | "void" | "array" "[" type "]" | "map" "[" type "," type "]" | "option" "{" type "}" | identifier ;
# Literals
integer_literal = digit , { digit } ;
float_literal = digit , { digit } , "." , digit , { digit } ;
string_literal = '"' , { character } , '"' ;
boolean_literal = "true" | "false" ;
# Expressions
expression = or_expression ;
or_expression = and_expression , { "or" , and_expression } ;
and_expression = equality_expression , { "and" , equality_expression } ;
equality_expression = relational_expression , { ( "=" | "<>" ) , relational_expression } ;
relational_expression = additive_expression , { ( "<" | ">" | "<=" | ">=" ) , additive_expression } ;
additive_expression = multiplicative_expression , { ( "+" | "-" ) , multiplicative_expression } ;
multiplicative_expression = unary_expression , { ( "*" | "/" | "%" ) , unary_expression } ;
unary_expression = [ ( "-" | "not" ) ] , primary_expression ;
primary_expression = identifier | integer_literal | float_literal | string_literal | boolean_literal | "(" , expression , ")" ;
# Statements
statement = block | assignment | if_statement | while_statement | for_statement | return_statement | expression_statement ;
block = "{" , { statement } , "}" ;
assignment = identifier , ":=" , expression , ";" ;
if_statement = "if" , "(" , expression , ")" , statement , [ "else" , statement ] ;
while_statement = "while" , "(" , expression , ")" , statement ;
for_statement = "for" , "(" , [ assignment ] , [ expression ] , ";" , [ assignment ] , ")" , statement ;
return_statement = "return" , [ expression ] , ";" ;
expression_statement = expression , ";" ;
# Declarations
declaration = class_declaration | function_declaration | variable_declaration ;
class_declaration = "class" , identifier , [ "(" , identifier , ")" ] , "{" , { class_member } , "}" ;
class_member = variable_declaration | function_declaration ;
function_declaration = identifier , "(" , [ parameter_list ] , ")" , [ "<" , "suspends" , ">" ] , ":" , type , "=" , block ;
parameter_list = parameter , { "," , parameter } ;
parameter = identifier , ":" , type ;
variable_declaration = "var" , identifier , ":" , type , [ ":=" , expression ] , ";" ;
# Programs
program = { declaration } ;
# Top-level rule
verse_program = { import_statement } , program ;
import_statement = "using" , "{" , string_literal , "}" , ";" ;