Skip to content

Commit dedc827

Browse files
committed
Fix #311
1 parent 2ab5d27 commit dedc827

File tree

2 files changed

+253
-270
lines changed

2 files changed

+253
-270
lines changed

Diff for: peglib.h

+16-2
Original file line numberDiff line numberDiff line change
@@ -3310,7 +3310,20 @@ class ParserGenerator {
33103310
}
33113311

33123312
// For debugging purpose
3313-
static Grammar &grammar() { return get_instance().g; }
3313+
static bool parse_test(const char *d, const char *s) {
3314+
Data data;
3315+
std::any dt = &data;
3316+
3317+
auto n = strlen(s);
3318+
auto r = get_instance().g[d].parse(s, n, dt);
3319+
return r.ret && r.len == n;
3320+
}
3321+
3322+
#if defined(__cpp_lib_char8_t)
3323+
static bool parse_test(const char8_t *d, const char8_t *s) {
3324+
reutnr parse_test(reinterpret_cast<const char *>(s), s);
3325+
}
3326+
#endif
33143327

33153328
private:
33163329
static ParserGenerator &get_instance() {
@@ -4086,7 +4099,8 @@ class ParserGenerator {
40864099
if (log) {
40874100
auto line = line_info(s, s);
40884101
log(line.first, line.second,
4089-
"The specified start rule '" + requested_start + "' is undefined.",
4102+
"The specified start rule '" + requested_start +
4103+
"' is undefined.",
40904104
"");
40914105
}
40924106
ret = false;

0 commit comments

Comments
 (0)