KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ast > Expr


1 package polyglot.ast;
2
3 import polyglot.types.Type;
4 import polyglot.util.CodeWriter;
5 import polyglot.visit.PrettyPrinter;
6
7 /**
8  * An <code>Expr</code> represents any Java expression. All expressions
9  * must be subtypes of Expr.
10  */

11 public interface Expr extends Receiver, Term
12 {
13     /**
14      * Return an equivalent expression, but with the type <code>type</code>.
15      */

16     Expr type(Type type);
17
18     /** Get the precedence of the expression. */
19     Precedence precedence();
20
21     /**
22      * Return whether the expression evaluates to a constant.
23      * This is not valid until after disambiguation.
24      */

25     boolean isConstant();
26
27     /** Returns the constant value of the expression, if any. */
28     Object JavaDoc constantValue();
29     
30     /**
31      * Correctly parenthesize the subexpression <code>expr<code>
32      * based on its precedence and the precedence of this expression.
33      *
34      * If the sub-expression has the same precedence as this expression
35      * we parenthesize if the sub-expression does not associate; e.g.,
36      * we parenthesis the right sub-expression of a left-associative
37      * operator.
38      */

39      void printSubExpr(Expr expr, boolean associative,
40                        CodeWriter w, PrettyPrinter pp);
41
42     /**
43      * Correctly parenthesize the subexpression <code>expr<code>
44      * based on its precedence and the precedence of this expression.
45      *
46      * This is equivalent to <code>printSubexpr(expr, true, w, pp)</code>
47      */

48     void printSubExpr(Expr expr, CodeWriter w, PrettyPrinter pp);
49 }
50
Popular Tags