From a9ce21b2ff3de3e063361e17961384ba0fe9d975 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Wed, 19 Jul 2023 13:45:40 +0800 Subject: grammar/abnf: Fix a bug of repeatedly adding non-terminals This bug caused a plain unambiguous grammar to become ambiguous. Funnily enough, this bug revealed a lot of bugs in the code for handling forests. I guess this is an unexpected surprise. :D --- grammar/src/abnf/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grammar') diff --git a/grammar/src/abnf/mod.rs b/grammar/src/abnf/mod.rs index f825bef..561a397 100644 --- a/grammar/src/abnf/mod.rs +++ b/grammar/src/abnf/mod.rs @@ -2495,8 +2495,8 @@ impl std::str::FromStr for Grammar { } if !appending_p { - nonterminals_map.insert(rule_name.clone(), nonterminals_vec.len()); - nonterminals_vec.push(rule_name.clone()); + // nonterminals_map.insert(rule_name.clone(), nonterminals_vec.len()); + // nonterminals_vec.push(rule_name.clone()); all_rules.insert(rule_name, transformed_rule); } else { -- cgit v1.2.3-18-g5258