Commit 7aa84975 authored by Max Kellermann's avatar Max Kellermann

SongFilter: implement the AND operator

parent 7a8d5070
......@@ -268,6 +268,13 @@
time stamp).
</para>
</listitem>
<listitem>
<para>
"<code>EXPRESSION1 AND EXPRESSION2 ...</code>": combine two or
more expressions with logical "and".
</para>
</listitem>
</itemizedlist>
<para>
......
......@@ -334,7 +334,23 @@ SongFilter::ParseExpression(const char *&s, bool fold_case)
return first;
}
throw std::runtime_error("Nested expressions not yet implemented");
if (ExpectWord(s) != "AND")
throw std::runtime_error("'AND' expected");
auto and_filter = std::make_unique<AndSongFilter>();
and_filter->AddItem(std::move(first));
while (true) {
and_filter->AddItem(ParseExpression(s, fold_case));
if (*s == ')') {
++s;
return and_filter;
}
if (ExpectWord(s) != "AND")
throw std::runtime_error("'AND' expected");
}
}
auto type = ExpectFilterType(s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment