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