diff --git a/sources/zweic/ScannerTest.scala b/sources/zweic/ScannerTest.scala new file mode 100755 index 0000000..0a73087 --- /dev/null +++ b/sources/zweic/ScannerTest.scala @@ -0,0 +1,39 @@ +/* zweic -- a compiler for zwei + * + * Stephane Micheloud & LAMP + * + * $Id$ + */ + +package zweic; + + +/** + * A small scanner test class; it reads in a file and prints out + * the sequence of tokens. + * + * usage: scala zweic.ScannerTest + */ +object ScannerTest { + import java.io.{FileInputStream, IOException}; + + def main(args: Array[String]): Unit = { + if (args.length != 1) { + Console.println("usage: scala zweic.ScannerTest "); + System.exit(1) + } + try { + val in = new FileInputStream(args(0)); + val scanner = new Scanner(in); + while (scanner.token != Tokens.EOF) { + Console.println(scanner.representation); + scanner.nextToken; + } + in.close + } + catch { + case e: IOException => Report.fail(e.getMessage()); + } + } + +}