mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-11-14 06:55:30 +00:00
Added peg::udl for 'tag' user defined literal.
This commit is contained in:
parent
1520849708
commit
6b63bd48af
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <sstream>
|
||||
|
||||
using namespace peg;
|
||||
using namespace peg::udl;
|
||||
using namespace std;
|
||||
|
||||
/*
|
||||
|
2
peglib.h
2
peglib.h
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user