Open ChristianGruen opened 3 months ago
Some of the redundancy is probably historical cruft, or plain oversight of the refactoring opportunities.
Some may be to provide a handle for grammar productions that can be used in the prose when describing the semantics, for example the rule SwitchCaseOperand ::= Expr
allows the prose to speak of the SwitchCaseOperand
.
Some may be due to quirks of the technology that was used in the past to generate the executable code of the Java applets that were once published on the W3C website.
One thing to bear in mind is that the names of grammar rules may appear elsewhere than in the specs. They can find their way into books and tutorials, and into product error messages. Renaming ExprSingle
to SingleExpr
may therefore have wider implications than you first imagine.
Thanks for the recent PR, which has addressed some of the suggestions from the initial comment. I am reopening this issue as some simplifications have not been considered yet:
"$" VarName
is used multiple times in the grammar. Would it make sense to introduce Var := "$" EQName
to reduce redundancy, as proposed above?
In addition, we have production rules like GroupingVariable ::= "$" VarName
, but GroupingVariable
is used nowhere in the text. We could simply use Var
instead.
I have done some further refactoring of productions relating to variable names under PR #1498
I’m a humble user of our grammar rules, and I’m definitely not an expert when it comes to their definition (my main obstacle is that changes to the XQuery grammar rules need to be compatible with the XPath and possibly XSLT grammars).
What made it difficult for me to read them in the past were the numerous redundancies (with some of them attached). Is this just “history”, or are there particular reasons for preserving or even enforcing redundance? I noticed that, sometimes, symbol names are used in the prose, but I failed to detect any reasonable pattern.
Do we believe it would be helpful to clean up the grammar rules, or does it rather feel out of scope?
…and so on.
PS: If we tweak the grammar, I would propose to rename
ExprSingle
toSingleExpr
.