antlr
Class TokenStreamCopyingHiddenTokenFilter

java.lang.Object
  extended by antlr.TokenStreamBasicFilter
      extended by antlr.TokenStreamHiddenTokenFilter
          extended by antlr.TokenStreamCopyingHiddenTokenFilter
All Implemented Interfaces:
antlr.ASdebug.IASDebugStream, antlr.TokenStream

public class TokenStreamCopyingHiddenTokenFilter
extends antlr.TokenStreamHiddenTokenFilter
implements antlr.TokenStream

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
TokenStreamCopyingHiddenTokenFilter(antlr.TokenStream input)
           
 
Method Summary
 void copy(int tokenType)
          Indicate that all tokens of type tokenType should be copied.
 void linkAndCopyToken(antlr.CommonHiddenStreamToken prev, antlr.CommonHiddenStreamToken monitored)
           
 antlr.Token nextToken()
          Return the next monitored token.
 antlr.CommonHiddenStreamToken partialCloneToken(antlr.CommonHiddenStreamToken t)
          Create a clone of the important parts of the given token.
 
Methods inherited from class antlr.TokenStreamHiddenTokenFilter
getDiscardMask, getHiddenAfter, getHiddenBefore, getHideMask, getInitialHiddenToken, hide, hide
 
Methods inherited from class antlr.TokenStreamBasicFilter
discard, discard, getEntireText, getOffsetInfo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenStreamCopyingHiddenTokenFilter

public TokenStreamCopyingHiddenTokenFilter(antlr.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 antlr.CommonHiddenStreamToken partialCloneToken(antlr.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(antlr.CommonHiddenStreamToken prev,
                             antlr.CommonHiddenStreamToken monitored)

nextToken

public antlr.Token nextToken()
                      throws antlr.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.

Specified by:
nextToken in interface antlr.TokenStream
Overrides:
nextToken in class antlr.TokenStreamHiddenTokenFilter
Throws:
antlr.TokenStreamException