-
Notifications
You must be signed in to change notification settings - Fork 145
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
[issue1146] Validate SAS file #227
base: main
Are you sure you want to change the base?
Conversation
… InputFileLine in root_task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a look at the code. I don't know the list of things this should check so I didn't verify completeness.
src/search/utils/input_file_parser.h
Outdated
/* | ||
Set context for error reporting. | ||
*/ | ||
void set_context(const std::string &context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is still relevant, but we have classes for the command line parsing that do something similar (for example SyntaxAnalyzerContext
, DecorateContext
, and ConstructContext
, they are different private classes for different use cases but all parallel code). They have an advantage over setting the context manually because they leave the context once they go out of scope. This way you can produce error messages with a stack trace of contexts.
One suggestion would be to use a similar design here, another (more complicated) option would be to extract the common functionality.
int num_facts = file_parser.read_line_int("number of facts in mutex group"); | ||
if (num_facts < 1) { | ||
file_parser.error("Number of facts in mutex group is less than 1, should be at least 1."); | ||
} | ||
vector<FactPair> invariant_group; | ||
invariant_group.reserve(num_facts); | ||
for (int j = 0; j < num_facts; ++j) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we already have a function that reads a list of facts? And doesn't it also need the check that there are no duplicate facts?
|
||
// TODO: Maybe we could move this into a separate function as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
if(next_line != "") { | ||
error("Expected end of file, found non-empty line " + next_line); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
void InputFileParser::confirm_end_of_file() { | |
assert(may_start_line); | |
if (!stream.eof()) { | |
line = find_next_line(); | |
error("Expected end of file, found non-empty line " + line); | |
} |
this would also remove the need of a bool flag in find_next_line
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just added renaming suggestions but i am happy as is.
void TaskParser::confirm_end_of_input() { | ||
find_next_line(false); | ||
if(line != "") { | ||
error("Expected end of task, found non-empty line " + line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename:
task -> task encoding
|
||
class InputFileParser { | ||
/* | ||
Parse a task file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename:
task file -> task encoding
No description provided.