
Object subclass: #TokenStream
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: ''  !


!TokenStream class methods ! !



!TokenStream methods !
 
advance
    "requires: there is a token at the head of the stream
                     i.e., the stream is not at the end.
      modifies: self
      effect: advances self to the next element."
    self implementedBySubclass!
  
atEnd
    "ensures: result is true just when there is no token to be returned."
    self implementedBySubclass!
   
peek
    "requires:  there is a token at the head of the stream
                     i.e., the stream is not at the end.
     effect: returns the token at the head of the stream."
    self implementedBySubclass! !

TokenStream subclass: #TokenStreamOverIndexedCollection
  instanceVariableNames: 
    'coll index '
  classVariableNames: ''
  poolDictionaries: ''    !


!TokenStreamOverIndexedCollection class methods !

on: anIndexedCollection
    ^self new initialize: anIndexedCollection! !



!TokenStreamOverIndexedCollection methods !

advance
    index := index + 1!

atEnd
    ^ index > coll size!
 
initialize: anIndexedCollection
    "private"
    coll := anIndexedCollection.
    index := 1!
   
peek
    ^ coll at: index! !
