public class PyExpr extends TargetExpr
Important: This class may only be used in implementing plugins (e.g. functions, directives).
Since the type information is rather generic it could potentially be shared with the JsExpr, but as JS doesn't currently have any uses, and Python types do differ in some aspects (such as with numbers), it's kept separate.
NOTE: Some expressions could potentially return multiple types (such as a ternary if with a String or number as potential results). If possible to avoid, the results will be improved, but if not, this class can be used with no type assumed.
| Constructor and Description |
|---|
PyExpr(String text,
int precedence)
Create a new Python expression with the given text and precedence.
|
| Modifier and Type | Method and Description |
|---|---|
PyStringExpr |
toPyString()
Convert the given type to a Python String expression.
|
equals, getPrecedence, getText, hashCode, toStringpublic PyExpr(String text, int precedence)
The precedence should be carefully considered for complex expressions. The precedence should represent the top most operator, or if there are multiple at the same level, the operator with the lowest value.
For example in the expression x + y * z, x + y has the lower precedence
(will evaluate last), and is most likely to be trumped if combined into a more complex
expression. So the precedence of the entire expression should be the + operators
precedence.
An expression with a precedence which can't be trumped (such variable access or a function call) should use Integer.MAX_VALUE to avoid unnecessary parenthesis.
text - The Python expression text.precedence - The precedence of the top-most operator or Integer.MAX_VALUE.public PyStringExpr toPyString()