Skip to content

Commit

Permalink
smt2_parsert::expression() without recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
kroening committed Aug 15, 2024
1 parent d55a9a7 commit b8cdaad
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/solvers/smt2/smt2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
#include "smt2_parser.h"

#include "smt2_format.h"
#include "smt2irep.h"

#include <util/arith_tools.h>
#include <util/bitvector_expr.h>
Expand Down Expand Up @@ -1010,6 +1011,29 @@ exprt smt2_parsert::bv_mod(const exprt::operandst &operands, bool is_signed)

exprt smt2_parsert::expression()
{
auto irep_opt = smt2irep(smt2_tokenizer);

if(!irep_opt.has_value())
throw error("EOF in an expression");

auto &irep_as_expr = static_cast<exprt &>(irep_opt.value());

// transform into exprt, without recursion using post-order
// traversal
irep_as_expr.visit_post([](exprt &expr) {
// is it a function application?
if(expr.get_sub().size() >= 2)
{
}
else
{
// literal or symbol
}
});

return irep_as_expr;

#if 0
switch(next_token())
{
case smt2_tokenizert::SYMBOL:
Expand Down Expand Up @@ -1076,6 +1100,7 @@ exprt smt2_parsert::expression()
}

UNREACHABLE;
#endif
}

void smt2_parsert::setup_expressions()
Expand Down

0 comments on commit b8cdaad

Please sign in to comment.