From ac602d5542af09c54c0bb9d073606f00964c7965 Mon Sep 17 00:00:00 2001 From: yhirose Date: Mon, 18 Jan 2021 17:50:45 -0500 Subject: [PATCH] Fixed more infinite loop grammar problems --- docs/native.wasm | Bin 360710 -> 360573 bytes peglib.h | 17 ++++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/native.wasm b/docs/native.wasm index da74b80af2c37e024754c6abfc9586b0e9334b7a..6d89c3c25b16d7555068a88b95575ba97f3d79db 100644 GIT binary patch delta 2197 zcmb_d?TZyv7(eHk**kOR<=$Ca*PAc&%;@H9?xup=HCOYVa96`#Obi5zHY%`Lh?4s1 zT@>=G2ziPkgo+k~D3CTNO6ZgSfI>uteF%-!&0Td{ceUS{xmSgRDEe?Y=iE8xInVFq zdCuF1x);W}KR+7K_csq83yvHM~BGY?UvDG#m`YD$hKrBy<4)SU#6i2<@X z9|8{4$5%z21SVr+WAj#>mUEzAxsTdORK>cvxHc((=UYbh7)U9EZO36hTW7n>}?N)?{f#2 z+0(<5#5@0wa3vK1D(NpKsVgBRHi>{qo!^oQQ5P0!C7D>$DF4Q!j}DD`hf*2`~wrT;$tPW?ZC~ zPSKWE{enFcNJ9BnsJ4rB5-t6k`bwtQkq!(Vz1rc4y4{M+z?+33{L);a(#M= zmOOKpU@Z_cf-Mkr7m)KUAP9VKAXXcQQ9S*FHZ{W#o)I}rxCcoEDP;49LIDho(KyU8 zDf>WNg{@rBT~gz-pd;m~Ipr3E+1)bnW)6!F`G61Xt0|GyX)mUgI_0LAzwO^eHP85x>H61cbsDz1L7&*Fnok&lQrZwL_SqW>Dfd@mnQp7+ zXK4`aZhVeb$v~gHPVYa8rpScIIZj-H9vJ{}ew_^6IV5hJ^I!~ zTCCrjrRVj{S$Z6?{Tr0%>`!`Uk&o78LOsXu^+;@?p?1#E@#6j-eQ1t)^xPap#i0#V z?61?yX7m1-u=%MQw67WDc6ZUsqb$KIH3IN?o3k)MnW4=U_OOun@+?NC$Q6J%!8_A0 zRznU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.h b/peglib.h index 9a4ce33..77b9bbb 100644 --- a/peglib.h +++ b/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