C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
exprtk::parser_error Namespace Reference

Classes

struct  type
 

Enumerations

enum  error_mode {
  e_unknown = 0 , e_syntax = 1 , e_token = 2 , e_numeric = 4 ,
  e_symtab = 5 , e_lexer = 6 , e_synthesis = 7 , e_helper = 8 ,
  e_parser = 9
}
 

Functions

type make_error (const error_mode mode, const std::string &diagnostic="", const std::string &src_location="")
 
type make_error (const error_mode mode, const lexer::token &tk, const std::string &diagnostic="", const std::string &src_location="")
 
std::string to_str (error_mode mode)
 
bool update_error (type &error, const std::string &expression)
 
void dump_error (const type &error)
 

Enumeration Type Documentation

◆ error_mode

Enumerator
e_unknown 
e_syntax 
e_token 
e_numeric 
e_symtab 
e_lexer 
e_synthesis 
e_helper 
e_parser 

Definition at line 22041 of file exprtk.hpp.

Function Documentation

◆ dump_error()

void exprtk::parser_error::dump_error ( const type error)
inline

Definition at line 22156 of file exprtk.hpp.

22157 {
22158 printf("Position: %02d Type: [%s] Msg: %s\n",
22159 static_cast<int>(error.token.position),
22160 exprtk::parser_error::to_str(error.mode).c_str(),
22161 error.diagnostic.c_str());
22162 }
std::string to_str(error_mode mode)
Definition exprtk.hpp:22098
std::size_t position
Definition exprtk.hpp:2400

References exprtk::parser_error::type::diagnostic, exprtk::parser_error::type::mode, exprtk::lexer::token::position, to_str(), and exprtk::parser_error::type::token.

Here is the call graph for this function:

◆ make_error() [1/2]

type exprtk::parser_error::make_error ( const error_mode  mode,
const lexer::token tk,
const std::string &  diagnostic = "",
const std::string &  src_location = "" 
)
inline

Definition at line 22084 of file exprtk.hpp.

22088 {
22089 type t;
22090 t.mode = mode;
22091 t.token = tk;
22092 t.diagnostic = diagnostic;
22093 t.src_location = src_location;
22094 exprtk_debug(("%s\n", diagnostic .c_str()));
22095 return t;
22096 }
#define exprtk_debug(params)
Definition exprtk.hpp:64

References exprtk::parser_error::type::diagnostic, exprtk_debug, exprtk::parser_error::type::mode, exprtk::parser_error::type::src_location, and exprtk::parser_error::type::token.

◆ make_error() [2/2]

type exprtk::parser_error::make_error ( const error_mode  mode,
const std::string &  diagnostic = "",
const std::string &  src_location = "" 
)
inline

Definition at line 22071 of file exprtk.hpp.

22074 {
22075 type t;
22076 t.mode = mode;
22077 t.token.type = lexer::token::e_error;
22078 t.diagnostic = diagnostic;
22079 t.src_location = src_location;
22080 exprtk_debug(("%s\n", diagnostic .c_str()));
22081 return t;
22082 }

References exprtk::parser_error::type::diagnostic, exprtk::lexer::token::e_error, exprtk_debug, exprtk::parser_error::type::mode, exprtk::parser_error::type::src_location, exprtk::parser_error::type::token, and exprtk::lexer::token::type.

Referenced by exprtk::parser< T >::expression_generator< Type >::assign_immutable_symbol(), exprtk::function_compositor< T >::compile_expression(), exprtk::parser< T >::expression_generator< Type >::conditional(), exprtk::parser< T >::expression_generator< Type >::conditional_string(), exprtk::parser< T >::expression_generator< Type >::conditional_vector(), exprtk::parser< T >::expression_generator< Type >::for_loop(), exprtk::parser< T >::expression_generator< Type >::function(), exprtk::parser< T >::expression_generator< Type >::generic_function_call(), exprtk::parser< T >::expression_generator< Type >::operator()(), exprtk::parser< T >::expression_generator< Type >::operator()(), exprtk::parser< T >::expression_generator< Type >::return_call(), exprtk::parser< T >::expression_generator< Type >::string_function_call(), exprtk::parser< T >::expression_generator< Type >::synthesize_assignment_expression(), exprtk::parser< T >::expression_generator< Type >::synthesize_assignment_operation_expression(), exprtk::parser< T >::expression_generator< Type >::synthesize_expression(), exprtk::parser< T >::expression_generator< Type >::synthesize_swap_expression(), exprtk::parser< T >::expression_generator< Type >::synthesize_vecarithmetic_operation_expression(), exprtk::parser< T >::expression_generator< Type >::synthesize_veceqineqlogic_operation_expression(), exprtk::parser< T >::expression_generator< Type >::vararg_function(), exprtk::parser< T >::expression_generator< Type >::vararg_function_call(), exprtk::parser< T >::expression_generator< Type >::vector_element(), and exprtk::parser< T >::expression_generator< Type >::while_loop().

Here is the caller graph for this function:

◆ to_str()

std::string exprtk::parser_error::to_str ( error_mode  mode)
inline

Definition at line 22098 of file exprtk.hpp.

22099 {
22100 switch (mode)
22101 {
22102 case e_unknown : return std::string("Unknown Error");
22103 case e_syntax : return std::string("Syntax Error" );
22104 case e_token : return std::string("Token Error" );
22105 case e_numeric : return std::string("Numeric Error");
22106 case e_symtab : return std::string("Symbol Error" );
22107 case e_lexer : return std::string("Lexer Error" );
22108 case e_helper : return std::string("Helper Error" );
22109 case e_parser : return std::string("Parser Error" );
22110 default : return std::string("Unknown Error");
22111 }
22112 }

References e_helper, e_lexer, e_numeric, e_parser, e_symtab, e_syntax, e_token, and e_unknown.

Referenced by complex_numbers(), composite(), dump_error(), immutable_symtab_example(), main(), expression_processor< T >::process(), run_test21(), and truth_table_generator().

Here is the caller graph for this function:

◆ update_error()

bool exprtk::parser_error::update_error ( type error,
const std::string &  expression 
)
inline

Definition at line 22114 of file exprtk.hpp.

22115 {
22116 if (
22117 expression.empty() ||
22118 (error.token.position > expression.size()) ||
22119 (std::numeric_limits<std::size_t>::max() == error.token.position)
22120 )
22121 {
22122 return false;
22123 }
22124
22125 std::size_t error_line_start = 0;
22126
22127 for (std::size_t i = error.token.position; i > 0; --i)
22128 {
22129 const details::char_t c = expression[i];
22130
22131 if (('\n' == c) || ('\r' == c))
22132 {
22133 error_line_start = i + 1;
22134 break;
22135 }
22136 }
22137
22138 std::size_t next_nl_position = std::min(expression.size(),
22139 expression.find_first_of('\n',error.token.position + 1));
22140
22141 error.column_no = error.token.position - error_line_start;
22142 error.error_line = expression.substr(error_line_start,
22143 next_nl_position - error_line_start);
22144
22145 error.line_no = 0;
22146
22147 for (std::size_t i = 0; i < next_nl_position; ++i)
22148 {
22149 if ('\n' == expression[i])
22150 ++error.line_no;
22151 }
22152
22153 return true;
22154 }

References exprtk::parser_error::type::column_no, exprtk::parser_error::type::error_line, exprtk::parser_error::type::line_no, exprtk::lexer::token::position, and exprtk::parser_error::type::token.

Referenced by expression_processor< T >::process(), run_test21(), and truth_table_generator().

Here is the caller graph for this function: