mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Fixed more infinite loop grammar problems
This commit is contained in:
parent
f560ceca97
commit
ac602d5542
BIN
docs/native.wasm
BIN
docs/native.wasm
Binary file not shown.
17
peglib.h
17
peglib.h
@ -3518,7 +3518,7 @@ private:
|
||||
for (auto &x : grammar) {
|
||||
auto &rule = x.second;
|
||||
|
||||
ReferenceChecker vis(*data.grammar, rule.params);
|
||||
ReferenceChecker vis(grammar, rule.params);
|
||||
rule.accept(vis);
|
||||
for (const auto &y : vis.error_s) {
|
||||
const auto &name = y.first;
|
||||
@ -3536,7 +3536,7 @@ private:
|
||||
// Link references
|
||||
for (auto &x : grammar) {
|
||||
auto &rule = x.second;
|
||||
LinkReferences vis(*data.grammar, rule.params);
|
||||
LinkReferences vis(grammar, rule.params);
|
||||
rule.accept(vis);
|
||||
}
|
||||
|
||||
@ -3561,12 +3561,12 @@ private:
|
||||
if (!ret) { return nullptr; }
|
||||
|
||||
// Set root definition
|
||||
auto &start_rule = (*data.grammar)[data.start];
|
||||
auto &start_rule = grammar[data.start];
|
||||
|
||||
// Check infinite loop
|
||||
{
|
||||
DetectInfiniteLoop vis(data.start_pos, data.start);
|
||||
start_rule.accept(vis);
|
||||
for (auto &[name, rule] : grammar) {
|
||||
DetectInfiniteLoop vis(rule.s_, name);
|
||||
rule.accept(vis);
|
||||
if (vis.has_error) {
|
||||
if (log) {
|
||||
auto line = line_info(s, vis.error_s);
|
||||
@ -3586,13 +3586,12 @@ private:
|
||||
}
|
||||
|
||||
start_rule.whitespaceOpe =
|
||||
wsp((*data.grammar)[WHITESPACE_DEFINITION_NAME].get_core_operator());
|
||||
wsp(grammar[WHITESPACE_DEFINITION_NAME].get_core_operator());
|
||||
}
|
||||
|
||||
// Word expression
|
||||
if (grammar.count(WORD_DEFINITION_NAME)) {
|
||||
start_rule.wordOpe =
|
||||
(*data.grammar)[WORD_DEFINITION_NAME].get_core_operator();
|
||||
start_rule.wordOpe = grammar[WORD_DEFINITION_NAME].get_core_operator();
|
||||
}
|
||||
|
||||
// Apply instructions
|
||||
|
Loading…
Reference in New Issue
Block a user