TokenStream.getText

Return the text of all tokens in this stream between {@code start} and {@code stop} (inclusive).

<p>If the specified {@code start} or {@code stop} token was not provided by this stream, or if the {@code stop} occurred before the {@code start} token, the behavior is unspecified.</p>

<p>For streams which ensure that the {@link Token#getTokenIndex} method is accurate for all of its provided tokens, this method behaves like the following code. Other streams may implement this method in other ways provided the behavior is consistent with this at a high level.</p>

<pre> TokenStream stream = ...; String text = ""; for (int i = start.getTokenIndex(); i &lt;= stop.getTokenIndex(); i++) { text += stream.get(i).getText(); } </pre>

@param start The first token in the interval to get text for. @param stop The last token in the interval to get text for (inclusive). @return The text of all tokens lying between the specified {@code start} and {@code stop} tokens.

@throws UnsupportedOperationException if this stream does not support this method for the specified tokens

  1. string getText(Interval interval)
  2. string getText()
  3. string getText(RuleContext ctx)
  4. string getText(Token start, Token stop)
    interface TokenStream
    string
    getText

Meta