File tree Expand file tree Collapse file tree 3 files changed +15
-26
lines changed Expand file tree Collapse file tree 3 files changed +15
-26
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,12 @@ decision_proceduret::resultt smt2_dect::read_result(std::istream &in)
143
143
144
144
while (in)
145
145
{
146
- irept parsed = smt2irep (in, get_message_handler ());
146
+ auto parsed_opt = smt2irep (in, get_message_handler ());
147
+
148
+ if (!parsed_opt.has_value ())
149
+ break ;
150
+
151
+ const auto &parsed = parsed_opt.value ();
147
152
148
153
if (parsed.id ()==" sat" )
149
154
res=resultt::D_SATISFIABLE;
Original file line number Diff line number Diff line change @@ -22,47 +22,33 @@ class smt2irept:public smt2_tokenizert
22
22
{
23
23
}
24
24
25
- inline irept operator ()()
26
- {
27
- parse ();
28
- return result;
29
- }
30
-
31
- bool parse ();
25
+ optionalt<irept> operator ()();
32
26
33
27
protected:
34
28
messaget log;
35
- irept result;
36
29
};
37
30
38
- bool smt2irept::parse ()
31
+ optionalt<irept> smt2irept::operator () ()
39
32
{
40
33
try
41
34
{
42
35
std::stack<irept> stack;
43
- result.clear ();
44
36
45
37
while (true )
46
38
{
47
39
switch (next_token ())
48
40
{
49
41
case END_OF_FILE:
50
42
if (stack.empty ())
51
- {
52
- result = irept (irep_idt ());
53
- return false ;
54
- }
43
+ return {};
55
44
else
56
45
throw error (" unexpected end of file" );
57
46
58
47
case STRING_LITERAL:
59
48
case NUMERAL:
60
49
case SYMBOL:
61
50
if (stack.empty ())
62
- {
63
- result = irept (buffer);
64
- return false ; // all done!
65
- }
51
+ return irept (buffer); // all done!
66
52
else
67
53
stack.top ().get_sub ().push_back (irept (buffer));
68
54
break ;
@@ -82,10 +68,7 @@ bool smt2irept::parse()
82
68
stack.pop ();
83
69
84
70
if (stack.empty ())
85
- {
86
- result = tmp;
87
- return false ; // all done!
88
- }
71
+ return tmp; // all done!
89
72
90
73
stack.top ().get_sub ().push_back (tmp);
91
74
break ;
@@ -100,11 +83,11 @@ bool smt2irept::parse()
100
83
{
101
84
log.error ().source_location .set_line (e.get_line_no ());
102
85
log.error () << e.what () << messaget::eom;
103
- return true ;
86
+ return {} ;
104
87
}
105
88
}
106
89
107
- irept smt2irep (std::istream &in, message_handlert &message_handler)
90
+ optionalt< irept> smt2irep (std::istream &in, message_handlert &message_handler)
108
91
{
109
92
return smt2irept (in, message_handler)();
110
93
}
Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ Author: Daniel Kroening, kroening@kroening.com
13
13
#include < iosfwd>
14
14
15
15
#include < util/irep.h>
16
+ #include < util/optional.h>
16
17
17
18
class message_handlert ;
18
19
19
- irept smt2irep (std::istream &, message_handlert &);
20
+ optionalt< irept> smt2irep (std::istream &, message_handlert &);
20
21
21
22
#endif // CPROVER_SOLVERS_SMT2_SMT2IREP_H
You can’t perform that action at this time.
0 commit comments