本文整理汇总了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 );
}
}
示例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();
}
}
}
示例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 );
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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" );
}
示例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" );
}
示例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() );
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例14: isDotNode
import antlr.collections.AST; //导入方法依赖的package包/类
private boolean isDotNode(AST n) {
return n != null && n.getType() == SqlTokenTypes.DOT;
}
示例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...
}
}
}
}