Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser bug fixes and refinements #109

Merged
merged 1 commit into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

public class ListCommandParser implements CommandParser<ListCommand> {
private static final String HEADER = "list";
private static final String READABLE_FORMAT = HEADER+" [t/LIST_TYPE]";
private static final String READABLE_FORMAT = HEADER+" [LIST_TYPE]";

private static final String REGEX_REF_LIST_TYPE = "ListType";

private static final Pattern REGEX_PATTERN = Pattern.compile(
HEADER+"\\s*((?<=\\s)t/(?<"+REGEX_REF_LIST_TYPE+">[^/]+))?",
HEADER+"\\s*((?<=\\s)(?<"+REGEX_REF_LIST_TYPE+">[^/]+))?",
Pattern.CASE_INSENSITIVE);

@Override
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/seedu/savvytasker/logic/parser/MasterParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class MasterParser {
private static final Pattern KEYWORD_PATTERN =
Pattern.compile("(\\S+)(\\s+|$)");
Pattern.compile("([^\\s/]+)([\\s/]+|$)");

private final Map<String, CommandParser<? extends Command>> commandParsers;
private final Map<String, AliasSymbol> aliasingSymbols;
Expand All @@ -26,6 +26,16 @@ public MasterParser() {
this.aliasingSymbols = new HashMap<String, AliasSymbol>();
}

/**
* Parses the input text, selecting an appropriate registered parser to parse it.
* The parser selected is based on the first header word of the input text. The text
* is preprocessed, replacing any of its tokens that are keywords to an alias, before
* being passed to the parser.
*
* @param userInput the text to be parse
* @return the command that was parsed if successful, or IncorrectCommand if there is no
* parser that can parse the text or if there is a format error with the text.
*/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test code review

public Command parse(String userInput) {
String[] pieces = preprocessInitial(userInput.trim());
if (pieces == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/**
* This class contains common parsing methods for parsing Task fields.
* Each of the parse method takes in a string which can be null, and return
* the respective parsed object.
*/
public class TaskFieldParser {
protected final DateParser dateParser;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/savvytasker/ui/TaskListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import seedu.savvytasker.model.task.ReadOnlyTask;

/**
* Panel containing the list of persons.
* Panel containing the list of tasks.
*/
public class TaskListPanel extends UiPart {
private final Logger logger = LogsCenter.getLogger(TaskListPanel.class);
Expand Down Expand Up @@ -74,7 +74,7 @@ private void addToPlaceholder() {
private void setEventHandlerForSelectionChangeEvent() {
taskListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
logger.fine("Selection in person list panel changed to : '" + newValue + "'");
logger.fine("Selection in task list panel changed to : '" + newValue + "'");
raise(new TaskPanelSelectionChangedEvent(newValue));
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/savvytasker/logic/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ public void parse_list_noParametersSpaces() throws ParseException {

@Test
public void parse_list_valid() throws ParseException {
assertNotNull(listParser.parse("list t/ Priority Level "));
assertNotNull(listParser.parse("list Priority Level "));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test code review 2

}

@Test
public void parse_list_invalidType() throws ParseException {
thrown.expect(ParseException.class);
listParser.parse("list t/ Error ");
listParser.parse("list Error ");
}

//==================================================================================
Expand Down