org.prorefactor.refactor.source
Class Token

java.lang.Object
  extended by org.prorefactor.refactor.source.Token
All Implemented Interfaces:
TETNode

public class Token
extends java.lang.Object
implements TETNode

A token is a handle to a bunch of source file IAtom objects, which contain the actual text/line/column. A macro or .i reference is also a token. Tokens may be nested, in the case where there are macro or .i references embedded in a token. We don't have to look to the embedded tokens to find all of the text though - the outer token points to all of the atoms. There is one special token type: AMPIF_CONDITIONAL. In that case, it only points to an "&ENDIF" atom, and there are two or more "expansions" which must be traversed to find the "&IF" and all code between. This special exception allows us to plug a tree structure for &IF branches into an otherwise flat token list.


Field Summary
static int AMPIF_CONDITIONAL
          There is one special token type: AMPIF_CONDITIONAL.
 
Constructor Summary
Token(TETNode parent)
           
Token(Token orig)
          Copy constructor.
 
Method Summary
 void addExpansion(java.lang.Object obj)
           
 void addNestedToken(Token nestedToken)
           
 java.util.List getExpansions()
          The expansions list is a list of Expansion objects, in the case of a curly expansion.
 java.util.List getNestedTokens()
          Our model keeps embedded curlies as embedded (nested) Token objects.
 java.io.File nearestEnclosingFile()
          Find the nearest enclosing File, ignoring that the *actual* text for the Token may have come from a Declaration some number of layers higher.
 int numExpansions()
           
 int numNestedTokens()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AMPIF_CONDITIONAL

public static final int AMPIF_CONDITIONAL
There is one special token type: AMPIF_CONDITIONAL. In that case, it only points to an "&ENDIF" atom, and there are two or more "expansions" which must be traversed to find the "&IF" and all code between. This special exception allows us to plug a tree structure for &IF branches into an otherwise flat token list.

See Also:
Constant Field Values
Constructor Detail

Token

public Token(TETNode parent)
See Also:
getParent()

Token

public Token(Token orig)
Copy constructor. Copies the pointers to other structures - does not clone. Sets type, firstAtom, terminatorAtom, parent. Does not set: expansions, nestedTokens, link, next, prev.

Method Detail

addExpansion

public void addExpansion(java.lang.Object obj)
See Also:
getExpansions()

addNestedToken

public void addNestedToken(Token nestedToken)
See Also:
getNestedTokens()

getExpansions

public java.util.List getExpansions()
The expansions list is a list of Expansion objects, in the case of a curly expansion. It is used (abused) as a list of ConditionalExpansion objects objects in the case of &IF..&ENDIF. It is also used (abused) for a list of Declaration objects, in the case of an &GLOBAL or an &SCOPED node. A Token may have expansions as well as nested tokens, which themselves have expansions. The list is null if no expansions have been added.


getNestedTokens

public java.util.List getNestedTokens()
Our model keeps embedded curlies as embedded (nested) Token objects. For a Token which is a curly reference, but contains nested curly references, the Token has both Expansions and nested Tokens. The list is null if no nestedTokens have been added.


nearestEnclosingFile

public java.io.File nearestEnclosingFile()
Description copied from interface: TETNode
Find the nearest enclosing File, ignoring that the *actual* text for the Token may have come from a Declaration some number of layers higher. Useful for reporting errors.

Specified by:
nearestEnclosingFile in interface TETNode
See Also:
TETNode.nearestEnclosingFile()

numExpansions

public int numExpansions()

numNestedTokens

public int numNestedTokens()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008 Joanju Software. All Rights Reserved.