private int GetNextChar()
{
int c = int.MinValue;
// consume from backString if possible
if (backString.Length > 0)
{
c = backString[0];
backString.Remove(0, 1);
#if DEBUG
log.Debug("Backup char '{0}'", (char)c);
#endif
return (c);
}
if (textReader == null) return (Eof);
try
{
while ((c = textReader.Read()) == 13) { } // skip LF (13)
}
catch (Exception)
{
return (Eof);
}
if (c == 10)
{
lineNumber++;
#if DEBUG
log.Debug("Line number incremented to {0}", lineNumber.ToString());
#endif
}
else if (c < 0)
{
c = Eof;
}
#if DEBUG
log.Debug("Read char '{0}' ({1})", (char)c, c);
#endif
return (c);
}