Added peg::udl for 'tag' user defined literal.

This commit is contained in:
yhirose 2017-03-25 18:28:15 -04:00
parent 1520849708
commit 6b63bd48af
4 changed files with 7 additions and 3 deletions

View File

@ -547,7 +547,7 @@ struct Interpreter
}
Value eval(const peg::Ast& ast, std::shared_ptr<Environment> env) {
using peg::operator"" _;
using namespace peg::udl;
if (debugger_) {
if (ast.original_tag == "STATEMENT"_) {
@ -715,7 +715,7 @@ private:
}
Value eval_call(const peg::Ast& ast, std::shared_ptr<Environment> env) {
using peg::operator"" _;
using namespace peg::udl;
Value val = eval(*ast.nodes[0], env);
@ -836,7 +836,7 @@ private:
}
return rval;
} else {
using peg::operator"" _;
using namespace peg::udl;
Value lval = eval(*ast.nodes[lvaloff], env);

View File

@ -6,6 +6,7 @@
#include <vector>
using namespace peg;
using namespace peg::udl;
using namespace std;
bool read_file(const char* path, vector<char>& buff)

View File

@ -11,6 +11,7 @@
#include <sstream>
using namespace peg;
using namespace peg::udl;
using namespace std;
/*

View File

@ -2151,9 +2151,11 @@ inline constexpr unsigned int str2tag(const char* str, int h = 0) {
return !str[h] ? 5381 : (str2tag(str, h + 1) * 33) ^ static_cast<unsigned char>(str[h]);
}
namespace udl {
inline constexpr unsigned int operator "" _(const char* s, size_t) {
return str2tag(s);
}
}
#endif
template <typename Annotation>