Add extra parsing checks to prevent iter_blocks from matching tokens after end of filter
This commit is contained in:
parent
9dd70f2004
commit
f862319f3b
2 changed files with 27 additions and 3 deletions
|
@ -260,7 +260,7 @@ impl MpsItemBlockFactory {
|
||||||
|
|
||||||
impl BoxedMpsOpFactory for MpsItemBlockFactory {
|
impl BoxedMpsOpFactory for MpsItemBlockFactory {
|
||||||
fn is_op_boxed(&self, tokens: &VecDeque<MpsToken>) -> bool {
|
fn is_op_boxed(&self, tokens: &VecDeque<MpsToken>) -> bool {
|
||||||
tokens[tokens.len() - 1].is_close_curly()
|
find_last_open_curly(tokens).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_op_boxed(
|
fn build_op_boxed(
|
||||||
|
@ -347,7 +347,12 @@ fn find_last_open_curly(tokens: &VecDeque<MpsToken>) -> Option<usize> {
|
||||||
if bracket_depth == 0 && curly_found {
|
if bracket_depth == 0 && curly_found {
|
||||||
return Some(i + 1);
|
return Some(i + 1);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
MpsToken::OpenBracket | MpsToken::CloseBracket => {
|
||||||
|
if bracket_depth == 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
if token.is_open_curly() {
|
if token.is_open_curly() {
|
||||||
|
|
|
@ -677,7 +677,7 @@ fn execute_compareitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_computeitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
fn execute_computeitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(artist? like `Bruno`).{
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{
|
||||||
let count = 1,
|
let count = 1,
|
||||||
item.track = count,
|
item.track = count,
|
||||||
item.title = ~`Song #{track}` item,
|
item.title = ~`Song #{track}` item,
|
||||||
|
@ -693,6 +693,25 @@ fn execute_computeitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn execute_complexitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
||||||
|
execute_single_line(
|
||||||
|
"files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().{
|
||||||
|
let count = 1,
|
||||||
|
item.track = count,
|
||||||
|
item.title = ~`Song #{track}` item,
|
||||||
|
if count > 5 {
|
||||||
|
item.filename = `¯\\\\_(ツ)_/¯`
|
||||||
|
} else {
|
||||||
|
item.filename = `/shrug`,
|
||||||
|
},
|
||||||
|
count = count + 1,
|
||||||
|
}.()",
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn execute_constructitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
fn execute_constructitemop_line() -> Result<(), Box<dyn MpsLanguageError>> {
|
||||||
execute_single_line(
|
execute_single_line(
|
||||||
|
|
Loading…
Reference in a new issue