KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ast > Unary


1 package polyglot.ast;
2
3 import polyglot.util.Enum;
4
5 /**
6  * A <code>Unary</code> represents a Java unary expression, an
7  * immutable pair of an expression and an an operator.
8  */

9 public interface Unary extends Expr
10 {
11     /** Unary expression operator. */
12     public static class Operator extends Enum JavaDoc {
13     boolean prefix;
14         String JavaDoc name;
15
16         public Operator(String JavaDoc name, boolean prefix) {
17         super(name + (prefix ? "" : "post"));
18             this.name = name;
19         this.prefix = prefix;
20     }
21
22         /** Returns true of the operator is a prefix operator, false if
23          * postfix. */

24     public boolean isPrefix() { return prefix; }
25
26         public String JavaDoc toString() { return name; }
27     }
28
29     public static final Operator BIT_NOT = new Operator("~", true);
30     public static final Operator NEG = new Operator("-", true);
31     public static final Operator POST_INC = new Operator("++", false);
32     public static final Operator POST_DEC = new Operator("--", false);
33     public static final Operator PRE_INC = new Operator("++", true);
34     public static final Operator PRE_DEC = new Operator("--", true);
35     public static final Operator POS = new Operator("+", true);
36     public static final Operator NOT = new Operator("!", true);
37
38     /** The sub-expression on that to apply the operator. */
39     Expr expr();
40     /** Set the sub-expression on that to apply the operator. */
41     Unary expr(Expr e);
42
43     /** The operator to apply on the sub-expression. */
44     Operator operator();
45     /** Set the operator to apply on the sub-expression. */
46     Unary operator(Operator o);
47 }
48
Popular Tags