public override int VisitProg(RParser.ProgContext context) { // PREORDER ACTIONS m_outputStream.WriteLine("digraph {\n"); string label = "Prog_" + ms_ASTElementCounter.ToString(); //m_outputStream.WriteLine("\"{0}\"->\"{1}\";", m_PTPath.Peek(), label); ms_ASTElementCounter++; m_PTPath.Push(label); base.VisitProg(context); // POSTORDER ACTIONS m_PTPath.Pop(); m_outputStream.WriteLine("}"); m_outputStream.Close(); if (true) { Process process = new Process(); // Configure the process using the StartInfo properties. process.StartInfo.FileName = @".\Graphviz\bin\dot.exe"; process.StartInfo.Arguments = "-Tgif " + m_outputFile + " -o" + Path.GetFileNameWithoutExtension(m_outputFile) + ".gif"; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); process.WaitForExit();// Waits here for the process to exit. } return(0); }
private static SyntaxNode Program(RParser.ProgContext prog, Func <ParserRuleContext, Scope, SyntaxNode> transform, Scope scope) { var statements = new List <StatementSyntax>(); var inner = new Scope(scope); inner.InitR(); var pre = inner.PreStatements(); foreach (var expr in prog.expr_or_assign()) { pre.Clear(); var statement = transform(expr, inner) as StatementSyntax; Debug.Assert(statement != null); statements.AddRange(pre); statements.Add(statement); } return(CSharp.Block(statements)); }
public override int VisitProg(RParser.ProgContext context) { // PREORDER ACTIONS // Create new element RASTComposite newElement = new RProg(); // Update root m_root = newElement; // Update parents stack m_parents.Push(newElement); // VISIT CHILDREN VisitElementsInContext(context._expressions, ContextType.CT_PROG); // POSTORDER ACTIONS // Update parents stack m_parents.Pop(); return(0); }
/// <summary> /// Exit a parse tree produced by <see cref="RParser.prog"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitProg([NotNull] RParser.ProgContext context) { }