Checklist for defining new operators
Checklist for adding or modifying operators in the java compiler:
- If the operator has a new lexical representation (i.e. you are not redefining the behaviour of an already existing operator), add a new token in com.sun.tools.javac.parser.Token
- Make sure that all characters that make up the operator are identified as such in the isSpecial() method of the com.sun.tools.javac.parser.Scanner class.
- If the operator is a new operator, add a corresponding tag to the com.sun.tools.javac.tree.JCTree class.
- Map the operator to its tag in the optag()/unoptag() method of the Parser class.
- Map the operator to one of the existing precedence level (or introduce your own) in the opPrec() method of the com.sun.tools.javac.tree.TreeInfo class.
- Add the name of the operator to the table of operators that is filled in the constructor of the TreeInfo class.
- Add the name of the operator to the operatorName() method of the com.sun.tools.javac.tree.Pretty class.
- Implement the operator either in the desugaring step (com.sun.tools.javac.comp.Lower class) or in the code-generation step (com.sun.tools.javac.jvm.Gen class)
Comments