java-antlr4-Add-standalone-generator.patch
1 | From 3b43b79da15be994348f13035474925ba592fe1f Mon Sep 17 00:00:00 2001 |
2 | From: LEPILLER Julien <julien.lepiller@irisa.fr> |
3 | Date: Fri, 15 Sep 2017 10:06:42 +0200 |
4 | Subject: [PATCH] Add standalone template generator |
5 | |
6 | --- |
7 | tool/src/org/antlr/v4/unicode/UnicodeRenderer.java | 33 ++++++++++++++++++++++ |
8 | 1 file changed, 33 insertions(+) |
9 | create mode 100644 tool/src/org/antlr/v4/unicode/UnicodeRenderer.java |
10 | |
11 | diff --git a/tool/src/org/antlr/v4/unicode/UnicodeRenderer.java b/tool/src/org/antlr/v4/unicode/UnicodeRenderer.java |
12 | new file mode 100644 |
13 | index 0000000..9e53213 |
14 | --- /dev/null |
15 | +++ b/tool/src/org/antlr/v4/unicode/UnicodeRenderer.java |
16 | @@ -0,0 +1,33 @@ |
17 | +package org.antlr.v4.unicode; |
18 | + |
19 | +import org.stringtemplate.v4.*; |
20 | +import org.stringtemplate.v4.misc.ErrorBuffer; |
21 | +import org.antlr.v4.unicode.UnicodeDataTemplateController; |
22 | + |
23 | +import java.io.File; |
24 | +import java.io.FileWriter; |
25 | +import java.io.IOException; |
26 | +import java.util.Map; |
27 | +import java.util.Map.Entry; |
28 | + |
29 | +public class UnicodeRenderer extends UnicodeDataTemplateController { |
30 | + public static void main(String[] arg) |
31 | + throws IOException { |
32 | + String inputdir = arg[0]; |
33 | + String input = arg[1]; |
34 | + String output = arg[2]; |
35 | + |
36 | + FileWriter fileWriter = new FileWriter(new File(output)); |
37 | + ErrorBuffer listener = new ErrorBuffer(); |
38 | + |
39 | + STGroupDir group = new STGroupDir(inputdir); |
40 | + ST st = group.getInstanceOf(input); |
41 | + |
42 | + for(Entry<String, Object> entry : getProperties().entrySet()) |
43 | + st.add(entry.getKey(), entry.getValue()); |
44 | + |
45 | + st.write(new AutoIndentWriter(fileWriter), listener); |
46 | + fileWriter.flush(); |
47 | + fileWriter.close(); |
48 | + } |
49 | +} |
50 | -- |
51 | 2.13.5 |
52 | |
53 |