MCPcopy Index your code
hub / github.com/antlr/codebuff / Compiler

Class Compiler

output/java8/1.4.17/Compiler.java:49–206  ·  view source on GitHub ↗

A compiler for a single template.

Source from the content-addressed store, hash-verified

47
48
49public class Compiler {
50 public static final String SUBTEMPLATE_PREFIX = "_sub";
51 public static final int TEMPLATE_INITIAL_CODE_SIZE = 15;
52 public static final Map<String, Interpreter.Option> supportedOptions = new HashMap<String, Interpreter.Option>() {{
53 put("anchor", Interpreter.Option.ANCHOR);
54 put("format", Interpreter.Option.FORMAT);
55 put("null", Interpreter.Option.NULL);
56 put("separator", Interpreter.Option.SEPARATOR);
57 put("wrap", Interpreter.Option.WRAP);
58 }};
59 public static final int NUM_OPTIONS = supportedOptions.size();
60 public static final Map<String, String> defaultOptionValues = new HashMap<String, String>() {{
61 put("anchor", "true");
62 put("wrap", "\n");
63 }};
64 public static Map<String, Short> funcs = new HashMap<String, Short>() {{
65 put("first", Bytecode.INSTR_FIRST);
66 put("last", Bytecode.INSTR_LAST);
67 put("rest", Bytecode.INSTR_REST);
68 put("trunc", Bytecode.INSTR_TRUNC);
69 put("strip", Bytecode.INSTR_STRIP);
70 put("trim", Bytecode.INSTR_TRIM);
71 put("length", Bytecode.INSTR_LENGTH);
72 put("strlen", Bytecode.INSTR_STRLEN);
73 put("reverse", Bytecode.INSTR_REVERSE);
74 }};
75
76 /** Name subtemplates {@code _sub1}, {@code _sub2}, ... */
77 public static int subtemplateCount = 0;
78 public STGroup group;
79
80 public Compiler() {
81 this(STGroup.defaultGroup);
82 }
83 public Compiler(STGroup group) {
84 this.group = group;
85 }
86
87 public CompiledST compile(String template) {
88 CompiledST code = compile(null, null, null, template, null);
89 code.hasFormalArgs = false;
90 return code;
91 }
92
93 /** Compile full template with unknown formal arguments. */
94
95 public CompiledST compile(String name, String template) {
96 CompiledST code = compile(null, name, null, template, null);
97 code.hasFormalArgs = false;
98 return code;
99 }
100
101 /** Compile full template with respect to a list of formal arguments. */
102
103 public CompiledST compile(String srcName, String name, List<FormalArgument> args, String template, Token templateToken) {
104 ANTLRStringStream is = new ANTLRStringStream(template);
105 is.name = srcName!=null ? srcName : name;
106 STLexer lexer;

Callers

nothing calls this directly

Calls 2

putMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected