1 16 package com.google.gwt.dev.js.ast; 17 18 21 public abstract class JsOperator { 22 23 protected static final int LEFT = 0x01; 24 protected static final int INFIX = 0x02; 25 protected static final int POSTFIX = 0x04; 26 protected static final int PREFIX = 0x08; 27 28 private final int mask; 29 30 private final int precedence; 31 32 private final String symbol; 33 34 protected JsOperator(String symbol, int precedence, int mask) { 35 this.symbol = symbol; 36 this.precedence = precedence; 37 this.mask = mask; 38 } 39 40 public int getPrecedence() { 41 return precedence; 42 } 43 44 public String getSymbol() { 45 return symbol; 46 } 47 48 public abstract boolean isKeyword(); 49 50 public boolean isLeftAssociative() { 51 return (mask & LEFT) != 0; 52 } 53 54 public boolean isPrecedenceLessThan(JsOperator other) { 55 return precedence < other.precedence; 56 } 57 58 public boolean isValidInfix() { 59 return (mask & INFIX) != 0; 60 } 61 62 public boolean isValidPostfix() { 63 return (mask & POSTFIX) != 0; 64 } 65 66 public boolean isValidPrefix() { 67 return (mask & PREFIX) != 0; 68 } 69 70 public String toString() { 71 return symbol; 72 } 73 } 74 | Popular Tags |