Hi,
I've created a lexer using flex. Now I want this lexer to be used in my C# application. I've tried to do this with code below:
private void btParse_Click(object sender, EventArgs e)
{
Process lex = new Process();
StreamWriter sIn = null;
StreamReader sOut = null;
StreamReader fileReader = null;
try
{
lex.StartInfo.UseShellExecute = false;
lex.StartInfo.FileName = tbLexerName.Text.Trim();
lex.StartInfo.RedirectStandardInput = true;
lex.StartInfo.RedirectStandardOutput = true;
lex.StartInfo.CreateNoWindow = true;
lex.Start();
sIn = lex.StandardInput;
sOut = lex.StandardOutput;
fileReader = new StreamReader(".\\" + tbInputFile.Text.Trim(), Encoding.UTF8);
sIn.WriteLine(fileReader.ReadToEnd());
fileReader.Close();
sIn.Close();
tbOutput.Text = sOut.ReadToEnd();
sOut.Close();
}
catch (Exception ex)
{
MessageBox.Show("An error occured: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (sIn != null)
sIn.Close();
if (sOut != null)
sOut.Close();
if (fileReader != null)
fileReader.Close();
lex.Close();
}
}
It works fine until the response from the lexer getting bigger than about 20KB. NO exception is thrown it just gets stuck. Lexer, not executed from the app, even with much bigger files works great, very fast. Any idea how to handle this?
Thanks in advance,
Szpilona