package seedu.doist.logic.parser;

import static seedu.doist.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.doist.logic.parser.CliSyntax.*;
import java.util.NoSuchElementException;

import seedu.doist.commons.exceptions.IllegalValueException;
import seedu.doist.logic.commands.AddCommand;
import seedu.doist.logic.commands.Command;
import seedu.doist.logic.commands.IncorrectCommand;

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

    ////argsTokenizer.getValue(PREFIX_PHONE).get() is an an example of how to use the tokenizer
    /**
     * 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) {
        ArgumentTokenizer argsTokenizer =
                new ArgumentTokenizer(PREFIX_FROM, PREFIX_TO, PREFIX_REMIND, PREFIX_EVERY, PREFIX_AS, PREFIX_BY,  PREFIX_UNDER);
        argsTokenizer.tokenize(args);
        try {
            System.out.println("REaching = " + argsTokenizer.getPreamble().get());
            return new AddCommand(
                    argsTokenizer.getPreamble().get(),
                    argsTokenizer.getValue(PREFIX_FROM).get(),
                    argsTokenizer.getValue(PREFIX_TO).get(),
                    argsTokenizer.getValue(PREFIX_REMIND).get(),
                    argsTokenizer.getValue(PREFIX_EVERY).get(),
                    argsTokenizer.getValue(PREFIX_AS).get(),
                    argsTokenizer.getValue(PREFIX_BY).get(),
                    argsTokenizer.getValue(PREFIX_UNDER).get()
                    );
        } catch (NoSuchElementException nsee) {
            return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
        } catch (IllegalValueException ive) {
            return new IncorrectCommand(ive.getMessage());
        }
    }

}

@@ -200,16 +200,80 @@
 ception;
+%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;
 %0A%0Aimport
@@ -408,32 +408,79 @@
 mmands.Command;%0A
+import seedu.doist.logic.commands.HelpCommand;%0A
 import seedu.doi
@@ -619,16 +619,162 @@
 rser %7B%0A%0A
+    private static final Pattern Add_Command_Regex = Pattern.compile(%22(?%3Cpreamble%3E%5B%5E%5C%5C%5C%5C%5D*)(?%3Cparameters%3E((%5C%5C%5C%5C)(%5C%5CS+)(%5C%5Cs+)(%5B%5E%5C%5C%5C%5C%5D*))*)%22);%0A    %0A
     ////
@@ -1053,24 +1053,457 @@
 ing args) %7B%0A
+        final Matcher matcher = Add_Command_Regex.matcher(args.trim());%0A        if (!matcher.matches() %7C%7C args.trim().equals(%22%22)) %7B%0A            System.out.println(%22hit%22);%0A            return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));%0A        %7D%0A%0A        final String argument = matcher.group(%22preamble%22);%0A        final String parameters = matcher.group(%22parameters%22);%0A              %0A
         Argu
@@ -1532,18 +1532,16 @@
 nizer =%0A
-  
         
@@ -1642,17 +1642,16 @@
 EFIX_BY,
- 
  PREFIX_
@@ -1693,14 +1693,30 @@
 ize(
+p
 ar
-gs);
+ameters); %0A        
 %0A   
@@ -1742,79 +1742,191 @@
     
-System.out.println(%22REaching = %22 + argsTokenizer.getPreamble().
+return new AddCommand();%0A        %7D catch (IllegalValueException ive) %7B%0A            return new IncorrectCommand(ive.getMessa
 ge
-t
 ());%0A
+        %7D%0A//       %0A//        try %7B%0A//            %0A//
     
@@ -1956,16 +1956,18 @@
 ommand(%0A
+//
         
@@ -2005,32 +2005,34 @@
 eamble().get(),%0A
+//
                 
@@ -2070,32 +2070,34 @@
 IX_FROM).get(),%0A
+//
                 
@@ -2133,32 +2133,34 @@
 EFIX_TO).get(),%0A
+//
                 
@@ -2200,32 +2200,34 @@
 _REMIND).get(),%0A
+//
                 
@@ -2266,32 +2266,34 @@
 X_EVERY).get(),%0A
+//
                 
@@ -2329,32 +2329,34 @@
 EFIX_AS).get(),%0A
+//
                 
@@ -2400,16 +2400,18 @@
 .get(),%0A
+//
         
@@ -2465,16 +2465,18 @@
 ).get()%0A
+//
         
@@ -2490,16 +2490,18 @@
      );%0A
+//
         
@@ -2536,24 +2536,26 @@
 ion nsee) %7B%0A
+//
             
@@ -2648,32 +2648,34 @@
 ESSAGE_USAGE));%0A
+//
         %7D catch 
@@ -2696,33 +2696,34 @@
 xception ive) %7B%0A
- 
+//
            retur
@@ -2721,55 +2721,11 @@
     
-return new IncorrectCommand(ive.getMessage());%0A
+%0A//
     

Edit class to implement own parser