org.antlr.v4.runtime.WritableToken类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(81)

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

WritableToken介绍

暂无

代码示例

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

protected void add(Token t) {
  if ( n>=tokens.length ) {
    tokens = Arrays.copyOf(tokens, tokens.length * 2);
  }
  if (t instanceof WritableToken) {
    ((WritableToken)t).setTokenIndex(getBufferStartIndex() + n);
  }
  tokens[n++] = t;
}

代码示例来源:origin: antlr/codebuff

String prefix = originalTokens.getText(Interval.of(0, firstToken.getTokenIndex())); // gets any comments in front + first real token
charPosInLine = firstToken.getCharPositionInLine()+firstToken.getText().length()+1; // start where first token left off
line = Tool.count(prefix, '\n') + 1;
output.append(prefix);

代码示例来源:origin: com.glispa.combo/combo-core

public final EscEscContext escEsc() throws RecognitionException {
  EscEscContext _localctx = new EscEscContext(_ctx, getState());
  enterRule(_localctx, 10, RULE_escEsc);
  try {
    enterOuterAlt(_localctx, 1);
    {
    setState(92);
    match(ESC);
    setState(93);
    match(ESC);
     ((WritableToken)_localctx.start).setText(""); 
    }
  }
  catch (RecognitionException re) {
    _localctx.exception = re;
    _errHandler.reportError(this, re);
    _errHandler.recover(this, re);
  }
  finally {
    exitRule();
  }
  return _localctx;
}

代码示例来源:origin: eu.rssw.openedge.parsers/proparse

@Override
public Token nextToken() {
 LOGGER.trace("Entering nextToken()");
 currentToken = source.nextToken();
 switch (currentToken.getType()) {
  case PreprocessorParser.COMMENT:
  case PreprocessorParser.WS:
   ((WritableToken) currentToken).setChannel(Token.HIDDEN_CHANNEL);
   break;
  case PreprocessorParser.AMPMESSAGE:
  case PreprocessorParser.AMPANALYZESUSPEND:
  case PreprocessorParser.AMPANALYZERESUME:
  case PreprocessorParser.AMPGLOBALDEFINE:
  case PreprocessorParser.AMPSCOPEDDEFINE:
  case PreprocessorParser.AMPUNDEFINE:
  case PreprocessorParser.INCLUDEDIRECTIVE:
   ((WritableToken) currentToken).setChannel(PREPROCESSOR_CHANNEL);
   break;
  case PreprocessorParser.PROPARSEDIRECTIVE:
   ((WritableToken) currentToken).setChannel(PROPARSE_CHANNEL);
   break;
  default:
 }
 return currentToken;
}

代码示例来源:origin: com.glispa.combo/combo-core

public final EscSpaceContext escSpace() throws RecognitionException {
  EscSpaceContext _localctx = new EscSpaceContext(_ctx, getState());
  enterRule(_localctx, 12, RULE_escSpace);
  try {
    enterOuterAlt(_localctx, 1);
    {
    setState(96);
    match(ESC);
    setState(97);
    match(SP);
     ((WritableToken)_localctx.start).setText(""); 
    }
  }
  catch (RecognitionException re) {
    _localctx.exception = re;
    _errHandler.reportError(this, re);
    _errHandler.recover(this, re);
  }
  finally {
    exitRule();
  }
  return _localctx;
}

代码示例来源:origin: Riverside-Software/sonar-openedge

@Override
public Token nextToken() {
 LOGGER.trace("Entering nextToken()");
 currentToken = source.nextToken();
 switch (currentToken.getType()) {
  case PreprocessorParser.COMMENT:
  case PreprocessorParser.WS:
   ((WritableToken) currentToken).setChannel(Token.HIDDEN_CHANNEL);
   break;
  case PreprocessorParser.AMPMESSAGE:
  case PreprocessorParser.AMPANALYZESUSPEND:
  case PreprocessorParser.AMPANALYZERESUME:
  case PreprocessorParser.AMPGLOBALDEFINE:
  case PreprocessorParser.AMPSCOPEDDEFINE:
  case PreprocessorParser.AMPUNDEFINE:
  case PreprocessorParser.INCLUDEDIRECTIVE:
   ((WritableToken) currentToken).setChannel(PREPROCESSOR_CHANNEL);
   break;
  case PreprocessorParser.PROPARSEDIRECTIVE:
   ((WritableToken) currentToken).setChannel(PROPARSE_CHANNEL);
   break;
  default:
 }
 return currentToken;
}

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

/** Add {@code n} elements to buffer.
 *
 * @return The actual number of elements added to the buffer.
 */
protected int fetch(int n) {
  if (fetchedEOF) {
    return 0;
  }
  for (int i = 0; i < n; i++) {
    Token t = tokenSource.nextToken();
    if ( t instanceof WritableToken ) {
      ((WritableToken)t).setTokenIndex(tokens.size());
    }
    tokens.add(t);
    if ( t.getType()==Token.EOF ) {
      fetchedEOF = true;
      return i + 1;
    }
  }
  return n;
}

代码示例来源:origin: com.glispa.combo/combo-core

public final EscPipeContext escPipe() throws RecognitionException {
  EscPipeContext _localctx = new EscPipeContext(_ctx, getState());
  enterRule(_localctx, 14, RULE_escPipe);
  try {
    enterOuterAlt(_localctx, 1);
    {
    setState(100);
    match(ESC);
    setState(101);
    match(PIPE);
     ((WritableToken)_localctx.start).setText(""); 
    }
  }
  catch (RecognitionException re) {
    _localctx.exception = re;
    _errHandler.reportError(this, re);
    _errHandler.recover(this, re);
  }
  finally {
    exitRule();
  }
  return _localctx;
}

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

protected void add(Token t) {
  if ( n>=tokens.length ) {
    tokens = Arrays.copyOf(tokens, tokens.length * 2);
  }
  if (t instanceof WritableToken) {
    ((WritableToken)t).setTokenIndex(getBufferStartIndex() + n);
  }
  tokens[n++] = t;
}

代码示例来源:origin: com.glispa.combo/combo-core

public final EscEndContext escEnd() throws RecognitionException {
  EscEndContext _localctx = new EscEndContext(_ctx, getState());
  enterRule(_localctx, 16, RULE_escEnd);
  try {
    enterOuterAlt(_localctx, 1);
    {
    setState(104);
    match(ESC);
    setState(105);
    match(END);
     ((WritableToken)_localctx.start).setText(""); 
    }
  }
  catch (RecognitionException re) {
    _localctx.exception = re;
    _errHandler.reportError(this, re);
    _errHandler.recover(this, re);
  }
  finally {
    exitRule();
  }
  return _localctx;
}

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

protected void add(Token t) {
  if ( n>=tokens.length ) {
    tokens = Arrays.copyOf(tokens, tokens.length * 2);
  }
  if (t instanceof WritableToken) {
    ((WritableToken)t).setTokenIndex(getBufferStartIndex() + n);
  }
  tokens[n++] = t;
}

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

protected void add(Token t) {
  if ( n>=tokens.length ) {
    tokens = Arrays.copyOf(tokens, tokens.length * 2);
  }
  if (t instanceof WritableToken) {
    ((WritableToken)t).setTokenIndex(getBufferStartIndex() + n);
  }
  tokens[n++] = t;
}

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

protected void add(@NotNull Token t) {
  if ( n>=tokens.length ) {
    tokens = Arrays.copyOf(tokens, tokens.length * 2);
  }
  if (t instanceof WritableToken) {
    ((WritableToken)t).setTokenIndex(getBufferStartIndex() + n);
  }
  tokens[n++] = t;
}

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

/** Add {@code n} elements to buffer.
 *
 * @return The actual number of elements added to the buffer.
 */
protected int fetch(int n) {
  if (fetchedEOF) {
    return 0;
  }
  for (int i = 0; i < n; i++) {
    Token t = tokenSource.nextToken();
    if ( t instanceof WritableToken ) {
      ((WritableToken)t).setTokenIndex(tokens.size());
    }
    tokens.add(t);
    if ( t.getType()==Token.EOF ) {
      fetchedEOF = true;
      return i + 1;
    }
  }
  return n;
}

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

/** Add {@code n} elements to buffer.
 *
 * @return The actual number of elements added to the buffer.
 */
protected int fetch(int n) {
  if (fetchedEOF) {
    return 0;
  }
  for (int i = 0; i < n; i++) {
    Token t = tokenSource.nextToken();
    if ( t instanceof WritableToken ) {
      ((WritableToken)t).setTokenIndex(tokens.size());
    }
    tokens.add(t);
    if ( t.getType()==Token.EOF ) {
      fetchedEOF = true;
      return i + 1;
    }
  }
  return n;
}

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

/** Add {@code n} elements to buffer.
 *
 * @return The actual number of elements added to the buffer.
 */
protected int fetch(int n) {
  if (fetchedEOF) {
    return 0;
  }
  for (int i = 0; i < n; i++) {
    Token t = tokenSource.nextToken();
    if ( t instanceof WritableToken ) {
      ((WritableToken)t).setTokenIndex(tokens.size());
    }
    tokens.add(t);
    if ( t.getType()==Token.EOF ) {
      fetchedEOF = true;
      return i + 1;
    }
  }
  return n;
}

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

/** Add {@code n} elements to buffer.
 *
 * @return The actual number of elements added to the buffer.
 */
protected int fetch(int n) {
  if (fetchedEOF) {
    return 0;
  }
  for (int i = 0; i < n; i++) {
    Token t = tokenSource.nextToken();
    if ( t instanceof WritableToken ) {
      ((WritableToken)t).setTokenIndex(tokens.size());
    }
    tokens.add(t);
    if ( t.getType()==Token.EOF ) {
      fetchedEOF = true;
      return i + 1;
    }
  }
  return n;
}

相关文章

WritableToken类方法