Class FilterTokenSource

java.lang.Object
io.github.douira.glsl_transformer.transform.FilterTokenSource
All Implemented Interfaces:
TokenSource

public class FilterTokenSource extends Object implements TokenSource
The filter token source wraps another token source but reads tokens from it until a given filter accepts one. When it encounters EOF it immediately returns it.
  • Constructor Details

    • FilterTokenSource

      public FilterTokenSource(TokenSource tokenSource)
      Creates a new filtering token source with a given token source to wrap.
      Parameters:
      tokenSource - The real token source to get tokens from
  • Method Details

    • setTokenSource

      public void setTokenSource(TokenSource tokenSource)
      Sets the token source on this filtering token source wrapper. May not be null.
      Parameters:
      tokenSource - The new token source
    • setTokenFilter

      public void setTokenFilter(TokenFilter<?> tokenFilter)
      Sets the token filter on this filtering token source wrapper. Set to null to effectively disable any manipulation of the tokens generated by the contained token source.
      Parameters:
      tokenFilter - The new token filter
    • nextToken

      public Token nextToken()
      Uses TokenSource.nextToken() on the real token source to filter to get tokens and then filters them with the contained token filter if there is one.
      Specified by:
      nextToken in interface TokenSource
    • getLine

      public int getLine()
      Specified by:
      getLine in interface TokenSource
    • getCharPositionInLine

      public int getCharPositionInLine()
      Specified by:
      getCharPositionInLine in interface TokenSource
    • getInputStream

      public CharStream getInputStream()
      Specified by:
      getInputStream in interface TokenSource
    • getSourceName

      public String getSourceName()
      Specified by:
      getSourceName in interface TokenSource
    • setTokenFactory

      public void setTokenFactory(TokenFactory<?> factory)
      Specified by:
      setTokenFactory in interface TokenSource
    • getTokenFactory

      public TokenFactory<?> getTokenFactory()
      Specified by:
      getTokenFactory in interface TokenSource