CQL2: Change function argument list to optional group
See issue #997
@dannbuckley I think that the original use of '{}' was correct. My understanding is that in BNF '{}' indicate that the enclosed expression can be repeated zero or more times. Isn't that want we want for a function? ... since a function can have zero or more arguments?
Hi @pvretano
I agree that the function rule should allow for zero or more arguments.
In my experience, and from what I've gleaned from the current CQL2 semantics, {braces} usually mean one or more whereas [square brackets] indicate an optional group (zero or one occurrences). To express the "zero or more" case, current CQL2 rules use both types of brackets in conjunction. Here are a few examples:
Boolean expression, with zero or more boolean terms
booleanExpression = booleanTerm [ { "OR" booleanTerm } ];
List predicate, with zero or more additional list items
isInListPredicate = scalarExpression ["NOT"] "IN" "(" inList ")";
inList = scalarExpression [ { "," scalarExpression } ];
Character literal with zero or more characters
characterLiteral = "'" [ {character} ] "'";
If we interpret {braces} to mean one or more, that means (a) that current functions require at least one argument, and (b) that functions can have multiple argument lists delimited by whitespace. If the function rule is updated to instead use [square brackets], then the first argument becomes optional and the function is limited to only having one argument list.
The expanded function rule would look something like this:
function = identifier "(" [ argument [ { "," argument } ] ] ")";