C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
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 22390 of file exprtk.hpp.

Function Documentation

◆ dump_error()

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

Definition at line 22505 of file exprtk.hpp.

22506 {
22507 printf("Position: %02d Type: [%s] Msg: %s\n",
22508 static_cast<int>(error.token.position),
22509 exprtk::parser_error::to_str(error.mode).c_str(),
22510 error.diagnostic.c_str());
22511 }
std::string to_str(error_mode mode)
Definition exprtk.hpp:22447
std::size_t position
Definition exprtk.hpp:2454

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 22433 of file exprtk.hpp.

22437 {
22438 type t;
22439 t.mode = mode;
22440 t.token = tk;
22441 t.diagnostic = diagnostic;
22442 t.src_location = src_location;
22443 exprtk_debug(("%s\n", diagnostic .c_str()));
22444 return t;
22445 }
#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 22420 of file exprtk.hpp.

22423 {
22424 type t;
22425 t.mode = mode;
22427 t.diagnostic = diagnostic;
22428 t.src_location = src_location;
22429 exprtk_debug(("%s\n", diagnostic .c_str()));
22430 return t;
22431 }

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 >::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 22447 of file exprtk.hpp.

22448 {
22449 switch (mode)
22450 {
22451 case e_unknown : return std::string("Unknown Error");
22452 case e_syntax : return std::string("Syntax Error" );
22453 case e_token : return std::string("Token Error" );
22454 case e_numeric : return std::string("Numeric Error");
22455 case e_symtab : return std::string("Symbol Error" );
22456 case e_lexer : return std::string("Lexer Error" );
22457 case e_helper : return std::string("Helper Error" );
22458 case e_parser : return std::string("Parser Error" );
22459 default : return std::string("Unknown Error");
22460 }
22461 }

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 22463 of file exprtk.hpp.

22464 {
22465 if (
22466 expression.empty() ||
22467 (error.token.position > expression.size()) ||
22468 (std::numeric_limits<std::size_t>::max() == error.token.position)
22469 )
22470 {
22471 return false;
22472 }
22473
22474 std::size_t error_line_start = 0;
22475
22476 for (std::size_t i = error.token.position; i > 0; --i)
22477 {
22478 const details::char_t c = expression[i];
22479
22480 if (('\n' == c) || ('\r' == c))
22481 {
22482 error_line_start = i + 1;
22483 break;
22484 }
22485 }
22486
22487 std::size_t next_nl_position = std::min(expression.size(),
22488 expression.find_first_of('\n',error.token.position + 1));
22489
22490 error.column_no = error.token.position - error_line_start;
22491 error.error_line = expression.substr(error_line_start,
22492 next_nl_position - error_line_start);
22493
22494 error.line_no = 0;
22495
22496 for (std::size_t i = 0; i < next_nl_position; ++i)
22497 {
22498 if ('\n' == expression[i])
22499 ++error.line_no;
22500 }
22501
22502 return true;
22503 }

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: