| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 package com.google.dart.antlr; | |
| 6 | |
| 7 import org.antlr.runtime.ANTLRFileStream; | |
| 8 import org.antlr.runtime.CharStream; | |
| 9 import org.antlr.runtime.CommonTokenStream; | |
| 10 | |
| 11 /** | |
| 12 * Test rig for testing the Dart grammar. | |
| 13 */ | |
| 14 public class TestGrammar { | |
| 15 public static void main(String... arguments) throws Exception { | |
| 16 boolean hasErrors = false; | |
| 17 if (arguments.length == 0) { | |
| 18 throw new AssertionError("No files given on command line"); | |
| 19 } | |
| 20 for (String argument : arguments) { | |
| 21 CharStream input = new ANTLRFileStream(argument, "UTF8"); | |
| 22 DartLexer lexer = new DartLexer(input); | |
| 23 CommonTokenStream tokens = new CommonTokenStream(lexer); | |
| 24 DartParser parser = new DartParser(tokens); | |
| 25 if (argument.endsWith(".lib")) { | |
| 26 parser.libraryUnit(); | |
| 27 } else if (argument.endsWith(".dart")) { | |
| 28 parser.compilationUnit(); | |
| 29 } else { | |
| 30 throw new AssertionError("Unknown file type: " + argument); | |
| 31 } | |
| 32 hasErrors |= lexer.hasErrors; | |
| 33 hasErrors |= parser.hasErrors; | |
| 34 } | |
| 35 if (hasErrors) { | |
| 36 throw new AssertionError("Parse errors"); | |
| 37 } | |
| 38 } | |
| 39 } | |
| OLD | NEW |