Skip to content

Conversation

@thuetter
Copy link
Collaborator

fixed parser; removed parser validation function; added exceptions for parser; adjusted tests accordingly

@thuetter thuetter linked an issue May 17, 2023 that may be closed by this pull request
@thuetter thuetter requested a review from mateuszpawlik May 17, 2023 13:23
Copy link
Collaborator

@mateuszpawlik mateuszpawlik left a comment

Choose a reason for hiding this comment

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

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.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would use std::invalid_argument.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment seems obsolete.

--open_nodes;
match_str = "";
++tokens_begin; // Advance tokens.
// Do not advance tokens - we're already at kLeftBracket or kRightBracket.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment doesn't fit here.


/// Convert vector of int values to is string representation.
///
/// TODO: Move this method to some util.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is a string converter so it fits here, no?

}

if (test_cases != identified_cases) {
std::cerr << "Validation test failed: only identified " <<
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
std::cerr << "Validation test failed: only identified " <<
std::cerr << "Validation test failed: correctly caught " <<

This is less confusing to me.

@thuetter
Copy link
Collaborator Author

Thanks for your comments. They are all addressed in the new commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Endless loop in BracketNotationParser

3 participants