Package info.bliki.wiki.template.expr.operator

Examples of info.bliki.wiki.template.expr.operator.Operator


   * Determine the current BinaryOperator
   *
   * @return <code>null</code> if no binary operator could be determined
   */
  private InfixOperator determineBinaryOperator() {
    Operator oper = null;
    for (int i = 0; i < fOperList.size(); i++) {
      oper = (Operator) fOperList.get(i);
      if (oper instanceof InfixOperator) {
        return (InfixOperator) oper;
      }
View Full Code Here


    return null;
  }

  private ASTNode parsePrimary() {
    if (fToken == TT_OPERATOR) {
      final Operator oper = determinePrefixOperator();

      if (oper instanceof PrefixOperator) {
        getNextToken();
        final ASTNode temp = parseLookaheadOperator(oper.getPrecedence());
        if (oper.getFunctionName().equals("PreMinus")) {
          // special cases for negative numbers
          if (temp instanceof NumberNode) {
            ((NumberNode) temp).toggleSign();
            return temp;
          }
View Full Code Here

    return getFactor();
  }

  private ASTNode parseLookaheadOperator(final int min_precedence) {
    ASTNode rhs = parsePrimary();
    Operator operLookahead;
    InfixOperator binOper;
    while (true) {
      final int lookahead = fToken;
      if (lookahead != TT_OPERATOR) {
        break;
      }
      operLookahead = determineBinaryOperator();
      if (operLookahead instanceof InfixOperator) {
        binOper = (InfixOperator) operLookahead;
        if (binOper.getPrecedence() > min_precedence) {
          rhs = parseOperators(rhs, operLookahead.getPrecedence());
          continue;
        } else if ((binOper.getPrecedence() == min_precedence) && (binOper.getGrouping() == InfixOperator.RIGHT_ASSOCIATIVE)) {
          rhs = parseOperators(rhs, operLookahead.getPrecedence());
          continue;
        }
      } else {
        operLookahead = determinePostfixOperator();

        if (operLookahead instanceof PostfixOperator) {
          if (operLookahead.getPrecedence() > min_precedence) {
            getNextToken();
            rhs = ((PostfixOperator) operLookahead).createFunction(fFactory, rhs);
            continue;
          }
        }
View Full Code Here

   * @param min_precedence
   * @return
   */
  private ASTNode parseOperators(ASTNode lhs, final int min_precedence) {
    ASTNode rhs = null;
    Operator oper;
    while (true) {
      if (fToken != TT_OPERATOR) {
        break;
      }
      oper = determineBinaryOperator();

      if (oper instanceof InfixOperator) {
        if (oper.getPrecedence() >= min_precedence) {
          getNextToken();
          rhs = parseLookaheadOperator(oper.getPrecedence());
          lhs = ((InfixOperator) oper).createFunction(fFactory, lhs, rhs);
          // lhs = parseArguments(lhs);
          continue;
        }
      } else {
View Full Code Here

      final Iterator i2 = operatorMap.keySet().iterator();
      System.out.println("public static final String[] OPERATOR_STRINGS = {");
      while (i2.hasNext()) {
        final String headStr = (String) i2.next();
        final Operator oper = (Operator) operatorMap.get(headStr);
        if (oper == null) {
          System.out.println("    \" null-value-in-operator-map \",");
        } else {
          System.out.println("    \"" + oper.getOperatorString() + "\",");
        }
      }
      System.out.println("};");

      final Iterator i3 = operatorMap.keySet().iterator();
      System.out.println("public static final Operator[] OPERATORS = {");
      while (i3.hasNext()) {
        final String headStr = (String) i3.next();
        final Operator oper = (Operator) operatorMap.get(headStr);
        if (oper instanceof DivideOperator) {
          final InfixOperator iOper = (DivideOperator) oper;
          String grouping = null;
          if (iOper.getGrouping() == InfixOperator.NONE) {
            grouping = "InfixOperator.NONE";
          } else if (iOper.getGrouping() == InfixOperator.LEFT_ASSOCIATIVE) {
            grouping = "InfixOperator.LEFT_ASSOCIATIVE";
          } else if (iOper.getGrouping() == InfixOperator.RIGHT_ASSOCIATIVE) {
            grouping = "InfixOperator.RIGHT_ASSOCIATIVE";
          }
          System.out.println("    new DivideOperator(\"" + iOper.getOperatorString() + "\", \"" + iOper.getFunctionName() + "\", "
              + iOper.getPrecedence() + ", " + grouping + "),");
        } else if (oper instanceof SubtractOperator) {
          final InfixOperator iOper = (SubtractOperator) oper;
          String grouping = null;
          if (iOper.getGrouping() == InfixOperator.NONE) {
            grouping = "InfixOperator.NONE";
          } else if (iOper.getGrouping() == InfixOperator.LEFT_ASSOCIATIVE) {
            grouping = "InfixOperator.LEFT_ASSOCIATIVE";
          } else if (iOper.getGrouping() == InfixOperator.RIGHT_ASSOCIATIVE) {
            grouping = "InfixOperator.RIGHT_ASSOCIATIVE";
          }
          System.out.println("    new SubtractOperator(\"" + iOper.getOperatorString() + "\", \"" + iOper.getFunctionName()
              + "\", " + iOper.getPrecedence() + ", " + grouping + "),");
        } else if (oper instanceof InfixOperator) {
          final InfixOperator iOper = (InfixOperator) oper;
          String grouping = null;
          if (iOper.getGrouping() == InfixOperator.NONE) {
            grouping = "InfixOperator.NONE";
          } else if (iOper.getGrouping() == InfixOperator.LEFT_ASSOCIATIVE) {
            grouping = "InfixOperator.LEFT_ASSOCIATIVE";
          } else if (iOper.getGrouping() == InfixOperator.RIGHT_ASSOCIATIVE) {
            grouping = "InfixOperator.RIGHT_ASSOCIATIVE";
          }
          System.out.println("    new InfixOperator(\"" + iOper.getOperatorString() + "\", \"" + iOper.getFunctionName() + "\", "
              + iOper.getPrecedence() + ", " + grouping + "),");
        } else if (oper instanceof PostfixOperator) {
          System.out.println("    new PostfixOperator(\"" + oper.getOperatorString() + "\", \"" + oper.getFunctionName() + "\", "
              + oper.getPrecedence() + "),");
        } else if (oper instanceof PreMinusOperator) {
          System.out.println("    new PreMinusOperator(\"" + oper.getOperatorString() + "\", \"" + oper.getFunctionName() + "\", "
              + oper.getPrecedence() + "),");
        } else if (oper instanceof PrePlusOperator) {
          System.out.println("    new PrePlusOperator(\"" + oper.getOperatorString() + "\", \"" + oper.getFunctionName() + "\", "
              + oper.getPrecedence() + "),");
        } else if (oper instanceof PrefixOperator) {
          System.out.println("    new PrefixOperator(\"" + oper.getOperatorString() + "\", \"" + oper.getFunctionName() + "\", "
              + oper.getPrecedence() + "),");
        }

      }
      System.out.println("};");
    } catch (FileNotFoundException e) {
View Full Code Here

  public static void generateOperatorTable(final InputStream is, final HashMap operatorMap, final HashMap operatorTokenStartSet) {
    String record = null;
    final BufferedReader r = new BufferedReader(new InputStreamReader(is));

    StringTokenizer tokenizer;
    Operator oper = null;
    String typeStr;
    String operatorStr;
    String headStr;
    String precedenceStr;
    String groupingStr;
View Full Code Here

TOP

Related Classes of info.bliki.wiki.template.expr.operator.Operator

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.