public virtual List <Token> Parse(List <Type> tokensType, Dictionary <string, string> variables) { this.variables = variables; this.newText = this.originalText; if (this.Variables != null && this.Variables.Count > 0) { this.newText = this.OnBeforeVariablesReplacing(this.newText); this.newText = this.VarsRegex.Replace(this.originalText, delegate(Match m) { string variable = m.Groups["tag"].Success ? m.Groups["tag"].Value : m.Groups["func"].Value; if (!this.Variables.ContainsKey(variable)) { throw new Exception(string.Format("Variable with name '{0}' is not found", variable)); } return(this.OnVariableMatch(this.newText, variable, this.Variables)); }); this.newText = this.OnAfterVariablesReplacing(this.newText); } this.tokensType = tokensType; this.tokens = new List <Token>(); this.tokensById = new Dictionary <string, Token>(); this.groups = new Dictionary <string, List <Token> >(); this.newText = this.OnBeforeParse(this.newText); MatchCollection matches = this.TokensRegex.Matches(this.newText); foreach (Match match in matches) { string tagName = match.Groups["tag"].Value; Token token = this.CreateToken(tagName, match); if (token != null) { token.Transformer = this; this.Tokens.Add(token); try { this.TokensById.Add(token.ID, token); } catch (ArgumentException e) { throw new TokenNotUniqueException(token); } this.Groups[tagName].Add(token); token.ParseAnchors(); } this.OnTokenMatch(token); } this.OnAfterParse(this.newText); return(this.tokens); }