-
Notifications
You must be signed in to change notification settings - Fork 147
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
draft realted to formats #144
Conversation
src/conv/k-g/k_parser.cpp
Outdated
@@ -254,6 +362,25 @@ bool parse_k | |||
else | |||
std::cout << "Unexpected command " << tokens[0] << " in k-file " << fileName << "\n"; | |||
} | |||
else if (command[0] == "KEYWORD") { | |||
if (tokens.size() == 2) { |
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 looks like there could be many keys in any order?
Therefore I would recommend to loop through them with a for-loop, split the keys at the "=" character, and decide then about the format. The last one has it?
The split could be done in an own function: std::pair<std::string, std::string> split_key(const char* key)
.
BTW, maybe some of the const char*
could be replacved by const std::string&
? 🤔
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.
yes there is usually mutiple keys (Formats), but I don't know if they come in any order. I will check it out.
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.
it's actually more complicated, they *Keyword options are 1- Number i.e (*KEYWORD 120m) this requests for 120 million words of memeory. 2- memory2=j, i.e ( *KEYWORD 120m memory2=j) this defines the memory allocation in words for the first core and j defines the memory allocation in words for each of the remaining cores. 3- NCPU i.e (*KEYWORD NCPU=n) it defines the number Shared Memory Parallel (SMP) threads of "n" to be used for each processor during the analyhsis. all these dont affect the format. for the format you have the standard where is nothing written after the *KEYWORD. For Long format you find LONG=S or LONG=Y or LONG=K. For I10 there is written I10 then LONG=S i.e (*KEYWORD I10 LONG=S). I don't konw if splitting the keys with the function will be any more different. but I think it will be nicer. I will prepare it
if (nodeFormat == ReadFormat::Standard) { | ||
tokens = read_line_node_standard(line.c_str()); | ||
} | ||
else if (nodeFormat == ReadFormat::Long) { |
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.
You need to catch the two line format here. E.g.:
- have a variable for the first line
- if this variable is empty and the result of read_line_node_long() has the size 4 => write it to the variable and go on
- if this variable is not empty => add the result of read_line_node_long() to it, generate the node, and clear the variable
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.
yes, thank you for the notes.
src/conv/k-g/k_parser.cpp
Outdated
std::string temp; | ||
|
||
for (size_t i = 0; i < strlen(line); ++i) { | ||
if (line[i] == ',' || line[i] == ' ') { |
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.
Spaces can appear in the fixed format data too. Therefore, you cannot use it as a flag for comma-separated(?)
How about using if (strchr(line, '\') != nullptr)
as criterion?
in a key file there is mutliple places where the format might be determined. this is a first draft to handle multiple cases of different formats.