EBNF StringTerminal
This commit is contained in:
parent
a55a806a60
commit
be501f540e
@ -28,6 +28,7 @@ pub enum EBNF {
|
||||
None,
|
||||
Nonterminal(String),
|
||||
CharTerminal(char),
|
||||
StringTerminal(String),
|
||||
Alternation(Vec<EBNF>),
|
||||
}
|
||||
|
||||
@ -46,6 +47,7 @@ impl fmt::Display for EBNF {
|
||||
write!(f, "")
|
||||
}
|
||||
EBNF::Nonterminal(name) => write!(f, "{name}"),
|
||||
EBNF::StringTerminal(term) => write!(f, r#""{term}""#),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,7 +71,8 @@ mod tests {
|
||||
EBNF::Nonterminal("other-rule".into()),
|
||||
EBNF::CharTerminal('q'),
|
||||
EBNF::CharTerminal('m'),
|
||||
EBNF::StringTerminal("focus".into()),
|
||||
]);
|
||||
assert_eq!(example.to_string(), "other-rule | 'q' | 'm'");
|
||||
assert_eq!(example.to_string(), "other-rule | 'q' | 'm' | \"focus\"");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user