package minijava.lexer import java.io.{InputStream, IOException} trait Lexer { // This indicates to the compiler that this trait will be composed // with a Reporter. This implies that the methods from the Reporter // trait will be available at run-time. self: Reporter => import Tokens._ // the input stream private var in: InputStream = _ /** Sets the input stream to use for lexing. */ def setInputStream(input: InputStream): Unit = { in = input // ... } /** Works like an iterator, and returns the next token from the input stream. */ def nextToken: Token = { // ... } }