Skip to content

Commit 93ab7b8

Browse files
committed
Revert "WIP: message handler"
This reverts commit 0e25e07cc8f1410080b4304caa5f5911c8fa4bc9.
1 parent e3d28c9 commit 93ab7b8

File tree

76 files changed

+226
-1699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+226
-1699
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Author: Daniel Kroening, [email protected]
2727
class java_bytecode_parsert final : public parsert
2828
{
2929
public:
30-
java_bytecode_parsert(bool skip_instructions, message_handlert &message_handler)
31-
: parsert(message_handler), skip_instructions(skip_instructions)
30+
explicit java_bytecode_parsert(bool skip_instructions)
31+
: skip_instructions(skip_instructions)
3232
{
3333
}
3434

@@ -1809,8 +1809,9 @@ std::optional<java_bytecode_parse_treet> java_bytecode_parse(
18091809
message_handlert &message_handler,
18101810
bool skip_instructions)
18111811
{
1812-
java_bytecode_parsert java_bytecode_parser(skip_instructions, message_handler);
1812+
java_bytecode_parsert java_bytecode_parser(skip_instructions);
18131813
java_bytecode_parser.in=&istream;
1814+
java_bytecode_parser.log.set_message_handler(message_handler);
18141815

18151816
bool parser_result=java_bytecode_parser.parse();
18161817

jbmc/unit/solvers/strings/string_constraint_instantiation/instantiate_not_contains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ decision_proceduret::resultt check_sat(const exprt &expr, const namespacet &ns)
172172
info.ns = &ns;
173173
info.prop = &sat_check;
174174
info.output_xml = false;
175-
bv_refinementt solver(info, null_message_handler);
175+
bv_refinementt solver(info);
176176
solver << expr;
177177
return solver();
178178
}

src/ansi-c/ansi_c_language.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,26 @@ bool ansi_c_languaget::parse(
7171
ansi_c_internal_additions(code);
7272
std::istringstream codestr(code);
7373

74-
ansi_c_parsert ansi_c_parser(message_handler);
74+
ansi_c_parser.clear();
7575
ansi_c_parser.set_file(ID_built_in);
7676
ansi_c_parser.in=&codestr;
77+
ansi_c_parser.log.set_message_handler(message_handler);
7778
ansi_c_parser.for_has_scope=config.ansi_c.for_has_scope;
7879
ansi_c_parser.ts_18661_3_Floatn_types=config.ansi_c.ts_18661_3_Floatn_types;
7980
ansi_c_parser.cpp98=false; // it's not C++
8081
ansi_c_parser.cpp11=false; // it's not C++
8182
ansi_c_parser.mode=config.ansi_c.mode;
8283

84+
ansi_c_scanner_init();
85+
8386
bool result=ansi_c_parser.parse();
8487

8588
if(!result)
8689
{
8790
ansi_c_parser.set_line_no(0);
8891
ansi_c_parser.set_file(path);
8992
ansi_c_parser.in=&i_preprocessed;
93+
ansi_c_scanner_init();
9094
result=ansi_c_parser.parse();
9195
}
9296

@@ -201,12 +205,13 @@ bool ansi_c_languaget::to_expr(
201205

202206
// parsing
203207

204-
ansi_c_parsert ansi_c_parser(get_message_handler());
208+
ansi_c_parser.clear();
205209
ansi_c_parser.set_file(irep_idt());
206210
ansi_c_parser.in=&i_preprocessed;
207211
ansi_c_parser.log.set_message_handler(message_handler);
208212
ansi_c_parser.mode=config.ansi_c.mode;
209213
ansi_c_parser.ts_18661_3_Floatn_types=config.ansi_c.ts_18661_3_Floatn_types;
214+
ansi_c_scanner_init();
210215

211216
bool result=ansi_c_parser.parse();
212217

src/ansi-c/ansi_c_parser.cpp

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,7 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include "c_storage_spec.h"
1212

13-
void ansi_c_parser_init(ansi_c_parsert *ansi_c_parser);
14-
void ansi_c_scanner_init(ansi_c_parsert *ansi_c_parser);
15-
int yyansi_cparse();
16-
17-
bool ansi_c_parsert::parse()
18-
{
19-
clear();
20-
ansi_c_scanner_init(this);
21-
ansi_c_parser_init(this);
22-
return yyansi_cparse()!=0;
23-
}
24-
25-
void ansi_c_parsert::clear()
26-
{
27-
parsert::clear();
28-
parse_tree.clear();
29-
30-
// scanner state
31-
tag_following=false;
32-
asm_block_following=false;
33-
parenthesis_counter=0;
34-
string_literal.clear();
35-
pragma_pack.clear();
36-
37-
// set up global scope
38-
scopes.clear();
39-
scopes.push_back(scopet());
40-
41-
ansi_c_scanner_init(nullptr);
42-
ansi_c_parser_init(nullptr);
43-
}
13+
ansi_c_parsert ansi_c_parser;
4414

4515
ansi_c_id_classt ansi_c_parsert::lookup(
4616
const irep_idt &base_name,
@@ -103,6 +73,14 @@ void ansi_c_parsert::add_tag_with_body(irept &tag)
10373
}
10474
}
10575

76+
extern char *yyansi_ctext;
77+
78+
int yyansi_cerror(const std::string &error)
79+
{
80+
ansi_c_parser.parse_error(error, yyansi_ctext);
81+
return 0;
82+
}
83+
10684
void ansi_c_parsert::add_declarator(
10785
exprt &declaration,
10886
irept &declarator)

src/ansi-c/ansi_c_parser.h

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ Author: Daniel Kroening, [email protected]
1818
#include "ansi_c_parse_tree.h"
1919
#include "ansi_c_scope.h"
2020

21+
int yyansi_cparse();
22+
2123
class ansi_c_parsert:public parsert
2224
{
2325
public:
2426
ansi_c_parse_treet parse_tree;
2527

26-
<<<<<<< HEAD
2728
ansi_c_parsert()
2829
: tag_following(false),
2930
asm_block_following(false),
@@ -33,25 +34,14 @@ class ansi_c_parsert:public parsert
3334
cpp11(false),
3435
for_has_scope(false),
3536
ts_18661_3_Floatn_types(false)
36-
=======
37-
explicit ansi_c_parsert(message_handlert &message_handler):
38-
parsert(message_handler),
39-
tag_following(false),
40-
asm_block_following(false),
41-
parenthesis_counter(0),
42-
mode(modet::NONE),
43-
cpp98(false),
44-
cpp11(false),
45-
for_has_scope(false),
46-
ts_18661_3_Floatn_types(false),
47-
Float128_type(false)
48-
>>>>>>> WIP: message handler
4937
{
5038
}
5139

52-
bool parse() override;
40+
virtual bool parse() override
41+
{
42+
return yyansi_cparse()!=0;
43+
}
5344

54-
<<<<<<< HEAD
5545
virtual void clear() override
5646
{
5747
parsert::clear();
@@ -69,9 +59,6 @@ class ansi_c_parsert:public parsert
6959
scopes.clear();
7060
scopes.push_back(scopet());
7161
}
72-
=======
73-
void clear() override;
74-
>>>>>>> WIP: message handler
7562

7663
// internal state of the scanner
7764
bool tag_following;
@@ -179,4 +166,9 @@ class ansi_c_parsert:public parsert
179166
std::list<std::map<const irep_idt, bool>> pragma_cprover_stack;
180167
};
181168

169+
extern ansi_c_parsert ansi_c_parser;
170+
171+
int yyansi_cerror(const std::string &error);
172+
void ansi_c_scanner_init();
173+
182174
#endif // CPROVER_ANSI_C_ANSI_C_PARSER_H

src/ansi-c/builtin_factory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static bool convert(
4747
{
4848
std::istringstream in(s.str());
4949

50-
ansi_c_parsert ansi_c_parser(message_handler);
50+
ansi_c_parser.clear();
5151
ansi_c_parser.set_file(ID_built_in);
5252
ansi_c_parser.in=&in;
5353
ansi_c_parser.log.set_message_handler(message_handler);
@@ -56,6 +56,8 @@ static bool convert(
5656
ansi_c_parser.cpp11=false; // it's not C++
5757
ansi_c_parser.mode=config.ansi_c.mode;
5858

59+
ansi_c_scanner_init();
60+
5961
if(ansi_c_parser.parse())
6062
return true;
6163

src/ansi-c/parser.y

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,12 @@
1313
#ifdef ANSI_C_DEBUG
1414
#define YYDEBUG 1
1515
#endif
16-
#define PARSER (*ansi_c_parser)
16+
#define PARSER ansi_c_parser
1717

1818
#include "ansi_c_parser.h"
1919

2020
int yyansi_clex();
21-
int yyansi_cerror(const std::string &error);
22-
23-
static ansi_c_parsert *ansi_c_parser;
24-
25-
void ansi_c_parser_init(ansi_c_parsert *_ansi_c_parser)
26-
{
27-
ansi_c_parser = _ansi_c_parser;
28-
}
21+
extern char *yyansi_ctext;
2922

3023
#include "parser_static.inc"
3124

src/ansi-c/scanner.l

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int isatty(int) { return 0; }
3838
#include "literals/convert_string_literal.h"
3939
#include "literals/unescape_string.h"
4040

41-
#define PARSER (*ansi_c_parser)
41+
#define PARSER ansi_c_parser
4242
#define YYSTYPE unsigned
4343
#undef ECHO
4444
#define ECHO
@@ -52,10 +52,6 @@ extern int yyansi_cdebug;
5252
#define loc() \
5353
{ newstack(yyansi_clval); PARSER.set_source_location(parser_stack(yyansi_clval)); }
5454

55-
static ansi_c_parsert *ansi_c_parser;
56-
57-
int yyansi_cerror(const std::string &error);
58-
5955
int make_identifier()
6056
{
6157
loc();
@@ -269,9 +265,8 @@ enable_or_disable ("enable"|"disable")
269265
%x OTHER_PRAGMA
270266

271267
%{
272-
void ansi_c_scanner_init(ansi_c_parsert *_ansi_c_parser)
268+
void ansi_c_scanner_init()
273269
{
274-
ansi_c_parser = _ansi_c_parser;
275270
#ifdef ANSI_C_DEBUG
276271
yyansi_cdebug=1;
277272
#endif
@@ -282,8 +277,7 @@ void ansi_c_scanner_init(ansi_c_parsert *_ansi_c_parser)
282277

283278
%%
284279

285-
<INITIAL>.|\n { PRECONDITION(ansi_c_parser);
286-
BEGIN(GRAMMAR);
280+
<INITIAL>.|\n { BEGIN(GRAMMAR);
287281
yyless(0); /* start again with this character */
288282
}
289283

@@ -1821,10 +1815,3 @@ __decltype { if(PARSER.cpp98 &&
18211815
%%
18221816

18231817
int yywrap() { return 1; }
1824-
1825-
int yyansi_cerror(const std::string &error)
1826-
{
1827-
PRECONDITION(ansi_c_parser);
1828-
ansi_c_parser->parse_error(error, yyansi_ctext);
1829-
return 0;
1830-
}

src/assembler/assembler_parser.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,12 @@ Author: Daniel Kroening, [email protected]
88

99
#include "assembler_parser.h"
1010

11-
<<<<<<< HEAD
1211
assembler_parsert assembler_parser;
1312

1413
extern char *yyassemblertext;
15-
=======
16-
int yyassemblerlex();
17-
void assembler_scanner_init(assembler_parsert *assembler_parser);
1814

19-
bool assembler_parsert::parse()
15+
int yyassemblererror(const std::string &error)
2016
{
21-
assembler_scanner_init(this);
22-
yyassemblerlex();
23-
return false;
24-
}
25-
>>>>>>> WIP: message handler
26-
27-
void assembler_parsert::clear()
28-
{
29-
parsert::clear();
30-
instructions.clear();
31-
assembler_scanner_init(nullptr);
17+
assembler_parser.parse_error(error, yyassemblertext);
18+
return 0;
3219
}

src/assembler/assembler_parser.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ Author: Daniel Kroening, [email protected]
1111
#define CPROVER_ASSEMBLER_ASSEMBLER_PARSER_H
1212

1313
#include <util/parser.h>
14-
<<<<<<< HEAD
1514

1615
#include <list>
1716

1817
int yyassemblerlex();
1918
int yyassemblererror(const std::string &error);
2019
void assembler_scanner_init();
21-
=======
22-
>>>>>>> WIP: message handler
2320

2421
class assembler_parsert:public parsert
2522
{
@@ -40,14 +37,24 @@ class assembler_parsert:public parsert
4037
instructions.push_back(instructiont());
4138
}
4239

43-
explicit assembler_parsert(message_handlert &message_handler)
44-
: parsert(message_handler)
40+
assembler_parsert()
4541
{
4642
}
4743

48-
bool parse() override;
44+
virtual bool parse()
45+
{
46+
yyassemblerlex();
47+
return false;
48+
}
4949

50-
void clear() override;
50+
virtual void clear()
51+
{
52+
parsert::clear();
53+
instructions.clear();
54+
// assembler_scanner_init();
55+
}
5156
};
5257

58+
extern assembler_parsert assembler_parser;
59+
5360
#endif // CPROVER_ASSEMBLER_ASSEMBLER_PARSER_H

0 commit comments

Comments
 (0)