#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct Dialect {
pub name: &'static str,
pub case_insensitive: bool,
pub hash_sharp: bool,
pub spaced_args: bool,
pub octave_reversed: bool,
pub default_loop_count: Option<u16>,
}
impl Dialect {
pub const PIKOPIKO: Dialect = Dialect {
name: "pikopiko",
case_insensitive: false,
hash_sharp: false,
spaced_args: false,
octave_reversed: false,
default_loop_count: None,
};
pub const CLASSIC: Dialect = Dialect {
name: "classic",
case_insensitive: true,
hash_sharp: true,
spaced_args: true,
octave_reversed: false,
default_loop_count: Some(2),
};
pub const CLASSIC_REVERSED: Dialect = Dialect {
name: "classic-reversed",
octave_reversed: true,
..Dialect::CLASSIC
};
pub const BUILTIN: &'static [Dialect] = &[
Dialect::PIKOPIKO,
Dialect::CLASSIC,
Dialect::CLASSIC_REVERSED,
];
pub fn builtin(name: &str) -> Option<Dialect> {
Dialect::BUILTIN.iter().copied().find(|d| d.name == name)
}
}
impl Default for Dialect {
fn default() -> Self {
Dialect::PIKOPIKO
}
}