-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add m4_define_default PARSER_NS for namespace overwritability
- Loading branch information
Showing
6 changed files
with
44 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
m4_changequote() | ||
|
||
yy::parser::symbol_type make_NUMBER(const std::string &s, const yy::parser::location_type& loc) { | ||
PARSER_NS ::parser::symbol_type make_NUMBER(const std::string &s, const PARSER_NS ::parser::location_type& loc) { | ||
errno = 0; | ||
long n = strtol (s.c_str(), NULL, 10); | ||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE)) | ||
throw yy::parser::syntax_error (loc, "integer is out of range: " + s); | ||
return yy::parser::make_NUMBER ((int) n, loc); | ||
throw PARSER_NS ::parser::syntax_error (loc, "integer is out of range: " + s); | ||
return PARSER_NS ::parser::make_NUMBER ((int) n, loc); | ||
} | ||
|
||
yy::parser::symbol_type make_FLOAT(const std::string &s, const yy::parser::location_type& loc) { | ||
PARSER_NS ::parser::symbol_type make_FLOAT(const std::string &s, const PARSER_NS ::parser::location_type& loc) { | ||
try { | ||
double n = std::stod(s.c_str()); | ||
return yy::parser::make_FLOAT((double)n, loc); | ||
return PARSER_NS ::parser::make_FLOAT((double)n, loc); | ||
} catch(std::out_of_range& e) { | ||
throw yy::parser::syntax_error (loc, "double is out of range: " + s); | ||
throw PARSER_NS ::parser::syntax_error (loc, "double is out of range: " + s); | ||
} | ||
} | ||
|
||
yy::parser::symbol_type make_STRING(const std::string &s, const yy::parser::location_type& loc) { | ||
return yy::parser::make_STRING(s.substr(1, s.size()-2), loc); | ||
PARSER_NS ::parser::symbol_type make_STRING(const std::string &s, const PARSER_NS ::parser::location_type& loc) { | ||
return PARSER_NS ::parser::make_STRING(s.substr(1, s.size()-2), loc); | ||
} | ||
|
||
yy::parser::symbol_type make_BOOL(std::string s, const yy::parser::location_type& loc) { | ||
PARSER_NS ::parser::symbol_type make_BOOL(std::string s, const PARSER_NS ::parser::location_type& loc) { | ||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c){ return std::tolower(c); }); | ||
bool b; | ||
std::istringstream(s) >> std::boolalpha >> b; | ||
return yy::parser::make_BOOL(b, loc); | ||
return PARSER_NS ::parser::make_BOOL(b, loc); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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