package com.joestelmach.natty;

import java.util.List;

import org.antlr.runtime.Token;
import org.antlr.runtime.TokenSource;

public class NattyTokenSource implements TokenSource {
  private List<Token> _tokens;
  private int _index = 0;
  
  public NattyTokenSource(List<Token> tokens) {
    _tokens = tokens;
  }

  public Token nextToken() {
    return _tokens.size() > _index ? _tokens.get(_index++) : null;
  }

  public String getSourceName() {
    return "natty";
  }
  
  public List<Token> getTokens() {
    return _tokens;  
  }
}

@@ -49,16 +49,54 @@
 .List;%0A%0A
+import org.antlr.runtime.CommonToken;%0A
 import o
@@ -213,16 +213,86 @@
 ource %7B%0A
+  private static final Token EOF_TOKEN = new CommonToken(Token.EOF);%0A%0A
   privat
@@ -512,12 +512,17 @@
 ) : 
-null
+EOF_TOKEN
 ;%0A  

Return EOF token when no more tokens available. Required for antlr 3.3+.