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


Java Token.getText方法代码示例

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


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

示例1: resolveType

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private EObject resolveType(final ParserRuleContext ruleContext, final EObject superType) {
    final EObject resolvedType;

    if (superType.eIsProxy()) {
        resolvedType = null;
    } else {
        resolvedType = create(superType.eClass(), ruleContext);
        EcoreUtil.replace(unresolved, resolvedType);

        final Token nameToken = ruleContext.getStart();
        final String name = nameToken.getText();
        final Scope typeScope = scope.with(resolvedType, TYPE_CONTAINER__TYPES);

        typeScope.with(IDENTIFIABLE_ELEMENT__NAME)
                .setValue(name, nameToken);

        typeScope.with(unresolved.eClass().getEStructuralFeature("type"))
                .setValue(superType, nameToken);
    }

    return resolvedType;
}
 
开发者ID:vrapio,项目名称:rest-modeling-framework,代码行数:23,代码来源:TypeDeclarationResolver.java

示例2: getArithmeticBinaryOperator

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static ArithmeticBinaryExpression.Type getArithmeticBinaryOperator(Token operator)
{
    switch (operator.getType()) {
        case SqlBaseLexer.PLUS:
            return ArithmeticBinaryExpression.Type.ADD;
        case SqlBaseLexer.MINUS:
            return ArithmeticBinaryExpression.Type.SUBTRACT;
        case SqlBaseLexer.ASTERISK:
            return ArithmeticBinaryExpression.Type.MULTIPLY;
        case SqlBaseLexer.SLASH:
            return ArithmeticBinaryExpression.Type.DIVIDE;
        case SqlBaseLexer.PERCENT:
            return ArithmeticBinaryExpression.Type.MODULUS;
    }

    throw new UnsupportedOperationException("Unsupported operator: " + operator.getText());
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:18,代码来源:AstBuilder.java

示例3: getComparisonOperator

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static ComparisonExpressionType getComparisonOperator(Token symbol)
{
    switch (symbol.getType()) {
        case SqlBaseLexer.EQ:
            return ComparisonExpressionType.EQUAL;
        case SqlBaseLexer.NEQ:
            return ComparisonExpressionType.NOT_EQUAL;
        case SqlBaseLexer.LT:
            return ComparisonExpressionType.LESS_THAN;
        case SqlBaseLexer.LTE:
            return ComparisonExpressionType.LESS_THAN_OR_EQUAL;
        case SqlBaseLexer.GT:
            return ComparisonExpressionType.GREATER_THAN;
        case SqlBaseLexer.GTE:
            return ComparisonExpressionType.GREATER_THAN_OR_EQUAL;
    }

    throw new IllegalArgumentException("Unsupported operator: " + symbol.getText());
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:20,代码来源:AstBuilder.java

示例4: getDateTimeFunctionType

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static CurrentTime.Type getDateTimeFunctionType(Token token)
{
    switch (token.getType()) {
        case SqlBaseLexer.CURRENT_DATE:
            return CurrentTime.Type.DATE;
        case SqlBaseLexer.CURRENT_TIME:
            return CurrentTime.Type.TIME;
        case SqlBaseLexer.CURRENT_TIMESTAMP:
            return CurrentTime.Type.TIMESTAMP;
        case SqlBaseLexer.LOCALTIME:
            return CurrentTime.Type.LOCALTIME;
        case SqlBaseLexer.LOCALTIMESTAMP:
            return CurrentTime.Type.LOCALTIMESTAMP;
    }

    throw new IllegalArgumentException("Unsupported special function: " + token.getText());
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:18,代码来源:AstBuilder.java

示例5: getIntervalFieldType

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static IntervalLiteral.IntervalField getIntervalFieldType(Token token)
{
    switch (token.getType()) {
        case SqlBaseLexer.YEAR:
            return IntervalLiteral.IntervalField.YEAR;
        case SqlBaseLexer.MONTH:
            return IntervalLiteral.IntervalField.MONTH;
        case SqlBaseLexer.DAY:
            return IntervalLiteral.IntervalField.DAY;
        case SqlBaseLexer.HOUR:
            return IntervalLiteral.IntervalField.HOUR;
        case SqlBaseLexer.MINUTE:
            return IntervalLiteral.IntervalField.MINUTE;
        case SqlBaseLexer.SECOND:
            return IntervalLiteral.IntervalField.SECOND;
    }

    throw new IllegalArgumentException("Unsupported interval field: " + token.getText());
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:20,代码来源:AstBuilder.java

示例6: unescapeStringLiteral

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public static String unescapeStringLiteral(TerminalNode terminalNode) {
  Token token = terminalNode.getSymbol();
  if (token.getType() != BQLLexer.STRING_LITERAL) {
    throw new IllegalArgumentException();
  }

  String text = token.getText();
  char initialChar = text.charAt(0);
  if (text.charAt(text.length() - 1) != initialChar) {
    throw new IllegalArgumentException("malformed string literal");
  }

  text = text.substring(1, text.length() - 1);
  if (initialChar == '\'') {
    text = text.replace("''", "'");
  } else if (initialChar == '"') {
    text = text.replace("\"\"", "\"");
  } else {
    throw new UnsupportedOperationException("Not supported yet.");
  }
  return text;
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:23,代码来源:BQLCompilerAnalyzer.java

示例7: getIntervalFieldType

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static IntervalLiteral.IntervalField getIntervalFieldType(Token token) {
  switch (token.getType()) {
    case SqlBaseLexer.YEAR:
      return IntervalLiteral.IntervalField.YEAR;
    case SqlBaseLexer.MONTH:
      return IntervalLiteral.IntervalField.MONTH;
    case SqlBaseLexer.DAY:
      return IntervalLiteral.IntervalField.DAY;
    case SqlBaseLexer.HOUR:
      return IntervalLiteral.IntervalField.HOUR;
    case SqlBaseLexer.MINUTE:
      return IntervalLiteral.IntervalField.MINUTE;
    case SqlBaseLexer.SECOND:
      return IntervalLiteral.IntervalField.SECOND;
    default:
      throw new IllegalArgumentException("Unsupported interval field: " + token.getText());
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:19,代码来源:AstBuilder.java

示例8: getComparisonOperator

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static ComparisonExpression.Type getComparisonOperator(Token symbol) {
  switch (symbol.getType()) {
    case SqlBaseLexer.EQ:
      return ComparisonExpression.Type.EQUAL;
    case SqlBaseLexer.NEQ:
      return ComparisonExpression.Type.NOT_EQUAL;
    case SqlBaseLexer.LT:
      return ComparisonExpression.Type.LESS_THAN;
    case SqlBaseLexer.LTE:
      return ComparisonExpression.Type.LESS_THAN_OR_EQUAL;
    case SqlBaseLexer.GT:
      return ComparisonExpression.Type.GREATER_THAN;
    case SqlBaseLexer.GTE:
      return ComparisonExpression.Type.GREATER_THAN_OR_EQUAL;
    default:
      throw new IllegalArgumentException("Unsupported operator: " + symbol.getText());
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:19,代码来源:AstBuilder.java

示例9: exitFunctionDecl

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
@Override
public void exitFunctionDecl(HogwashParser.FunctionDeclContext ctx) {
	boolean optionalArgsStarted = false;
	for (Symbol sym : this.currentScope.getAllSymbols()) {
		ArgumentSymbol arg = (ArgumentSymbol) sym;
		if (arg.hasDefault()) optionalArgsStarted = true;
		else if (optionalArgsStarted) {
			Token tk = arg.getToken();
			String name = tk.getText();
			ErrorMessage em = new ErrorMessage(ErrorKind.OPT_ARG_NOT_LAST, name);
			this.generateError(arg.getToken(), em);
			break;
		}
	}
	this.currentScope = this.currentScope.getEnclosingScope();
}
 
开发者ID:loganbraga,项目名称:hogwash,代码行数:17,代码来源:DefinePhase.java

示例10: exitDeclaration

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
@Override
public void exitDeclaration(ObjCParser.DeclarationContext ctx) {
    String decl = getCode(ctx.declaration_minus_semi()) + ";\n";

    //获取注释
    Token prior = ctx.getStart();
    int indx = prior.getTokenIndex();
    List<Token> cmtChannel = tokens.getHiddenTokensToLeft(indx,
            ObjCLexer.COMMENT_CHANNEL);
    if (cmtChannel != null) {
        String txt = "";
        for (Token cmt : cmtChannel) {
            if (cmt != null) {
                txt = txt + cmt.getText() + "\n";
            }
        }
        setComment(ctx, txt);
    }
    if (getComment(ctx) != null) {
        decl = getComment(ctx) + decl;
    }

    setCode(ctx, decl);
}
 
开发者ID:Consoar,项目名称:Objc2Lua,代码行数:25,代码来源:ParserObjcListener.java

示例11: enterVerbExpr

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
@Override
public void enterVerbExpr(
		de.interactive_instruments.antlr.sbvr.SBVRParser.VerbExprContext ctx) {

	Token verbToken = ctx.verb;

	if (verbToken != null) {

		String concept = verbToken.getText();
		/*
		 * TODO this simple noun check is usually done automatically using the
		 * SbvrParserHelper; a more thorough test could be performed here
		 */
		if (!isVerb(concept)) {
			String msg = concept + " is not a known verb concept.";
			addErrorMessage(Category.NOT_A_VERB_CONCEPT, msg, verbToken);
		}
	}
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:20,代码来源:SbvrValidationErrorListener.java

示例12: getArithmeticBinaryOperator

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
private static ArithmeticBinaryExpression.Type getArithmeticBinaryOperator(Token operator) {
  switch (operator.getType()) {
    case SqlBaseLexer.PLUS:
      return ArithmeticBinaryExpression.Type.ADD;
    case SqlBaseLexer.MINUS:
      return ArithmeticBinaryExpression.Type.SUBTRACT;
    case SqlBaseLexer.ASTERISK:
      return ArithmeticBinaryExpression.Type.MULTIPLY;
    case SqlBaseLexer.SLASH:
      return ArithmeticBinaryExpression.Type.DIVIDE;
    case SqlBaseLexer.PERCENT:
      return ArithmeticBinaryExpression.Type.MODULUS;
    default:
      throw new UnsupportedOperationException("Unsupported operator: " + operator.getText());
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:17,代码来源:AstBuilder.java

示例13: visitNameExpr

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
@Override
public Expression visitNameExpr(NameExprContext ctx) {

	List<String> names = new ArrayList<String>();

	for (Token t : ctx.values) {
		String s = t.getText();
		// strip leading and trailing "'"
		names.add(s.substring(1, s.length() - 1));
	}

	if (names.size() == 1) {

		StringLiteral sl = new StringLiteral();
		sl.setValue(names.get(0));
		return sl;

	} else {

		StringLiteralList sll = new StringLiteralList();
		sll.setValues(names);

		return sll;
	}
}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:26,代码来源:Sbvr2FolVisitor.java

示例14: resolve

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public Symbol resolve(Token token) throws UndefinedIdentifierException {
    String id = token.getText();
    if (!table.containsKey(id)) {
        throw new UndefinedIdentifierException(new Symbol(token));
    }
    return table.get(id);
}
 
开发者ID:xephonhq,项目名称:tsdb-proxy-java,代码行数:8,代码来源:SymbolTable.java

示例15: Symbol

import org.antlr.v4.runtime.Token; //导入方法依赖的package包/类
public Symbol(Token token) {
    this.id = token.getText();
    line = token.getLine();
    // TODO: do we need + 1? since in a lot of editors column and line all starts from 1
    // in ANTLR line starts from 1, but char index start from 0
    column = token.getCharPositionInLine();
    type = DataType.UNDEFINED_TYPE;
}
 
开发者ID:xephonhq,项目名称:tsdb-proxy-java,代码行数:9,代码来源:Symbol.java


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