deny empty tuplets
This commit is contained in:
parent
7bf1f0c6b1
commit
bbccf46d47
1 changed files with 9 additions and 2 deletions
|
@ -170,6 +170,9 @@ pub struct Tuplet(pub TokenVec);
|
||||||
impl Token for Tuplet {
|
impl Token for Tuplet {
|
||||||
fn apply(&self, mut context: Context) -> Result<Context, CompilerError> {
|
fn apply(&self, mut context: Context) -> Result<Context, CompilerError> {
|
||||||
debug!("⚡ {}", type_name::<Self>());
|
debug!("⚡ {}", type_name::<Self>());
|
||||||
|
if self.0.as_ref().is_empty() {
|
||||||
|
return Err(CompilerError::Nilplet);
|
||||||
|
}
|
||||||
let mut old_result = context.result.clone();
|
let mut old_result = context.result.clone();
|
||||||
context.result.clear();
|
context.result.clear();
|
||||||
let mut new_context = self
|
let mut new_context = self
|
||||||
|
@ -294,10 +297,14 @@ pub struct SlopeNotFoundError(String);
|
||||||
pub enum CompilerError {
|
pub enum CompilerError {
|
||||||
#[error("expression evaluation: {0:?}")]
|
#[error("expression evaluation: {0:?}")]
|
||||||
FastEval(#[from] fasteval::Error),
|
FastEval(#[from] fasteval::Error),
|
||||||
#[error("{0}")]
|
#[error(transparent)]
|
||||||
VariableNotFound(#[from] VariableNotFoundError),
|
VariableNotFound(#[from] VariableNotFoundError),
|
||||||
#[error("{0}")]
|
#[error(transparent)]
|
||||||
SlopeNotFound(#[from] SlopeNotFoundError),
|
SlopeNotFound(#[from] SlopeNotFoundError),
|
||||||
|
#[error(
|
||||||
|
"You successfully made a nilplet / noplet (and I don't know what to do with it).\nTo resume compilation, remove any occurrence of \"[]\" in your sheet music."
|
||||||
|
)]
|
||||||
|
Nilplet,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Context {
|
impl Context {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue