internal PoLine ReadLine()
{
string s = reader.ReadLine();
if (s == null)
return null;
lineNumber += 1;
s = s.Trim();
if (s == "") {
return new PoLine() {kind = PoLineKind.Blank};
}
else if (s.StartsWith("#:")) {
s = s.Substring(2).Trim(); // Remove command part.
string[] a = s.Split(new char[] { ' ', '\t', ',' }, 2, StringSplitOptions.RemoveEmptyEntries);
return new PoLine() { kind = PoLineKind.LocationComment, str1 = a[0], str2 = a[1] };
}
else if (s.StartsWith("#")) {
return new PoLine() { kind = PoLineKind.Comment };
}
else if (s.StartsWith("\"")) {
if (!s.EndsWith("\"") || s.Length < 2)
PoSyntaxError();
s = s.Substring(1, s.Length - 2);
return new PoLine() { kind = PoLineKind.String, str1 = ConvertQuotedString(s) };
}
else {
int i = 0;
while (i < s.Length && s[i] != ' ' && s[i] != '\t')
++i;
if (i >= s.Length || i == 0)
PoSyntaxError();
string keyword = s.Substring(0, i);
s = s.Substring(i).Trim();
if (!(s.StartsWith("\"") && s.EndsWith("\"") && s.Length > 1))
PoSyntaxError();
s = s.Substring(1, s.Length - 2);
return new PoLine() { kind = PoLineKind.KeywordString, str1 = keyword, str2 = ConvertQuotedString(s) };
}
}