Compiler { public ValidatedTemplate validate(String template) throws CodeSyntaxException { CodeList sink = new CodeList(); CodeStats stats = new CodeStats(); Tokenizer tokenizer = new Tokenizer(template, sink, formatterTable, predicateTable); tokenizer.setValidate(); tokenizer.consume(); CodeMachine machine = new CodeMachine(); machine.setValidate(); for (Instruction inst : sink.getInstructions()) { machine.accept(inst); stats.accept(inst); } machine.complete(); stats.complete(); List<ErrorInfo> errors = joinErrors(tokenizer.getErrors(), machine.getErrors()); return new ValidatedTemplate(sink, stats, errors); } Compiler(FormatterTable formatterTable, PredicateTable predicateTable); FormatterTable formatterTable(); PredicateTable predicateTable(); CompilerExecutor newExecutor(); CompiledTemplate compile(String template); CompiledTemplate compile(String template, boolean safeMode, boolean preprocess); ValidatedTemplate validate(String template);  }
@Test public void testValidate() throws CodeException { CodeList code = new CodeList(); code.accept(new VariableInst("@")); code.accept(new EofInst()); ValidatedTemplate validated = COMPILER.validate("{@}"); assertEquals(validated.code().getInstructions(), code.getInstructions()); }