<commit_before>package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.util.NoSuchElementException;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.IncorrectCommand;
import seedu.address.model.task.exceptions.InvalidDurationException;
import seedu.address.model.task.exceptions.PastDateTimeException;


//@@author A0140023E
/**
 * Parses input arguments and creates a new AddCommand object
 */
public class AddCommandParser {

    /**
     * Parses the given {@code String} of arguments in the context of the AddCommand
     * and returns an AddCommand object for execution.
     */
    public Command parse(String args) {
        DateTimeExtractor dateTimeExtractor = new DateTimeExtractor(args);
        // TODO Returns an exception in a method? Doesn't make sense
        // Returns a string? seems brittle
        try {
            // process StartEndDateTime first because it is more constrained
            dateTimeExtractor.processStartEndDateTime();
        } catch (PastDateTimeException e) {
            return new IncorrectCommand(e.getMessage());
        } catch (InvalidDurationException e) {
            return new IncorrectCommand(e.getMessage());
        } catch (IllegalValueException e) {
            // Dates can't be parsed so we silently skip first
            // all other exceptions have been handled
            // Pass rose from Uncle to Jane by tmr
            // we should not return an error because that case is a valid task
            System.out.println("No date is found for start and en date");
        }
        // TODO Returns an exception in a method? Doesn't make sense
        // Returns a string? seems brittle
        try {
            dateTimeExtractor.processDeadline();
        } catch (PastDateTimeException e) {
            return new IncorrectCommand(e.getMessage());
        } catch (IllegalValueException e) {
            // No date is found so we silently skip
            System.out.println("No date found for deadline!");
        }

        // TODO ArgumentTokenizer became very irrelevant in this class but is it still relevant for other classes?
        ArgumentTokenizer argsTokenizer = new ArgumentTokenizer(PREFIX_TAG);
        argsTokenizer.tokenize(dateTimeExtractor.getProcessedArgs());
        try {
            String nameArgs = argsTokenizer.getPreamble().get();<commit_msg>Update comments in AddCommandParser<commit_after>package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.util.NoSuchElementException;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.IncorrectCommand;
import seedu.address.model.task.exceptions.InvalidDurationException;
import seedu.address.model.task.exceptions.PastDateTimeException;


//@@author A0140023E
/**
 * Parses input arguments and creates a new AddCommand object
 */
public class AddCommandParser {

    /**
     * Parses the given {@code String} of arguments in the context of the AddCommand
     * and returns an AddCommand object for execution.
     */
    public Command parse(String args) {
        DateTimeExtractor dateTimeExtractor = new DateTimeExtractor(args);
        // TODO Returns an exception in a method? Doesn't make sense
        // Returns a string? seems brittle, therefore to rewrite the class to preserve state
        try {
            // process StartEndDateTime first because it is more constrained
            dateTimeExtractor.processStartEndDateTime();
        } catch (PastDateTimeException e) {
            return new IncorrectCommand(e.getMessage());
        } catch (InvalidDurationException e) {
            return new IncorrectCommand(e.getMessage());
        } catch (IllegalValueException e) {
            // Dates can't be parsed so we silently skip first
            // all other exceptions have been handled
            // Pass rose from Uncle to Jane by tmr
            // we should not return an error because that case is a valid task
            System.out.println("No date is found for start and end date");
        }
        // TODO Returns an exception in a method? Doesn't make sense
        // Returns a string? seems brittle
        try {
            dateTimeExtractor.processDeadline();
        } catch (PastDateTimeException e) {
            return new IncorrectCommand(e.getMessage());
        } catch (IllegalValueException e) {
            // No date is found so we silently skip
            System.out.println("No date found for deadline!");
        }

        // TODO ArgumentTokenizer became very irrelevant in this class but is it still relevant for other classes?
        ArgumentTokenizer argsTokenizer = new ArgumentTokenizer(PREFIX_TAG);
        argsTokenizer.tokenize(dateTimeExtractor.getProcessedArgs());
        try {
            String nameArgs = argsTokenizer.getPreamble().get();
{'fraction_non_alphanumeric': 0.07472237907020515, 'fraction_numerical': 0.002635046113306983, 'mean_word_length': 2.890190336749634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2495624', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1296, 'n_words': 436}