本文整理汇总了Java中org.antlr.runtime.tree.CommonTree.getType方法的典型用法代码示例。如果您正苦于以下问题:Java CommonTree.getType方法的具体用法?Java CommonTree.getType怎么用?Java CommonTree.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.runtime.tree.CommonTree
的用法示例。
在下文中一共展示了CommonTree.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertNode
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static Object convertNode(CommonTree node, DatabaseDialect dialect) {
switch (node.getType()) {
case SQLLexer.CREATE_TABLE: return convertCreateTable(node, dialect);
case SQLLexer.DROP_TABLE: return convertDropTable(node);
case SQLLexer.ALTER_TABLE: return convertAlterTable(node);
case SQLLexer.CREATE_SEQUENCE: return convertCreateSequence(node);
case SQLLexer.DROP_SEQUENCE: return convertDropSequence(node);
case SQLLexer.CREATE_INDEX: return convertCreateIndex(node);
case SQLLexer.COMMENT_TABLE: return convertTableComment(node);
case SQLLexer.COMMENT_COLUMN: return convertColumnComment(node);
}
if (node.isNil()) {
List<Object> nodes = convertNodes(getChildNodes(node), dialect);
return nodes.toArray();
}
throw new ParseException("Unknown token type", "'" + node.getText() + "'");
}
示例2: convertColumnSpec
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static void convertColumnSpec(CommonTree node, DBTable table) {
String columnName = convertString(childAt(0, node));
String columnTypeName;
Integer size = null;
Integer fractionDigits = null;
int detailOffset = 2;
columnTypeName = convertString(childAt(1, node));
if (node.getChildCount() > 2 && childAt(2, node).getType() == SQLLexer.SIZE) {
detailOffset++;
CommonTree sizeNode = childAt(2, node);
size = convertInteger(childAt(0, sizeNode));
if (sizeNode.getChildCount() > 1) {
CommonTree subNode2 = childAt(1, sizeNode);
if (subNode2.getType() == SQLLexer.INT) {
fractionDigits = convertInteger(subNode2);
} else {
// TODO v1.0 support (n BYTE) / (n CHAR)
}
}
}
DBColumn column = new DBColumn(columnName, table, DBDataType.getInstance(columnTypeName), size, fractionDigits);
table.addColumn(column);
for (int i = detailOffset; i < node.getChildCount(); i++)
convertColumnDetail(childAt(i, node), column);
}
示例3: hasOptionalFieldReference
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static boolean hasOptionalFieldReference(CommonTree node)
{
switch (node.getType())
{
case FTSParser.TERM:
case FTSParser.EXACT_TERM:
case FTSParser.PHRASE:
case FTSParser.EXACT_PHRASE:
case FTSParser.SYNONYM:
case FTSParser.PROXIMITY:
case FTSParser.RANGE:
return true;
default:
return false;
}
}
示例4: buildNegation
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
/**
* @param notNode CommonTree
* @param factory QueryModelFactory
* @param functionEvaluationContext FunctionEvaluationContext
* @param selectors Map<String, Selector>
* @param columnMap HashMap<String, Column>
* @return Constraint
*/
private Constraint buildNegation(CommonTree notNode, QueryModelFactory factory,
FunctionEvaluationContext functionEvaluationContext, Map<String, Selector> selectors,
HashMap<String, Column> columnMap)
{
if (notNode.getType() == CMISParser.NEGATION)
{
Constraint constraint = buildTest((CommonTree) notNode.getChild(0), factory, functionEvaluationContext,
selectors, columnMap);
constraint.setOccur(Occur.EXCLUDE);
return constraint;
} else
{
return buildTest(notNode, factory, functionEvaluationContext, selectors, columnMap);
}
}
示例5: buildFTSTest
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
static private Constraint buildFTSTest(CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext,
Selector selector, Map<String, Column> columnMap, String defaultField)
{
CommonTree testNode = argNode;
switch (testNode.getType())
{
case CMIS_FTSParser.DISJUNCTION:
case CMIS_FTSParser.CONJUNCTION:
return buildFTSConnective(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField);
case CMIS_FTSParser.TERM:
return buildTerm(testNode, factory, functionEvaluationContext, selector, columnMap);
case CMIS_FTSParser.PHRASE:
return buildPhrase(testNode, factory, functionEvaluationContext, selector, columnMap);
default:
throw new FTSQueryException("Unsupported FTS option " + testNode.getText());
}
}
示例6: convertExpressionNode
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private static Expression convertExpressionNode(CommonTree node) {
switch (node.getType()) {
case SQLLexer.OR: return convertOr(node);
case SQLLexer.AND: return convertAnd(node);
case SQLLexer.XOR: return convertXor(node);
case SQLLexer.EQ: return convertEq(node);
case SQLLexer.BANGEQ: return convertBangEq(node);
case SQLLexer.LTGT: return convertBangEq(node); // <>
case SQLLexer.GT: return convertGt(node);
case SQLLexer.GE: return convertGe(node);
case SQLLexer.LT: return convertLt(node);
case SQLLexer.LE: return convertLe(node);
case SQLLexer.IS: return convertIs(node);
case SQLLexer.NOT: return convertNot(node);
case SQLLexer.NULL: return convertNull(node);
case SQLLexer.LIKE: return convertLike(node);
case SQLLexer.IN: return convertIn(node);
case SQLLexer.BETWEEN: return convertBetween(node);
case SQLLexer.PLUS: return convertPlus(node);
case SQLLexer.SUB: return convertSub(node);
case SQLLexer.STAR: return convertStar(node);
case SQLLexer.SLASH: return convertSlash(node);
case SQLLexer.PERCENT: return convertPercent(node);
case SQLLexer.BARBAR: return convertBarBar(node);
case SQLLexer.INVOCATION: return convertInvocation(node);
case SQLLexer.QUOTED_NAME: return convertQuotedName(node);
case SQLLexer.IDENTIFIER: return convertIdentifier(node);
case SQLLexer.STRING: return convertStringToExpression(node);
case SQLLexer.INT: return convertInt(node);
default: throw new ParseException("Unknown token type (" + node.getType() + ")", "'" + node.getText() + "'");
}
}
示例7: convertLike
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static Expression<?> convertLike(CommonTree node) {
Expression<?> valueEx = convertExpressionNode(childAt(0, node));
CommonTree child1 = childAt(1, node);
boolean not = (child1.getType() == SQLLexer.NOT);
int collectionIndex = (not ? 2 : 1);
Expression<?> refEx = convertExpressionNode(childAt(collectionIndex, node));
Expression<?> result = new LikeExpression(valueEx, refEx);
if (not)
result = new LogicalComplementExpression(result);
return result;
}
示例8: convertIn
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static Expression<?> convertIn(CommonTree node) {
Expression<?> valueEx = convertExpressionNode(childAt(0, node));
CommonTree child1 = childAt(1, node);
boolean not = (child1.getType() == SQLLexer.NOT);
int collectionIndex = (not ? 2 : 1);
Expression<? extends Collection<?>> collEx = convertValueList(childAt(collectionIndex, node));
Expression<?> result = new ValueCollectionContainsExpression("IN", valueEx, collEx);
if (not)
result = new LogicalComplementExpression(result);
return result;
}
示例9: convertTableDetail
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static void convertTableDetail(CommonTree node, DBTable table, DatabaseDialect dialect) {
switch (node.getType()) {
case SQLLexer.COLUMN_SPEC: convertColumnSpec(node, table); break;
case SQLLexer.PRIMARY: convertInlinePK(node, table, dialect); break;
default: throw new ParseException("Unknown table detail token type",
String.valueOf(node.getText()),
node.getLine(),
node.getCharPositionInLine());
}
}
示例10: convertColumnDetail
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static void convertColumnDetail(CommonTree node, DBColumn column) {
switch (node.getType()) {
case SQLLexer.NOT : column.setNullable(false); break;
case SQLLexer.DEFAULT : column.setNullable(false); break;
default: throw new ParseException("Unknown column detail token type",
String.valueOf(node.getText()),
node.getLine(),
node.getCharPositionInLine());
}
}
示例11: createNode
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private HostNode createNode(DefaultHostGraph graph, CommonTree tree) {
HostNode result = graph.addNode();
int tokenType = tree.getType();
graph.addEdge(result,
TypeLabel.createLabel(EdgeRole.NODE_TYPE, this.tokens[tokenType]),
result);
if (this.textTypes.get(tokenType) && tree.getText() != null) {
HostNode nameNode = graph.addNode(JavaStringAlgebra.instance, tree.getText());
graph.addEdge(result, TEXT_LABEL, nameNode);
}
return result;
}
示例12: isAutoPhrasable
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static boolean isAutoPhrasable(CommonTree node, boolean defaultConjunction) {
if((node.getType() == FTSParser.CONJUNCTION) && (node.getChildCount() > 1))
{
int simpleTermCount = 0;
for (Object current : node.getChildren())
{
CommonTree child = (CommonTree) current;
if((child.getType() == FTSParser.MANDATORY) || (child.getType() == FTSParser.DEFAULT))
{
if(child.getChildCount() > 0)
{
CommonTree item = (CommonTree)child.getChild(0);
if((item.getType() == FTSParser.TERM) && (item.getChildCount() == 1))
{
simpleTermCount++;
}
}
}
else
{
return false;
}
}
return simpleTermCount > 1;
}
return false;
}
示例13: setBoost
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
static private void setBoost(Constraint constraint, CommonTree subNode)
{
for (int i = 0, l = subNode.getChildCount(); i < l; i++)
{
CommonTree child = (CommonTree) subNode.getChild(i);
if (child.getType() == FTSParser.BOOST)
{
String boostString = child.getChild(0).getText();
float boost = Float.parseFloat(boostString);
constraint.setBoost(boost);
return;
}
}
}
示例14: isStarWithNoField
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
private static boolean isStarWithNoField(CommonTree testNode)
{
if (testNode.getType() == FTSParser.TERM && testNode.getChildCount() == 1)
{
CommonTree child = (CommonTree) testNode.getChild(0);
if (child.getType() == FTSParser.STAR)
{
return true;
}
}
return false;
}
示例15: findFieldReference
import org.antlr.runtime.tree.CommonTree; //导入方法依赖的package包/类
static private CommonTree findFieldReference(CommonTree node)
{
for (int i = 0, l = node.getChildCount(); i < l; i++)
{
CommonTree child = (CommonTree) node.getChild(i);
if (child.getType() == FTSParser.FIELD_REF)
{
return child;
}
}
return null;
}