-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smt2_parsert::expression() without recursion
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -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: | ||
|
@@ -1076,6 +1100,7 @@ exprt smt2_parsert::expression() | |
} | ||
|
||
UNREACHABLE; | ||
#endif | ||
} | ||
|
||
void smt2_parsert::setup_expressions() | ||
|