當前位置: 首頁>>代碼示例>>Java>>正文


Java Token.getType方法代碼示例

本文整理匯總了Java中org.antlr.v4.runtime.Token.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java Token.getType方法的具體用法?Java Token.getType怎麽用?Java Token.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.antlr.v4.runtime.Token的用法示例。


在下文中一共展示了Token.getType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: slashIsRegex

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
@Override
protected boolean slashIsRegex() {
    Token lastToken = getPreviousToken();
    if (lastToken == null) {
        return true;
    }
    switch (lastToken.getType()) {
    case PainlessLexer.RBRACE:
    case PainlessLexer.RP:
    case PainlessLexer.OCTAL:
    case PainlessLexer.HEX:
    case PainlessLexer.INTEGER:
    case PainlessLexer.DECIMAL:
    case PainlessLexer.ID:
    case PainlessLexer.DOTINTEGER:
    case PainlessLexer.DOTID:
        return false;
    default:
        return true;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:EnhancedPainlessLexer.java

示例2: recover

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
@Override
public void recover(final Parser recognizer, final RecognitionException re) {
    final Token token = re.getOffendingToken();
    String message;

    if (token == null) {
        message = "no parse token found.";
    } else if (re instanceof InputMismatchException) {
        message = "unexpected token [" + getTokenErrorDisplay(token) + "]" +
                " was expecting one of [" + re.getExpectedTokens().toString(recognizer.getVocabulary()) + "].";
    } else if (re instanceof NoViableAltException) {
        if (token.getType() == PainlessParser.EOF) {
            message = "unexpected end of script.";
        } else {
            message = "invalid sequence of tokens near [" + getTokenErrorDisplay(token) + "].";
        }
    } else {
        message =  "unexpected token near [" + getTokenErrorDisplay(token) + "].";
    }

    Location location = new Location(sourceName, token == null ? -1 : token.getStartIndex());
    throw location.createError(new IllegalArgumentException(message, re));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:24,代碼來源:ParserErrorStrategy.java

示例3: dot

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
/**
 "If an operator has whitespace on the right side only, it is treated as a
 postfix unary operator. As an example, the ++ operator in a++ b is treated
 as a postfix unary operator."
 "If an operator has no whitespace on the left but is followed immediately
 by a dot (.), it is treated as a postfix unary operator. As an example,
 the ++ operator in a++.b is treated as a postfix unary operator (a++ .b
 rather than a ++ .b)."
 */
public static boolean isPostfixOp(TokenStream tokens) {
	int stop = getLastOpTokenIndex(tokens);
	if ( stop==-1 ) return false;

	int start = tokens.index();
	Token prevToken = tokens.get(start-1); // includes hidden-channel tokens
	Token nextToken = tokens.get(stop+1);
	boolean prevIsWS = isLeftOperatorWS(prevToken);
	boolean nextIsWS = isRightOperatorWS(nextToken);
	boolean result =
		!prevIsWS && nextIsWS ||
		!prevIsWS && nextToken.getType()==SwiftParser.DOT;
	String text = tokens.getText(Interval.of(start, stop));
	//System.out.println("isPostfixOp: '"+prevToken+"','"+text+"','"+nextToken+"' is "+result);
	return result;
}
 
開發者ID:marcelganczak,項目名稱:ts-swift-transpiler,代碼行數:26,代碼來源:SwiftSupport.java

示例4: 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

示例5: 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

示例6: 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

示例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;
    }

    throw new IllegalArgumentException("Unsupported interval field: " + token.getText());
}
 
開發者ID:dbiir,項目名稱:rainbow,代碼行數:20,代碼來源:AstBuilder.java

示例8: initIfFirstRun

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private void initIfFirstRun() {
  if (indentations.isEmpty()) {
    indentations.push(0);
    // First invocation. Look for the first non-NL. Enqueue it, and possibly an indentation if that non-NL
    // token doesn't start at char 0.
    Token firstRealToken;
    do {
      firstRealToken = pullToken();
    }
    while(firstRealToken.getType() == nlToken);

    if (firstRealToken.getCharPositionInLine() > 0) {
      indentations.push(firstRealToken.getCharPositionInLine());
      dentsBuffer.add(createToken(indentToken, firstRealToken));
    }
    dentsBuffer.add(firstRealToken);
  }
}
 
開發者ID:Khushmeet,項目名稱:newton,代碼行數:19,代碼來源:DenterHelper.java

示例9: 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

示例10: nextToken

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
public Token nextToken() {
  initIfFirstRun();
  Token t = dentsBuffer.isEmpty()
    ? pullToken()
    : dentsBuffer.remove();
  if (reachedEof) {
    return t;
  }
  final Token r;
  if (t.getType() == nlToken) {
    r = handleNewlineToken(t);
  } else if (t.getType() == Token.EOF) {
    r = eofHandler.apply(t);

  } else {
    r = t;
  }
  return r;
}
 
開發者ID:Khushmeet,項目名稱:newton,代碼行數:20,代碼來源:DenterHelper.java

示例11: computeFeatureVectorForToken

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
public void computeFeatureVectorForToken(int i) {
	Token curToken = tokens.get(i);
	if ( curToken.getType()==Token.EOF ) return;

	int[] features = getFeatures(i);

	int injectNL_WS = getInjectWSCategory(tokens, i);

	int aligned = -1; // "don't care"
	if ( (injectNL_WS&0xFF)==CAT_INJECT_NL ) {
		TerminalNode node = tokenToNodeMap.get(curToken);
		aligned = getAlignmentCategory(doc, node, indentSize);
	}

	// track feature -> injectws, align decisions for token i
	corpus.addExemplar(doc, features, injectNL_WS, aligned);
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:18,代碼來源:Trainer.java

示例12: 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

示例13: insertSemicolon

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private static boolean insertSemicolon(Token previous, Token next) {
    if (previous == null || next.getType() != PainlessLexer.RBRACK) {
        return false;
    }
    switch (previous.getType()) {
    case PainlessLexer.RBRACK:     // };} would be weird!
    case PainlessLexer.SEMICOLON:  // already have a semicolon, no need to add one
    case PainlessLexer.LBRACK:     // empty blocks don't need a semicolon
        return false;
    default:
        return true;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,代碼來源:EnhancedPainlessLexer.java

示例14: emit

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
public void emit(Token token) {
    tokenIndex++;
    lastTokenType = token.getType();
    //System.out.println("EM: " + tokenNames[lastTokenType != -1 ? lastTokenType : 0] + ": " + lastTokenType + " TLE = " + (tlePos == tokenIndex) + " " + tlePos + "/" + tokenIndex + " " + token.getText());
    if (token.getType() == ROLLBACK_ONE) {
       ((PositionAdjustingLexerATNSimulator)getInterpreter()).resetAcceptPosition(getInputStream(), _tokenStartCharIndex - 1, _tokenStartLine, _tokenStartCharPositionInLine - 1);
    }
    super.emit(token);
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:10,代碼來源:GroovyLexer.java

示例15: binaryOperationFromToken

import org.antlr.v4.runtime.Token; //導入方法依賴的package包/類
private BinaryFunctionExpr.Op binaryOperationFromToken(Token token) {
  switch (token.getType()) {
    case CellExpressionLexer.EQUALS:
      return BinaryFunctionExpr.Op.EQUALS;
    case CellExpressionLexer.NOT_EQUALS:
      return BinaryFunctionExpr.Op.NOT_EQUALS;
    case CellExpressionLexer.GREATER_THAN:
      return BinaryFunctionExpr.Op.GREATER_THAN;
    case CellExpressionLexer.GREATER_EQUALS:
      return BinaryFunctionExpr.Op.GREATER_EQUALS;
    case CellExpressionLexer.LESS_THAN:
      return BinaryFunctionExpr.Op.LESS_THAN;
    case CellExpressionLexer.LESS_EQUALS:
      return BinaryFunctionExpr.Op.LESS_EQUALS;
    case CellExpressionLexer.AND:
      return BinaryFunctionExpr.Op.AND;
    case CellExpressionLexer.OR:
      return BinaryFunctionExpr.Op.OR;
    case CellExpressionLexer.XOR:
      return BinaryFunctionExpr.Op.XOR;
    case CellExpressionLexer.PLUS:
      return BinaryFunctionExpr.Op.PLUS;
    case CellExpressionLexer.MINUS:
      return BinaryFunctionExpr.Op.MINUS;
    case CellExpressionLexer.MULT:
      return BinaryFunctionExpr.Op.MULTIPLICATION;
    case CellExpressionLexer.DIV:
      return BinaryFunctionExpr.Op.DIVISION;
    case CellExpressionLexer.MOD:
      return BinaryFunctionExpr.Op.MODULO;
    default:
      throw new ParseRuntimeException(
          new ParseException(token.getLine(), token.getCharPositionInLine(),
              "Unsupported singlesided operation: \"" + token.getType() + "\""));
  }
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:37,代碼來源:ExpressionParser.java


注:本文中的org.antlr.v4.runtime.Token.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。