antlr.Token.getText()方法的使用及代码示例

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

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

Token.getText介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

protected String retrieveLookAheadText(int lookAheadPosition) throws TokenStreamException {
  Token token = LT(lookAheadPosition);
  return token == null ? null : token.getText();
}

代码示例来源:origin: jenkinsci/jenkins

public final int  token() throws RecognitionException, TokenStreamException {
  int value=0;
  
  Token  t = null;
  
  t = LT(1);
  match(TOKEN);
  if ( inputState.guessing==0 ) {
    
    value = Integer.parseInt(t.getText());
    
  }
  return value;
}

代码示例来源:origin: hibernate/hibernate-orm

protected void out(Token token) {
  out( token.getText() );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void initialize(Token tok) {
  super.initialize(tok);
  filename = tok.getFilename();
  line = tok.getLine();
  column = tok.getColumn();
  String text = tok.getText();
  textLength = StringHelper.isEmpty(text) ? 0 : text.length();
}

代码示例来源:origin: apache/geode

protected Token makeToken(int t) {
    Token tok = super.makeToken(t);
    if (tok.getType() == EOF) tok.setText("EOF");
    if (tok.getText() == null) {
     tok.setText("(no text)");
    }
    return tok;
  }
public OQLLexer(InputStream in) {

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void startQualifiedAttribute(Token attributeNameToken, Token qualifierToken) {
  final String attributeName = attributeNameToken.getText();
  final String qualifierName = qualifierToken.getText();
  if ( PARSING_LOGGER.isDebugEnabled() ) {
    PARSING_LOGGER.debugf(
        "%s Start qualified attribute : %s.%s",
        StringHelper.repeat( ">>", attributeNodeStack.depth() + 1 ),
        attributeName,
        qualifierName
    );
  }
  final AttributeNodeImplementor<?> attributeNode = resolveAttributeNode( attributeName );
  attributeNodeStack.push( attributeNode );
  final PathQualifierType pathQualifierType = resolvePathQualifier( qualifierName );
  graphSourceStack.push( pathQualifierType.getSubGraphCreator() );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void startAttribute(Token attributeNameToken) {
  final String attributeName = attributeNameToken.getText();
  if ( PARSING_LOGGER.isDebugEnabled() ) {
    PARSING_LOGGER.debugf(
        "%s Start attribute : %s",
        StringHelper.repeat( ">>", attributeNodeStack.depth() + 1 ),
        attributeName
    );
  }
  final AttributeNodeImplementor attributeNode = resolveAttributeNode( attributeName );
  attributeNodeStack.push( attributeNode );
  graphSourceStack.push( PathQualifierType.VALUE.getSubGraphCreator() );
}

代码示例来源:origin: jenkinsci/jenkins

l=LabelAtom.get(a.getText());
break;
l=LabelAtom.get(hudson.util.QuotedStringTokenizer.unquote(s.getText()));
break;

代码示例来源:origin: hibernate/hibernate-orm

@Override
protected void startSubGraph(Token subTypeToken) {
  final String subTypeName = subTypeToken == null ? null : subTypeToken.getText();
  if ( PARSING_LOGGER.isDebugEnabled() ) {
    PARSING_LOGGER.debugf(
        "%s Starting graph : %s",
        StringHelper.repeat( ">>", attributeNodeStack.depth() + 2 ),
        subTypeName
    );
  }
  final AttributeNodeImplementor<?> attributeNode = attributeNodeStack.getCurrent();
  graphStack.push(
      graphSourceStack.getCurrent()
          .createSubGraph( attributeNode, subTypeName, sessionFactory )
  );
}

代码示例来源:origin: checkstyle/checkstyle

public final void mSINGLE_LINE_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
  int _ttype; Token _token=null; int _begin=text.length();
  _ttype = SINGLE_LINE_COMMENT;
  int _saveIndex;
  Token content=null;
  
  match("//");
  if ( inputState.guessing==0 ) {
    mCommentListener.reportSingleLineComment("//", getLine(),
    getColumn() - 3);
  }
  mSINGLE_LINE_COMMENT_CONTENT(true);
  content=_returnToken;
  if ( inputState.guessing==0 ) {
    text.setLength(_begin); text.append(content.getText());
  }
  if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
    _token = makeToken(_ttype);
    _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
  }
  _returnToken = _token;
}

代码示例来源:origin: checkstyle/checkstyle

/**
 * Create block comment from token.
 * @param token
 *        Token object.
 * @return DetailAST with BLOCK_COMMENT type.
 */
public static DetailAST createBlockCommentNode(Token token) {
  final DetailAST blockComment = new DetailAST();
  blockComment.initialize(TokenTypes.BLOCK_COMMENT_BEGIN, BLOCK_MULTIPLE_COMMENT_BEGIN);
  // column counting begins from 0
  blockComment.setColumnNo(token.getColumn() - 1);
  blockComment.setLineNo(token.getLine());
  final DetailAST blockCommentContent = new DetailAST();
  blockCommentContent.setType(TokenTypes.COMMENT_CONTENT);
  // column counting begins from 0
  // plus length of '/*'
  blockCommentContent.setColumnNo(token.getColumn() - 1 + 2);
  blockCommentContent.setLineNo(token.getLine());
  blockCommentContent.setText(token.getText());
  final DetailAST blockCommentClose = new DetailAST();
  blockCommentClose.initialize(TokenTypes.BLOCK_COMMENT_END, BLOCK_MULTIPLE_COMMENT_END);
  final Map.Entry<Integer, Integer> linesColumns = countLinesColumns(
      token.getText(), token.getLine(), token.getColumn());
  blockCommentClose.setLineNo(linesColumns.getKey());
  blockCommentClose.setColumnNo(linesColumns.getValue());
  blockComment.addChild(blockCommentContent);
  blockComment.addChild(blockCommentClose);
  return blockComment;
}

代码示例来源:origin: hibernate/hibernate-orm

match(IDENT);
if ( inputState.guessing==0 ) {
  buffer.append( i.getText() );
    match(IDENT);
    if ( inputState.guessing==0 ) {
      buffer.append( '.').append( i2.getText() );

代码示例来源:origin: apache/geode

public final void hintIdentifier() throws RecognitionException, TokenStreamException {
  
  returnAST = null;
  ASTPair currentAST = new ASTPair();
  AST hintIdentifier_AST = null;
  Token  n = null;
  AST n_AST = null;
  
  n = LT(1);
  n_AST = astFactory.create(n);
  astFactory.addASTChild(currentAST, n_AST);
  match(StringLiteral);
  if ( inputState.guessing==0 ) {
    hintIdentifier_AST = (AST)currentAST.root;
    hintIdentifier_AST =(AST)astFactory.create(HINT,n.getText(),"org.apache.geode.cache.query.internal.parse.ASTHintIdentifier") ;
    currentAST.root = hintIdentifier_AST;
    currentAST.child = hintIdentifier_AST!=null &&hintIdentifier_AST.getFirstChild()!=null ?
      hintIdentifier_AST.getFirstChild() : hintIdentifier_AST;
    currentAST.advanceChildToEnd();
  }
  hintIdentifier_AST = (AST)currentAST.root;
  returnAST = hintIdentifier_AST;
}

代码示例来源:origin: checkstyle/checkstyle

text.setLength(_begin); text.append(content.getText());

代码示例来源:origin: hibernate/hibernate-orm

a_AST = (AST)returnAST;
match(CLOSE);
if (!( i.getText().equalsIgnoreCase("treat") ))
 throw new SemanticException(" i.getText().equalsIgnoreCase(\"treat\") ");

代码示例来源:origin: hibernate/hibernate-orm

+ token.getText()
        + "' is being interpreted as an identifier due to: " + mte.getMessage()
);

代码示例来源:origin: hibernate/hibernate-orm

a_AST = (AST)returnAST;
match(CLOSE);
if (!(i.getText().equalsIgnoreCase("treat") ))
 throw new SemanticException("i.getText().equalsIgnoreCase(\"treat\") ");

代码示例来源:origin: checkstyle/checkstyle

/**
 * Create single-line comment from token.
 * @param token to create the AST
 * @return DetailAST with SINGLE_LINE_COMMENT type
 */
private static DetailAST createSlCommentNode(Token token) {
  final DetailAST slComment = new DetailAST();
  slComment.setType(TokenTypes.SINGLE_LINE_COMMENT);
  slComment.setText("//");
  // column counting begins from 0
  slComment.setColumnNo(token.getColumn() - 1);
  slComment.setLineNo(token.getLine());
  final DetailAST slCommentContent = new DetailAST();
  slCommentContent.setType(TokenTypes.COMMENT_CONTENT);
  // column counting begins from 0
  // plus length of '//'
  slCommentContent.setColumnNo(token.getColumn() - 1 + 2);
  slCommentContent.setLineNo(token.getLine());
  slCommentContent.setText(token.getText());
  slComment.addChild(slCommentContent);
  return slComment;
}

代码示例来源:origin: checkstyle/checkstyle

astFactory.addASTChild(currentAST, returnAST);
else if (((LA(1)==AT) && (LA(2)==IDENT))&&(LA(1)==AT && !LT(2).getText().equals("interface"))) {
  annotation();
  astFactory.addASTChild(currentAST, returnAST);

代码示例来源:origin: hibernate/hibernate-orm

i_AST.setType( METHOD_CALL );
i_AST.setText( i_AST.getText() + " (" + functionName + ")" );
jpaFunctionSyntax_AST = (AST)astFactory.make( (new ASTArray(3)).add(i_AST).add(astFactory.create(IDENT,unquote(n.getText()))).add(a_AST));

相关文章