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

Function Documentation

◆ dump_error()

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

Definition at line 22421 of file exprtk.hpp.

22422 {
22423 printf("Position: %02d Type: [%s] Msg: %s\n",
22424 static_cast<int>(error.token.position),
22425 exprtk::parser_error::to_str(error.mode).c_str(),
22426 error.diagnostic.c_str());
22427 }
std::string to_str(error_mode mode)
Definition exprtk.hpp:22363
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 22349 of file exprtk.hpp.

22353 {
22354 type t;
22355 t.mode = mode;
22356 t.token = tk;
22357 t.diagnostic = diagnostic;
22358 t.src_location = src_location;
22359 exprtk_debug(("%s\n", diagnostic .c_str()));
22360 return t;
22361 }
#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 22336 of file exprtk.hpp.

22339 {
22340 type t;
22341 t.mode = mode;
22342 t.token.type = lexer::token::e_error;
22343 t.diagnostic = diagnostic;
22344 t.src_location = src_location;
22345 exprtk_debug(("%s\n", diagnostic .c_str()));
22346 return t;
22347 }

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

22364 {
22365 switch (mode)
22366 {
22367 case e_unknown : return std::string("Unknown Error");
22368 case e_syntax : return std::string("Syntax Error" );
22369 case e_token : return std::string("Token Error" );
22370 case e_numeric : return std::string("Numeric Error");
22371 case e_symtab : return std::string("Symbol Error" );
22372 case e_lexer : return std::string("Lexer Error" );
22373 case e_helper : return std::string("Helper Error" );
22374 case e_parser : return std::string("Parser Error" );
22375 default : return std::string("Unknown Error");
22376 }
22377 }

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

22380 {
22381 if (
22382 expression.empty() ||
22383 (error.token.position > expression.size()) ||
22384 (std::numeric_limits<std::size_t>::max() == error.token.position)
22385 )
22386 {
22387 return false;
22388 }
22389
22390 std::size_t error_line_start = 0;
22391
22392 for (std::size_t i = error.token.position; i > 0; --i)
22393 {
22394 const details::char_t c = expression[i];
22395
22396 if (('\n' == c) || ('\r' == c))
22397 {
22398 error_line_start = i + 1;
22399 break;
22400 }
22401 }
22402
22403 std::size_t next_nl_position = std::min(expression.size(),
22404 expression.find_first_of('\n',error.token.position + 1));
22405
22406 error.column_no = error.token.position - error_line_start;
22407 error.error_line = expression.substr(error_line_start,
22408 next_nl_position - error_line_start);
22409
22410 error.line_no = 0;
22411
22412 for (std::size_t i = 0; i < next_nl_position; ++i)
22413 {
22414 if ('\n' == expression[i])
22415 ++error.line_no;
22416 }
22417
22418 return true;
22419 }

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: