Java Code Examples for com.google.javascript.rhino.Token#LE

The following examples show how to use com.google.javascript.rhino.Token#LE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cardumen_0087_t.java    From coming with MIT License 6 votes vote down vote up
static boolean isBooleanResultHelper(Node n) {
  switch (n.getType()) {
    // Primitives
    case Token.TRUE:
    case Token.FALSE:
    // Comparisons
    case Token.EQ:
    case Token.NE:
    case Token.SHEQ:
    case Token.SHNE:
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
    // Queries
    case Token.IN:
    case Token.INSTANCEOF:
    // Inversion
    case Token.NOT:
    // delete operator returns a boolean.
    case Token.DELPROP:
      return true;
    default:
      return false;
  }
}
 
Example 2
Source File: jMutRepair_003_s.java    From coming with MIT License 6 votes vote down vote up
static boolean isBooleanResultHelper(Node n) {
  switch (n.getType()) {
    // Primitives
    case Token.TRUE:
    case Token.FALSE:
    // Comparisons
    case Token.EQ:
    case Token.NE:
    case Token.SHEQ:
    case Token.SHNE:
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
    // Queries
    case Token.IN:
    case Token.INSTANCEOF:
    // Inversion
    case Token.NOT:
    // delete operator returns a boolean.
    case Token.DELPROP:
      return true;
    default:
      return false;
  }
}
 
Example 3
Source File: PeepholeFoldConstants.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param value The value to compare to "undefined"
 * @param op The boolean op to compare with
 * @return Whether the boolean op is true or false
 */
private static boolean compareToUndefined(Node value, int op) {
  Preconditions.checkState(NodeUtil.isLiteralValue(value, true));
  boolean valueUndefined = NodeUtil.isUndefined(value);
  boolean valueNull = (Token.NULL == value.getType());
  boolean equivalent = valueUndefined || valueNull;
  switch (op) {
    case Token.EQ:
      // undefined is only equal to null or an undefined value
      return equivalent;
    case Token.NE:
      return !equivalent;
    case Token.SHEQ:
      return valueUndefined;
    case Token.SHNE:
      return !valueUndefined;
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
      return false;
    default:
      throw new IllegalStateException("unexpected.");
  }
}
 
Example 4
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the inverse of an operator if it is invertible.
 * ex. '>' ==> '<'
 */
static int getInverseOperator(int type) {
  switch (type) {
    case Token.GT:
      return Token.LT;
    case Token.LT:
      return Token.GT;
    case Token.GE:
      return Token.LE;
    case Token.LE:
      return Token.GE;
  }
  return Token.ERROR;
}
 
Example 5
Source File: jMutRepair_003_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the inverse of an operator if it is invertible.
 * ex. '>' ==> '<'
 */
static int getInverseOperator(int type) {
  switch (type) {
    case Token.GT:
      return Token.LT;
    case Token.LT:
      return Token.GT;
    case Token.GE:
      return Token.LE;
    case Token.LE:
      return Token.GE;
  }
  return Token.ERROR;
}
 
Example 6
Source File: Cardumen_0014_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns the inverse of an operator if it is invertible.
 * ex. '>' ==> '<'
 */
static int getInverseOperator(int type) {
  switch (type) {
    case Token.GT:
      return Token.LT;
    case Token.LT:
      return Token.GT;
    case Token.GE:
      return Token.LE;
    case Token.LE:
      return Token.GE;
  }
  return Token.ERROR;
}
 
Example 7
Source File: Closure_78_PeepholeFoldConstants_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param value The value to compare to "undefined"
 * @param op The boolean op to compare with
 * @return Whether the boolean op is true or false
 */
private boolean compareToUndefined(Node value, int op) {
  boolean valueUndefined = ((Token.NAME == value.getType()
      && value.getString().equals("undefined"))
      || (Token.VOID == value.getType()
          && NodeUtil.isLiteralValue(value.getFirstChild(), false)));
  boolean valueNull = (Token.NULL == value.getType());
  boolean equivalent = valueUndefined || valueNull;
  switch (op) {
    case Token.EQ:
      // undefined is only equal to null or an undefined value
      return equivalent;
    case Token.NE:
      return !equivalent;
    case Token.SHEQ:
      return valueUndefined;
    case Token.SHNE:
      return !valueUndefined;
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
      return false;
    default:
      throw new IllegalStateException("unexpected.");
  }
}
 
Example 8
Source File: Closure_80_NodeUtil_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * A "simple" operator is one whose children are expressions,
 * has no direct side-effects (unlike '+='), and has no
 * conditional aspects (unlike '||').
 */
static boolean isSimpleOperatorType(int type) {
  switch (type) {
    case Token.ADD:
    case Token.BITAND:
    case Token.BITNOT:
    case Token.BITOR:
    case Token.BITXOR:
    case Token.COMMA:
    case Token.DIV:
    case Token.EQ:
    case Token.GE:
    case Token.GETELEM:
    case Token.GETPROP:
    case Token.GT:
    case Token.INSTANCEOF:
    case Token.LE:
    case Token.LSH:
    case Token.LT:
    case Token.MOD:
    case Token.MUL:
    case Token.NE:
    case Token.NOT:
    case Token.RSH:
    case Token.SHEQ:
    case Token.SHNE:
    case Token.SUB:
    case Token.TYPEOF:
    case Token.VOID:
    case Token.POS:
    case Token.NEG:
    case Token.URSH:
      return true;

    default:
      return false;
  }
}
 
Example 9
Source File: NodeUtil.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A "simple" operator is one whose children are expressions,
 * has no direct side-effects (unlike '+='), and has no
 * conditional aspects (unlike '||').
 */
static boolean isSimpleOperatorType(int type) {
  switch (type) {
    case Token.ADD:
    case Token.BITAND:
    case Token.BITNOT:
    case Token.BITOR:
    case Token.BITXOR:
    case Token.COMMA:
    case Token.DIV:
    case Token.EQ:
    case Token.GE:
    case Token.GETELEM:
    case Token.GETPROP:
    case Token.GT:
    case Token.INSTANCEOF:
    case Token.LE:
    case Token.LSH:
    case Token.LT:
    case Token.MOD:
    case Token.MUL:
    case Token.NE:
    case Token.NOT:
    case Token.RSH:
    case Token.SHEQ:
    case Token.SHNE:
    case Token.SUB:
    case Token.TYPEOF:
    case Token.VOID:
    case Token.POS:
    case Token.NEG:
    case Token.URSH:
      return true;

    default:
      return false;
  }
}
 
Example 10
Source File: Closure_10_NodeUtil_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns true if the operator on this node is relational.
 * the returned set does not include the equalities.
 */
static boolean isRelationalOperation(Node n) {
  switch (n.getType()) {
    case Token.GT: // equal
    case Token.GE: // not equal
    case Token.LT: // exactly equal
    case Token.LE: // exactly not equal
      return true;
  }
  return false;
}
 
Example 11
Source File: Cardumen_0087_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Returns true if the operator on this node is relational.
 * the returned set does not include the equalities.
 */
static boolean isRelationalOperation(Node n) {
  switch (n.getType()) {
    case Token.GT: // equal
    case Token.GE: // not equal
    case Token.LT: // exactly equal
    case Token.LE: // exactly not equal
      return true;
  }
  return false;
}
 
Example 12
Source File: Closure_86_NodeUtil_t.java    From coming with MIT License 4 votes vote down vote up
static int precedence(int type) {
  switch (type) {
    case Token.COMMA:  return 0;
    case Token.ASSIGN_BITOR:
    case Token.ASSIGN_BITXOR:
    case Token.ASSIGN_BITAND:
    case Token.ASSIGN_LSH:
    case Token.ASSIGN_RSH:
    case Token.ASSIGN_URSH:
    case Token.ASSIGN_ADD:
    case Token.ASSIGN_SUB:
    case Token.ASSIGN_MUL:
    case Token.ASSIGN_DIV:
    case Token.ASSIGN_MOD:
    case Token.ASSIGN: return 1;
    case Token.HOOK:   return 2;  // ?: operator
    case Token.OR:     return 3;
    case Token.AND:    return 4;
    case Token.BITOR:  return 5;
    case Token.BITXOR: return 6;
    case Token.BITAND: return 7;
    case Token.EQ:
    case Token.NE:
    case Token.SHEQ:
    case Token.SHNE:   return 8;
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
    case Token.INSTANCEOF:
    case Token.IN:     return 9;
    case Token.LSH:
    case Token.RSH:
    case Token.URSH:   return 10;
    case Token.SUB:
    case Token.ADD:    return 11;
    case Token.MUL:
    case Token.MOD:
    case Token.DIV:    return 12;
    case Token.INC:
    case Token.DEC:
    case Token.NEW:
    case Token.DELPROP:
    case Token.TYPEOF:
    case Token.VOID:
    case Token.NOT:
    case Token.BITNOT:
    case Token.POS:
    case Token.NEG:    return 13;

    case Token.ARRAYLIT:
    case Token.CALL:
    case Token.EMPTY:
    case Token.FALSE:
    case Token.FUNCTION:
    case Token.GETELEM:
    case Token.GETPROP:
    case Token.GET_REF:
    case Token.IF:
    case Token.LP:
    case Token.NAME:
    case Token.NULL:
    case Token.NUMBER:
    case Token.OBJECTLIT:
    case Token.REGEXP:
    case Token.RETURN:
    case Token.STRING:
    case Token.THIS:
    case Token.TRUE:
      return 15;

    default: throw new Error("Unknown precedence for " +
                             Node.tokenToName(type) +
                             " (type " + type + ")");
  }
}
 
Example 13
Source File: Cardumen_00200_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Converts an operator's token value (see {@link Token}) to a string
 * representation.
 *
 * @param operator the operator's token value to convert
 * @return the string representation or {@code null} if the token value is
 * not an operator
 */
static String opToStr(int operator) {
  switch (operator) {
    case Token.BITOR: return "|";
    case Token.OR: return "||";
    case Token.BITXOR: return "^";
    case Token.AND: return "&&";
    case Token.BITAND: return "&";
    case Token.SHEQ: return "===";
    case Token.EQ: return "==";
    case Token.NOT: return "!";
    case Token.NE: return "!=";
    case Token.SHNE: return "!==";
    case Token.LSH: return "<<";
    case Token.IN: return "in";
    case Token.LE: return "<=";
    case Token.LT: return "<";
    case Token.URSH: return ">>>";
    case Token.RSH: return ">>";
    case Token.GE: return ">=";
    case Token.GT: return ">";
    case Token.MUL: return "*";
    case Token.DIV: return "/";
    case Token.MOD: return "%";
    case Token.BITNOT: return "~";
    case Token.ADD: return "+";
    case Token.SUB: return "-";
    case Token.POS: return "+";
    case Token.NEG: return "-";
    case Token.ASSIGN: return "=";
    case Token.ASSIGN_BITOR: return "|=";
    case Token.ASSIGN_BITXOR: return "^=";
    case Token.ASSIGN_BITAND: return "&=";
    case Token.ASSIGN_LSH: return "<<=";
    case Token.ASSIGN_RSH: return ">>=";
    case Token.ASSIGN_URSH: return ">>>=";
    case Token.ASSIGN_ADD: return "+=";
    case Token.ASSIGN_SUB: return "-=";
    case Token.ASSIGN_MUL: return "*=";
    case Token.ASSIGN_DIV: return "/=";
    case Token.ASSIGN_MOD: return "%=";
    case Token.VOID: return "void";
    case Token.TYPEOF: return "typeof";
    case Token.INSTANCEOF: return "instanceof";
    default: return null;
  }
}
 
Example 14
Source File: Closure_80_NodeUtil_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Converts an operator's token value (see {@link Token}) to a string
 * representation.
 *
 * @param operator the operator's token value to convert
 * @return the string representation or {@code null} if the token value is
 * not an operator
 */
static String opToStr(int operator) {
  switch (operator) {
    case Token.BITOR: return "|";
    case Token.OR: return "||";
    case Token.BITXOR: return "^";
    case Token.AND: return "&&";
    case Token.BITAND: return "&";
    case Token.SHEQ: return "===";
    case Token.EQ: return "==";
    case Token.NOT: return "!";
    case Token.NE: return "!=";
    case Token.SHNE: return "!==";
    case Token.LSH: return "<<";
    case Token.IN: return "in";
    case Token.LE: return "<=";
    case Token.LT: return "<";
    case Token.URSH: return ">>>";
    case Token.RSH: return ">>";
    case Token.GE: return ">=";
    case Token.GT: return ">";
    case Token.MUL: return "*";
    case Token.DIV: return "/";
    case Token.MOD: return "%";
    case Token.BITNOT: return "~";
    case Token.ADD: return "+";
    case Token.SUB: return "-";
    case Token.POS: return "+";
    case Token.NEG: return "-";
    case Token.ASSIGN: return "=";
    case Token.ASSIGN_BITOR: return "|=";
    case Token.ASSIGN_BITXOR: return "^=";
    case Token.ASSIGN_BITAND: return "&=";
    case Token.ASSIGN_LSH: return "<<=";
    case Token.ASSIGN_RSH: return ">>=";
    case Token.ASSIGN_URSH: return ">>>=";
    case Token.ASSIGN_ADD: return "+=";
    case Token.ASSIGN_SUB: return "-=";
    case Token.ASSIGN_MUL: return "*=";
    case Token.ASSIGN_DIV: return "/=";
    case Token.ASSIGN_MOD: return "%=";
    case Token.VOID: return "void";
    case Token.TYPEOF: return "typeof";
    case Token.INSTANCEOF: return "instanceof";
    default: return null;
  }
}
 
Example 15
Source File: Cardumen_00200_t.java    From coming with MIT License 4 votes vote down vote up
static int precedence(int type) {
  switch (type) {
    case Token.COMMA:  return 0;
    case Token.ASSIGN_BITOR:
    case Token.ASSIGN_BITXOR:
    case Token.ASSIGN_BITAND:
    case Token.ASSIGN_LSH:
    case Token.ASSIGN_RSH:
    case Token.ASSIGN_URSH:
    case Token.ASSIGN_ADD:
    case Token.ASSIGN_SUB:
    case Token.ASSIGN_MUL:
    case Token.ASSIGN_DIV:
    case Token.ASSIGN_MOD:
    case Token.ASSIGN: return 1;
    case Token.HOOK:   return 2;  // ?: operator
    case Token.OR:     return 3;
    case Token.AND:    return 4;
    case Token.BITOR:  return 5;
    case Token.BITXOR: return 6;
    case Token.BITAND: return 7;
    case Token.EQ:
    case Token.NE:
    case Token.SHEQ:
    case Token.SHNE:   return 8;
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
    case Token.INSTANCEOF:
    case Token.IN:     return 9;
    case Token.LSH:
    case Token.RSH:
    case Token.URSH:   return 10;
    case Token.SUB:
    case Token.ADD:    return 11;
    case Token.MUL:
    case Token.MOD:
    case Token.DIV:    return 12;
    case Token.INC:
    case Token.DEC:
    case Token.NEW:
    case Token.DELPROP:
    case Token.TYPEOF:
    case Token.VOID:
    case Token.NOT:
    case Token.BITNOT:
    case Token.POS:
    case Token.NEG:    return 13;

    case Token.CALL:
    case Token.GETELEM:
    case Token.GETPROP:
    // Data values
    case Token.ARRAYLIT:
    case Token.EMPTY:  // TODO(johnlenz): remove this.
    case Token.FALSE:
    case Token.FUNCTION:
    case Token.NAME:
    case Token.NULL:
    case Token.NUMBER:
    case Token.OBJECTLIT:
    case Token.REGEXP:
    case Token.STRING:
    case Token.STRING_KEY:
    case Token.THIS:
    case Token.TRUE:
      return 15;

    default: throw new Error("Unknown precedence for " +
                             Token.name(type) +
                             " (type " + type + ")");
  }
}
 
Example 16
Source File: jKali_003_t.java    From coming with MIT License 4 votes vote down vote up
/**
 * Converts an operator's token value (see {@link Token}) to a string
 * representation.
 *
 * @param operator the operator's token value to convert
 * @return the string representation or {@code null} if the token value is
 * not an operator
 */
static String opToStr(int operator) {
  switch (operator) {
    case Token.BITOR: return "|";
    case Token.OR: return "||";
    case Token.BITXOR: return "^";
    case Token.AND: return "&&";
    case Token.BITAND: return "&";
    case Token.SHEQ: return "===";
    case Token.EQ: return "==";
    case Token.NOT: return "!";
    case Token.NE: return "!=";
    case Token.SHNE: return "!==";
    case Token.LSH: return "<<";
    case Token.IN: return "in";
    case Token.LE: return "<=";
    case Token.LT: return "<";
    case Token.URSH: return ">>>";
    case Token.RSH: return ">>";
    case Token.GE: return ">=";
    case Token.GT: return ">";
    case Token.MUL: return "*";
    case Token.DIV: return "/";
    case Token.MOD: return "%";
    case Token.BITNOT: return "~";
    case Token.ADD: return "+";
    case Token.SUB: return "-";
    case Token.POS: return "+";
    case Token.NEG: return "-";
    case Token.ASSIGN: return "=";
    case Token.ASSIGN_BITOR: return "|=";
    case Token.ASSIGN_BITXOR: return "^=";
    case Token.ASSIGN_BITAND: return "&=";
    case Token.ASSIGN_LSH: return "<<=";
    case Token.ASSIGN_RSH: return ">>=";
    case Token.ASSIGN_URSH: return ">>>=";
    case Token.ASSIGN_ADD: return "+=";
    case Token.ASSIGN_SUB: return "-=";
    case Token.ASSIGN_MUL: return "*=";
    case Token.ASSIGN_DIV: return "/=";
    case Token.ASSIGN_MOD: return "%=";
    case Token.VOID: return "void";
    case Token.TYPEOF: return "typeof";
    case Token.INSTANCEOF: return "instanceof";
    default: return null;
  }
}
 
Example 17
Source File: Closure_74_PeepholeFoldConstants_t.java    From coming with MIT License 4 votes vote down vote up
private Node tryFoldBinaryOperator(Node subtree) {
  Node left = subtree.getFirstChild();

  if (left == null) {
    return subtree;
  }

  Node right = left.getNext();

  if (right == null) {
    return subtree;
  }

  // If we've reached here, node is truly a binary operator.
  switch(subtree.getType()) {
    case Token.GETPROP:
      return tryFoldGetProp(subtree, left, right);

    case Token.GETELEM:
      return tryFoldGetElem(subtree, left, right);

    case Token.INSTANCEOF:
      return tryFoldInstanceof(subtree, left, right);

    case Token.AND:
    case Token.OR:
      return tryFoldAndOr(subtree, left, right);

    case Token.LSH:
    case Token.RSH:
    case Token.URSH:
      return tryFoldShift(subtree, left, right);

    case Token.ASSIGN:
      return tryFoldAssign(subtree, left, right);

    case Token.ADD:
      return tryFoldAdd(subtree, left, right);

    case Token.SUB:
    case Token.DIV:
    case Token.MOD:
      return tryFoldArithmeticOp(subtree, left, right);

    case Token.MUL:
    case Token.BITAND:
    case Token.BITOR:
    case Token.BITXOR:
      Node result = tryFoldArithmeticOp(subtree, left, right);
      if (result != subtree) {
        return result;
      }
      return tryFoldLeftChildOp(subtree, left, right);

    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
    case Token.EQ:
    case Token.NE:
    case Token.SHEQ:
    case Token.SHNE:
      return tryFoldComparison(subtree, left, right);

    default:
      return subtree;
  }
}
 
Example 18
Source File: Cardumen_00200_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Converts an operator's token value (see {@link Token}) to a string
 * representation.
 *
 * @param operator the operator's token value to convert
 * @return the string representation or {@code null} if the token value is
 * not an operator
 */
static String opToStr(int operator) {
  switch (operator) {
    case Token.BITOR: return "|";
    case Token.OR: return "||";
    case Token.BITXOR: return "^";
    case Token.AND: return "&&";
    case Token.BITAND: return "&";
    case Token.SHEQ: return "===";
    case Token.EQ: return "==";
    case Token.NOT: return "!";
    case Token.NE: return "!=";
    case Token.SHNE: return "!==";
    case Token.LSH: return "<<";
    case Token.IN: return "in";
    case Token.LE: return "<=";
    case Token.LT: return "<";
    case Token.URSH: return ">>>";
    case Token.RSH: return ">>";
    case Token.GE: return ">=";
    case Token.GT: return ">";
    case Token.MUL: return "*";
    case Token.DIV: return "/";
    case Token.MOD: return "%";
    case Token.BITNOT: return "~";
    case Token.ADD: return "+";
    case Token.SUB: return "-";
    case Token.POS: return "+";
    case Token.NEG: return "-";
    case Token.ASSIGN: return "=";
    case Token.ASSIGN_BITOR: return "|=";
    case Token.ASSIGN_BITXOR: return "^=";
    case Token.ASSIGN_BITAND: return "&=";
    case Token.ASSIGN_LSH: return "<<=";
    case Token.ASSIGN_RSH: return ">>=";
    case Token.ASSIGN_URSH: return ">>>=";
    case Token.ASSIGN_ADD: return "+=";
    case Token.ASSIGN_SUB: return "-=";
    case Token.ASSIGN_MUL: return "*=";
    case Token.ASSIGN_DIV: return "/=";
    case Token.ASSIGN_MOD: return "%=";
    case Token.VOID: return "void";
    case Token.TYPEOF: return "typeof";
    case Token.INSTANCEOF: return "instanceof";
    default: return null;
  }
}
 
Example 19
Source File: jMutRepair_003_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * Converts an operator's token value (see {@link Token}) to a string
 * representation.
 *
 * @param operator the operator's token value to convert
 * @return the string representation or {@code null} if the token value is
 * not an operator
 */
static String opToStr(int operator) {
  switch (operator) {
    case Token.BITOR: return "|";
    case Token.OR: return "||";
    case Token.BITXOR: return "^";
    case Token.AND: return "&&";
    case Token.BITAND: return "&";
    case Token.SHEQ: return "===";
    case Token.EQ: return "==";
    case Token.NOT: return "!";
    case Token.NE: return "!=";
    case Token.SHNE: return "!==";
    case Token.LSH: return "<<";
    case Token.IN: return "in";
    case Token.LE: return "<=";
    case Token.LT: return "<";
    case Token.URSH: return ">>>";
    case Token.RSH: return ">>";
    case Token.GE: return ">=";
    case Token.GT: return ">";
    case Token.MUL: return "*";
    case Token.DIV: return "/";
    case Token.MOD: return "%";
    case Token.BITNOT: return "~";
    case Token.ADD: return "+";
    case Token.SUB: return "-";
    case Token.POS: return "+";
    case Token.NEG: return "-";
    case Token.ASSIGN: return "=";
    case Token.ASSIGN_BITOR: return "|=";
    case Token.ASSIGN_BITXOR: return "^=";
    case Token.ASSIGN_BITAND: return "&=";
    case Token.ASSIGN_LSH: return "<<=";
    case Token.ASSIGN_RSH: return ">>=";
    case Token.ASSIGN_URSH: return ">>>=";
    case Token.ASSIGN_ADD: return "+=";
    case Token.ASSIGN_SUB: return "-=";
    case Token.ASSIGN_MUL: return "*=";
    case Token.ASSIGN_DIV: return "/=";
    case Token.ASSIGN_MOD: return "%=";
    case Token.VOID: return "void";
    case Token.TYPEOF: return "typeof";
    case Token.INSTANCEOF: return "instanceof";
    default: return null;
  }
}
 
Example 20
Source File: Closure_60_NodeUtil_s.java    From coming with MIT License 4 votes vote down vote up
static int precedence(int type) {
  switch (type) {
    case Token.COMMA:  return 0;
    case Token.ASSIGN_BITOR:
    case Token.ASSIGN_BITXOR:
    case Token.ASSIGN_BITAND:
    case Token.ASSIGN_LSH:
    case Token.ASSIGN_RSH:
    case Token.ASSIGN_URSH:
    case Token.ASSIGN_ADD:
    case Token.ASSIGN_SUB:
    case Token.ASSIGN_MUL:
    case Token.ASSIGN_DIV:
    case Token.ASSIGN_MOD:
    case Token.ASSIGN: return 1;
    case Token.HOOK:   return 2;  // ?: operator
    case Token.OR:     return 3;
    case Token.AND:    return 4;
    case Token.BITOR:  return 5;
    case Token.BITXOR: return 6;
    case Token.BITAND: return 7;
    case Token.EQ:
    case Token.NE:
    case Token.SHEQ:
    case Token.SHNE:   return 8;
    case Token.LT:
    case Token.GT:
    case Token.LE:
    case Token.GE:
    case Token.INSTANCEOF:
    case Token.IN:     return 9;
    case Token.LSH:
    case Token.RSH:
    case Token.URSH:   return 10;
    case Token.SUB:
    case Token.ADD:    return 11;
    case Token.MUL:
    case Token.MOD:
    case Token.DIV:    return 12;
    case Token.INC:
    case Token.DEC:
    case Token.NEW:
    case Token.DELPROP:
    case Token.TYPEOF:
    case Token.VOID:
    case Token.NOT:
    case Token.BITNOT:
    case Token.POS:
    case Token.NEG:    return 13;

    case Token.CALL:
    case Token.GETELEM:
    case Token.GETPROP:
    // Data values
    case Token.ARRAYLIT:
    case Token.EMPTY:  // TODO(johnlenz): remove this.
    case Token.FALSE:
    case Token.FUNCTION:
    case Token.NAME:
    case Token.NULL:
    case Token.NUMBER:
    case Token.OBJECTLIT:
    case Token.REGEXP:
    case Token.STRING:
    case Token.THIS:
    case Token.TRUE:
      return 15;

    default: throw new Error("Unknown precedence for " +
                             Node.tokenToName(type) +
                             " (type " + type + ")");
  }
}