Specialized preprocessor for handling any kind of input stream. More...
Classes | |
struct | token_desc |
Description of a preprocessing chunk. More... | |
Public Member Functions | |
preprocessor_data (preprocessor_streambuf &, filesystem::scoped_istream, const std::string &history, const std::string &name, int line, const std::string &dir, const std::string &domain, std::unique_ptr< std::map< std::string, std::string >> defines, bool is_define=false) | |
virtual bool | get_chunk () override |
Preprocesses and sends some text to the parent_ buffer. More... | |
virtual preprocessor::MODE | parse_mode () override |
Returns the appropriate parsing mode for this preprocessor. More... | |
Public Member Functions inherited from preprocessor | |
virtual | ~preprocessor () |
virtual void | init () |
Allows specifying any actions that need to be called after the constructor completes. More... | |
Private Member Functions | |
std::string | read_word () |
std::string | read_line () |
std::string | read_rest_of_line () |
void | skip_spaces () |
void | skip_eol () |
void | push_token (token_desc::token_type) |
void | pop_token () |
void | put (char) |
void | put (const std::string &) |
void | conditional_skip (bool skip) |
Private Attributes | |
filesystem::scoped_istream | in_scope_ |
Manages the lifetime of the std::istream pointer we own. More... | |
buffered_istream | in_ |
Input stream. More... | |
std::string | directory_ |
std::vector< std::string > | strings_ |
Buffer for delayed input processing. More... | |
std::unique_ptr< std::map< std::string, std::string > > | local_defines_ |
Mapping of macro arguments to their content. More... | |
std::vector< token_desc > | tokens_ |
Stack of nested preprocessing chunks. More... | |
int | slowpath_ |
Set to true whenever input tokens cannot be directly sent to the target buffer. More... | |
int | skipping_ |
Non-zero when the preprocessor has to skip some input text. More... | |
int | linenum_ |
bool | is_define_ |
True iff we are currently parsing a macros content, otherwise false. More... | |
Friends | |
bool | operator== (preprocessor_data::token_desc::token_type, char) |
bool | operator== (char, preprocessor_data::token_desc::token_type) |
bool | operator!= (preprocessor_data::token_desc::token_type, char) |
bool | operator!= (char, preprocessor_data::token_desc::token_type) |
Additional Inherited Members | |
Public Types inherited from preprocessor | |
enum | MODE { NO_PARSING , PARSES_FILE , PARSES_MACRO } |
Protected Member Functions inherited from preprocessor | |
preprocessor (preprocessor_streambuf &t) | |
Sets up a new preprocessor for stream buffer t. More... | |
Protected Attributes inherited from preprocessor | |
preprocessor_streambuf & | parent_ |
Specialized preprocessor for handling any kind of input stream.
This is the core of the preprocessor.
Definition at line 645 of file preprocessor.cpp.
preprocessor_data::preprocessor_data | ( | preprocessor_streambuf & | t, |
filesystem::scoped_istream | i, | ||
const std::string & | history, | ||
const std::string & | name, | ||
int | line, | ||
const std::string & | dir, | ||
const std::string & | domain, | ||
std::unique_ptr< std::map< std::string, std::string >> | defines, | ||
bool | is_define = false |
||
) |
Definition at line 828 of file preprocessor.cpp.
References get_file_code(), INLINED_PREPROCESS_DIRECTIVE_CHAR, push_token(), s, preprocessor_data::token_desc::start, and t.
|
private |
Definition at line 1077 of file preprocessor.cpp.
References preprocessor_data::token_desc::process_if, push_token(), preprocessor_data::token_desc::skip_else, and skipping_.
Referenced by get_chunk().
|
overridevirtual |
Preprocesses and sends some text to the parent_ buffer.
Implements preprocessor.
Definition at line 1086 of file preprocessor.cpp.
References preprocessor_streambuf::add_preprocessor(), preproc_define::arguments, b, c, conditional_skip(), current_dir_str, current_file_str, d, DBG_PREPROC, preprocessor_streambuf::defines_, deprecated_message(), preproc_define::deprecation_level, preproc_define::deprecation_message, preproc_define::deprecation_version, preprocessor_streambuf::depth(), directory_, filesystem::directory_name(), do_version_check(), e, buffered_istream::eof(), lg::err(), preprocessor_streambuf::error(), filename, FOR_REMOVAL, buffered_istream::get(), preprocessor_streambuf::get_current_file(), get_filename(), get_location(), filesystem::get_wml_location(), i, in, in_, INLINED_PREPROCESS_DIRECTIVE_CHAR, preproc_define::is_deprecated(), left_curly_str, game_config::images::level, lineno_string(), preproc_define::linenum, linenum_, local_defines_, preproc_define::location, preprocessor_streambuf::location_, LOG_PREPROC, preprocessor_data::token_desc::macro_chunk, preprocessor_data::token_desc::macro_parens, preprocessor_data::token_desc::macro_space, OP_INVALID, preproc_define::optional_arguments, preprocessor::parent_, parse_version_op(), buffered_istream::peek(), pop_token(), utils::portable_isspace(), PREEMPTIVE, preprocessor::preprocessor_streambuf, preprocessor_data::token_desc::process_else, preprocessor_data::token_desc::process_if, push_token(), put(), preprocessor_streambuf::quoted_, utils::quoted_split(), read_line(), read_rest_of_line(), read_word(), right_curly_str, s, preprocessor_data::token_desc::skip_else, skip_eol(), preprocessor_data::token_desc::skip_if, skip_spaces(), skipping_, slowpath_, utils::split(), preprocessor_data::token_desc::start, version_info::str(), preprocessor_data::token_desc::string, strings_, preproc_define::textdomain, preprocessor_streambuf::textdomain_, tokens_, token::type, preproc_define::value, preprocessor_data::token_desc::verbatim, preprocessor_streambuf::warning(), game_config::wesnoth_version, and WRN_PREPROC.
|
inlineoverridevirtual |
Returns the appropriate parsing mode for this preprocessor.
Reimplemented from preprocessor.
Definition at line 742 of file preprocessor.cpp.
References is_define_, preprocessor::PARSES_FILE, and preprocessor::PARSES_MACRO.
|
private |
Definition at line 907 of file preprocessor.cpp.
References preprocessor_data::token_desc::macro_chunk, preprocessor_data::token_desc::macro_parens, preprocessor_data::token_desc::macro_space, preprocessor_data::token_desc::string, strings_, tokens_, and preprocessor_data::token_desc::verbatim.
Referenced by get_chunk().
|
private |
Definition at line 877 of file preprocessor.cpp.
References INLINED_PREPROCESS_DIRECTIVE_CHAR, linenum_, preprocessor_streambuf::location_, preprocessor_data::token_desc::macro_chunk, preprocessor_data::token_desc::macro_space, preprocessor::parent_, s, skipping_, slowpath_, preprocessor_data::token_desc::string, strings_, t, preprocessor_streambuf::textdomain_, tokens_, and preprocessor_data::token_desc::verbatim.
Referenced by conditional_skip(), get_chunk(), and preprocessor_data().
|
private |
Definition at line 1032 of file preprocessor.cpp.
References preprocessor_streambuf::buffer_, c, INLINED_PREPROCESS_DIRECTIVE_CHAR, preprocessor_streambuf::linenum_, linenum_, preprocessor_streambuf::location_, preprocessor::parent_, skipping_, slowpath_, and strings_.
Referenced by get_chunk().
|
private |
Definition at line 1062 of file preprocessor.cpp.
References preprocessor_streambuf::buffer_, preprocessor::parent_, s, skipping_, slowpath_, and strings_.
|
private |
Definition at line 995 of file preprocessor.cpp.
References c, buffered_istream::eof(), buffered_istream::get(), in_, and linenum_.
Referenced by get_chunk().
|
private |
Definition at line 1017 of file preprocessor.cpp.
References c, buffered_istream::eof(), buffered_istream::get(), in_, and buffered_istream::peek().
Referenced by get_chunk().
|
private |
Definition at line 978 of file preprocessor.cpp.
References c, buffered_istream::get(), in_, buffered_istream::peek(), and utils::portable_isspace().
Referenced by get_chunk().
|
private |
Definition at line 962 of file preprocessor.cpp.
References c, buffered_istream::eof(), buffered_istream::get(), in_, and linenum_.
Referenced by get_chunk().
|
private |
Definition at line 949 of file preprocessor.cpp.
References c, buffered_istream::eof(), buffered_istream::get(), in_, and buffered_istream::peek().
Referenced by get_chunk().
|
friend |
Definition at line 768 of file preprocessor.cpp.
|
friend |
Definition at line 763 of file preprocessor.cpp.
|
friend |
Definition at line 758 of file preprocessor.cpp.
|
friend |
Definition at line 753 of file preprocessor.cpp.
|
private |
Definition at line 688 of file preprocessor.cpp.
Referenced by get_chunk().
|
private |
Input stream.
Definition at line 686 of file preprocessor.cpp.
Referenced by get_chunk(), read_line(), read_rest_of_line(), read_word(), skip_eol(), and skip_spaces().
|
private |
Manages the lifetime of the std::istream
pointer we own.
Since in_ uses the stream as well this object must be created before in_ and destroyed after in_ is destroyed.
Definition at line 683 of file preprocessor.cpp.
|
private |
True iff we are currently parsing a macros content, otherwise false.
Definition at line 715 of file preprocessor.cpp.
Referenced by parse_mode().
|
private |
Definition at line 712 of file preprocessor.cpp.
Referenced by get_chunk(), push_token(), put(), read_line(), and skip_eol().
|
private |
Mapping of macro arguments to their content.
Definition at line 694 of file preprocessor.cpp.
Referenced by get_chunk().
|
private |
Non-zero when the preprocessor has to skip some input text.
Increased whenever entering a conditional branch that is not useful, e.g. a ifdef that evaluates to false.
Definition at line 711 of file preprocessor.cpp.
Referenced by conditional_skip(), get_chunk(), push_token(), and put().
|
private |
Set to true whenever input tokens cannot be directly sent to the target buffer.
For instance, this happens with macro arguments. In that case, the output is redirected toward strings_ until it can be processed.
Definition at line 704 of file preprocessor.cpp.
Referenced by get_chunk(), push_token(), and put().
|
private |
Buffer for delayed input processing.
Definition at line 691 of file preprocessor.cpp.
Referenced by get_chunk(), pop_token(), push_token(), and put().
|
private |
Stack of nested preprocessing chunks.
Definition at line 697 of file preprocessor.cpp.
Referenced by get_chunk(), pop_token(), and push_token().