From be501f540e0a48364cffe03645abdb017b9a5dfa Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 31 Jan 2024 00:47:45 -0800 Subject: [PATCH] EBNF StringTerminal --- src/representation.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/representation.rs b/src/representation.rs index ceb0fd7..59a7f87 100644 --- a/src/representation.rs +++ b/src/representation.rs @@ -28,6 +28,7 @@ pub enum EBNF { None, Nonterminal(String), CharTerminal(char), + StringTerminal(String), Alternation(Vec), } @@ -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\""); } }