forked from antlr/antlr4
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RuntimeTestDescriptor.java
99 lines (78 loc) · 3.06 KB
/
RuntimeTestDescriptor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
package org.antlr.v4.test.runtime;
import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.misc.Pair;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
/** This object represents all the information we need about a single test and is the
* in-memory representation of a descriptor file
*/
public class RuntimeTestDescriptor {
/** A type in {"Lexer", "Parser", "CompositeLexer", "CompositeParser"} */
public final GrammarType testType;
/** Return a string representing the name of the target currently testing
* this descriptor.
* Multiple instances of the same descriptor class
* can be created to test different targets.
*/
public final String name;
public final String notes;
/** Parser input. Return "" if not input should be provided to the parser or lexer. */
public final String input;
/** Output from executing the parser. Return null if no output is expected. */
public final String output;
/** Parse errors Return null if no errors are expected. */
public final String errors;
/** The rule at which parsing should start */
public final String startRule;
public final String grammarName;
public final String grammar;
/** List of grammars imported into the grammar */
public final List<Pair<String, String>> slaveGrammars;
/** For lexical tests, dump the DFA of the default lexer mode to stdout */
public final boolean showDFA;
/** For parsing, engage the DiagnosticErrorListener, dumping results to stderr */
public final boolean showDiagnosticErrors;
public final boolean traceATN;
public final PredictionMode predictionMode;
public final boolean buildParseTree;
public final String[] skipTargets;
public final URI uri;
public RuntimeTestDescriptor(GrammarType testType, String name, String notes,
String input, String output, String errors,
String startRule,
String grammarName, String grammar, List<Pair<String, String>> slaveGrammars,
boolean showDiagnosticErrors, boolean traceATN, boolean showDFA, PredictionMode predictionMode,
boolean buildParseTree, String[] skipTargets, URI uri) {
this.testType = testType;
this.name = name;
this.notes = notes;
this.input = input;
this.output = output;
this.errors = errors;
this.startRule = startRule;
this.grammarName = grammarName;
this.grammar = grammar;
this.slaveGrammars = slaveGrammars;
this.showDFA = showDFA;
this.showDiagnosticErrors = showDiagnosticErrors;
this.traceATN = traceATN;
this.predictionMode = predictionMode;
this.buildParseTree = buildParseTree;
this.skipTargets = skipTargets != null ? skipTargets : new String[0];
this.uri = uri;
}
/** Return true if this test should be ignored for the indicated target */
public boolean ignore(String targetName) {
return Arrays.asList(skipTargets).contains(targetName);
}
@Override
public String toString() {
return name;
}
}