Package info.bliki.wiki.template.expr.ast

Examples of info.bliki.wiki.template.expr.ast.ASTNode


   *
   */
  public ASTNode optimizeFunction(final FunctionNode functionNode) {
    if (functionNode.size() > 0) {
      boolean doubleOnly = true;
      ASTNode node;
      for (int i = 1; i < functionNode.size(); i++) {
        node = functionNode.get(i);
        if (node instanceof NumberNode) {
          functionNode.set(i, new DoubleNode(((NumberNode) functionNode.get(i)).doubleValue()));
        } else if (functionNode.get(i) instanceof FunctionNode) {
          ASTNode optNode = optimizeFunction((FunctionNode) functionNode.get(i));
          if (!(optNode instanceof DoubleNode)) {
            doubleOnly = false;
          }
          functionNode.set(i, optNode);
        } else {
View Full Code Here


    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) {
View Full Code Here

   *          the already parsed left-hand-side of the operator
   * @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;
      }
View Full Code Here

   * @return the parsed ASTNode representation of the given formula string
   * @throws SyntaxError
   */
  public ASTNode parse(final String expression) throws SyntaxError {
    initialize(expression);
    final ASTNode temp = parseOperators(parsePrimary(), 0);
    if (fToken != TT_EOF) {
      if (fToken == TT_PRECEDENCE_CLOSE) {
        throwSyntaxError("Too many closing ')'; End-of-file not reached.");
      }

View Full Code Here

   *
   * @return
   * @see
   */
  private ASTNode getNumber(final boolean negative) throws SyntaxError {
    ASTNode temp = null;
    final Object[] result = getNumberString();
    String number = (String) result[0];
    final int numFormat = ((Integer) result[1]).intValue();
    try {
      if (negative) {
View Full Code Here

  //
  // return fFactory.createString(ident);
  // }

  private ASTNode getFactor() throws SyntaxError {
    ASTNode temp;

    if (fToken == TT_CONSTANT) {
      temp = fFactory.createSymbol(fOperatorString);
      getNextToken();
      return temp;
View Full Code Here

   *
   */
  public ASTNode optimizeFunction(final FunctionNode functionNode) {
    if (functionNode.size() > 0) {
      boolean doubleOnly = true;
      ASTNode node;
      for (int i = 1; i < functionNode.size(); i++) {
        node = functionNode.get(i);
        if (node instanceof NumberNode) {
          functionNode.set(i, new DoubleNode(((NumberNode) functionNode.get(i)).doubleValue()));
        } else if (functionNode.get(i) instanceof FunctionNode) {
          ASTNode optNode = optimizeFunction((FunctionNode) functionNode.get(i));
          if (!(optNode instanceof DoubleNode)) {
            doubleOnly = false;
          }
          functionNode.set(i, optNode);
        } else {
View Full Code Here

   *
   */
  public ASTNode optimizeFunction(final FunctionNode functionNode) {
    if (functionNode.size() > 0) {
      boolean doubleOnly = true;
      ASTNode node;
      for (int i = 1; i < functionNode.size(); i++) {
        node = functionNode.get(i);
        if (node instanceof NumberNode) {
          functionNode.set(i, new DoubleNode(((NumberNode) functionNode.get(i)).doubleValue()));
        } else if (functionNode.get(i) instanceof FunctionNode) {
          ASTNode optNode = optimizeFunction((FunctionNode) functionNode.get(i));
          if (!(optNode instanceof DoubleNode)) {
            doubleOnly = false;
          }
          functionNode.set(i, optNode);
        } else {
View Full Code Here

    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

TOP

Related Classes of info.bliki.wiki.template.expr.ast.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.