Skip to content

Commit

Permalink
Fix #311
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Nov 12, 2024
1 parent 2ab5d27 commit dedc827
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 270 deletions.
18 changes: 16 additions & 2 deletions peglib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3310,7 +3310,20 @@ class ParserGenerator {
}

// For debugging purpose
static Grammar &grammar() { return get_instance().g; }
static bool parse_test(const char *d, const char *s) {
Data data;
std::any dt = &data;

auto n = strlen(s);
auto r = get_instance().g[d].parse(s, n, dt);
return r.ret && r.len == n;
}

#if defined(__cpp_lib_char8_t)
static bool parse_test(const char8_t *d, const char8_t *s) {
reutnr parse_test(reinterpret_cast<const char *>(s), s);
}
#endif

private:
static ParserGenerator &get_instance() {
Expand Down Expand Up @@ -4086,7 +4099,8 @@ class ParserGenerator {
if (log) {
auto line = line_info(s, s);
log(line.first, line.second,
"The specified start rule '" + requested_start + "' is undefined.",
"The specified start rule '" + requested_start +
"' is undefined.",
"");
}
ret = false;
Expand Down
Loading

0 comments on commit dedc827

Please sign in to comment.