#[derive(Debug, Clone)]
pub(crate) struct Keywords<'a> {
pub feature: &'a [&'a str],
pub background: &'a [&'a str],
pub rule: &'a [&'a str],
pub scenario: &'a [&'a str],
pub scenario_outline: &'a [&'a str],
pub examples: &'a [&'a str],
pub given: &'a [&'a str],
pub when: &'a [&'a str],
pub then: &'a [&'a str],
pub and: &'a [&'a str],
pub but: &'a [&'a str],
}
impl<'a> Keywords<'a> {
pub fn get(key: &str) -> Option<Keywords<'a>> {
let result = include!(concat!(env!("OUT_DIR"), "/match.gen.rs"));
if let Some(result) = result {
return Some(result);
}
Some(match key {
"formal" => FORMAL_SPEC_KEYWORDS,
_ => return None,
})
}
pub fn all(&self) -> Vec<&'a str> {
let mut v = vec![];
for x in [
self.feature,
self.background,
self.rule,
self.scenario,
self.rule,
self.scenario_outline,
self.examples,
self.given,
self.when,
self.then,
self.and,
self.but,
]
.iter()
{
v.append(&mut x.to_vec());
}
v.sort();
v
}
}
impl<'a> Default for Keywords<'a> {
fn default() -> Self {
EN
}
}
const FORMAL_SPEC_KEYWORDS: Keywords<'static> = Keywords {
feature: &["Section"],
background: &["Context"],
rule: &["Rule"],
scenario: &["Proof", "Evidence"],
scenario_outline: &["Demonstration"],
examples: &["Examples"],
given: &["Given"],
when: &["When"],
then: &["Then"],
and: &["*", "And"],
but: &["But"],
};
include!(concat!(env!("OUT_DIR"), "/keywords.gen.rs"));