@Override
    public Makefile parse(String makefilePath) throws IOException {
        MakefileBuilder makefileBuilder = new MakefileBuilder();

        String currentTarget = null;
        MakefileExecution currentExecution = null;

        BufferedReader lineReader = new BufferedReader(new FileReader(makefilePath));

        for (String line = lineReader.readLine(); line != null; line = lineReader.readLine()) {
            if (StringUtils.isBlank(line) || line.startsWith("#")) {
                continue;
            }

            if (isTarget(line)) {
                if (currentTarget != null) {
                    makefileBuilder.addTarget(currentTarget, currentExecution);
                }

                TargetAndParents targetAndParents = parseTargetLine(line);
                currentTarget = targetAndParents.target;
                currentExecution = new MakefileExecution(targetAndParents.parents);

            } else if (isCommand(line)) {
                if (currentExecution == null) {
                    throw new IllegalStateException("Command without target: " + line);
                }
                currentExecution.addCommand(parseCommand(line));
            }
        }

        if (currentTarget != null) {
            makefileBuilder.addTarget(currentTarget, currentExecution);
        }

        return makefileBuilder.build();
    }