antlr

## Class TokenStreamCopyingHiddenTokenFilter

- Object
- - TokenStreamHiddenTokenFilter
  - - TokenStreamCopyingHiddenTokenFilter

-     public class TokenStreamCopyingHiddenTokenFilter
      extends TokenStreamHiddenTokenFilter

  This class provides TokenStreamHiddenTokenFilters with the concept of tokens which can be copied so that they are seen by both the hidden token stream as well as the parser itself. This is useful when one wants to use an existing parser (like the Java parser included with ANTLR) that throws away some tokens to create a parse tree which can be used to spit out a copy of the code with only minor modifications. This code is partially derived from the public domain ANLTR TokenStream

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TokenStreamCopyingHiddenTokenFilter(TokenStream input)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `copy(int tokenType)` Indicate that all tokens of type tokenType should be copied.
    `void` | `linkAndCopyToken(CommonHiddenStreamToken prev, CommonHiddenStreamToken monitored)`
    `Token` | `nextToken()` Return the next monitored token.
    `CommonHiddenStreamToken` | `partialCloneToken(CommonHiddenStreamToken t)` Create a clone of the important parts of the given token.

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TokenStreamCopyingHiddenTokenFilter

          public TokenStreamCopyingHiddenTokenFilter(TokenStream input)

  - ### Method Detail

    - #### copy

          public void copy(int tokenType)

      Indicate that all tokens of type tokenType should be copied. The copy is put in the stream of hidden tokens, and the original is returned in the stream of normal tokens.
      Parameters:
        `tokenType` - integer representing the token type to copied

    - #### partialCloneToken

          public CommonHiddenStreamToken partialCloneToken(CommonHiddenStreamToken t)

      Create a clone of the important parts of the given token. Note that this does NOT copy the hiddenBefore and hiddenAfter fields.
      Parameters:
        `t` - token to partially clone
      Returns:
        newly created partial clone

    - #### linkAndCopyToken

          public void linkAndCopyToken(CommonHiddenStreamToken prev,
                              CommonHiddenStreamToken monitored)

    - #### nextToken

          public Token nextToken()
                          throws TokenStreamException

      Return the next monitored token. Test the token following the monitored token. If following is another monitored token, save it for the next invocation of nextToken (like a single lookahead token) and return it then. If following is unmonitored, nondiscarded (hidden) channel token, add it to the monitored token. Note: EOF must be a monitored Token.
      Throws:
        `TokenStreamException`