public IList <Token> Parse(string source) { var tokens = new List <Token>(); var line = 1; var column = 1; for (int i = 0; i < source.Length;) { bool shouldContinue = false; foreach (var re in IgnoreList) { var m = re.Match(source, i); if (m.Success) { var n = m.Groups[0].Value.Count(c => c == '\n'); if (n > 0) { line += n; column = 1; } i += m.Length; shouldContinue = true; break; } } if (shouldContinue) { continue; } var token = ParserContainer.ParseToken(source, ref i); if (token == null) { throw new UnexpectedTokenException(TokenType.NoMatch, string.Format("Unexpected token: L{0}:C{1}", line, column)); } tokens.Add(token); token.SourceInfo = new SourceInfo(FilePath, line, column); } return(tokens); }