Lavender Context-Free Grammar

Lavender's grammar is incredibly context-sensitive due to the ability to define arbitrary prefix and infix operators. However, the context-free grammar is presented here. Tokens may be separated by any amount of whitespace and comments. Note that Lavender's context-free grammar is inherently ambiguous in a way that cannot be resolved without global context. Because of this, the CLavender implementation does not actually use this grammar in any parsing step; it uses context-sensitive parsing instead.

Module: <ModuleElement> [\n <Module>]
ModuleElement: <Command> | <FunctionDef>

Command: @ <Name> [Rest of Line]
FunctionDef: ( <Function> ) | <Function>

Function: def [FuncName] ( [Params] ) [let <Locals>] <Funcbody>
FuncName: <Identifier> | {uir}_<Symbol>
Params: [=>] [...] <Name> | [=>] <Name> [, <Params>]
Locals: <Name> ( <Expression> ) [, <Locals>]
Funcbody: => <Expression> | <Piecewise> [Piecewise...]
Piecewise: => <ExpressionNoFunc> ; <ExpressionNoFunc>

Expression: <ExpressionNoFunc> | <Function> 
ExpressionNoFunc: <Operand> [<Operator> [Expression]]
Operand: ( <Expression> ) | <ValueCall> | <FunctionCall> | <Vect> | <QualIdentifier> | <Primary>
Operator: <QualIdentifier> [QualIdentifier...]

ValueCall: [ <Expression> ] <ArgList>
FunctionCall: <QualIdentifier> <ArgList>
Vect: { [ArgListElements] }
ArgList: () | <Operand> | ( <ArgListElements> )
ArgListElements: <Expression> [, <ArgListElements>]

QualIdentifier: [<Name> : ] <Identifier>
Identifier: <Name> | <Symbol>

Name: <Letter> [LetterOrDigit...]
LetterOrDigit: <Letter> | <Digit>
Letter: ONE OF A-Z a-z _
Digit: ONE OF 0-9
Symbol: <SymbolPart> [SymbolPart...]
SymbolPart: ONE OF ~ ? * / % : + - & | ^ = ! < >

Primary: <Number> | <String> | <FuncValue>
Number: IEEE FLoating-Point Literal
String: " [Not " or newline, escape \", \', \n, \t, \\] "
FuncValue: \ <QualIdentifier> [\]