* @throws ParseException
*/
public TemplateAST parse(final Template template) throws ParseException {
Lexer lexer = null;
final Engine myEngine = template.engine;
final Resource resource = template.resource;
final TextStatementFactory textStatFactory = myEngine.getTextStatementFactory();
this.template = template;
this.engine = myEngine;
this.textStatementFactory = textStatFactory;
this.locateVarForce = !myEngine.isLooseVar();
this.nativeFactory = myEngine.getNativeFactory();
this.varmgr = new VariantManager(myEngine);
this.currentLabelIndex = 0;
this.labelsIndexMap.put(null, 0);
try {
//ISSUE: LexerProvider
lexer = new Lexer(resource.openReader());
lexer.setTrimCodeBlockBlankLine(myEngine.isTrimCodeBlockBlankLine());
if (resource instanceof ResourceOffset) {
lexer.setOffset((ResourceOffset) resource);
} else {
lexer.setOffset(0, 0);