當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。