7import org.antlr.v4.runtime.*;
8import org.antlr.v4.runtime.dfa.*;
9import org.antlr.v4.runtime.atn.*;
31 BitSet conflictingAlts,
43 Recognizer<?,?> recognizer,
44 Object offendingSymbol,
46 int charPositionInLine,
48 RecognitionException
e) {
49 if (!DartParser.errorHasOccurred) DartParser.prepareForErrors();
55 private static void normalExit() {
60 private static void compileTimeErrorExit() {
65 private static void helpAndExit() {
66 System.err.println(
"Expected arguments: [--verbose] <file>...");
73 public static void runAsBatch() throws IOException, RecognitionException {
75 long startTime = System.currentTimeMillis();
76 InputStreamReader input =
new InputStreamReader(System.in);
77 BufferedReader bufferedInput =
new BufferedReader(input);
80 System.out.println(
">>> BATCH START");
81 while ((cmdLine = bufferedInput.readLine()) !=
null) {
82 if (cmdLine.length() == 0) {
85 (
result.numberOfFileArguments -
result.numberOfFailures) +
86 "/" +
result.numberOfFileArguments +
") " +
87 (System.currentTimeMillis() - startTime) +
"ms");
88 if (
result.numberOfFailures > 0) compileTimeErrorExit();
92 String[] lineArgs = cmdLine.split(
"\\s+");
93 result = parseFiles(lineArgs);
95 System.err.println(
">>> EOF STDERR");
96 String resultPassString =
97 result.numberOfFailures == 0 ?
"PASS" :
"PARSE_FAIL";
98 System.out.println(
">>> TEST " + resultPassString +
" " +
99 (System.currentTimeMillis() - startTime) +
"ms");
100 startTime = System.currentTimeMillis();
109 throws IOException, RecognitionException {
113 result.numberOfFileArguments = arguments.length;
114 for (
int i = 0;
i < arguments.length;
i++) {
115 String filePath = arguments[
i];
116 if (filePath.startsWith(
"-")) {
117 result.numberOfFileArguments--;
119 if (filePath.equals(
"--verbose"))
verbose =
true;
124 if (
verbose) System.err.println(
"Parsing file: " + filePath);
125 DartLexer lexer =
new DartLexer(
new ANTLRFileStream(filePath));
126 DartParser
parser =
new DartParser(
new CommonTokenStream(lexer));
128 lexer.addErrorListener(errorListener);
129 parser.addErrorListener(errorListener);
130 if (!
parser.parseLibrary(filePath))
result.numberOfFailures++;
135 public static void main(String[]
args)
throws Exception {
136 if (
args.length == 0) helpAndExit();
139 if (
result.numberOfFileArguments == 0) {
141 }
else if (
result.numberOfFileArguments == 1) {
142 if (
result.numberOfFailures > 0) {
143 System.err.println(
"Parsing failed");
144 compileTimeErrorExit();
146 System.out.println(
"Parsing succeeded.");
149 if (
result.numberOfFailures > 0) {
151 "Parsed " +
result.numberOfFileArguments +
" files, " +
152 result.numberOfFailures +
" failed.");
153 compileTimeErrorExit();
155 System.out.println(
"Parsed " +
result.numberOfFileArguments +
156 " files successfully.");
void syntaxError(Recognizer<?,?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e)
void reportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs)
void reportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, ATNConfigSet configs)
void reportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, ATNConfigSet configs)
int numberOfFileArguments
Class for main which will parse files given as command line arguments.
static void main(String[] args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args