Skip to content

Commit 94f521f

Browse files
author
Daniel Kroening
committed
smt2 parser: use let with multiple bindings
This avoids deeply recursive expressions.
1 parent a32efa9 commit 94f521f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/solvers/smt2/smt2_parser.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,21 +208,18 @@ exprt smt2_parsert::let_expression()
208208
b.first = add_fresh_id(b.first, b.second);
209209
}
210210

211-
exprt expr=expression();
211+
exprt where = expression();
212212

213213
if(next_token() != smt2_tokenizert::CLOSE)
214214
throw error("expected ')' after let");
215215

216-
exprt result=expr;
216+
binding_exprt::variablest variables;
217+
exprt::operandst values;
217218

218-
// go backwards, build let_expr
219-
for(auto r_it=bindings.rbegin(); r_it!=bindings.rend(); r_it++)
219+
for(const auto &b : bindings)
220220
{
221-
const let_exprt let(
222-
symbol_exprt(r_it->first, r_it->second.type()),
223-
r_it->second,
224-
result);
225-
result=let;
221+
variables.push_back(symbol_exprt(b.first, b.second.type()));
222+
values.push_back(b.second);
226223
}
227224

228225
// we keep these in the id_map in order to retain globally
@@ -231,7 +228,7 @@ exprt smt2_parsert::let_expression()
231228
// restore renamings
232229
renaming_map=old_renaming_map;
233230

234-
return result;
231+
return let_exprt(variables, values, where);
235232
}
236233

237234
exprt smt2_parsert::quantifier_expression(irep_idt id)

0 commit comments

Comments
 (0)