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 &, std::istream *, std::string const &history, std::string const &name, int line, std::string const &dir, std::string const &domain, std::map< std::string, std::string > *defines, bool is_define=false) | |
| ~preprocessor_data () | |
| virtual bool | get_chunk () |
| virtual int | is_macro () |
| retruns 1 if this parses a macro, -1 if this doesnt parse text (if this is no preprocessor_data). 0 otherwise (this parses a file). 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 (std::string const &) |
| void | conditional_skip (bool skip) |
Private Member Functions inherited from preprocessor | |
| preprocessor * | get_old_preprocessor () |
| Preprocesses and sends some text to the target_ buffer. More... | |
| virtual | ~preprocessor () |
| Restores the old preprocessing context of target_. More... | |
| preprocessor (preprocessor_streambuf &) | |
| Sets up a new preprocessor for stream buffer t. More... | |
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::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... | |
Private Attributes inherited from preprocessor | |
| preprocessor_streambuf & | target_ |
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) |
Specialized preprocessor for handling any kind of input stream.
This is the core of the preprocessor.
Definition at line 453 of file preprocessor.cpp.
| preprocessor_data::preprocessor_data | ( | preprocessor_streambuf & | t, |
| std::istream * | i, | ||
| std::string const & | history, | ||
| std::string const & | name, | ||
| int | line, | ||
| std::string const & | dir, | ||
| std::string const & | domain, | ||
| std::map< std::string, std::string > * | defines, | ||
| bool | is_define = false |
||
| ) |
Definition at line 606 of file preprocessor.cpp.
References preprocessor_streambuf::buffer_, get_file_code(), preprocessor_streambuf::linenum_, preprocessor_streambuf::location_, push_token(), preprocessor_data::token_desc::START, and preprocessor_streambuf::textdomain_.
Referenced by get_chunk().
| preprocessor_data::~preprocessor_data | ( | ) |
Definition at line 646 of file preprocessor.cpp.
References local_defines_.
|
private |
Definition at line 811 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().
|
virtual |
Implements preprocessor.
Definition at line 817 of file preprocessor.cpp.
References preproc_define::arguments, conditional_skip(), current_dir_str, current_file_str, d, DBG_PREPROC, preprocessor_streambuf::defines_, preprocessor_streambuf::depth_, directory_, filesystem::directory_name(), do_version_check(), buffered_istream::eof(), lg::err(), error(), preprocessor_streambuf::error(), buffered_istream::get(), preprocessor_streambuf::get_current_file(), get_filename(), get_location(), filesystem::get_wml_location(), i, in_, mp_ui_alerts::items, lineno_string(), preproc_define::linenum, preprocessor_data::token_desc::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, parse_version_op(), buffered_istream::peek(), pop_token(), utils::portable_isspace(), pos, preprocessor_data(), 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(), preprocessor_data::token_desc::SKIP_ELSE, skip_eol(), preprocessor_data::token_desc::SKIP_IF, skip_spaces(), skipping_, slowpath_, utils::split(), preprocessor_data::token_desc::stack_pos, preprocessor_data::token_desc::START, version_info::str(), preprocessor_data::token_desc::STRING, strings_, preprocessor::target_, preproc_define::textdomain, preprocessor_streambuf::textdomain_, tokens_, preprocessor_data::token_desc::type, preproc_define::value, preprocessor_data::token_desc::VERBATIM, preprocessor_streambuf::warning(), and WRN_PREPROC.
|
inlinevirtual |
retruns 1 if this parses a macro, -1 if this doesnt parse text (if this is no preprocessor_data). 0 otherwise (this parses a file).
Reimplemented from preprocessor.
Definition at line 536 of file preprocessor.cpp.
|
private |
Definition at line 676 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 651 of file preprocessor.cpp.
References linenum_, preprocessor_streambuf::location_, preprocessor_data::token_desc::MACRO_CHUNK, preprocessor_data::token_desc::MACRO_SPACE, skipping_, slowpath_, preprocessor_data::token_desc::STRING, strings_, preprocessor::target_, preprocessor_streambuf::textdomain_, tokens_, and preprocessor_data::token_desc::VERBATIM.
Referenced by conditional_skip(), get_chunk(), and preprocessor_data().
|
private |
Definition at line 773 of file preprocessor.cpp.
References preprocessor_streambuf::buffer_, c, preprocessor_streambuf::linenum_, linenum_, preprocessor_streambuf::location_, skipping_, slowpath_, strings_, and preprocessor::target_.
Referenced by get_chunk().
|
private |
Definition at line 799 of file preprocessor.cpp.
References preprocessor_streambuf::buffer_, skipping_, slowpath_, strings_, and preprocessor::target_.
|
private |
Definition at line 746 of file preprocessor.cpp.
References c, buffered_istream::eof(), buffered_istream::get(), in_, and linenum_.
Referenced by get_chunk().
|
private |
Definition at line 762 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 732 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 719 of file preprocessor.cpp.
References buffered_istream::eof(), buffered_istream::get(), in_, and linenum_.
Referenced by get_chunk().
|
private |
Definition at line 709 of file preprocessor.cpp.
References buffered_istream::eof(), buffered_istream::get(), in_, and buffered_istream::peek().
Referenced by get_chunk().
|
friend |
Definition at line 548 of file preprocessor.cpp.
|
friend |
Definition at line 549 of file preprocessor.cpp.
|
friend |
Definition at line 543 of file preprocessor.cpp.
|
friend |
Definition at line 547 of file preprocessor.cpp.
|
private |
Definition at line 493 of file preprocessor.cpp.
Referenced by get_chunk().
|
private |
Input stream.
Definition at line 491 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 488 of file preprocessor.cpp.
|
private |
true iff we are currently parsing a macros content, otherwise false.
Definition at line 514 of file preprocessor.cpp.
|
private |
Definition at line 512 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 497 of file preprocessor.cpp.
Referenced by get_chunk(), and ~preprocessor_data().
|
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 511 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 505 of file preprocessor.cpp.
Referenced by get_chunk(), push_token(), and put().
|
private |
Buffer for delayed input processing.
Definition at line 495 of file preprocessor.cpp.
Referenced by get_chunk(), pop_token(), push_token(), and put().
|
private |
Stack of nested preprocessing chunks.
Definition at line 499 of file preprocessor.cpp.
Referenced by get_chunk(), pop_token(), and push_token().
1.8.8