/* Read from the open file fp, and create the linked data structure
   that represents the Makefile contained in the file.
   See the top of pmake.h for the specification of Makefile contents.
 */
Rule *parse_file(FILE *fp) {
    char line[MAXLINE];
    Rule *head = NULL, *current = NULL;

    while (fgets(line, MAXLINE, fp)) {
        if (strlen(line) == MAXLINE - 1 && line[MAXLINE - 2] != '\n') {
            fprintf(stderr, "ERROR: Line too long\n");
            exit(1);
        }

        // Ignore empty lines and comments
        if (line[0] == '\n' || line[0] == '#') {
            continue;
        }

        // If the line starts with a tab, it's an action line
        if (line[0] == '\t') {
            if (current == NULL) {
                fprintf(stderr, "ERROR: Action line without target\n");
                exit(1);
            }
            Action *act = (Action *) malloc(sizeof(Action));
            act->args = (char **) malloc(sizeof(char *) * MAXLINE);

            // Parse the command into an array of strings
            char *arg = strtok(line, " \t\n");
            int i = 0;
            while (arg != NULL) {
                act->args[i] = strdup(arg);
                i++;
                if (i >= MAXLINE - 1) {
                    fprintf(stderr, "ERROR: Too many arguments in action line\n");
                    exit(1);
                }
                arg = strtok(NULL, " \t\n");
            }
            act->args[i] = NULL;
            act->next_act = NULL;

            // Attach the action to the current rule
            if (current->actions == NULL) {
                current->actions = act;
            } else {
                Action *act_curr = current->actions;
                while (act_curr->next_act != NULL) {
                    act_curr = act_curr->next_act;
                }
                act_curr->next_act = act;
            }

        } else {  // It's a target line
            if (current != NULL && current->target == NULL) {
                fprintf(stderr, "ERROR: Empty target\n");
                exit(1);
            }
            else {
                // Parse the target name and create a new Rule node for this target
                Rule *rule = (Rule *) malloc(sizeof(Rule));
                rule->target = strdup(strtok(line, " \t\n"));

                // Parse the dependencies and create a new Dependency node for each of them
                Dependency *dep_head = NULL, *dep_curr = NULL;
                char *dep_str = strtok(NULL, " \t\n");
                while (dep_str != NULL) {
                    Dependency *dep = (Dependency *) malloc(sizeof(Dependency));
                    dep->rule = (Rule *) malloc(sizeof(Rule));
                    dep->rule->target = strdup(dep_str);
                    dep->next_dep = NULL;

                    // Attach the dependency to the current rule
                    if (dep_curr == NULL) {
                        dep_head = dep;
                    } else {
                        dep_curr->next_dep = dep;
                    }
                    dep_curr = dep;
                    dep_str = strtok(NULL, " \t\n");
                }
                rule->dependencies = dep_head;

                // Attach the rule to the list of rules
                rule->actions = NULL;
                rule->next_rule = NULL;
                if (head == NULL) {
                    head = rule;
                } else {
                    current->next_rule = rule;
                }
                current = rule;
            }
        }
    }

    return head;
}


the first letter in the target is not supposed to be missing and there is supposed to be one colon not two colons showing up after the target 