internal static bool LineTryMatch(this Lines lines, int lineNo, Regex regex, out Match match, bool consume) { if (!lines.Any()) { match = null; return(false); } if (lines.Count() < lineNo) { match = null; return(false); } var line = lines[lineNo]; match = regex.Match(line); if (match.Success && consume) { lines.Consume(lineNo, match.Index, match.Length); } return(match.Success); }
internal void ParseProcedures(Lines lines) { while (lines.Any()) { if (!ParseProcedure(lines)) { if (!ParseEvent(lines)) { ParseDocumentation(lines); } } } }
internal void ParseDocumentation(Lines lines) { lines.FirstLineMustMatch(Patterns.BeginDocumentation); lines.LastLineMustMatch(Patterns.EndDocumentation); if (lines.FirstLineTryMatch(Patterns.BeginSection)) { lines.LastLineMustMatch(Patterns.EndSection); } lines.Unindent(2); while (lines.Any()) { Listener.OnCodeLine(lines.FirstLineMustMatch(Patterns.Any).Value); } }