// PRINT public override ASTNode VisitPrintActionStmt(CLUBSParser.PrintActionStmtContext context) { PrintActionNode node = new PrintActionNode(new SourcePosition(context.start)); // Add all elements of the print statement. foreach (CLUBSParser.PrintContentContext content in context.printContent()) { node.Content.Add(Visit(content) as ExpressionNode); } return(node); }
// PRINT public override string Visit(PrintActionNode node, object obj) { StringBuilder builder = new StringBuilder(); builder.Append($"Console.WriteLine("); // Append all content foreach (ASTNode child in node.Content) { if (child is ReferenceNode childReference && childReference.Type is SetTypeNode) { builder.Append($"string.Join(\", \", {Visit(child)})"); // If type is Set, use String.Join }
// PRINT public override TypeNode Visit(PrintActionNode node, object obj) { node.Content.ForEach(x => Visit(x)); return(null); }
public abstract T Visit(PrintActionNode node, object obj);