-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestParser.java
More file actions
21 lines (16 loc) · 853 Bytes
/
TestParser.java
File metadata and controls
21 lines (16 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.io.FileInputStream;
import java.io.IOException;
public class TestParser {
public static void main(String[] args) throws Exception {
String inputFile = "test_sample.t4";
if (args.length > 0) inputFile = args[0];
org.antlr.v4.runtime.ANTLRInputStream input = new org.antlr.v4.runtime.ANTLRInputStream(new FileInputStream(inputFile));
generated.T4Lexer lexer = new generated.T4Lexer(input);
org.antlr.v4.runtime.CommonTokenStream tokens = new org.antlr.v4.runtime.CommonTokenStream(lexer);
generated.T4Parser parser = new generated.T4Parser(tokens);
parser.setBuildParseTree(true);
org.antlr.v4.runtime.tree.ParseTree tree = parser.program();
System.out.println("Parse successful!");
System.out.println("Parse tree: " + tree.toStringTree(parser));
}
}