mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2025-01-22 21:35:29 +00:00
Code cleanup.
This commit is contained in:
parent
50ea1858c1
commit
91fe3b755c
@ -369,7 +369,7 @@ auto syntax = R"(
|
|||||||
|
|
||||||
Rules additional_rules = {
|
Rules additional_rules = {
|
||||||
{
|
{
|
||||||
"NAME", usr([](const char* s, size_t n, SemanticValues& sv, any& c) -> size_t {
|
"NAME", usr([](const char* s, size_t n, SemanticValues& sv, any& dt) -> size_t {
|
||||||
static vector<string> names = { "PEG", "BNF" };
|
static vector<string> names = { "PEG", "BNF" };
|
||||||
for (const auto& name: names) {
|
for (const auto& name: names) {
|
||||||
if (name.size() <= n && !name.compare(0, name.size(), s, name.size())) {
|
if (name.size() <= n && !name.compare(0, name.size(), s, name.size())) {
|
||||||
|
12
peglib.h
12
peglib.h
@ -2058,7 +2058,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check duplicated definitions
|
// Check duplicated definitions
|
||||||
bool ret = data.duplicates.empty();;
|
bool ret = data.duplicates.empty();
|
||||||
|
|
||||||
for (const auto& x: data.duplicates) {
|
for (const auto& x: data.duplicates) {
|
||||||
if (log) {
|
if (log) {
|
||||||
@ -2404,7 +2404,7 @@ public:
|
|||||||
if (grammar_ != nullptr) {
|
if (grammar_ != nullptr) {
|
||||||
const auto& rule = (*grammar_)[start_];
|
const auto& rule = (*grammar_)[start_];
|
||||||
auto r = rule.parse(s, n, path);
|
auto r = rule.parse(s, n, path);
|
||||||
output_log(s, n, log, r);
|
output_log(s, n, r);
|
||||||
return r.ret && r.len == n;
|
return r.ret && r.len == n;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2419,7 +2419,7 @@ public:
|
|||||||
if (grammar_ != nullptr) {
|
if (grammar_ != nullptr) {
|
||||||
const auto& rule = (*grammar_)[start_];
|
const auto& rule = (*grammar_)[start_];
|
||||||
auto r = rule.parse(s, n, dt, path);
|
auto r = rule.parse(s, n, dt, path);
|
||||||
output_log(s, n, log, r);
|
output_log(s, n, r);
|
||||||
return r.ret && r.len == n;
|
return r.ret && r.len == n;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2435,7 +2435,7 @@ public:
|
|||||||
if (grammar_ != nullptr) {
|
if (grammar_ != nullptr) {
|
||||||
const auto& rule = (*grammar_)[start_];
|
const auto& rule = (*grammar_)[start_];
|
||||||
auto r = rule.parse_and_get_value(s, n, val, path);
|
auto r = rule.parse_and_get_value(s, n, val, path);
|
||||||
output_log(s, n, log, r);
|
output_log(s, n, r);
|
||||||
return r.ret && r.len == n;
|
return r.ret && r.len == n;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2452,7 +2452,7 @@ public:
|
|||||||
if (grammar_ != nullptr) {
|
if (grammar_ != nullptr) {
|
||||||
const auto& rule = (*grammar_)[start_];
|
const auto& rule = (*grammar_)[start_];
|
||||||
auto r = rule.parse_and_get_value(s, n, dt, val, path);
|
auto r = rule.parse_and_get_value(s, n, dt, val, path);
|
||||||
output_log(s, n, log, r);
|
output_log(s, n, r);
|
||||||
return r.ret && r.len == n;
|
return r.ret && r.len == n;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -2538,7 +2538,7 @@ public:
|
|||||||
Log log;
|
Log log;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void output_log(const char* s, size_t n, Log log, const Definition::Result& r) const {
|
void output_log(const char* s, size_t n, const Definition::Result& r) const {
|
||||||
if (log) {
|
if (log) {
|
||||||
if (!r.ret) {
|
if (!r.ret) {
|
||||||
if (r.message_pos) {
|
if (r.message_pos) {
|
||||||
|
Loading…
Reference in New Issue
Block a user