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


Java AST.setFirstChild方法代码示例

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


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

示例1: createSortSpecification

import antlr.collections.AST; //导入方法依赖的package包/类
private SortSpecification createSortSpecification(
		AST ident,
		CollationSpecification collationSpecification,
		OrderingSpecification orderingSpecification) {
	AST sortSpecification = getASTFactory().create( SORT_SPEC, "{{sort specification}}" );
	AST sortKey = getASTFactory().create( SORT_KEY, "{{sort key}}" );
	AST newIdent = getASTFactory().create( ident.getType(), ident.getText() );
	sortKey.setFirstChild( newIdent );
	sortSpecification.setFirstChild( sortKey );
	if ( collationSpecification != null ) {
		sortSpecification.addChild( collationSpecification );
	}
	if ( orderingSpecification != null ) {
		sortSpecification.addChild( orderingSpecification );
	}
	return ( SortSpecification ) sortSpecification;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:OrderByFragmentParser.java

示例2: mutateRowValueConstructorSyntax

import antlr.collections.AST; //导入方法依赖的package包/类
private void mutateRowValueConstructorSyntax(int operandColumnSpan) {
	final int comparisonType = getType();
	final String comparisonText = getText();

	final int expansionConnectorType = getExpansionConnectorType();
	final String expansionConnectorText = getExpansionConnectorText();

	setType( expansionConnectorType );
	setText( expansionConnectorText );

	String[] mutationTexts = extractMutationTexts( getOperand(), operandColumnSpan );

	AST container = this;
	for ( int i = operandColumnSpan - 1; i > 0; i-- ) {
		if ( i == 1 ) {
			AST op1 = getASTFactory().create( comparisonType, comparisonText );
			AST operand1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[0] );
			op1.setFirstChild( operand1 );
			container.setFirstChild( op1 );
			AST op2 = getASTFactory().create( comparisonType, comparisonText );
			AST operand2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[1] );
			op2.setFirstChild( operand2 );
			op1.setNextSibling( op2 );
		}
		else {
			AST op = getASTFactory().create( comparisonType, comparisonText );
			AST operand = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[i] );
			op.setFirstChild( operand );
			AST newContainer = getASTFactory().create( expansionConnectorType, expansionConnectorText );
			container.setFirstChild( newContainer );
			newContainer.setNextSibling( op );
			container = newContainer;
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:AbstractNullnessCheckNode.java

示例3: handleDotStructure

import antlr.collections.AST; //导入方法依赖的package包/类
private void handleDotStructure(AST dotStructureRoot) {
	final String expression = ASTUtil.getPathText( dotStructureRoot );
	final Object constant = ReflectHelper.getConstantValue( expression );
	if ( constant != null ) {
		dotStructureRoot.setFirstChild( null );
		dotStructureRoot.setType( HqlTokenTypes.JAVA_CONSTANT );
		dotStructureRoot.setText( expression );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:QueryTranslatorImpl.java

示例4: makeSiblingOfParent

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Makes the child node a sibling of the parent, reconnecting all siblings.
 *
 * @param parent the parent
 * @param child the child
 */
public static void makeSiblingOfParent(AST parent, AST child) {
	AST prev = findPreviousSibling( parent, child );
	if ( prev != null ) {
		prev.setNextSibling( child.getNextSibling() );
	}
	else { // child == parent.getFirstChild()
		parent.setFirstChild( child.getNextSibling() );
	}
	child.setNextSibling( parent.getNextSibling() );
	parent.setNextSibling( child );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ASTUtil.java

示例5: insertChild

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Inserts the child as the first child of the parent, all other children are shifted over to the 'right'.
 *
 * @param parent the parent
 * @param child the new first child
 */
public static void insertChild(AST parent, AST child) {
	if ( parent.getFirstChild() == null ) {
		parent.setFirstChild( child );
	}
	else {
		AST n = parent.getFirstChild();
		parent.setFirstChild( child );
		child.setNextSibling( n );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ASTUtil.java

示例6: generateSyntheticDotNodeForNonQualifiedPropertyRef

import antlr.collections.AST; //导入方法依赖的package包/类
private AST generateSyntheticDotNodeForNonQualifiedPropertyRef(AST property, FromElement fromElement) {
	AST dot = getASTFactory().create( DOT, "{non-qualified-property-ref}" );
	// TODO : better way?!?
	( (DotNode) dot ).setPropertyPath( ( (FromReferenceNode) property ).getPath() );

	IdentNode syntheticAlias = (IdentNode) getASTFactory().create( IDENT, "{synthetic-alias}" );
	syntheticAlias.setFromElement( fromElement );
	syntheticAlias.setResolved();

	dot.setFirstChild( syntheticAlias );
	dot.addChild( property );

	return dot;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:HqlSqlWalker.java

示例7: dupTree

import antlr.collections.AST; //导入方法依赖的package包/类
/**Duplicate a tree, assuming this is a root node of a tree--
 * duplicate that node and what's below; ignore siblings of root node.
 */
public AST dupTree(AST t) {
    AST result = dup(t);		// make copy of root
    // copy all children of root.
    if (t != null) {
        result.setFirstChild(dupList(t.getFirstChild()));
    }
    return result;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:12,代码来源:ASTFactory.java

示例8: 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

示例9: translate

import antlr.collections.AST; //导入方法依赖的package包/类
protected void translate(
		int valueElements, int comparisonType,
		String comparisonText, String[] lhsElementTexts,
		String[] rhsElementTexts,
		ParameterSpecification lhsEmbeddedCompositeParameterSpecification,
		ParameterSpecification rhsEmbeddedCompositeParameterSpecification,
		AST container) {
	for ( int i = valueElements - 1; i > 0; i-- ) {
		if ( i == 1 ) {
			AST op1 = getASTFactory().create( comparisonType, comparisonText );
			AST lhs1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[0] );
			AST rhs1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[0] );
			op1.setFirstChild( lhs1 );
			lhs1.setNextSibling( rhs1 );
			container.setFirstChild( op1 );
			AST op2 = getASTFactory().create( comparisonType, comparisonText );
			AST lhs2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[1] );
			AST rhs2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[1] );
			op2.setFirstChild( lhs2 );
			lhs2.setNextSibling( rhs2 );
			op1.setNextSibling( op2 );

			// "pass along" our initial embedded parameter node(s) to the first generated
			// sql fragment so that it can be handled later for parameter binding...
			SqlFragment fragment = (SqlFragment) lhs1;
			if ( lhsEmbeddedCompositeParameterSpecification != null ) {
				fragment.addEmbeddedParameter( lhsEmbeddedCompositeParameterSpecification );
			}
			if ( rhsEmbeddedCompositeParameterSpecification != null ) {
				fragment.addEmbeddedParameter( rhsEmbeddedCompositeParameterSpecification );
			}
		}
		else {
			AST op = getASTFactory().create( comparisonType, comparisonText );
			AST lhs = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[i] );
			AST rhs = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[i] );
			op.setFirstChild( lhs );
			lhs.setNextSibling( rhs );
			AST newContainer = getASTFactory().create( HqlSqlTokenTypes.AND, "AND" );
			container.setFirstChild( newContainer );
			newContainer.setNextSibling( op );
			container = newContainer;
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:BinaryLogicOperatorNode.java

示例10: addDiscriminatorWhereFragment

import antlr.collections.AST; //导入方法依赖的package包/类
public void addDiscriminatorWhereFragment(
		RestrictableStatement statement,
		Queryable persister,
		Map enabledFilters,
		String alias) {
	String whereFragment = persister.filterFragment( alias, enabledFilters ).trim();
	if ( "".equals( whereFragment ) ) {
		return;
	}
	if ( whereFragment.startsWith( "and" ) ) {
		whereFragment = whereFragment.substring( 4 );
	}

	// Need to parse off the column qualifiers; this is assuming (which is true as of now)
	// that this is only used from update and delete HQL statement parsing
	whereFragment = StringHelper.replace(
			whereFragment,
			persister.generateFilterConditionAlias( alias ) + ".",
			""
	);

	// Note: this simply constructs a "raw" SQL_TOKEN representing the
	// where fragment and injects this into the tree.  This "works";
	// however it is probably not the best long-term solution.
	//
	// At some point we probably want to apply an additional grammar to
	// properly tokenize this where fragment into constituent parts
	// focused on the operators embedded within the fragment.
	SqlFragment discrimNode = (SqlFragment) create( SQL_TOKEN, whereFragment );

	JoinProcessor.processDynamicFilterParameters(
			whereFragment,
			discrimNode,
			hqlSqlWalker
	);

	if ( statement.getWhereClause().getNumberOfChildren() == 0 ) {
		statement.getWhereClause().setFirstChild( discrimNode );
	}
	else {
		AST and = create( AND, "{and}" );
		AST currentFirstChild = statement.getWhereClause().getFirstChild();
		and.setFirstChild( discrimNode );
		and.addChild( currentFirstChild );
		statement.getWhereClause().setFirstChild( and );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:SyntheticAndFactory.java

示例11: prepareVersioned

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected void prepareVersioned(AST updateNode, AST versioned) throws SemanticException {
	UpdateStatement updateStatement = (UpdateStatement) updateNode;
	FromClause fromClause = updateStatement.getFromClause();
	if ( versioned != null ) {
		// Make sure that the persister is versioned
		Queryable persister = fromClause.getFromElement().getQueryable();
		if ( !persister.isVersioned() ) {
			throw new SemanticException( "increment option specified for update of non-versioned entity" );
		}

		VersionType versionType = persister.getVersionType();
		if ( versionType instanceof UserVersionType ) {
			throw new SemanticException( "user-defined version types not supported for increment option" );
		}

		AST eq = getASTFactory().create( HqlSqlTokenTypes.EQ, "=" );
		AST versionPropertyNode = generateVersionPropertyNode( persister );

		eq.setFirstChild( versionPropertyNode );

		AST versionIncrementNode = null;
		if ( isTimestampBasedVersion( versionType ) ) {
			versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
			ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
			( (ParameterNode) versionIncrementNode ).setHqlParameterSpecification( paramSpec );
			parameters.add( 0, paramSpec );
		}
		else {
			// Not possible to simply re-use the versionPropertyNode here as it causes
			// OOM errors due to circularity :(
			versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PLUS, "+" );
			versionIncrementNode.setFirstChild( generateVersionPropertyNode( persister ) );
			versionIncrementNode.addChild( getASTFactory().create( HqlSqlTokenTypes.IDENT, "1" ) );
		}

		eq.addChild( versionIncrementNode );

		evaluateAssignment( eq, persister, 0 );

		AST setClause = updateStatement.getSetClause();
		AST currentFirstSetElement = setClause.getFirstChild();
		setClause.setFirstChild( eq );
		eq.setNextSibling( currentFirstSetElement );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:HqlSqlWalker.java


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