Grammar:
POSTFIXEXPR:: = infixexpr [ID [NL]]
INFIXEXPR:: = prefixexpr
| INFIXEXPR ID [NL] inf2424ixexpr
PREFIXEXPR:: = [?-? |? +? |?!? |? ~?] simpleexpr
An expression consists of an operator and an operand.
6.12.1. Prefix operations
The prefix Operation op E is represented by the prefix operator op (must be? +?,?-?,?!? or? one). The expression op e is equivalent to the suffix method applied to the E.UNARY_OP.
Prefix operators are different from normal function applications, and their operand expressions are not necessarily atomic. For example, the input sequence-sin (x) reads as-(sin (x)), and the function applied negate sin (x) will be parsed to apply the infix sin to the operand negate and (x).
6.12.2. Suffix operations
The suffix operator can be any identifier. The suffix Operation e op is interpreted as E.op.
6.12.3. infix operation
The infix operator can be any identifier. The precedence and correlation of infix operators are defined as follows:
The precedence of the infix operator is determined by the first character of the operator. Characters are listed below in ascending order of precedence, and the characters in the same row have the same precedence.
(All letters)
|
^
&
< >
= !
:
+ -
* / %
(All other special characters)
That is, the operator with the beginning of the letter has the lowest priority, and then the? |? The beginning of the operator, the same below.
One exception to this rule is the assignment operator (§6.12.4). The value of the assignment operator is the same as the simple assignment (=). That is, the priority is lower than any other operator.
The correlation of operators is determined by the last character of the operator. The operator at the end of the "??" is right-related. All other operators are left-related.
The precedence and relevance of the operators determine how the expression part nodes are set:
If there are multiple infix operations in the expression, then the operator with the high priority will be tighter than the lower priority binding.
If there is a coherent infix operation E0 OP1 E1 OP2...OPN en, and the operator OP1,..., OPN has the same priority, then all these operators will have the same relevance. If all operators are left-related, the sequence resolves to the (... (E0 OP1 E1) op2 ...) Opn en. Otherwise, if all operators are right-related, the sequence resolves to e0 op1 (E1 op2 (... opn en) ...)
Postfix operators always have a lower precedence than infix operators. For example E1 OP1 E2 OP2 is always equivalent to (E1 OP1 E2) op2.
The right operand of the left correlation operator can consist of several parameters in parentheses, such as e op (E1,..., en). The expression will be parsed to E.op (E1,..., en).
The left correlation bit Operation e1 op E2 resolves to e1.op (E2). If the OP is right-related, the same operation will be parsed to {Val x=e1; E2.op (x)}, where x is a new name.
6.12.4. Assignment operators
An assignment operator is an operator tick (the Syntax class op in (§1.1)) that ends with an equal sign "=", except for operators with the following conditions:
(1) The operator is also started by an equal sign, or
(2) The operator is a (<=), (>=), (! =)
The assignment operator does special processing, and if there is no other valid explanation, the extension is assigned to the value.
We consider an assignment operator, such as + =. In the infix operation L + = R, L and R are expressions. This operation can be re-interpreted as an operation that is responsible for assigning values
L = L + R
Unless the calculation of the operation's L is calculated only once
Re-parsing occurs under the following two conditions.
1. L on the left does not have a member named + = and cannot be converted by an implicit conversion (§6.25) to a value that has the member + =.
2. The assignment operation L = L + R is of the correct type. In particular, it implies that L refers to a variable or object, and that the variable or object can be assigned a value and can be transformed into a value with a member named +.
Scala prefixes, infix and suffix operations