org.antlr.runtime.Token.setCharPositionInLine()方法的使用及代码示例

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

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

Token.setCharPositionInLine介绍

暂无

代码示例

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

input.index(),input.index());
eof.setLine(getLine());
eof.setCharPositionInLine(getCharPositionInLine());
return eof;

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

public void setCharPositionInLine(int value){
  token.setCharPositionInLine(value);
}

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

public void setCharPositionInLine(int value){
  token.setCharPositionInLine(value);
}

代码示例来源:origin: btrplace/scheduler

public void offer(int ttype, String ttext) {
 Token t = new CommonToken(ttype, ttext);
 t.setLine(getLine());
 t.setCharPositionInLine(getCharPositionInLine());
 emit(t);
}

代码示例来源:origin: org.btrplace/btrpsl

public void offer(int ttype, String ttext) {
 Token t = new CommonToken(ttype, ttext);
 t.setLine(getLine());
 t.setCharPositionInLine(getCharPositionInLine());
 emit(t);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.drools

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 */
public Token emit() {
  Token t = new DroolsToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

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

/** Returns the EOF token (default), if you need
 *  to return a custom token instead override this method.
 */
public Token getEOFToken() {
  Token eof = new CommonToken(input,Token.EOF,
                Token.DEFAULT_CHANNEL,
                input.index(),input.index());
  eof.setLine(getLine());
  eof.setCharPositionInLine(getCharPositionInLine());
  return eof;
}

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

/** Returns the EOF token (default), if you need
 *  to return a custom token instead override this method.
 */
public Token getEOFToken() {
  Token eof = new CommonToken(input,Token.EOF,
                Token.DEFAULT_CHANNEL,
                input.index(),input.index());
  eof.setLine(getLine());
  eof.setCharPositionInLine(getCharPositionInLine());
  return eof;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 *
 *  If you are building trees, then you should also override
 *  Parser or TreeParser.getMissingSymbol().
 */
public Token emit() {
  Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

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

/** Returns the EOF token (default), if you need
 *  to return a custom token instead override this method.
 */
public Token getEOFToken() {
  Token eof = new CommonToken(input,Token.EOF,
                Token.DEFAULT_CHANNEL,
                input.index(),input.index());
  eof.setLine(getLine());
  eof.setCharPositionInLine(getCharPositionInLine());
  return eof;
}

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

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 *
 *  If you are building trees, then you should also override
 *  Parser or TreeParser.getMissingSymbol().
 */
public Token emit() {
  Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

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

/** Returns the EOF token (default), if you need
 *  to return a custom token instead override this method.
 */
public Token getEOFToken() {
  Token eof = new CommonToken(input,Token.EOF,
                Token.DEFAULT_CHANNEL,
                input.index(),input.index());
  eof.setLine(getLine());
  eof.setCharPositionInLine(getCharPositionInLine());
  return eof;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime

/** Returns the EOF token (default), if you need
 *  to return a custom token instead override this method.
 */
public Token getEOFToken() {
  Token eof = new CommonToken(input,Token.EOF,
                Token.DEFAULT_CHANNEL,
                input.index(),input.index());
  eof.setLine(getLine());
  eof.setCharPositionInLine(getCharPositionInLine());
  return eof;
}

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

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 *
 *  If you are building trees, then you should also override
 *  Parser or TreeParser.getMissingSymbol().
 */
public Token emit() {
  Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

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

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 *
 *  If you are building trees, then you should also override
 *  Parser or TreeParser.getMissingSymbol().
 */
public Token emit() {
  Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

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

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 *
 *  If you are building trees, then you should also override
 *  Parser or TreeParser.getMissingSymbol().
 */
public Token emit() {
  Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/** The standard method called to automatically emit a token at the
 *  outermost lexical rule.  The token object should point into the
 *  char buffer start..stop.  If there is a text override in 'text',
 *  use that to set the token's text.  Override this method to emit
 *  custom Token objects.
 *
 *  If you are building trees, then you should also override
 *  Parser or TreeParser.getMissingSymbol().
 */
public Token emit() {
  Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
  t.setLine(state.tokenStartLine);
  t.setText(state.text);
  t.setCharPositionInLine(state.tokenStartCharPositionInLine);
  emit(t);
  return t;
}

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

public final void mSYNPRED() throws RecognitionException {
  try {
    int _type = SYNPRED;
    int _channel = DEFAULT_TOKEN_CHANNEL;
    // org/antlr/v4/parse/ANTLRLexer.g:491:14: ( '=>' )
    // org/antlr/v4/parse/ANTLRLexer.g:491:16: '=>'
    {
    match("=>"); if (state.failed) return;
    if ( state.backtracking==0 ) {
            Token t = new CommonToken(input, state.type, state.channel,
                         state.tokenStartCharIndex, getCharIndex()-1);
            t.setLine(state.tokenStartLine);
            t.setText(state.text);
            t.setCharPositionInLine(state.tokenStartCharPositionInLine);
            grammarError(ErrorType.V3_SYNPRED, t);
            _channel=HIDDEN;
            }
    }
    state.type = _type;
    state.channel = _channel;
  }
  finally {
    // do for sure before leaving
  }
}
// $ANTLR end "SYNPRED"

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

public final void mERRCHAR() throws RecognitionException {
  try {
    int _type = ERRCHAR;
    int _channel = DEFAULT_TOKEN_CHANNEL;
    // org/antlr/v4/parse/ANTLRLexer.g:787:5: ( . )
    // org/antlr/v4/parse/ANTLRLexer.g:787:7: .
    {
    matchAny(); if (state.failed) return;
    if ( state.backtracking==0 ) {
         Token t = new CommonToken(input, state.type, state.channel, state.tokenStartCharIndex, getCharIndex()-1);
         t.setLine(state.tokenStartLine);
         t.setText(state.text);
         t.setCharPositionInLine(state.tokenStartCharPositionInLine);
         String msg = getTokenErrorDisplay(t) + " came as a complete surprise to me";
         grammarError(ErrorType.SYNTAX_ERROR, t, msg);
         state.syntaxErrors++;
         skip();
       }
    }
    state.type = _type;
    state.channel = _channel;
  }
  finally {
    // do for sure before leaving
  }
}
// $ANTLR end "ERRCHAR"

代码示例来源:origin: org.eclipse.epsilon/epsilon-core

protected void updateASTLocations(AST ast) {
  
  ast.setColumn(preprocessor.getTrace().getEglColumnNumberFor(ast.getLine(), ast.getColumn()));
  ast.setLine(preprocessor.getTrace().getEglLineNumberFor(ast.getLine()));
  
  for (Token token : ast.getExtraTokens()) {
    if (token == null) continue;
    token.setCharPositionInLine(preprocessor.getTrace().getEglColumnNumberFor(token.getLine(), token.getCharPositionInLine()));
    token.setLine(preprocessor.getTrace().getEglLineNumberFor(token.getLine()));
  }
  
  boolean done = updateRegionsOfStaticTextASTs(ast);
  
  ast.setRegion(null); // Force ast to recompute its region
  
  if (!done) {
    for (AST child : ast.getChildren()) {
      updateASTLocations(child);
    }
  }
}

相关文章