package com.jfireel.template.parser.impl;

import com.jfireel.template.ScanMode;
import com.jfireel.template.Template;
import com.jfireel.template.execution.Execution;
import com.jfireel.template.parser.Invoker;
import com.jfireel.template.parser.Parser;

import java.util.Deque;

public class ExecutionBeginParser extends Parser {

	@Override
	public int parse(String sentence, int offset, Deque<Execution> executions, Template template, StringBuilder cache,
			Invoker next) {
		if (isExecutionBegin(offset, sentence) == false) {
			return next.scan(sentence, offset, executions, template, cache);
		}
		offset += 2;
		template.setMode(ScanMode.EXECUTION);
		extractLiterals(cache, executions);
		offset = skipWhiteSpace(offset, sentence);
		return offset;
	}

}
