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

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

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

Grammar.getTokenType介绍

[英]Return a set of all possible token or char types for this grammar
[中]返回此语法的所有可能的标记或字符类型的集合

代码示例

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

public String getElementName(String name) {
  if (".".equals(name)) {
    return "_wild";
  }
  if ( getCodeGenerator().g.getRule(name)!=null ) return name;
  int ttype = getCodeGenerator().g.getTokenType(name);
  if ( ttype==Token.INVALID_TYPE ) return name;
  return getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
}

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

public String getElementName(String name) {
  if (".".equals(name)) {
    return "_wild";
  }
  if ( getCodeGenerator().g.getRule(name)!=null ) return name;
  int ttype = getCodeGenerator().g.getTokenType(name);
  if ( ttype==Token.INVALID_TYPE ) return name;
  return getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
}

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

public String getElementName(String name) {
  if (".".equals(name)) {
    return "_wild";
  }
  if ( getCodeGenerator().g.getRule(name)!=null ) return name;
  int ttype = getCodeGenerator().g.getTokenType(name);
  if ( ttype==Token.INVALID_TYPE ) return name;
  return getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
}

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

public String getElementName(String name) {
  if (".".equals(name)) {
    return "_wild";
  }
  if ( getCodeGenerator().g.getRule(name)!=null ) return name;
  int ttype = getCodeGenerator().g.getTokenType(name);
  if ( ttype==Token.INVALID_TYPE ) return name;
  return getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
}

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

protected int getTokenType(GrammarAST atom) {
  int ttype;
  if ( g.isLexer() ) {
    ttype = CharSupport.getCharValueFromGrammarCharLiteral(atom.getText());
  }
  else {
    ttype = g.getTokenType(atom.getText());
  }
  return ttype;
}

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

protected int getTokenType(GrammarAST atom) {
  int ttype;
  if ( g.isLexer() ) {
    ttype = CharSupport.getCharValueFromGrammarCharLiteral(atom.getText());
  }
  else {
    ttype = g.getTokenType(atom.getText());
  }
  return ttype;
}

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

protected int getTokenType(GrammarAST atom) {
  int ttype;
  if ( g.isLexer() ) {
    ttype = CharSupport.getCharValueFromGrammarCharLiteral(atom.getText());
  }
  else {
    ttype = g.getTokenType(atom.getText());
  }
  return ttype;
}

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

public String getImplicitTokenLabel(String tokenName) {
  ST st = getTemplates().getInstanceOf("ImplicitTokenLabel");
  int ttype = getCodeGenerator().g.getTokenType(tokenName);
  if ( tokenName.startsWith("'") ) {
    return "s"+ttype;
  }
  String text = getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
  st.add("tokenName", text);
  return st.render();
}

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

public MatchToken(OutputModelFactory factory, TerminalAST ast) {
  super(factory, ast);
  Grammar g = factory.getGrammar();
  CodeGenerator gen = factory.getGenerator();
  ttype = g.getTokenType(ast.getText());
  name = gen.getTarget().getTokenTypeAsTargetLabel(g, ttype);
}

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

public String getImplicitTokenLabel(String tokenName) {
  ST st = getTemplates().getInstanceOf("ImplicitTokenLabel");
  int ttype = getCodeGenerator().g.getTokenType(tokenName);
  if ( tokenName.startsWith("'") ) {
    return "s"+ttype;
  }
  String text = getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
  st.add("tokenName", text);
  return st.render();
}

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

public MatchToken(OutputModelFactory factory, TerminalAST ast) {
  super(factory, ast);
  Grammar g = factory.getGrammar();
  CodeGenerator gen = factory.getGenerator();
  ttype = g.getTokenType(ast.getText());
  name = gen.getTarget().getTokenTypeAsTargetLabel(g, ttype);
}

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

public String getImplicitTokenLabel(String tokenName) {
  ST st = getTemplates().getInstanceOf("ImplicitTokenLabel");
  int ttype = getCodeGenerator().g.getTokenType(tokenName);
  if ( tokenName.startsWith("'") ) {
    return "s"+ttype;
  }
  String text = getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
  st.add("tokenName", text);
  return st.render();
}

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

public MatchToken(OutputModelFactory factory, TerminalAST ast) {
  super(factory, ast);
  Grammar g = factory.getGrammar();
  CodeGenerator gen = factory.getGenerator();
  ttype = g.getTokenType(ast.getText());
  name = gen.getTarget().getTokenTypeAsTargetLabel(g, ttype);
}

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

public MatchToken(OutputModelFactory factory, TerminalAST ast) {
  super(factory, ast);
  Grammar g = factory.getGrammar();
  CodeGenerator gen = factory.getGenerator();
  ttype = g.getTokenType(ast.getText());
  name = gen.getTarget().getTokenTypeAsTargetLabel(g, ttype);
}

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

protected int getTokenType(@NotNull GrammarAST atom) {
  int ttype;
  if ( g.isLexer() ) {
    ttype = CharSupport.getCharValueFromGrammarCharLiteral(atom.getText());
  }
  else {
    ttype = g.getTokenType(atom.getText());
  }
  return ttype;
}

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

public String getImplicitTokenLabel(String tokenName) {
  ST st = getTemplates().getInstanceOf("ImplicitTokenLabel");
  int ttype = getCodeGenerator().g.getTokenType(tokenName);
  if ( tokenName.startsWith("'") ) {
    return "s"+ttype;
  }
  String text = getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
  st.add("tokenName", text);
  return st.render();
}

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

public String getImplicitTokenLabel(String tokenName) {
  ST st = getTemplates().getInstanceOf("ImplicitTokenLabel");
  int ttype = getCodeGenerator().g.getTokenType(tokenName);
  if ( tokenName.startsWith("'") ) {
    return "s"+ttype;
  }
  String text = getTokenTypeAsTargetLabel(getCodeGenerator().g, ttype);
  st.add("tokenName", text);
  return st.render();
}

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

/** From label {@code A} build graph {@code o-A->o}. */
@Override
public Handle tokenRef(TerminalAST node) {
  ATNState left = newState(node);
  ATNState right = newState(node);
  int ttype = g.getTokenType(node.getText());
  left.addTransition(new AtomTransition(right, ttype));
  node.atnState = left;
  return new Handle(left, right);
}

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

/** From label {@code A} build graph {@code o-A->o}. */
@Override
public Handle tokenRef(TerminalAST node) {
  ATNState left = newState(node);
  ATNState right = newState(node);
  int ttype = g.getTokenType(node.getText());
  left.addTransition(new AtomTransition(right, ttype));
  node.atnState = left;
  return new Handle(left, right);
}

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

/** From label {@code A} build graph {@code o-A->o}. */
@NotNull
@Override
public Handle tokenRef(@NotNull TerminalAST node) {
  ATNState left = newState(node);
  ATNState right = newState(node);
  int ttype = g.getTokenType(node.getText());
  left.addTransition(new AtomTransition(right, ttype));
  node.atnState = left;
  return new Handle(left, right);
}

相关文章