-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpp_parsert: construct with message handler
This both avoids an object of static lifetime as well as it fixes the (transitive) use of the deprecated messaget() constructor.
- Loading branch information
1 parent
bc5efc9
commit 045c6e2
Showing
6 changed files
with
40 additions
and
43 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
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 |
---|---|---|
|
@@ -11,25 +11,12 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "cpp_parser.h" | ||
|
||
#include <util/config.h> | ||
|
||
cpp_parsert cpp_parser; | ||
|
||
bool cpp_parse(); | ||
bool cpp_parse(cpp_parsert &, message_handlert &); | ||
|
||
bool cpp_parsert::parse() | ||
{ | ||
// We use the ANSI-C scanner | ||
ansi_c_parser.cpp98=true; | ||
ansi_c_parser.cpp11 = | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 || | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 || | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17; | ||
ansi_c_parser.ts_18661_3_Floatn_types=false; | ||
ansi_c_parser.in=in; | ||
ansi_c_parser.mode=mode; | ||
ansi_c_parser.set_file(get_file()); | ||
ansi_c_parser.log.set_message_handler(log.get_message_handler()); | ||
|
||
return cpp_parse(); | ||
token_buffer.ansi_c_parser.in = in; | ||
token_buffer.ansi_c_parser.mode = mode; | ||
token_buffer.ansi_c_parser.set_file(get_file()); | ||
return cpp_parse(*this, log.get_message_handler()); | ||
} |
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
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 |
---|---|---|
|
@@ -11,8 +11,6 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "cpp_token_buffer.h" | ||
|
||
#include <ansi-c/ansi_c_parser.h> | ||
|
||
int cpp_token_buffert::LookAhead(unsigned offset) | ||
{ | ||
PRECONDITION(current_pos <= token_vector.size()); | ||
|
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 |
---|---|---|
|
@@ -12,17 +12,28 @@ Author: Daniel Kroening, [email protected] | |
#ifndef CPROVER_CPP_CPP_TOKEN_BUFFER_H | ||
#define CPROVER_CPP_CPP_TOKEN_BUFFER_H | ||
|
||
#include <util/config.h> | ||
#include <util/invariant.h> | ||
|
||
#include <ansi-c/ansi_c_parser.h> | ||
|
||
#include "cpp_token.h" | ||
|
||
#include <list> | ||
|
||
#include <util/invariant.h> | ||
|
||
class cpp_token_buffert | ||
{ | ||
public: | ||
cpp_token_buffert():current_pos(0) | ||
explicit cpp_token_buffert(message_handlert &message_handler) | ||
: ansi_c_parser(message_handler), current_pos(0) | ||
{ | ||
// We use the ANSI-C scanner | ||
ansi_c_parser.cpp98 = true; | ||
ansi_c_parser.cpp11 = | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP11 || | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP14 || | ||
config.cpp.cpp_standard == configt::cppt::cpp_standardt::CPP17; | ||
ansi_c_parser.ts_18661_3_Floatn_types = false; | ||
} | ||
|
||
typedef unsigned int post; | ||
|
@@ -51,6 +62,8 @@ class cpp_token_buffert | |
return tokens.back(); | ||
} | ||
|
||
ansi_c_parsert ansi_c_parser; | ||
|
||
protected: | ||
typedef std::list<cpp_tokent> tokenst; | ||
tokenst tokens; | ||
|
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