diff --git a/docs/grammar.ebnf b/docs/grammar.ebnf index 34feacc..1b881c6 100644 --- a/docs/grammar.ebnf +++ b/docs/grammar.ebnf @@ -11,16 +11,29 @@ /* A program is a sequence of top-level declarations and statements. */ = - ( - | - | - | - | - | )* + * + = + "export" + | + + = + + | + | + | + +non_exportable_declaration = + + | + | + | + | + | + = - "export"? "module" "{" + "module" "{" ( | | @@ -42,7 +55,7 @@ /* Rules for defining functions, structs, enums, and their components. */ = - "export"? "fn" ? "(" ? ")" ( "->" )? + "fn" ? "(" ? ")" ( "->" )? = "this" ("," ( "," )* )? @@ -52,7 +65,7 @@ ":" = - "export"? "struct" ? "{" "}" + "struct" ? "{" "}" = ( "," )* @@ -61,7 +74,7 @@ ":" = - "export"? "enum" ? "{" "}" + "enum" ? "{" "}" = ( "," )* @@ -88,20 +101,23 @@ = ";" | - | | ";" | ";" | ";" | ";" | ";" - | ";" | | | + | + | ";" = - ( ":" )? "=" - | ":" ( "=" )? + + + = + ":" ( "=" )? + | "=" = "let" @@ -112,8 +128,11 @@ ? = - "else" ? - | "else" + "else" + + = + + | ? = "|" "|" @@ -152,7 +171,7 @@ "switch" "(" ")" "{" * ? "}" = - ( | ) ( "(" ")" )? "->" + ( "(" ")" )? "->" = "->" @@ -204,45 +223,41 @@ ( )* = - * + * - = - ( | )* + = + ( | )* /* --- Primary Expressions & Literals --- */ /* The highest-precedence expressions, including literals and grouped expressions. */ - = + = - | - | - | - | - | + | + | ( "{" "}" )? + + = + ( "<" ">" )? + + = + | | | | - | = "(" ")" - = - "::" - - = - ( | ) ".@" ? - = "(" ")" = ( ",")* ? - = - "{" ( | )? ","? "}" + = + ( | )? ","? = ( "," )* @@ -278,15 +293,23 @@ = "!" | "-" | "~" | "&" | "*" = - "[" ? ":" ? "]" - | "[" "]" + "[" | "." + | "::" ( "<" ">" )? | "->" | ".@" ? | ".[" "]" | ".#" | ".*" + = + + | ":" ? "]" + + = + "]" + | ":" ? "]" + /* --- Type System --- */ /* Rules for defining types, type names, and type qualifiers. */ @@ -307,11 +330,10 @@ | "?" ? = - ( "<" ">" )? + ( "::" ( "<" ">" )? )* = - - | "::" + ( "::" identifier )* = ( "," )*