Exemplo n.º 1
0
        // 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
                }
Exemplo n.º 3
0
 // PRINT
 public override TypeNode Visit(PrintActionNode node, object obj)
 {
     node.Content.ForEach(x => Visit(x));
     return(null);
 }
Exemplo n.º 4
0
 public abstract T Visit(PrintActionNode node, object obj);