package com.davidmogar.njc.ast;

import com.davidmogar.njc.ast.statements.Block;

import java.util.List;

public class Program implements AstNode {

    public List<Block> blocks;

    public Program(List<Block> blocks) {
        this.blocks = blocks;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        blocks.forEach(builder::append);
        return builder.toString();
    }
}

package com.davidmogar.njc.ast;

import com.davidmogar.njc.ast.statements.definitions.Definition;

import java.util.List;

public class Program implements AstNode {

    public List<Definition> definitions;

    public Program(List<Definition> definitions) {
        this.definitions = definitions;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        definitions.forEach(builder::append);
        return builder.toString();
    }
}

Change Program to accept definitions instead of blocks