summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-07-19 13:45:40 +0800
committerJSDurand <mmemmew@gmail.com>2023-07-19 13:45:40 +0800
commita9ce21b2ff3de3e063361e17961384ba0fe9d975 (patch)
tree42f4ca238780b789c73b5c4c9ad36da64d470d3d
parent0f960b0ecaa30be08d859bf5ca910b7603e66a10 (diff)
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
-rw-r--r--grammar/src/abnf/mod.rs4
1 files changed, 2 insertions, 2 deletions
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 {