Package com.sonar.sslr.api

Examples of com.sonar.sslr.api.AstNode


    return result ? BigInteger.ONE : BigInteger.ZERO;
  }

  BigInteger evalRelationalExpression(AstNode exprAst) {
    String operator = exprAst.getChild(1).getTokenValue();
    AstNode lhs = exprAst.getChild(0);
    AstNode rhs = exprAst.getChild(2);
    boolean result;
    if (operator.equals("<")) {
      result = evalToInt(lhs).compareTo(evalToInt(rhs)) < 0;
    } else if (operator.equals(">")) {
      result = evalToInt(lhs).compareTo(evalToInt(rhs)) > 0;
View Full Code Here


  // ///////////////// bitwise expressions ///////////////////////
  BigInteger evalAndExpression(AstNode exprAst) {
    int noChildren = exprAst.getNumberOfChildren();
    BigInteger result = evalToInt(exprAst.getChild(0));
    for(int i = 2; i < noChildren; i+=2){
      AstNode operand = exprAst.getChild(i);
      result = result.and(evalToInt(operand));
    }

    return result;
  }
View Full Code Here

  BigInteger evalInclusiveOrExpression(AstNode exprAst) {
    int noChildren = exprAst.getNumberOfChildren();
    BigInteger result = evalToInt(exprAst.getChild(0));
    for(int i = 2; i < noChildren; i+=2){
      AstNode operand = exprAst.getChild(i);
      result = result.or(evalToInt(operand));
    }

    return result;
  }
View Full Code Here

  BigInteger evalExclusiveOrExpression(AstNode exprAst) {
    int noChildren = exprAst.getNumberOfChildren();
    BigInteger result = evalToInt(exprAst.getChild(0));
    for(int i = 2; i < noChildren; i+=2){
      AstNode operand = exprAst.getChild(i);
      result = result.xor(evalToInt(operand));
    }

    return result;
  }
View Full Code Here

  // ///////////////// other ... ///////////////////
  BigInteger evalUnaryExpression(AstNode exprAst) {
    // only 'unary-operator cast-expression' production is allowed in #if-context

    String operator = exprAst.getChild(0).getTokenValue();
    AstNode operand = exprAst.getChild(1);
    if (operator.equals("+")) {
      return evalToInt(operand);
    } else if (operator.equals("-")) {
      return evalToInt(operand).negate();
    } else if (operator.equals("!")) {
View Full Code Here

    }
  }

  BigInteger evalShiftExpression(AstNode exprAst) {
    String operator;
    AstNode rhs;
    BigInteger result = evalToInt(exprAst.getChild(0));
    int noChildren = exprAst.getNumberOfChildren();

    for(int i = 2; i < noChildren; i+=2){
      operator = exprAst.getChild(i-1).getTokenValue();
View Full Code Here

    return result;
  }

  BigInteger evalAdditiveExpression(AstNode exprAst) {
    String operator;
    AstNode rhs;
    BigInteger result = evalToInt(exprAst.getChild(0));
    int noChildren = exprAst.getNumberOfChildren();

    for(int i = 2; i < noChildren; i+=2){
      operator = exprAst.getChild(i-1).getTokenValue();
View Full Code Here

    return result;
  }

  BigInteger evalMultiplicativeExpression(AstNode exprAst) {
    String operator;
    AstNode rhs;
    BigInteger result = evalToInt(exprAst.getChild(0));
    int noChildren = exprAst.getNumberOfChildren();

    for(int i = 2; i < noChildren; i+=2){
      operator = exprAst.getChild(i-1).getTokenValue();
View Full Code Here

    return result;
  }

  BigInteger evalConditionalExpression(AstNode exprAst) {
    if (exprAst.getNumberOfChildren() == 5) {
        AstNode decisionOperand = exprAst.getChild(0);
        AstNode trueCaseOperand = exprAst.getChild(2);
        AstNode falseCaseOperand = exprAst.getChild(4);
        return eval(decisionOperand) ? evalToInt(trueCaseOperand) : evalToInt(falseCaseOperand);
    }
    else {
        AstNode decisionOperand = exprAst.getChild(0);
        AstNode falseCaseOperand = exprAst.getChild(3);
        BigInteger decision = evalToInt(decisionOperand);
        return decision.compareTo(BigInteger.ZERO) != 0 ? decision : evalToInt(falseCaseOperand);
    }
  }
View Full Code Here

TOP

Related Classes of com.sonar.sslr.api.AstNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.