diff --git a/sources/zweic/ParserTest.scala b/sources/zweic/ParserTest.scala new file mode 100755 index 0000000..c2dafd4 --- /dev/null +++ b/sources/zweic/ParserTest.scala @@ -0,0 +1,40 @@ +/* zweic -- a compiler for zwei + * + * Stephane Micheloud & LAMP + * + * $Id$ + */ + +package zweic; + + +/** + * A small parser test class; it reads in a file and prints out + * every/the first syntax error that is found. Programs which + * do not yield error messages are supposed to be syntactically + * correct. + * + * usage: scala zweic.ParserTest + */ +object ParserTest { + import java.io.{FileInputStream, IOException}; + + def main(args: Array[String]): Unit = { + if (args.length == 0) { + Console.println("usage: scala zweic.ParserTest "); + System.exit(1) + } + try { + val in = new FileInputStream(args(0)); + new Parser(in).parse; + in.close(); + if (Report.errors > 0) + System.err.println(Report.errors + " errors found." ); + System.exit(if (Report.errors > 0) 1 else 0); + } + catch { + case e: IOException => Report.fail(e.getMessage()); + } + } + +}