// $Id: EOPLLexers.scala,v 1.1 2005/10/28 20:46:16 leavens Exp leavens $
package interp;

import tools._;

/** This parses the given String.
 *  To use it, do:
 *  <pre>
 *     val parser = new ParsersSubClass with EOPLLexers( myString );
 *     parser.startProduction(parser.input) match {  ... };
 *  </pre>
 */
class EOPLLexers(s: String) extends Parsers with TokenParsers {

  /** Iterator over s. */
  private val in : Iterator[char] = s.elements;

  /** Separator characters for the EOPL languages. */
  private val separators: String = "(),;";

  /** The input to parse, already tokenized. */
  val input : Stream[String] = Stream.fromIterator(new Tokenizer(in, separators));

  /** The basic method to return the next token. */
  def nextToken() = new Parser[String] {
    def apply(in: inputType): Result = 
      if (in.isEmpty) None else Some(Pair(in.head, in.tail));
  }
}
