LambdaGrammar
Grammar that parses a lambda expression.
A lambda has the form param1 param2?: body content, where the header (param1 param2?:) defines parameters and the body is everything after the delimiter.
Parameters are word-character identifiers, optionally suffixed with ? to mark them as optional. The delimiter is a colon (:).
If the header cannot be parsed (i.e. no valid parameter-delimiter sequence is found), the entire input is treated as a body with no parameters.
The grammar is context-aware: while parsing the header, normal tokens (parameter names, whitespace, etc.) are matched individually. Once the delimiter is matched, a stateful body token activates and captures the entire remaining input in one shot.