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


Java AST.getType方法代码示例

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


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

示例1: visit

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
public void visit(AST node) {
	if ( dotRoot != null ) {
		// we are already processing a dot-structure
		if ( ASTUtil.isSubtreeChild( dotRoot, node ) ) {
			return;
		}
		// we are now at a new tree level
		dotRoot = null;
	}

	if ( node.getType() == HqlTokenTypes.DOT ) {
		dotRoot = node;
		handleDotStructure( dotRoot );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:QueryTranslatorImpl.java

示例2: beginFunctionTemplate

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected void beginFunctionTemplate(AST node, AST nameNode) {
	// NOTE for AGGREGATE both nodes are the same; for METHOD the first is the METHOD, the second is the
	// 		METHOD_NAME
	FunctionNode functionNode = (FunctionNode) node;
	SQLFunction sqlFunction = functionNode.getSQLFunction();
	if ( sqlFunction == null ) {
		// if SQLFunction is null we just write the function out as it appears in the hql statement
		super.beginFunctionTemplate( node, nameNode );
	}
	else {
		// this function has a registered SQLFunction -> redirect output and catch the arguments
		outputStack.addFirst( writer );
		if ( node.getType() == CAST ) {
			writer = new CastFunctionArguments();
		}
		else {
			writer = new StandardFunctionArguments();
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:SqlGenerator.java

示例3: processConstant

import antlr.collections.AST; //导入方法依赖的package包/类
public void processConstant(AST constant, boolean resolveIdent) throws SemanticException {
	// If the constant is an IDENT, figure out what it means...
	boolean isIdent = ( constant.getType() == IDENT || constant.getType() == WEIRD_IDENT );
	if ( resolveIdent && isIdent && isAlias( constant.getText() ) ) {
		// IDENT is a class alias in the FROM.
		IdentNode ident = (IdentNode) constant;
		// Resolve to an identity column.
		ident.resolve( false, true );
	}
	else {
		// IDENT might be the name of a class.
		Queryable queryable = walker.getSessionFactoryHelper().findQueryableUsingImports( constant.getText() );
		if ( isIdent && queryable != null ) {
			constant.setText( queryable.getDiscriminatorSQLValue() );
		}
		// Otherwise, it's a literal.
		else {
			processLiteral( constant );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:LiteralProcessor.java

示例4: next

import antlr.collections.AST; //导入方法依赖的package包/类
/** Find the next subtree with structure and token types equal to
 * those of 'template'.
 */
public AST next(AST template) {
    AST t = null;
    AST sibling = null;

    if (cursor == null) {	// do nothing if no tree to work on
        return null;
    }

    // Start walking sibling list looking for subtree matches.
    for (; cursor != null; cursor = cursor.getNextSibling()) {
        // as a quick optimization, check roots first.
        if (cursor.getType() == template.getType()) {
            // if roots match, do full match test on children.
            if (cursor.getFirstChild() != null) {
                if (isSubtree(cursor.getFirstChild(), template.getFirstChild())) {
                    return cursor;
                }
            }
        }
    }
    return t;
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:26,代码来源:ASTIterator.java

示例5: getCollation

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Locate the specified <tt>collation specification</tt>, if one.
 *
 * @return The <tt>collation specification</tt>, or null if none was specified.
 */
public CollationSpecification getCollation() {
	AST possible = getSortKey().getNextSibling();
	return  possible != null && OrderByTemplateTokenTypes.COLLATE == possible.getType()
			? ( CollationSpecification ) possible
			: null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:SortSpecification.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: getDataType

import antlr.collections.AST; //导入方法依赖的package包/类
public Type getDataType() {
	final AST expression = getFirstChild();
	// option is used to hold each WHEN/ELSE in turn
	AST option = expression.getNextSibling();
	while ( option != null ) {
		final AST result;
		if ( option.getType() == HqlSqlTokenTypes.WHEN ) {
			result = option.getFirstChild().getNextSibling();
		}
		else if ( option.getType() == HqlSqlTokenTypes.ELSE ) {
			result = option.getFirstChild();
		}
		else {
			throw new QueryException(
					"Unexpected node type :" +
							ASTUtil.getTokenTypeName( HqlSqlTokenTypes.class, option.getType() ) +
							"; expecting WHEN or ELSE"
			);
		}

		if ( SqlNode.class.isInstance( result ) ) {
			final Type nodeDataType = ( (SqlNode) result ).getDataType();
			if ( nodeDataType != null ) {
				return nodeDataType;
			}
		}

		option = option.getNextSibling();
	}

	throw new QueryException( "Could not determine data type for simple case statement" );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:SimpleCaseNode.java

示例8: getDataType

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
public Type getDataType() {
	// option is used to hold each WHEN/ELSE in turn
	AST option = getFirstChild();
	while ( option != null ) {
		final AST result;
		if ( option.getType() == HqlSqlTokenTypes.WHEN ) {
			result = option.getFirstChild().getNextSibling();
		}
		else if ( option.getType() == HqlSqlTokenTypes.ELSE ) {
			result = option.getFirstChild();
		}
		else {
			throw new QueryException(
					"Unexpected node type :" +
							ASTUtil.getTokenTypeName( HqlSqlTokenTypes.class, option.getType() ) +
							"; expecting WHEN or ELSE"
			);
		}

		if ( SqlNode.class.isInstance( result ) ) {
			final Type nodeDataType = ( (SqlNode) result ).getDataType();
			if ( nodeDataType != null ) {
				return nodeDataType;
			}
		}

		option = option.getNextSibling();
	}

	throw new QueryException( "Could not determine data type for searched case statement" );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:SearchedCaseNode.java

示例9: processNumeric

import antlr.collections.AST; //导入方法依赖的package包/类
public void processNumeric(AST literal) {
	if ( literal.getType() == NUM_INT
			|| literal.getType() == NUM_LONG
			|| literal.getType() == NUM_BIG_INTEGER ) {
		literal.setText( determineIntegerRepresentation( literal.getText(), literal.getType() ) );
	}
	else if ( literal.getType() == NUM_FLOAT
			|| literal.getType() == NUM_DOUBLE
			|| literal.getType() == NUM_BIG_DECIMAL ) {
		literal.setText( determineDecimalRepresentation( literal.getText(), literal.getType() ) );
	}
	else {
		LOG.unexpectedLiteralTokenType( literal.getType() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:LiteralProcessor.java

示例10: lookupProperty

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected AST lookupProperty(AST dot, boolean root, boolean inSelect) throws SemanticException {
	DotNode dotNode = (DotNode) dot;
	FromReferenceNode lhs = dotNode.getLhs();
	AST rhs = lhs.getNextSibling();
	switch ( rhs.getType() ) {
		case SqlTokenTypes.ELEMENTS:
		case SqlTokenTypes.INDICES:
			if ( LOG.isDebugEnabled() ) {
				LOG.debugf(
						"lookupProperty() %s => %s(%s)",
						dotNode.getPath(),
						rhs.getText(),
						lhs.getPath()
				);
			}
			CollectionFunction f = (CollectionFunction) rhs;
			// Re-arrange the tree so that the collection function is the root and the lhs is the path.
			f.setFirstChild( lhs );
			lhs.setNextSibling( null );
			dotNode.setFirstChild( f );
			resolve( lhs );            // Don't forget to resolve the argument!
			f.resolve( inSelect );    // Resolve the collection function now.
			return f;
		default:
			// Resolve everything up to this dot, but don't resolve the placeholders yet.
			dotNode.resolveFirstChild();
			return dotNode;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:HqlSqlWalker.java

示例11: isOrderExpressionResultVariableRef

import antlr.collections.AST; //导入方法依赖的package包/类
@Override
protected boolean isOrderExpressionResultVariableRef(AST orderExpressionNode) throws SemanticException {
	// ORDER BY is not supported in a subquery
	// TODO: should an exception be thrown if an ORDER BY is in a subquery?
	if ( !isSubQuery() &&
			orderExpressionNode.getType() == IDENT &&
			selectExpressionsByResultVariable.containsKey( orderExpressionNode.getText() ) ) {
		return true;
	}
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:HqlSqlWalker.java

示例12: processEqualityExpression

import antlr.collections.AST; //导入方法依赖的package包/类
/**
 * Post process equality expressions, clean up the subtree.
 *
 * @param x The equality expression.
 *
 * @return AST - The clean sub-tree.
 */
@Override
public AST processEqualityExpression(AST x) {
	if ( x == null ) {
		LOG.processEqualityExpression();
		return null;
	}

	int type = x.getType();
	if ( type == EQ || type == NE ) {
		boolean negated = type == NE;
		if ( x.getNumberOfChildren() == 2 ) {
			AST a = x.getFirstChild();
			AST b = a.getNextSibling();
			// (EQ NULL b) => (IS_NULL b)
			if ( a.getType() == NULL && b.getType() != NULL ) {
				return createIsNullParent( b, negated );
			}
			// (EQ a NULL) => (IS_NULL a)
			else if ( b.getType() == NULL && a.getType() != NULL ) {
				return createIsNullParent( a, negated );
			}
			else if ( b.getType() == EMPTY ) {
				return processIsEmpty( a, negated );
			}
			else {
				return x;
			}
		}
		else {
			return x;
		}
	}
	else {
		return x;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:HqlParser.java

示例13: match

import antlr.collections.AST; //导入方法依赖的package包/类
protected void match(AST t, int ttype) throws MismatchedTokenException {
    //System.out.println("match("+ttype+"); cursor is "+t);
    if (t == null || t == ASTNULL || t.getType() != ttype) {
        throw new MismatchedTokenException(getTokenNames(), t, ttype, false);
    }
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:7,代码来源:TreeParser.java

示例14: isDotNode

import antlr.collections.AST; //导入方法依赖的package包/类
private boolean isDotNode(AST n) {
	return n != null && n.getType() == SqlTokenTypes.DOT;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:DotNode.java

示例15: resolve

import antlr.collections.AST; //导入方法依赖的package包/类
public void resolve(boolean generateJoin, boolean implicitJoin, String classAlias, AST parent) {
	if (!isResolved()) {
		if (getWalker().getCurrentFromClause().isFromElementAlias(getText())) {
			if (resolveAsAlias()) {
				setResolved();
				// We represent a from-clause alias
			}
		}
		else if (parent != null && parent.getType() == SqlTokenTypes.DOT) {
			DotNode dot = (DotNode) parent;
			if (parent.getFirstChild() == this) {
				if (resolveAsNakedComponentPropertyRefLHS(dot)) {
					// we are the LHS of the DOT representing a naked comp-prop-ref
					setResolved();
				}
			}
			else {
				if (resolveAsNakedComponentPropertyRefRHS(dot)) {
					// we are the RHS of the DOT representing a naked comp-prop-ref
					setResolved();
				}
			}
		}
		else {
			DereferenceType result = resolveAsNakedPropertyRef();
			if (result == DereferenceType.PROPERTY_REF) {
				// we represent a naked (simple) prop-ref
				setResolved();
			}
			else if (result == DereferenceType.COMPONENT_REF) {
				// EARLY EXIT!!!  return so the resolve call explicitly coming from DotNode can
				// resolve this...
				return;
			}
		}

		// if we are still not resolved, we might represent a constant.
		//      needed to add this here because the allowance of
		//      naked-prop-refs in the grammar collides with the
		//      definition of literals/constants ("nondeterminism").
		//      TODO: cleanup the grammar so that "processConstants" is always just handled from here
		if (!isResolved()) {
			try {
				getWalker().getLiteralProcessor().processConstant(this, false);
			}
			catch (Throwable ignore) {
				// just ignore it for now, it'll get resolved later...
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:IdentNode.java


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