Fix for Issue #10: Endless loop in BracketNotationParser bug#28
Open
Fix for Issue #10: Endless loop in BracketNotationParser bug#28
Conversation
Collaborator
mateuszpawlik
left a comment
There was a problem hiding this comment.
Only minor comments from my side. I followed the parsing logic but didn't verify carefully.
| std::vector<std::string> tokens = get_tokens(tree_string); | ||
|
|
||
| if (tree_string.size() < 2) { | ||
| throw std::runtime_error("PARSER-ERROR: Tree string needs at least two characters."); |
| if (match_str == kLeftBracket || match_str == kRightBracket) { // Root has an empty label. | ||
| if (match_str == kLeftBracket) { // Root has an empty label. | ||
| match_str = ""; | ||
| // Do not advance tokens - we're already at kLeftBracket or kRightBracket. |
Collaborator
There was a problem hiding this comment.
This comment seems obsolete.
| --open_nodes; | ||
| match_str = ""; | ||
| ++tokens_begin; // Advance tokens. | ||
| // Do not advance tokens - we're already at kLeftBracket or kRightBracket. |
Collaborator
There was a problem hiding this comment.
This comment doesn't fit here.
test/common/to_string_converters.h
Outdated
|
|
||
| /// Convert vector of int values to is string representation. | ||
| /// | ||
| /// TODO: Move this method to some util. |
Collaborator
There was a problem hiding this comment.
It is a string converter so it fits here, no?
| } | ||
|
|
||
| if (test_cases != identified_cases) { | ||
| std::cerr << "Validation test failed: only identified " << |
Collaborator
There was a problem hiding this comment.
Suggested change
| std::cerr << "Validation test failed: only identified " << | |
| std::cerr << "Validation test failed: correctly caught " << |
This is less confusing to me.
Collaborator
Author
|
Thanks for your comments. They are all addressed in the new commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixed parser; removed parser validation function; added exceptions for parser; adjusted tests accordingly