The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
preprocessor_data Class Reference

Specialized preprocessor for handling any kind of input stream. More...

Inheritance diagram for preprocessor_data:
Inheritance graph

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
preprocessorget_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::stringstrings_
 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_desctokens_
 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_streambuftarget_
 

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)
 

Detailed Description

Specialized preprocessor for handling any kind of input stream.

This is the core of the preprocessor.

Definition at line 453 of file preprocessor.cpp.

Constructor & Destructor Documentation

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 
)
preprocessor_data::~preprocessor_data ( )

Definition at line 646 of file preprocessor.cpp.

References local_defines_.

Member Function Documentation

void preprocessor_data::conditional_skip ( bool  skip)
private
bool preprocessor_data::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.

virtual int preprocessor_data::is_macro ( )
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.

void preprocessor_data::pop_token ( )
private
void preprocessor_data::push_token ( token_desc::TOKEN_TYPE  t)
private
void preprocessor_data::put ( char  c)
private
void preprocessor_data::put ( std::string const &  s)
private
std::string preprocessor_data::read_line ( )
private

Definition at line 746 of file preprocessor.cpp.

References c, buffered_istream::eof(), buffered_istream::get(), in_, and linenum_.

Referenced by get_chunk().

std::string preprocessor_data::read_rest_of_line ( )
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().

std::string preprocessor_data::read_word ( )
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().

void preprocessor_data::skip_eol ( )
private

Definition at line 719 of file preprocessor.cpp.

References buffered_istream::eof(), buffered_istream::get(), in_, and linenum_.

Referenced by get_chunk().

void preprocessor_data::skip_spaces ( )
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().

Friends And Related Function Documentation

bool operator!= ( preprocessor_data::token_desc::TOKEN_TYPE  rhs,
char  lhs 
)
friend

Definition at line 548 of file preprocessor.cpp.

bool operator!= ( char  lhs,
preprocessor_data::token_desc::TOKEN_TYPE  rhs 
)
friend

Definition at line 549 of file preprocessor.cpp.

bool operator== ( preprocessor_data::token_desc::TOKEN_TYPE  ,
char   
)
friend

Definition at line 543 of file preprocessor.cpp.

bool operator== ( char  lhs,
preprocessor_data::token_desc::TOKEN_TYPE  rhs 
)
friend

Definition at line 547 of file preprocessor.cpp.

Member Data Documentation

std::string preprocessor_data::directory_
private

Definition at line 493 of file preprocessor.cpp.

Referenced by get_chunk().

buffered_istream preprocessor_data::in_
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().

filesystem::scoped_istream preprocessor_data::in_scope_
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.

bool preprocessor_data::is_define_
private

true iff we are currently parsing a macros content, otherwise false.

Definition at line 514 of file preprocessor.cpp.

int preprocessor_data::linenum_
private

Definition at line 512 of file preprocessor.cpp.

Referenced by get_chunk(), push_token(), put(), read_line(), and skip_eol().

std::map<std::string, std::string>* preprocessor_data::local_defines_
private

Mapping of macro arguments to their content.

Definition at line 497 of file preprocessor.cpp.

Referenced by get_chunk(), and ~preprocessor_data().

int preprocessor_data::skipping_
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().

int preprocessor_data::slowpath_
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().

std::vector< std::string > preprocessor_data::strings_
private

Buffer for delayed input processing.

Definition at line 495 of file preprocessor.cpp.

Referenced by get_chunk(), pop_token(), push_token(), and put().

std::vector< token_desc > preprocessor_data::tokens_
private

Stack of nested preprocessing chunks.

Definition at line 499 of file preprocessor.cpp.

Referenced by get_chunk(), pop_token(), and push_token().


The documentation for this class was generated from the following file: