Skip to content

Commit

Permalink
update: more robust handling of macros and lists in visitor
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Lorenzo Susini <49318629+loresuso@users.noreply.github.com>
  • Loading branch information
loresuso and jasondellaluce authored May 19, 2023
1 parent 21a7424 commit 5178406
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions userspace/engine/filter_details_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void filter_details_resolver::visitor::visit(ast::and_expr* e)
{
m_expect_macro = true;
e->children[i]->accept(this);
m_expect_macro = false;
}
}

Expand All @@ -47,6 +48,7 @@ void filter_details_resolver::visitor::visit(ast::or_expr* e)
{
m_expect_macro = true;
e->children[i]->accept(this);
m_expect_macro = false;
}
}

Expand All @@ -59,7 +61,6 @@ void filter_details_resolver::visitor::visit(ast::list_expr* e)
{
if(m_expect_list)
{
m_expect_list = false;
for(const auto& item : e->values)
{
if(m_details.known_lists.find(item) != m_details.known_lists.end())
Expand All @@ -72,14 +73,17 @@ void filter_details_resolver::visitor::visit(ast::list_expr* e)

void filter_details_resolver::visitor::visit(ast::binary_check_expr* e)
{
m_expect_macro = false;
m_details.fields.insert(e->field);
m_details.operators.insert(e->op);
m_expect_list = true;
e->value->accept(this);
m_expect_list = false;
}

void filter_details_resolver::visitor::visit(ast::unary_check_expr* e)
{
m_expect_macro = false;
m_details.fields.insert(e->field);
m_details.operators.insert(e->op);
}
Expand All @@ -88,7 +92,6 @@ void filter_details_resolver::visitor::visit(ast::value_expr* e)
{
if(m_expect_macro)
{
m_expect_macro = false;
auto it = m_details.known_macros.find(e->value);
if(it == m_details.known_macros.end())
{
Expand Down

0 comments on commit 5178406

Please sign in to comment.