public EvoQLExpression(string query, IEnumerable<GetTypes> defaultTypes) { MemoryStream stream = new MemoryStream(); String errorString; StreamWriter writer = new StreamWriter(stream); writer.Write(query); writer.Flush(); Scanner scanner = new Scanner(stream); Parser parser = new Parser(scanner); MemoryStream errorStream = new MemoryStream(); StreamWriter errorWriter = new StreamWriter(errorStream); parser.errors.errorStream = errorWriter; parser.Parse(); errorWriter.Flush(); errorStream.Seek(0, SeekOrigin.Begin); errorString = new StreamReader(errorStream).ReadToEnd(); errorStream.Close(); stream.Close(); if (parser.errors.count > 0) { Errors = errorString.Split('\n'); HadErrors = true; } else { Tree = parser.RootTree; } }
public EvoQLExpression(string query, IEnumerable <GetTypes> defaultTypes) { MemoryStream stream = new MemoryStream(); String errorString; StreamWriter writer = new StreamWriter(stream); writer.Write(query); writer.Flush(); Scanner scanner = new Scanner(stream); Parser parser = new Parser(scanner); MemoryStream errorStream = new MemoryStream(); StreamWriter errorWriter = new StreamWriter(errorStream); parser.errors.errorStream = errorWriter; parser.Parse(); errorWriter.Flush(); errorStream.Seek(0, SeekOrigin.Begin); errorString = new StreamReader(errorStream).ReadToEnd(); errorStream.Close(); stream.Close(); if (parser.errors.count > 0) { Errors = errorString.Split('\n'); HadErrors = true; } else { Tree = parser.RootTree; } }