Aprepro 5.0x
|
#include <aprepro.h>
Public Types | |
enum class | SYMBOL_TYPE { INTERNAL = 0 , VARIABLE = 1 , STRING_VARIABLE = 2 , UNDEFINED_VARIABLE = 5 , FUNCTION = 3 , STRING_FUNCTION = 4 , ARRAY_FUNCTION = 6 , ARRAY_VARIABLE = 7 , IMMUTABLE_VARIABLE = 11 , IMMUTABLE_STRING_VARIABLE = 12 } |
Public Member Functions | |
Aprepro () | |
construct a new parser aprepro context | |
~Aprepro () | |
Aprepro (const Aprepro &)=delete | |
Aprepro & | operator= (const Aprepro &)=delete |
bool | state_is_immutable () const |
const std::ostringstream & | parsing_results () const |
void | clear_results () |
std::string | long_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 () const |
bool | parse_file (const std::string &filename) |
void | statistics (std::ostream *out=nullptr) const |
SYMBOL_TYPE | get_symbol_type (const SEAMS::symrec *symbol) 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 |
int | get_warning_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 | set_error_streams (std::ostream *c_error, std::ostream *c_warning, std::ostream *c_info, bool close_error, bool close_warning, bool close_info) |
void | dumpsym (const char *type, bool doInternal) const |
void | dumpsym (int type, bool doInternal) const |
void | dumpsym_json () const |
void | dumpsym (int type, const char *pre, bool doInternal) const |
array * | make_array (size_t r, size_t c) |
array * | make_array (const array &from) |
void | redefine_array (array *data) |
void | add_history (const std::string &original, const std::string &substitution) |
const std::vector< history_data > & | get_history () |
void | clear_history () |
Static Public Member Functions | |
static const std::string & | version () |
static const std::string & | short_version () |
Public Attributes | |
aprepro_options | ap_options |
std::stack< file_rec > | ap_file_list {} |
std::stack< std::ostream * > | outputStream {} |
class Scanner * | lexer {nullptr} |
bool | closeInfo {false} |
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) |
std::vector< SEAMS::symrec * > | get_sorted_sym_table () const |
Private Attributes | |
std::unique_ptr< Symtable > | sym_table |
std::vector< array * > | array_allocations {} |
std::ostringstream | parsingResults {} |
std::istringstream | stringInput {} |
bool | stringInteractive {false} |
class Scanner * | stringScanner {nullptr} |
std::ostream * | errorStream {&std::cerr} |
std::ostream * | warningStream {&std::cerr} |
bool | closeError {false} |
bool | closeWarning {false} |
std::vector< history_data > | history {} |
int | parseErrorCount {0} |
int | parseWarningCount {0} |
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.
|
strong |
SEAMS::Aprepro::Aprepro | ( | ) |
construct a new parser aprepro context
SEAMS::Aprepro::~Aprepro | ( | ) |
|
delete |
void SEAMS::Aprepro::add_history | ( | const std::string & | original, |
const std::string & | substitution ) |
void SEAMS::Aprepro::add_variable | ( | const std::string & | sym_name, |
array * | value ) |
void SEAMS::Aprepro::add_variable | ( | const std::string & | sym_name, |
const std::string & | sym_value, | ||
bool | immutable = false, | ||
bool | internal = false ) |
void SEAMS::Aprepro::add_variable | ( | const std::string & | sym_name, |
double | sym_value, | ||
bool | immutable = false, | ||
bool | internal = false ) |
std::fstream * SEAMS::Aprepro::check_open_file | ( | const std::string & | file, |
const char * | mode ) |
void SEAMS::Aprepro::clear_history | ( | ) |
void SEAMS::Aprepro::clear_results | ( | ) |
void SEAMS::Aprepro::dumpsym | ( | const char * | type, |
bool | doInternal ) const |
void SEAMS::Aprepro::dumpsym | ( | int | type, |
bool | doInternal ) const |
void SEAMS::Aprepro::dumpsym | ( | int | type, |
const char * | pre, | ||
bool | doInternal ) const |
void SEAMS::Aprepro::dumpsym_json | ( | ) | const |
void SEAMS::Aprepro::error | ( | const std::string & | msg, |
bool | line_info = true, | ||
bool | prefix = true ) const |
Return number of warnings reported during parse
|
inline |
Error handling.
const std::vector< history_data > & SEAMS::Aprepro::get_history | ( | ) |
|
private |
Aprepro::SYMBOL_TYPE SEAMS::Aprepro::get_symbol_type | ( | const SEAMS::symrec * | symbol | ) | const |
std::vector< std::string > SEAMS::Aprepro::get_variable_names | ( | bool | doInternal = false | ) |
|
inline |
Return number of errors reported during parse
symrec * SEAMS::Aprepro::getsym | ( | const char * | sym_name | ) | const |
symrec * SEAMS::Aprepro::getsym | ( | const std::string & | sym_name | ) | const |
void SEAMS::Aprepro::info | ( | const std::string & | msg, |
bool | line_info = false, | ||
bool | prefix = true ) const |
|
private |
std::string SEAMS::Aprepro::long_version | ( | ) | const |
Return long version: # Algebraic Preprocessor (Aprepro) version X.X (date)
array * SEAMS::Aprepro::make_array | ( | size_t | r, |
size_t | c ) |
std::fstream * SEAMS::Aprepro::open_file | ( | const std::string & | file, |
const char * | mode ) |
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.
filename | input file name |
bool SEAMS::Aprepro::parse_stream | ( | std::istream & | in, |
const std::string & | in_name = "stream input" ) |
Invoke the scanner and parser for a stream.
in | input stream |
in_name | stream name for error messages |
bool SEAMS::Aprepro::parse_string | ( | const std::string & | input, |
const std::string & | sname = "string stream" ) |
Invoke the scanner and parser on an input string.
input | input string |
sname | stream name for error messages |
bool SEAMS::Aprepro::parse_string_interactive | ( | const std::string & | input | ) |
Invoke the scanner and parser on an input string in an interactive manner.
input | input stringInput |
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.
input | vector of input strings |
sname | stream name for error messages |
|
inline |
Return an std::ostringstream reference to get the results of the parse_* call (* = stream, file, or string).
symrec * SEAMS::Aprepro::putsym | ( | const std::string & | sym_name, |
SYMBOL_TYPE | sym_type, | ||
bool | is_internal ) |
void SEAMS::Aprepro::redefine_array | ( | array * | data | ) |
void SEAMS::Aprepro::remove_variable | ( | const std::string & | sym_name | ) |
void SEAMS::Aprepro::set_error_streams | ( | std::ostream * | c_error, |
std::ostream * | c_warning, | ||
std::ostream * | c_info ) |
void SEAMS::Aprepro::set_error_streams | ( | std::ostream * | c_error, |
std::ostream * | c_warning, | ||
std::ostream * | c_info, | ||
bool | close_error, | ||
bool | close_warning, | ||
bool | close_info ) |
int SEAMS::Aprepro::set_option | ( | const std::string & | option, |
const std::string & | optional_value = std::string("") ) |
|
static |
Return string representation of current version of aprepro.
|
inline |
void SEAMS::Aprepro::statistics | ( | std::ostream * | out = nullptr | ) | const |
|
inline |
Get the string interactive flag, which indicates if we are in the middle of parsing a string in an interactive manner.
|
static |
Return string representation of current version of aprepro + commit date.
void SEAMS::Aprepro::warning | ( | const std::string & | msg, |
bool | line_info = true, | ||
bool | prefix = true ) const |
std::stack<file_rec> SEAMS::Aprepro::ap_file_list {} |
aprepro_options SEAMS::Aprepro::ap_options |
|
private |
|
private |
bool SEAMS::Aprepro::closeInfo {false} |
|
private |
bool SEAMS::Aprepro::doIncludeSubstitution {true} |
bool SEAMS::Aprepro::doLoopSubstitution {true} |
|
private |
|
private |
std::ostream* SEAMS::Aprepro::infoStream {&std::cout} |
|
mutable |
bool SEAMS::Aprepro::isCollectingLoop {false} |
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.
std::stack<std::ostream *> SEAMS::Aprepro::outputStream {} |
|
mutableprivate |
|
mutableprivate |
|
private |
bool SEAMS::Aprepro::stateImmutable {false} |
|
private |
|
private |
|
private |
|
private |
|
private |