当前位置: 首页>>代码示例>>Java>>正文


Java AST.getNextSibling方法代码示例

本文整理汇总了Java中antlr.collections.AST.getNextSibling方法的典型用法代码示例。如果您正苦于以下问题:Java AST.getNextSibling方法的具体用法?Java AST.getNextSibling怎么用?Java AST.getNextSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在antlr.collections.AST的用法示例。


在下文中一共展示了AST.getNextSibling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOrdering

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Locate the specified <tt>ordering specification</tt>, if one.
 *
 * @return The <tt>ordering specification</tt>, or null if none was specified.
 */
public OrderingSpecification getOrdering() {
	// IMPL NOTE : the ordering-spec would be either the 2nd or 3rd child (of the overall sort-spec), if it existed,
	// 		depending on whether a collation-spec was specified.

	AST possible = getSortKey().getNextSibling();
	if ( possible == null ) {
		// There was no sort-spec parts specified other then the sort-key so there can be no ordering-spec...
		return null;
	}

	if ( OrderByTemplateTokenTypes.COLLATE == possible.getType() ) {
		// the 2nd child was a collation-spec, so we need to check the 3rd child instead.
		possible = possible.getNextSibling();
	}

	return possible != null && OrderByTemplateTokenTypes.ORDER_SPEC == possible.getType()
			?  ( OrderingSpecification ) possible
			:  null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:SortSpecification.java

示例2: resolve

import antlr.collections.AST; //导入方法依赖的package包/类
public void resolve(boolean inSelect) throws SemanticException {
	// Get the function name node.
	AST nameNode = getFirstChild();
	AST exprListNode = nameNode.getNextSibling();

	initializeMethodNode( nameNode, inSelect );

	// If the expression list has exactly one expression, and the type of the expression is a collection
	// then this might be a collection function, such as index(c) or size(c).
	if ( ASTUtil.hasExactlyOneChild( exprListNode ) ) {
		if ( "type".equals( methodName ) ) {
			typeDiscriminator( exprListNode.getFirstChild() );
			return;
		}
		if ( isCollectionPropertyMethod() ) {
			collectionProperty( exprListNode.getFirstChild(), nameNode );
			return;
		}
	}

	dialectFunction( exprListNode );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:MethodNode.java

示例3: doWorkForFindAll

import antlr.collections.AST; //导入方法依赖的package包/类
private void doWorkForFindAll(Vector v, AST target, boolean partialMatch) {
    AST sibling;

    // Start walking sibling lists, looking for matches.
    siblingWalk:
    for (sibling = this;
         sibling != null;
         sibling = sibling.getNextSibling()) {
        if ((partialMatch && sibling.equalsTreePartial(target)) ||
            (!partialMatch && sibling.equalsTree(target))) {
            v.appendElement(sibling);
        }
        // regardless of match or not, check any children for matches
        if (sibling.getFirstChild() != null) {
            ((BaseAST)sibling.getFirstChild()).doWorkForFindAll(v, target, partialMatch);
        }
    }
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:19,代码来源:BaseAST.java

示例4: getIndexOfChild

import antlr.collections.AST; //导入方法依赖的package包/类
public int getIndexOfChild(Object parent, Object child) {
    if (parent == null || child == null) {
        throw new IllegalArgumentException("root or child is null");
    }
    AST p = (AST)parent;
    AST c = p.getFirstChild();
    if (c == null) {
        throw new ArrayIndexOutOfBoundsException("node has no children");
    }
    int i = 0;
    while (c != null && c != child) {
        c = c.getNextSibling();
        i++;
    }
    if (c == child) {
        return i;
    }
    throw new java.util.NoSuchElementException("node is not a child");
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:20,代码来源:JTreeASTModel.java

示例5: getChild

import antlr.collections.AST; //导入方法依赖的package包/类
public Object getChild(Object parent, int index) {
    if (parent == null) {
        return null;
    }
    AST p = (AST)parent;
    AST c = p.getFirstChild();
    if (c == null) {
        throw new ArrayIndexOutOfBoundsException("node has no children");
    }
    int i = 0;
    while (c != null && i < index) {
        c = c.getNextSibling();
        i++;
    }
    return c;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:17,代码来源:JTreeASTModel.java

示例6: getFirstSelectExpression

import antlr.collections.AST; //导入方法依赖的package包/类
protected AST getFirstSelectExpression() {
	AST n = getFirstChild();
	// Skip 'DISTINCT' and 'ALL', so we return the first expression node.
	while ( n != null && ( n.getType() == SqlTokenTypes.DISTINCT || n.getType() == SqlTokenTypes.ALL ) ) {
		n = n.getNextSibling();
	}
	return n;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SelectClause.java

示例7: setPropertyNameAndPath

import antlr.collections.AST; //导入方法依赖的package包/类
private void setPropertyNameAndPath(AST parent) {
	if ( isDotNode( parent ) ) {
		DotNode dotNode = (DotNode) parent;
		AST lhs = dotNode.getFirstChild();
		AST rhs = lhs.getNextSibling();
		propertyName = rhs.getText();
		propertyPath = propertyPath + "." + propertyName; // Append the new property name onto the unresolved path.
		dotNode.propertyPath = propertyPath;
		LOG.debugf( "Unresolved property path is now '%s'", dotNode.propertyPath );
	}
	else {
		LOG.debugf( "Terminal getPropertyPath = [%s]", propertyPath );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:DotNode.java

示例8: getFirstArgumentType

import antlr.collections.AST; //导入方法依赖的package包/类
public Type getFirstArgumentType() {
	AST argument = getFirstChild();
	while ( argument != null ) {
		if ( argument instanceof SqlNode ) {
			final Type type = ( (SqlNode) argument ).getDataType();
			if ( type != null ) {
				return type;
			}
			argument = argument.getNextSibling();
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:AggregateNode.java

示例9: getFirstArgumentType

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
public Type getFirstArgumentType() {
	AST argument = getFirstChild();
	while ( argument != null ) {
		if ( argument instanceof SqlNode ) {
			final Type type = ( (SqlNode) argument ).getDataType();
			if ( type != null ) {
				return type;
			}
			argument = argument.getNextSibling();
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:MethodNode.java

示例10: equalsList

import antlr.collections.AST; //导入方法依赖的package包/类
/** Is t an exact structural and equals() match of this tree.  The
   *  'this' reference is considered the start of a sibling list.
   */
  public boolean equalsList(AST t) {
      AST sibling;

      // the empty tree is not a match of any non-null tree.
      if (t == null) {
          return false;
      }

      // Otherwise, start walking sibling lists.  First mismatch, return false.
      for (sibling = this;
	 sibling != null && t != null;
	 sibling = sibling.getNextSibling(), t = t.getNextSibling())
{
          // as a quick optimization, check roots first.
          if (!sibling.equals(t)) {
              return false;
          }
          // if roots match, do full list match test on children.
          if (sibling.getFirstChild() != null) {
              if (!sibling.getFirstChild().equalsList(t.getFirstChild())) {
                  return false;
              }
          }
          // sibling has no kids, make sure t doesn't either
          else if (t.getFirstChild() != null) {
              return false;
          }
      }
      if (sibling == null && t == null) {
          return true;
      }
      // one sibling list has more than the other
      return false;
  }
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:38,代码来源:BaseAST.java

示例11: dupList

import antlr.collections.AST; //导入方法依赖的package包/类
/** Duplicate tree including siblings of root. */
public AST dupList(AST t) {
    AST result = dupTree(t);            // if t == null, then result==null
    AST nt = result;
    while (t != null) {						// for each sibling of the root
        t = t.getNextSibling();
        nt.setNextSibling(dupTree(t));	// dup each subtree, building new tree
        nt = nt.getNextSibling();
    }
    return result;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:12,代码来源:ASTFactory.java

示例12: isSubtreeChild

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Determine if a given node (test) is contained anywhere in the subtree
 * of another given node (fixture).
 *
 * @param fixture The node against which to testto be checked for children.
 * @param test The node to be tested as being a subtree child of the parent.
 *
 * @return True if child is contained in the parent's collection of children.
 */
public static boolean isSubtreeChild(AST fixture, AST test) {
	AST n = fixture.getFirstChild();
	while ( n != null ) {
		if ( n == test ) {
			return true;
		}
		if ( n.getFirstChild() != null && isSubtreeChild( n, test ) ) {
			return true;
		}
		n = n.getNextSibling();
	}
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:ASTUtil.java

示例13: findPreviousSibling

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Find the previous sibling in the parent for the given child.
 *
 * @param parent the parent node
 * @param child the child to find the previous sibling of
 *
 * @return the previous sibling of the child
 */
public static AST findPreviousSibling(AST parent, AST child) {
	AST prev = null;
	AST n = parent.getFirstChild();
	while ( n != null ) {
		if ( n == child ) {
			return prev;
		}
		prev = n;
		n = n.getNextSibling();
	}
	throw new IllegalArgumentException( "Child not found in parent!" );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:ASTUtil.java

示例14: getPathText

import antlr.collections.AST; //导入方法依赖的package包/类
private static void getPathText(StringBuilder buf, AST n) {
	AST firstChild = n.getFirstChild();
	// If the node has a first child, recurse into the first child.
	if ( firstChild != null ) {
		getPathText( buf, firstChild );
	}
	// Append the text of the current node.
	buf.append( n.getText() );
	// If there is a second child (RHS), recurse into that child.
	if ( firstChild != null && firstChild.getNextSibling() != null ) {
		getPathText( buf, firstChild.getNextSibling() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ASTUtil.java

示例15: make

import antlr.collections.AST; //导入方法依赖的package包/类
/** Make a tree from a list of nodes.  The first element in the
 *  array is the root.  If the root is null, then the tree is
 *  a simple list not a tree.  Handles null children nodes correctly.
 *  For example, build(a, b, null, c) yields tree (a b c).  build(null,a,b)
 *  yields tree (nil a b).
 */
public AST make(AST[] nodes) {
    if (nodes == null || nodes.length == 0) return null;
    AST root = nodes[0];
    AST tail = null;
    if (root != null) {
        root.setFirstChild(null);	// don't leave any old pointers set
    }
    // link in children;
    for (int i = 1; i < nodes.length; i++) {
        if (nodes[i] == null) continue;	// ignore null nodes
        if (root == null) {
            // Set the root and set it up for a flat list
            root = tail = nodes[i];
        }
        else if (tail == null) {
            root.setFirstChild(nodes[i]);
            tail = root.getFirstChild();
        }
        else {
            tail.setNextSibling(nodes[i]);
            tail = tail.getNextSibling();
        }
        // Chase tail to last sibling
        while (tail.getNextSibling() != null) {
            tail = tail.getNextSibling();
        }
    }
    return root;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:36,代码来源:ASTFactory.java


注:本文中的antlr.collections.AST.getNextSibling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。