/* Prototype Grammar for Nutmeg - developed with the help of https://bottlecaps.de/rr/ui */ Statements ::= Statement ( ';' Statement )* ';'? Statement ::= Expression | Binding Binding ::= Pattern ':=' Expression | Annotation* ('def'|'function'|'finesse') DefinitionalFunctionCall ('=>>'|':') Statements ('enddef'|'end') Annotation ::= '@' ('command'|'unittest') DefinitionalFunctionCall ::= Identifier '(' Pattern ')' | Pattern '.' Identifier | Pattern '.' Identifier '(' Pattern ')' Pattern ::= LiteralConstant | Modifier? Identifier | '(' Pattern? ')' | Pattern '(' Pattern ')' | Pattern ( ',' Pattern ) Modifer ::= 'var' | 'val' | 'const' Expression ::= LiteralConstant | Identifier | '(' Expression? ')' | Expression InfixOperator Expression | FunctionCall | LetExpression | IfExpression | IfNotExpression | SwitchExpression | LoopExpression | LambdaExpression | AssertExpression FunctionCall ::= Expression '(' Expression ')' | Expression '.' Identifier | Expression '.' Identifier '(' Expression ')' LetExpression ::= 'let' Statements 'in' Statements ('endlet'|'end') IfExpression ::= 'if' Expression ('then'|':') Statements ( ('elseif'|'elseifnot') Expression ('then'|':') Statments )* ('else' ':'? Statements)? ('endif'|'end') IfNotExpression ::= 'ifnot' Expression ('then'|':') Statements ( ('elseif'|'elseifnot') Expression ('then'|':') Statments )* ('else' ':'? Statements)? ('endifnot'|'end') SwitchExpression ::= 'switch' Expression ':'? ( ( 'case' Expression )+ ( 'then' | ':' ) Statements )+ ( 'else' ':'? Expression )? ( 'end' | 'endcase' ) ( 'end' | 'endswitch' ) LoopExpression ::= 'for' Query ('do'|':') Statements ('endfor'|'end') LambdaExpression ::= 'fn' LambdaFunctionCall ('=>>'|':') Statements ('endfn'|'end') LambdaFunctionCall ::= Pattern? | Identifier? '(' Pattern ')' | Pattern '.' Identifier | Pattern '.' Identifier '(' Pattern ')' AssertExpression ::= 'assert' Expression Query ::= Expression | Binding | Pattern 'in' Expression | Query ('while'|'until') Expression ( 'then' Expression )? | Query 'afterwards' Expression | '(' Query ')' | Query ('&&' Query)* | Query ('||' Query)* InfixOperator ::= ',' | '+' | '*' | '-' | '/' | '//' | 'and' | 'or' | '..' | '...' /* This is not quite right */ Identifier ::= [http://www.w3.org/TR/xml-names/#NT-NCName] LiteralConstant ::= Character | String | Number | Boolean | Null