static LineParser() { BeginOfFile = new LinePattern(LineType.BeginOfFile, MarkerLines.BeginOfFile, string.Empty); var emptyLine = new LinePattern(LineType.Empty, "^$", string.Empty); var msgctxt = new LinePattern(LineType.MessageContext, @"msgctxt\s+"".*""", @"""(.*)"""); var msgid = new LinePattern(LineType.MessageId, @"msgid\s+"".*""", @"""(.*)"""); var msgidplural = new LinePattern(LineType.MessageIdPlural, @"msgid_plural\s+"".*""", @"""(.*)"""); var msgstr = new LinePattern(LineType.MessageString, @"msgstr\s+"".*""", @"""(.*)"""); var msgstrplural = new LinePattern(LineType.MessageStringPlural, @"msgstr\[\d+\]\s+"".*""", @"""(.*)"""); var text = new LinePattern(LineType.Text, "\"", @"""(.*)"""); var comment = new LinePattern(LineType.Comment, "#", @"#([\s:,.|]\s*.*)"); var endOfFile = new LinePattern(LineType.EndOfFile, MarkerLines.EndOfFile, string.Empty); BeginOfFile .CanBeFollowedBy(msgid) .CanBeFollowedBy(comment) .CanBeFollowedBy(msgctxt) .CanBeFollowedBy(emptyLine); msgctxt .CanBeFollowedBy(text) .CanBeFollowedBy(msgid); msgid .CanBeFollowedBy(msgstr) .CanBeFollowedBy(text) .CanBeFollowedBy(msgidplural); msgstr .CanBeFollowedBy(text) .CanBeFollowedBy(comment) .CanBeFollowedBy(msgctxt) .CanBeFollowedBy(msgid) .CanBeFollowedBy(endOfFile) .CanBeFollowedBy(emptyLine); msgidplural .CanBeFollowedBy(msgstrplural) .CanBeFollowedBy(text); msgstrplural .CanBeFollowedBy(msgstrplural) .CanBeFollowedBySameAs(msgstr); text .After(msgid) .CanBeFollowedBySameAs(msgid) .After(msgstr) .CanBeFollowedBySameAs(msgstr) .After(msgidplural) .CanBeFollowedBySameAs(msgidplural) .After(msgstrplural) .CanBeFollowedBySameAs(msgstrplural) .After(msgctxt) .CanBeFollowedBySameAs(msgctxt); comment .CanBeFollowedBy(comment) .CanBeFollowedBy(msgctxt) .CanBeFollowedBy(msgid) .CanBeFollowedBy(emptyLine) .CanBeFollowedBy(endOfFile); emptyLine .CanBeIgnored(); }