org.antlr.v4.tool.Grammar.getMaxTokenType()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.antlr.v4.tool.Grammar.getMaxTokenType()方法的一些代码示例,展示了Grammar.getMaxTokenType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grammar.getMaxTokenType()方法的具体详情如下:
包路径:org.antlr.v4.tool.Grammar
类名称:Grammar
方法名:getMaxTokenType

Grammar.getMaxTokenType介绍

[英]How many token types have been allocated so far?
[中]到目前为止分配了多少令牌类型?

代码示例

代码示例来源:origin: org.antlr/antlr4

/**
 * Gets the symbolic names assigned to tokens in the grammar.
 */
public String[] getTokenSymbolicNames() {
  int numTokens = getMaxTokenType();
  String[] symbolicNames = new String[numTokens+1];
  for (int i = 0; i < Math.min(symbolicNames.length, typeToTokenList.size()); i++) {
    if (typeToTokenList.get(i) == null || typeToTokenList.get(i).startsWith(AUTO_GENERATED_TOKEN_NAME_PREFIX)) {
      continue;
    }
    symbolicNames[i] = typeToTokenList.get(i);
  }
  return symbolicNames;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Gets the symbolic names assigned to tokens in the grammar.
 */
public String[] getTokenSymbolicNames() {
  int numTokens = getMaxTokenType();
  String[] symbolicNames = new String[numTokens+1];
  for (int i = 0; i < Math.min(symbolicNames.length, typeToTokenList.size()); i++) {
    if (typeToTokenList.get(i) == null || typeToTokenList.get(i).startsWith(AUTO_GENERATED_TOKEN_NAME_PREFIX)) {
      continue;
    }
    symbolicNames[i] = typeToTokenList.get(i);
  }
  return symbolicNames;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Gets the symbolic names assigned to tokens in the grammar.
 */
public String[] getTokenSymbolicNames() {
  int numTokens = getMaxTokenType();
  String[] symbolicNames = new String[numTokens+1];
  for (int i = 0; i < Math.min(symbolicNames.length, typeToTokenList.size()); i++) {
    if (typeToTokenList.get(i) == null || typeToTokenList.get(i).startsWith(AUTO_GENERATED_TOKEN_NAME_PREFIX)) {
      continue;
    }
    symbolicNames[i] = typeToTokenList.get(i);
  }
  return symbolicNames;
}

代码示例来源:origin: uk.co.nichesolutions/antlr4

/**
 * Gets the symbolic names assigned to tokens in the grammar.
 */
public String[] getTokenSymbolicNames() {
  int numTokens = getMaxTokenType();
  String[] symbolicNames = new String[numTokens+1];
  for (int i = 0; i < Math.min(symbolicNames.length, typeToTokenList.size()); i++) {
    if (typeToTokenList.get(i) == null || typeToTokenList.get(i).startsWith(AUTO_GENERATED_TOKEN_NAME_PREFIX)) {
      continue;
    }
    symbolicNames[i] = typeToTokenList.get(i);
  }
  return symbolicNames;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

public ParserATNFactory(Grammar g) {
  if (g == null) {
    throw new NullPointerException("g");
  }
  this.g = g;
  ATNType atnType = g instanceof LexerGrammar ? ATNType.LEXER : ATNType.PARSER;
  int maxTokenType = g.getMaxTokenType();
  this.atn = new ATN(atnType, maxTokenType);
}

代码示例来源:origin: org.antlr/antlr4

public ParserATNFactory(Grammar g) {
  if (g == null) {
    throw new NullPointerException("g");
  }
  this.g = g;
  ATNType atnType = g instanceof LexerGrammar ? ATNType.LEXER : ATNType.PARSER;
  int maxTokenType = g.getMaxTokenType();
  this.atn = new ATN(atnType, maxTokenType);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public ParserATNFactory(Grammar g) {
  if (g == null) {
    throw new NullPointerException("g");
  }
  this.g = g;
  ATNType atnType = g instanceof LexerGrammar ? ATNType.LEXER : ATNType.PARSER;
  int maxTokenType = g.getMaxTokenType();
  this.atn = new ATN(atnType, maxTokenType);
}

代码示例来源:origin: uk.co.nichesolutions/antlr4

public ParserATNFactory(Grammar g) {
  if (g == null) {
    throw new NullPointerException("g");
  }
  this.g = g;
  ATNType atnType = g instanceof LexerGrammar ? ATNType.LEXER : ATNType.PARSER;
  int maxTokenType = g.getMaxTokenType();
  this.atn = new ATN(atnType, maxTokenType);
}

代码示例来源:origin: uk.co.nichesolutions/antlr4

/**
 * Gets the literal names assigned to tokens in the grammar.
 */
public String[] getTokenLiteralNames() {
  int numTokens = getMaxTokenType();
  String[] literalNames = new String[numTokens+1];
  for (int i = 0; i < Math.min(literalNames.length, typeToStringLiteralList.size()); i++) {
    literalNames[i] = typeToStringLiteralList.get(i);
  }
  for (Map.Entry<String, Integer> entry : stringLiteralToTypeMap.entrySet()) {
    if (entry.getValue() >= 0 && entry.getValue() < literalNames.length && literalNames[entry.getValue()] == null) {
      literalNames[entry.getValue()] = entry.getKey();
    }
  }
  return literalNames;
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4

/**
 * Gets the symbolic names assigned to tokens in the grammar.
 */
@NotNull
public String[] getTokenSymbolicNames() {
  int numTokens = getMaxTokenType();
  String[] symbolicNames = new String[numTokens+1];
  for (int i = 0; i < Math.min(symbolicNames.length, typeToTokenList.size()); i++) {
    if (typeToTokenList.get(i) == null || typeToTokenList.get(i).startsWith(AUTO_GENERATED_TOKEN_NAME_PREFIX)) {
      continue;
    }
    symbolicNames[i] = typeToTokenList.get(i);
  }
  return symbolicNames;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Gets an array of display names for tokens defined or imported by the
 * grammar. The array index is the token type, and the value is the result
 * of {@link #getTokenDisplayName} for the corresponding token type.
 *
 * @see #getTokenDisplayName
 * @return The display names of all tokens defined in the grammar.
 */
public String[] getTokenDisplayNames() {
  int numTokens = getMaxTokenType();
  String[] tokenNames = new String[numTokens+1];
  for (int i = 0; i < tokenNames.length; i++) {
    tokenNames[i] = getTokenDisplayName(i);
  }
  return tokenNames;
}

代码示例来源:origin: org.antlr/antlr4

/**
 * Gets an array of token names for tokens defined or imported by the
 * grammar. The array index is the token type, and the value is the result
 * of {@link #getTokenName} for the corresponding token type.
 *
 * @see #getTokenName
 * @return The token names of all tokens defined in the grammar.
 */
public String[] getTokenNames() {
  int numTokens = getMaxTokenType();
  String[] tokenNames = new String[numTokens+1];
  for (int i = 0; i < tokenNames.length; i++) {
    tokenNames[i] = getTokenName(i);
  }
  return tokenNames;
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4

/**
 * Gets an array of token names for tokens defined or imported by the
 * grammar. The array index is the token type, and the value is the result
 * of {@link #getTokenName} for the corresponding token type.
 *
 * @see #getTokenName
 * @return The token names of all tokens defined in the grammar.
 */
public String[] getTokenNames() {
  int numTokens = getMaxTokenType();
  String[] tokenNames = new String[numTokens+1];
  for (int i = 0; i < tokenNames.length; i++) {
    tokenNames[i] = getTokenName(i);
  }
  return tokenNames;
}

代码示例来源:origin: uk.co.nichesolutions/antlr4

/**
 * Gets an array of display names for tokens defined or imported by the
 * grammar. The array index is the token type, and the value is the result
 * of {@link #getTokenDisplayName} for the corresponding token type.
 *
 * @see #getTokenDisplayName
 * @return The display names of all tokens defined in the grammar.
 */
public String[] getTokenDisplayNames() {
  int numTokens = getMaxTokenType();
  String[] tokenNames = new String[numTokens+1];
  for (int i = 0; i < tokenNames.length; i++) {
    tokenNames[i] = getTokenDisplayName(i);
  }
  return tokenNames;
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4

public ParserATNFactory(@NotNull Grammar g) {
  if (g == null) {
    throw new NullPointerException("g");
  }
  this.g = g;
  ATNType atnType = g instanceof LexerGrammar ? ATNType.LEXER : ATNType.PARSER;
  int maxTokenType = g.getMaxTokenType();
  this.atn = new ATN(atnType, maxTokenType);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/** Return a set of all possible token or char types for this grammar */
public IntSet getTokenTypes() {
  if ( isLexer() ) {
    return getAllCharValues();
  }
  return IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, getMaxTokenType());
}

代码示例来源:origin: org.antlr/antlr4

/** Return a set of all possible token or char types for this grammar */
public IntSet getTokenTypes() {
  if ( isLexer() ) {
    return getAllCharValues();
  }
  return IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, getMaxTokenType());
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4

/** Return a set of all possible token or char types for this grammar */
public IntSet getTokenTypes() {
  if ( isLexer() ) {
    return getAllCharValues();
  }
  return IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, getMaxTokenType());
}

代码示例来源:origin: uk.co.nichesolutions/antlr4

/** Return a set of all possible token or char types for this grammar */
public IntSet getTokenTypes() {
  if ( isLexer() ) {
    return getAllCharValues();
  }
  return IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, getMaxTokenType());
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/** Return a set of all possible token or char types for this grammar */
public IntSet getTokenTypes() {
  if ( isLexer() ) {
    return getAllCharValues();
  }
  return IntervalSet.of(Token.MIN_USER_TOKEN_TYPE, getMaxTokenType());
}

相关文章