public string Preprocess(string script, string scriptName)
{
StringBuilder output = new StringBuilder(script.Length);
output.AppendLine(Constants.NEW_SCRIPT_MARKER + scriptName + "\"");
StringReader reader = new StringReader(script);
string thisLine;
_scriptName = scriptName;
_lineNumber = 0;
while ((thisLine = reader.ReadLine()) != null)
{
_lineNumber++;
thisLine = RemoveComments(thisLine);
if (thisLine.Length > 0)
{
if (thisLine[0] != '#')
{
thisLine = PreProcessLine(thisLine);
}
else
{
thisLine = PreProcessDirective(thisLine);
}
}
if (thisLine.Length >= MAX_LINE_LENGTH)
{
// For compatibility with legacy CSPARSER, which assumes lines
// will not be longer than 500 chars. Remove once new compiler
// is implemented.
RecordError(ErrorCode.LineTooLong, "Line too long (max line length = " + MAX_LINE_LENGTH + ")");
}
output.AppendLine(thisLine);
}
reader.Close();
if (_conditionalStatements.Count > 0)
{
RecordError(ErrorCode.IfWithoutEndIf, "Missing #endif");
}
return output.ToString();
}