Aprepro 5.0x
Loading...
Searching...
No Matches
SEAMS::Aprepro Class Reference

#include <aprepro.h>

Collaboration diagram for SEAMS::Aprepro:

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
 
Apreprooperator= (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::symrecgetsym (const char *sym_name) const
 
SEAMS::symrecgetsym (const std::string &sym_name) const
 
SEAMS::symrecputsym (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
 
arraymake_array (size_t r, size_t c)
 
arraymake_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_recap_file_list {}
 
std::stack< std::ostream * > outputStream {}
 
class Scannerlexer {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< Symtablesym_table
 
std::vector< array * > array_allocations {}
 
std::ostringstream parsingResults {}
 
std::istringstream stringInput {}
 
bool stringInteractive {false}
 
class ScannerstringScanner {nullptr}
 
std::ostream * errorStream {&std::cerr}
 
std::ostream * warningStream {&std::cerr}
 
bool closeError {false}
 
bool closeWarning {false}
 
std::vector< history_datahistory {}
 
int parseErrorCount {0}
 
int parseWarningCount {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 class SEAMS::Aprepro::SYMBOL_TYPE
strong
Enumerator
INTERNAL 
VARIABLE 
STRING_VARIABLE 
UNDEFINED_VARIABLE 
FUNCTION 
STRING_FUNCTION 
ARRAY_FUNCTION 
ARRAY_VARIABLE 
IMMUTABLE_VARIABLE 
IMMUTABLE_STRING_VARIABLE 

Constructor & Destructor Documentation

◆ Aprepro() [1/2]

SEAMS::Aprepro::Aprepro ( )

construct a new parser aprepro context

◆ ~Aprepro()

SEAMS::Aprepro::~Aprepro ( )

◆ Aprepro() [2/2]

SEAMS::Aprepro::Aprepro ( const Aprepro & )
delete

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,
array * value )

◆ add_variable() [2/3]

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

◆ add_variable() [3/3]

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

◆ 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

◆ dumpsym_json()

void SEAMS::Aprepro::dumpsym_json ( ) const

◆ error()

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

Return number of warnings 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_sorted_sym_table()

std::vector< SEAMS::symrec * > SEAMS::Aprepro::get_sorted_sym_table ( ) const
private

◆ get_symbol_type()

Aprepro::SYMBOL_TYPE SEAMS::Aprepro::get_symbol_type ( const SEAMS::symrec * symbol) const

◆ get_variable_names()

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

◆ get_warning_count()

int SEAMS::Aprepro::get_warning_count ( ) const
inline

Return number of errors reported during parse

◆ 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

◆ long_version()

std::string SEAMS::Aprepro::long_version ( ) const

Return long version: # Algebraic Preprocessor (Aprepro) version X.X (date)

◆ make_array() [1/2]

array * SEAMS::Aprepro::make_array ( const array & from)

◆ make_array() [2/2]

array * SEAMS::Aprepro::make_array ( size_t r,
size_t c )

◆ open_file()

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

◆ operator=()

Aprepro & SEAMS::Aprepro::operator= ( const Aprepro & )
delete

◆ 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
filenameinput 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
ininput stream
in_namestream 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
inputinput string
snamestream 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
inputinput 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
inputvector of input strings
snamestream 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 )

◆ redefine_array()

void SEAMS::Aprepro::redefine_array ( array * data)

◆ remove_variable()

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

◆ set_error_streams() [1/2]

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

◆ set_error_streams() [2/2]

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 )

◆ set_option()

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

◆ short_version()

const std::string & SEAMS::Aprepro::short_version ( )
static

Return string representation of current version of aprepro.

◆ 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 ( ) const
inline

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

◆ version()

const std::string & SEAMS::Aprepro::version ( )
static

Return string representation of current version of aprepro + commit date.

◆ 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

◆ array_allocations

std::vector<array *> SEAMS::Aprepro::array_allocations {}
private

◆ closeError

bool SEAMS::Aprepro::closeError {false}
private

◆ closeInfo

bool SEAMS::Aprepro::closeInfo {false}

◆ closeWarning

bool SEAMS::Aprepro::closeWarning {false}
private

◆ 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}
mutableprivate

◆ parseWarningCount

int SEAMS::Aprepro::parseWarningCount {0}
mutableprivate

◆ 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::unique_ptr<Symtable> 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: