public override int VisitCompileUnit(MINICParser.CompileUnitContext context) { CASTCompileUnit newnode = new CASTCompileUnit(context.GetText(), null, 2); m_root = newnode; m_parents.Push(newnode); this.VisitElementsInContext(context.statement(), m_parentContext, contextType.CT_COMPILEUNIT_MAINBODY); this.VisitElementsInContext(context.functionDefinition(), m_parentContext, contextType.CT_COMPILEUNIT_FUNCTIONDEFINITIONS); m_parents.Pop(); return(0); }
public override int VisitCompileUnit([NotNull] MINICParser.CompileUnitContext context) { int serial = ms_serialCounter++; string s = "CompileUnit_" + serial; m_labels.Push(s); outFile.WriteLine("digraph G{"); base.VisitChildren(context); outFile.WriteLine("}"); m_labels.Pop(); outFile.Close(); // Prepare the process dot to run ProcessStartInfo start = new ProcessStartInfo(); // Enter in the command line arguments, everything you would enter after the executable name itself start.Arguments = "-Tgif " + Path.GetFileName("test.dot") + " -o " + Path.GetFileNameWithoutExtension("test") + ".gif"; // Enter the executable to run, including the complete path start.FileName = "dot"; // Do you want to show a console window? start.WindowStyle = ProcessWindowStyle.Hidden; start.CreateNoWindow = true; int exitCode; // Run the external process & wait for it to finish using (Process proc = Process.Start(start)) { proc.WaitForExit(); // Retrieve the app's exit code exitCode = proc.ExitCode; } return(0); }