public override int VisitCompileUnit(firstParser.CompileUnitContext context)
        {
            CASTCompileUnit newNode = new CASTCompileUnit(nodeType.NT_COMPILEUNIT, m_parents.Peek(), 1);

            m_parents.Push(newNode);
            base.VisitCompileUnit(context);
            m_parents.Pop();
            return(0);
        }
Пример #2
0
        public override int VisitCompileUnit(firstParser.CompileUnitContext context)
        {
            CASTCompileUnit newnode = new CASTCompileUnit(context.GetText(), nodeType.NT_COMPILEUNIT, null, 1);

            m_root = newnode;
            m_parents.Push(newnode);

            this.VisitElementsInContext(context.expr(), m_parentContext, contextType.CT_COMPILEUNIT_EXPRESSIONS);

            m_parents.Pop();
            return(0);
        }
        public override int VisitCompileUnit([NotNull] firstParser.CompileUnitContext context)
        {
            int serial = ms_serialCounter++;
            //string s = "CompileUnit_" + serial;
            string s = context.GetText();

            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);
        }