Remove duplication of precedence in `mathics/core/parser/operators.py`
Mathics scannner is now getting close to complete in recording operator precedence. If information is lacking, it should be added to mathics-scanner. For example, we may need to add information about prefix-ops, postfix ops, left binary ops, etc.
This should be used instead of mathics/core/parser/operators.py and that removed or reduced.
Note that one gentle way to do this is to first start out with mathics-scanner, and then merge in information that is currently in this file. And this is also a way to tell whether things are fully done: if the set difference of what is in operators.py minus the scanner tables is not empty, we need to add more.
@rocky in mathics/core/parser/operators.py there's information about the type of the operator (e.g.: prefix, postfix, binary). How that information would be added to the YAML?
I can think of four possibilities:.
- add a new field for the operator kind, e.g
operand-kind: prefix - or change the single precedence field name into one of 3 or 4, e.g
prefix-operator: 160,postfix-operator: 160 - change the precedence value to include the additional
precedence: [160, "prefix"] - expanding the above: change "precedence" to "operator" and include the name in the list:
operator: ["Alternative, "binary", 160]
Of these the last one seems to lead to the least possibility of inconsistency. The first case allows for the possibility that an operator-kind could be specified while precedence isn't. And the second case allows for two mutually exclusive precedence names. The third case I suppose would have to be checked datatype: a tuple of two items with the first a number and the second a string of one of some categories.
In all of these possibilities, there could be default values to make it easier to convert the existing data.
There aren't many operators so it could be done all at once.
I like the 2nd possibility. We have, e.g. Increment and PreIncrement with the same symbol.
There aren't many operators so it could be done all at once.
I like the 2nd possibility. We have, e.g.
IncrementandPreIncrementwith the same symbol.
Ok - implementor's choice!