org.pz.platypus
Class TokenList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Token>
              extended by org.pz.platypus.TokenList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Token>, java.util.Collection<Token>, java.util.List<Token>, java.util.RandomAccess

public class TokenList
extends java.util.ArrayList<Token>

The ArrayList of Tokens that we generate in the parser and pass to the output plug-in.

Author:
alb
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
TokenList()
           
 
Method Summary
 boolean areNextTokenContentsEqualTo(int i, java.lang.String s)
          See if the next immediate token (if any), is equal to s.
 void dump(GDD gdd)
          dumps all the tokens in the output token list to System.out
 Token getNextToken(int tokNumber)
          Gets the next token after the token pointed to by the tokenNumber
 Token getPrevToken(int tokNum)
          Returns the token previous to the one whose number is passed in
 boolean isNextToken(int i, TokenType tokType)
          See if next immediate token (if any), is of type tokType.
 boolean lineSoFarEmitsText(int tokNum)
          Gets all the preceding tokens in this input line and sees whether any of them contain text.
 int searchAheadFor(int currTokIndex, TokenType tokType)
          Start searching for tokType token in the list.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

TokenList

public TokenList()
Method Detail

getNextToken

public Token getNextToken(int tokNumber)
Gets the next token after the token pointed to by the tokenNumber

Parameters:
tokNumber - the number of the current token
Returns:
the token after the current token. Null, if there's an error or the current token is the last token

getPrevToken

public Token getPrevToken(int tokNum)
Returns the token previous to the one whose number is passed in

Parameters:
tokNum - the number of the current token
Returns:
the token priort to the current token, or null if an error occurred.

lineSoFarEmitsText

public boolean lineSoFarEmitsText(int tokNum)
Gets all the preceding tokens in this input line and sees whether any of them contain text.

Parameters:
tokNum - the present token
Returns:
true if text is emitted false if not

dump

public void dump(GDD gdd)
dumps all the tokens in the output token list to System.out

Parameters:
gdd - the GDD

isNextToken

public boolean isNextToken(int i,
                           TokenType tokType)
See if next immediate token (if any), is of type tokType.

Parameters:
i - the current position
tokType - tokType to compare with
Returns:
if i+1 th token type is equal to tokType.

areNextTokenContentsEqualTo

public boolean areNextTokenContentsEqualTo(int i,
                                           java.lang.String s)
See if the next immediate token (if any), is equal to s.

Parameters:
i - the current position
s - the token str
Returns:
if i+1 th token contents are equal to s.

searchAheadFor

public int searchAheadFor(int currTokIndex,
                          TokenType tokType)
Start searching for tokType token in the list. Search from currTokIndex + 1 to the end.

Parameters:
currTokIndex -
tokType -
Returns:
the index at which tokType is found


Copyright © 2008-10 Pacific Data Works LLC