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

tokenize_verilog: tokens can have a sign in general #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions src/ENCRYPTO_utils/parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @param str the string to tokenize
* @param tokens the result vector of wire id
*/
void tokenize_verilog(const std::string& str, std::vector<uint32_t>& tokens, const std::string& delimiters) {
void tokenize_verilog(const std::string& str, std::vector<int>& tokens, const std::string& delimiters) {

tokens.clear();

Expand All @@ -38,7 +38,7 @@ void tokenize_verilog(const std::string& str, std::vector<uint32_t>& tokens, con

while (std::string::npos != pos || std::string::npos != lastPos) {
// Found a token, add it to the vector.
tokens.push_back(atoi(str.substr(lastPos, pos - lastPos).c_str()));
tokens.push_back(stoi(str.substr(lastPos, pos - lastPos)));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
Expand All @@ -64,7 +64,7 @@ void tokenize(const std::string& str, std::vector<uint32_t>& tokens, const std::

while (std::string::npos != pos || std::string::npos != lastPos) {
// Found a token, add it to the vector.
tokens.push_back(atoi(str.substr(lastPos, pos - lastPos).c_str()));
tokens.push_back(stoi(str.substr(lastPos, pos - lastPos)));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
Expand Down
2 changes: 1 addition & 1 deletion src/ENCRYPTO_utils/parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ int32_t parse_options(int32_t* argcp, char*** argvp, parsing_ctx* options, uint3
*/
void print_usage(std::string progname, parsing_ctx* options, uint32_t nops);
void tokenize(const std::string& str, std::vector<uint32_t>& tokens, const std::string& delimiters = "| \t");
void tokenize_verilog(const std::string& str, std::vector<uint32_t>& tokens, const std::string& delimiters = " \t");
void tokenize_verilog(const std::string& str, std::vector<int>& tokens, const std::string& delimiters = " \t");

#endif /* PARSE_OPTIONS_H_ */