Aprepro 5.0x

Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
SEAMS::Aprepro Class Reference

`#include <aprepro.h>`

Collaboration diagram for SEAMS::Aprepro:
[legend]

## Public Types
enum | SYMBOL_TYPE { SYMBOL_TYPE::VARIABLE = 1, SYMBOL_TYPE::STRING_VARIABLE = 2, SYMBOL_TYPE::UNDEFINED_VARIABLE = 5, SYMBOL_TYPE::FUNCTION = 3, SYMBOL_TYPE::STRING_FUNCTION = 4, SYMBOL_TYPE::ARRAY_FUNCTION = 6, SYMBOL_TYPE::ARRAY_VARIABLE = 7, SYMBOL_TYPE::IMMUTABLE_VARIABLE = 11, SYMBOL_TYPE::IMMUTABLE_STRING_VARIABLE = 12 }

## Public Member Functions
| Aprepro ()
| construct a new parser aprepro context More...
| ~Aprepro ()
bool | state_is_immutable () const
const std::ostringstream & | parsing_results () const
void | clear_results ()
std::string | version () const
bool | parse_stream (std::istream &in, const std::string &in_name="stream input")
bool | parse_string (const std::string &input, const std::string &sname="string stream")
bool | parse_strings (const std::vector< std::string > &input, const std::string &sname)
bool | parse_string_interactive (const std::string &input)
bool | string_interactive ()
bool | parse_file (const std::string &filename)
void | statistics (std::ostream *out=nullptr) const
SEAMS::symrec * | getsym (const char *sym_name) const
SEAMS::symrec * | getsym (const std::string &sym_name) const
SEAMS::symrec * | putsym (const std::string &sym_name, SYMBOL_TYPE sym_type, bool is_internal)
void | add_variable (const std::string &sym_name, const std::string &sym_value, bool immutable=false, bool internal=false)
void | add_variable (const std::string &sym_name, double sym_value, bool immutable=false, bool internal=false)
void | add_variable (const std::string &sym_name, array *value)
std::vector< std::string > | get_variable_names (bool doInternal=false)
void | remove_variable (const std::string &sym_name)
int | set_option (const std::string &option, const std::string &optional_value=std::string(""))
std::fstream * | open_file (const std::string &file, const char *mode)
std::fstream * | check_open_file (const std::string &file, const char *mode)
int | get_error_count () const
void | error (const std::string &msg, bool line_info=true, bool prefix=true) const
void | warning (const std::string &msg, bool line_info=true, bool prefix=true) const
void | info (const std::string &msg, bool line_info=false, bool prefix=true) const
void | set_error_streams (std::ostream *c_error, std::ostream *c_warning, std::ostream *c_info)
void | dumpsym (const char *type, bool doInternal) const
void | dumpsym (int type, bool doInternal) const
void | dumpsym (int type, const char *pre, bool doInternal) const
void | add_history (const std::string &original, const std::string &substitution)
const std::vector< history_data > & | get_history ()
void | clear_history ()

## Public Attributes
aprepro_options | ap_options
std::stack< file_rec > | ap_file_list
std::stack< std::ostream * > | outputStream
class Scanner * | lexer {nullptr}
std::ostream * | infoStream {&std::cout}
bool | stateImmutable {false}
bool | doLoopSubstitution {true}
bool | doIncludeSubstitution {true}
bool | isCollectingLoop {false}
bool | inIfdefGetvar {false}

## Private Member Functions
void | init_table (const char *comment)

## Private Attributes
std::vector< symrec * > | sym_table
std::ostringstream | parsingResults
std::istringstream | stringInput
bool | stringInteractive {false}
class Scanner * | stringScanner {nullptr}
std::ostream * | errorStream {&std::cerr}
std::ostream * | warningStream {&std::cerr}
std::vector< history_data > | history
int | parseErrorCount {0}

## Detailed Description

The Aprepro class brings together all components. It creates an instance of the Parser and Scanner classes and connects them. Then the input stream is fed into the scanner object and the parser gets it's token sequence. Furthermore the aprepro object is available in the grammar rules as a parameter. Therefore the aprepro class contains a reference to the structure into which the parsed data is saved.

## Member Enumeration Documentation

## ◆ SYMBOL_TYPE

enum SEAMS::Aprepro::SYMBOL_TYPE
| strong

Enumerator
VARIABLE |
STRING_VARIABLE |
UNDEFINED_VARIABLE |
FUNCTION |
STRING_FUNCTION |
ARRAY_FUNCTION |
ARRAY_VARIABLE |
IMMUTABLE_VARIABLE |
IMMUTABLE_STRING_VARIABLE |

## Constructor & Destructor Documentation

## ◆ Aprepro()

SEAMS::Aprepro::Aprepro | ( |  | ) |

construct a new parser aprepro context

## ◆ ~Aprepro()

SEAMS::Aprepro::~Aprepro | ( |  | ) |

## Member Function Documentation

## ◆ add_history()

void SEAMS::Aprepro::add_history | ( | const std::string & | original,
|  | const std::string & | substitution
| ) |  |

## ◆ add_variable() [1/3]

void SEAMS::Aprepro::add_variable | ( | const std::string & | sym_name,
|  | const std::string & | sym_value,
|  | bool | immutable = `false`,
|  | bool | internal = `false`
| ) |  |

## ◆ add_variable() [2/3]

void SEAMS::Aprepro::add_variable | ( | const std::string & | sym_name,
|  | double | sym_value,
|  | bool | immutable = `false`,
|  | bool | internal = `false`
| ) |  |

## ◆ add_variable() [3/3]

void SEAMS::Aprepro::add_variable | ( | const std::string & | sym_name,
|  | array * | value
| ) |  |

## ◆ check_open_file()

std::fstream * SEAMS::Aprepro::check_open_file | ( | const std::string & | file,
|  | const char * | mode
| ) |  |

## ◆ clear_history()

void SEAMS::Aprepro::clear_history | ( |  | ) |

## ◆ clear_results()

void SEAMS::Aprepro::clear_results | ( |  | ) |

## ◆ dumpsym() [1/3]

void SEAMS::Aprepro::dumpsym | ( | const char * | type,
|  | bool | doInternal
| ) |  | const

## ◆ dumpsym() [2/3]

void SEAMS::Aprepro::dumpsym | ( | int | type,
|  | bool | doInternal
| ) |  | const

## ◆ dumpsym() [3/3]

void SEAMS::Aprepro::dumpsym | ( | int | type,
|  | const char * | pre,
|  | bool | doInternal
| ) |  | const

## ◆ error()

void SEAMS::Aprepro::error | ( | const std::string & | msg,
|  | bool | line_info = `true`,
|  | bool | prefix = `true`
| ) |  | const

Return number of errors reported during parse

## ◆ get_error_count()

int SEAMS::Aprepro::get_error_count | ( |  | ) | const
| inline

Error handling.

## ◆ get_history()

const std::vector< history_data > & SEAMS::Aprepro::get_history | ( |  | ) |

## ◆ get_variable_names()

std::vector< std::string > SEAMS::Aprepro::get_variable_names | ( | bool | doInternal = `false` | ) |

## ◆ getsym() [1/2]

symrec * SEAMS::Aprepro::getsym | ( | const char * | sym_name | ) | const

## ◆ getsym() [2/2]

symrec * SEAMS::Aprepro::getsym | ( | const std::string & | sym_name | ) | const

## ◆ info()

void SEAMS::Aprepro::info | ( | const std::string & | msg,
|  | bool | line_info = `false`,
|  | bool | prefix = `true`
| ) |  | const

## ◆ init_table()

void SEAMS::Aprepro::init_table | ( | const char * | comment | ) |
| private

## ◆ open_file()

std::fstream * SEAMS::Aprepro::open_file | ( | const std::string & | file,
|  | const char * | mode
| ) |  |

## ◆ parse_file()

bool SEAMS::Aprepro::parse_file | ( | const std::string & | filename | ) |

Invoke the scanner and parser on a file. Use parse_stream with a std::ifstream if detection of file reading errors is required.

Parameters

  filename | input file name

Returns
  true if successfully parsed

## ◆ parse_stream()

bool SEAMS::Aprepro::parse_stream | ( | std::istream & | in,
|  | const std::string & | in_name = `"stream input"`
| ) |  |

Invoke the scanner and parser for a stream.

Parameters

  in | input stream
  in_name | stream name for error messages

Returns
  true if successfully parsed

## ◆ parse_string()

bool SEAMS::Aprepro::parse_string | ( | const std::string & | input,
|  | const std::string & | sname = `"string stream"`
| ) |  |

Invoke the scanner and parser on an input string.

Parameters

  input | input string
  sname | stream name for error messages

Returns
  true if successfully parsed

## ◆ parse_string_interactive()

bool SEAMS::Aprepro::parse_string_interactive | ( | const std::string & | input | ) |

Invoke the scanner and parser on an input string in an interactive manner.

Parameters

  input | input stringInput

Returns
  true if successfully parsed

## ◆ parse_strings()

bool SEAMS::Aprepro::parse_strings | ( | const std::vector< std::string > & | input,
|  | const std::string & | sname
| ) |  |

Invoke the scanner and parser on a vector of strings.

Parameters

  input | vector of input strings
  sname | stream name for error messages

Returns
  true if successfully parsed

## ◆ parsing_results()

const std::ostringstream& SEAMS::Aprepro::parsing_results | ( |  | ) | const
| inline

Return an std::ostringstream reference to get the results of the parse_* call (* = stream, file, or string).

## ◆ putsym()

symrec * SEAMS::Aprepro::putsym | ( | const std::string & | sym_name,
|  | SYMBOL_TYPE | sym_type,
|  | bool | is_internal
| ) |  |

## ◆ remove_variable()

void SEAMS::Aprepro::remove_variable | ( | const std::string & | sym_name | ) |

## ◆ set_error_streams()

void SEAMS::Aprepro::set_error_streams | ( | std::ostream * | c_error,
|  | std::ostream * | c_warning,
|  | std::ostream * | c_info
| ) |  |

## ◆ set_option()

int SEAMS::Aprepro::set_option | ( | const std::string & | option,
|  | const std::string & | optional_value = `std::string("")`
| ) |  |

## ◆ state_is_immutable()

bool SEAMS::Aprepro::state_is_immutable | ( |  | ) | const
| inline

## ◆ statistics()

void SEAMS::Aprepro::statistics | ( | std::ostream * | out = `nullptr` | ) | const

## ◆ string_interactive()

bool SEAMS::Aprepro::string_interactive | ( |  | ) |
| inline

Get the string interactive flag, which indicates if we are in the middle of parsing a string in an interactive manner.

## ◆ version()

std::string SEAMS::Aprepro::version | ( |  | ) | const

Return string representation of current version of aprepro.

## ◆ warning()

void SEAMS::Aprepro::warning | ( | const std::string & | msg,
|  | bool | line_info = `true`,
|  | bool | prefix = `true`
| ) |  | const

## Member Data Documentation

## ◆ ap_file_list

std::stack<file_rec> SEAMS::Aprepro::ap_file_list

## ◆ ap_options

aprepro_options SEAMS::Aprepro::ap_options

## ◆ doIncludeSubstitution

bool SEAMS::Aprepro::doIncludeSubstitution {true}

## ◆ doLoopSubstitution

bool SEAMS::Aprepro::doLoopSubstitution {true}

## ◆ errorStream

std::ostream* SEAMS::Aprepro::errorStream {&std::cerr}
| private

## ◆ history

std::vector<history_data> SEAMS::Aprepro::history
| private

## ◆ infoStream

std::ostream* SEAMS::Aprepro::infoStream {&std::cout}

## ◆ inIfdefGetvar

bool SEAMS::Aprepro::inIfdefGetvar {false}
| mutable

## ◆ isCollectingLoop

bool SEAMS::Aprepro::isCollectingLoop {false}

## ◆ lexer

class Scanner* SEAMS::Aprepro::lexer {nullptr}

Pointer to the current lexer instance, this is used to connect the parser to the scanner. It is used in the yylex macro.

## ◆ outputStream

std::stack<std::ostream *> SEAMS::Aprepro::outputStream

## ◆ parseErrorCount

int SEAMS::Aprepro::parseErrorCount {0}
| mutable private

## ◆ parsingResults

std::ostringstream SEAMS::Aprepro::parsingResults
| private

## ◆ stateImmutable

bool SEAMS::Aprepro::stateImmutable {false}

## ◆ stringInput

std::istringstream SEAMS::Aprepro::stringInput
| private

## ◆ stringInteractive

bool SEAMS::Aprepro::stringInteractive {false}
| private

## ◆ stringScanner

class Scanner* SEAMS::Aprepro::stringScanner {nullptr}
| private

## ◆ sym_table

std::vector<symrec *> SEAMS::Aprepro::sym_table
| private

## ◆ warningStream

std::ostream* SEAMS::Aprepro::warningStream {&std::cerr}
| private

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

- aprepro.h
- apr_aprepro.cc
- apr_init.cc