aboutsummaryrefslogtreecommitdiff
path: root/grammar/src/abnf/mod.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2026-10-16 14:01:01 +0800
committerJSDurand <mmemmew@gmail.com>2026-10-16 14:02:10 +0800
commitfba9a90cfc6aca2a26cce72f55fb261789139781 (patch)
treeb4b121791ad639e745df689c0d5a8ed7a9e5dcc4 /grammar/src/abnf/mod.rs
parent3ae0cf9898485a2ec35df7d23cd274e7dea5796d (diff)
new startHEADmaster
Now I tested and discussed with claude, and had a working version of this project. The rest is to port the claude version to my own writings. So this serves as the starting point before that attempt. In the new attempt the design is better, and a number of bugs were found and supposedly fixed, so let us see how this goes at the end.
Diffstat (limited to 'grammar/src/abnf/mod.rs')
-rw-r--r--grammar/src/abnf/mod.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/grammar/src/abnf/mod.rs b/grammar/src/abnf/mod.rs
index b53dcc1..2e2d0f2 100644
--- a/grammar/src/abnf/mod.rs
+++ b/grammar/src/abnf/mod.rs
@@ -2439,9 +2439,9 @@ impl std::str::FromStr for Grammar {
break;
}
- if appending_p && nonterminals_map.get(&rule_name).is_none() {
+ if appending_p && !nonterminals_map.contains_key(&rule_name) {
return Err(Error::AppendToNothing(current_skipped_index));
- } else if !appending_p && nonterminals_map.get(&rule_name).is_some() {
+ } else if !appending_p && nonterminals_map.contains_key(&rule_name) {
return Err(Error::CreateAgain(current_skipped_index));
}
@@ -2473,13 +2473,13 @@ impl std::str::FromStr for Grammar {
for data in rule_data {
match data {
IntermediateConstruct::Terminal(name) => {
- if terminals_map.get(&name).is_none() {
+ if !terminals_map.contains_key(&name) {
terminals_map.insert(name.clone(), terminals_vec.len());
terminals_vec.push(name);
}
}
IntermediateConstruct::Nonterminal(name) => {
- if nonterminals_map.get(&name).is_none() {
+ if !nonterminals_map.contains_key(&name) {
return Err(Error::UnknownNonterminal(name));
}
}