C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
exprtk::lexer::parser_helper Class Reference

#include <exprtk.hpp>

Inheritance diagram for exprtk::lexer::parser_helper:
[legend]
Collaboration diagram for exprtk::lexer::parser_helper:
[legend]

Public Types

enum  token_advance_mode { e_hold = 0 , e_advance = 1 }
typedef token token_t
typedef generator generator_t

Public Member Functions

bool init (const std::string &str)
generator_t & lexer ()
const generator_t & lexer () const
void store_token ()
void restore_token ()
void next_token ()
const token_t & current_token () const
const token_t & peek_next_token ()
void advance_token (const token_advance_mode mode)
bool token_is (const token_t::token_type &ttype, const token_advance_mode mode=e_advance)
bool token_is (const token_t::token_type &ttype, const std::string &value, const token_advance_mode mode=e_advance)
bool token_is (const std::string &value, const token_advance_mode mode=e_advance)
bool token_is_arithmetic_opr (const token_advance_mode mode=e_advance)
bool token_is_ineq_opr (const token_advance_mode mode=e_advance)
bool token_is_left_bracket (const token_advance_mode mode=e_advance)
bool token_is_right_bracket (const token_advance_mode mode=e_advance)
bool token_is_bracket (const token_advance_mode mode=e_advance)
bool token_is_loop (const token_advance_mode mode=e_advance)
bool peek_token_is (const token_t::token_type &ttype)
bool peek_token_is (const std::string &s)

Private Attributes

generator_t lexer_
token_t current_token_
token_t store_current_token_

Detailed Description

Definition at line 4410 of file exprtk.hpp.

Member Typedef Documentation

◆ generator_t

◆ token_t

Definition at line 4414 of file exprtk.hpp.

Member Enumeration Documentation

◆ token_advance_mode

Enumerator
e_hold 
e_advance 

Definition at line 4468 of file exprtk.hpp.

4469 {
4470 e_hold = 0,
4471 e_advance = 1
4472 };

Member Function Documentation

◆ advance_token()

void exprtk::lexer::parser_helper::advance_token ( const token_advance_mode mode)
inline

Definition at line 4474 of file exprtk.hpp.

4475 {
4476 if (e_advance == mode)
4477 {
4478 next_token();
4479 }
4480 }

References e_advance, and next_token().

Referenced by token_is(), token_is(), token_is(), token_is_arithmetic_opr(), token_is_bracket(), token_is_ineq_opr(), token_is_left_bracket(), and token_is_right_bracket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ current_token()

const token_t & exprtk::lexer::parser_helper::current_token ( ) const
inline

Definition at line 4458 of file exprtk.hpp.

4459 {
4460 return current_token_;
4461 }

References current_token_.

Referenced by exprtk::parser< Type >::check_block_statement_closure(), exprtk::parser< Type >::compile(), exprtk::parser< Type >::parse_assert_statement(), exprtk::parser< Type >::parse_base_function_call(), exprtk::parser< Type >::parse_base_operation(), exprtk::parser< Type >::parse_branch(), exprtk::parser< Type >::parse_break_statement(), exprtk::parser< Type >::parse_conditional_statement(), exprtk::parser< Type >::parse_conditional_statement_01(), exprtk::parser< Type >::parse_conditional_statement_02(), exprtk::parser< Type >::parse_const_string(), exprtk::parser< Type >::parse_continue_statement(), exprtk::parser< Type >::parse_corpus(), exprtk::parser< Type >::parse_define_constvar_statement(), exprtk::parser< Type >::parse_define_string_statement(), exprtk::parser< Type >::parse_define_var_statement(), exprtk::parser< Type >::parse_define_vector_statement(), exprtk::parser< Type >::parse_expression(), exprtk::parser< Type >::parse_for_loop(), exprtk::parser< Type >::parse_function_call(), exprtk::parser< Type >::parse_function_call_0(), exprtk::parser< Type >::parse_function_invocation(), exprtk::parser< Type >::parse_generic_function_call(), exprtk::parser< Type >::parse_igeneric_function_params(), exprtk::parser< Type >::parse_multi_sequence(), exprtk::parser< Type >::parse_multi_switch_statement(), exprtk::parser< Type >::parse_not_statement(), exprtk::parser< Type >::parse_overload_function_call(), exprtk::parser< Type >::parse_range(), exprtk::parser< Type >::parse_repeat_until_loop(), exprtk::parser< Type >::parse_return_statement(), exprtk::parser< Type >::parse_special_function(), exprtk::parser< Type >::parse_string(), exprtk::parser< Type >::parse_string_function_call(), exprtk::parser< Type >::parse_string_range_statement(), exprtk::parser< Type >::parse_swap_statement(), exprtk::parser< Type >::parse_switch_statement(), exprtk::parser< Type >::parse_symbol(), exprtk::parser< Type >::parse_symtab_symbol(), exprtk::parser< Type >::parse_ternary_conditional_statement(), exprtk::parser< Type >::parse_uninitialised_var_statement(), exprtk::parser< Type >::parse_vararg_function(), exprtk::parser< Type >::parse_vararg_function_call(), exprtk::parser< Type >::parse_vector(), exprtk::parser< Type >::parse_vector_index(), exprtk::parser< Type >::parse_while_loop(), exprtk::parser< Type >::post_bracket_process(), exprtk::parser< Type >::post_variable_process(), expression_processor< T >::parse_function_definition_impl::process(), exprtk::parser< T >::parse_special_function_impl< Type, NumberOfParameters >::process(), exprtk::parser< Type >::simplify_unary_negation_branch(), exprtk::parser< Type >::synthesize_vector_element(), token_is(), token_is(), token_is(), token_is_arithmetic_opr(), token_is_bracket(), token_is_ineq_opr(), token_is_left_bracket(), and token_is_right_bracket().

Here is the caller graph for this function:

◆ init()

bool exprtk::lexer::parser_helper::init ( const std::string & str)
inline

Definition at line 4417 of file exprtk.hpp.

4418 {
4419 if (!lexer_.process(str))
4420 {
4421 return false;
4422 }
4423
4424 lexer_.begin();
4425
4426 next_token();
4427
4428 return true;
4429 }

References lexer_, and next_token().

Referenced by exprtk::parser< Type >::compile(), and expression_processor< T >::parse_function_definition_impl::process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lexer() [1/2]

generator_t & exprtk::lexer::parser_helper::lexer ( )
inline

◆ lexer() [2/2]

const generator_t & exprtk::lexer::parser_helper::lexer ( ) const
inline

Definition at line 4436 of file exprtk.hpp.

4437 {
4438 return lexer_;
4439 }

References lexer_.

◆ next_token()

void exprtk::lexer::parser_helper::next_token ( )
inline

Definition at line 4453 of file exprtk.hpp.

4454 {
4455 current_token_ = lexer_.next_token();
4456 }

References current_token_, and lexer_.

Referenced by advance_token(), exprtk::parser< Type >::compile(), init(), exprtk::parser< Type >::parse_assert_statement(), exprtk::parser< Type >::parse_base_function_call(), exprtk::parser< Type >::parse_branch(), exprtk::parser< Type >::parse_break_statement(), exprtk::parser< Type >::parse_conditional_statement(), exprtk::parser< Type >::parse_conditional_statement_02(), exprtk::parser< Type >::parse_const_string(), exprtk::parser< Type >::parse_continue_statement(), exprtk::parser< Type >::parse_corpus(), exprtk::parser< Type >::parse_define_var_statement(), exprtk::parser< Type >::parse_expression(), exprtk::parser< Type >::parse_for_loop(), exprtk::parser< Type >::parse_function_call(), exprtk::parser< Type >::parse_function_call_0(), exprtk::parser< Type >::parse_generic_function_call(), exprtk::parser< Type >::parse_multi_switch_statement(), exprtk::parser< Type >::parse_null_statement(), exprtk::parser< Type >::parse_overload_function_call(), exprtk::parser< Type >::parse_repeat_until_loop(), exprtk::parser< Type >::parse_return_statement(), exprtk::parser< Type >::parse_string(), exprtk::parser< Type >::parse_string_function_call(), exprtk::parser< Type >::parse_swap_statement(), exprtk::parser< Type >::parse_switch_statement(), exprtk::parser< Type >::parse_symtab_symbol(), exprtk::parser< Type >::parse_vararg_function(), exprtk::parser< Type >::parse_vararg_function_call(), exprtk::parser< Type >::parse_vector(), exprtk::parser< Type >::parse_while_loop(), exprtk::parser< Type >::post_bracket_process(), expression_processor< T >::parse_function_definition_impl::process(), and exprtk::parser< T >::parse_special_function_impl< Type, NumberOfParameters >::process().

Here is the caller graph for this function:

◆ peek_next_token()

const token_t & exprtk::lexer::parser_helper::peek_next_token ( )
inline

Definition at line 4463 of file exprtk.hpp.

4464 {
4465 return lexer_.peek_next_token();
4466 }

References lexer_.

◆ peek_token_is() [1/2]

bool exprtk::lexer::parser_helper::peek_token_is ( const std::string & s)
inline

Definition at line 4620 of file exprtk.hpp.

4621 {
4622 return (exprtk::details::imatch(lexer_.peek_next_token().value,s));
4623 }
bool imatch(const char_t c1, const char_t c2)
Definition exprtk.hpp:190

References exprtk::details::imatch(), and lexer_.

Here is the call graph for this function:

◆ peek_token_is() [2/2]

bool exprtk::lexer::parser_helper::peek_token_is ( const token_t::token_type & ttype)
inline

◆ restore_token()

void exprtk::lexer::parser_helper::restore_token ( )
inline

Definition at line 4447 of file exprtk.hpp.

4448 {
4449 lexer_.restore();
4451 }

References current_token_, lexer_, and store_current_token_.

◆ store_token()

void exprtk::lexer::parser_helper::store_token ( )
inline

Definition at line 4441 of file exprtk.hpp.

4442 {
4443 lexer_.store();
4445 }

References current_token_, lexer_, and store_current_token_.

◆ token_is() [1/3]

bool exprtk::lexer::parser_helper::token_is ( const std::string & value,
const token_advance_mode mode = e_advance )
inline

Definition at line 4511 of file exprtk.hpp.

4513 {
4514 if (!exprtk::details::imatch(value,current_token().value))
4515 {
4516 return false;
4517 }
4518
4519 advance_token(mode);
4520
4521 return true;
4522 }
void advance_token(const token_advance_mode mode)
Definition exprtk.hpp:4474
const token_t & current_token() const
Definition exprtk.hpp:4458

References advance_token(), current_token(), e_advance, and exprtk::details::imatch().

Here is the call graph for this function:

◆ token_is() [2/3]

bool exprtk::lexer::parser_helper::token_is ( const token_t::token_type & ttype,
const std::string & value,
const token_advance_mode mode = e_advance )
inline

Definition at line 4494 of file exprtk.hpp.

4497 {
4498 if (
4499 (current_token().type != ttype) ||
4501 )
4502 {
4503 return false;
4504 }
4505
4506 advance_token(mode);
4507
4508 return true;
4509 }

References advance_token(), current_token(), e_advance, and exprtk::details::imatch().

Here is the call graph for this function:

◆ token_is() [3/3]

bool exprtk::lexer::parser_helper::token_is ( const token_t::token_type & ttype,
const token_advance_mode mode = e_advance )
inline

Definition at line 4482 of file exprtk.hpp.

4483 {
4484 if (current_token().type != ttype)
4485 {
4486 return false;
4487 }
4488
4489 advance_token(mode);
4490
4491 return true;
4492 }

References advance_token(), current_token(), and e_advance.

Referenced by exprtk::parser< Type >::parse_assert_statement(), exprtk::parser< Type >::parse_base_function_call(), exprtk::parser< Type >::parse_branch(), exprtk::parser< Type >::parse_break_statement(), exprtk::parser< Type >::parse_conditional_statement(), exprtk::parser< Type >::parse_conditional_statement_01(), exprtk::parser< Type >::parse_conditional_statement_02(), exprtk::parser< Type >::parse_corpus(), exprtk::parser< Type >::parse_define_constvar_statement(), exprtk::parser< Type >::parse_define_var_statement(), exprtk::parser< Type >::parse_define_vector_statement(), exprtk::parser< Type >::parse_expression(), exprtk::parser< Type >::parse_for_loop(), exprtk::parser< Type >::parse_function_call(), exprtk::parser< Type >::parse_function_call_0(), exprtk::parser< Type >::parse_generic_function_call(), exprtk::parser< Type >::parse_igeneric_function_params(), exprtk::parser< Type >::parse_multi_sequence(), exprtk::parser< Type >::parse_multi_switch_statement(), exprtk::parser< Type >::parse_pending_string_rangesize(), exprtk::parser< Type >::parse_pending_vector_index_operator(), exprtk::parser< Type >::parse_range(), exprtk::parser< Type >::parse_repeat_until_loop(), exprtk::parser< Type >::parse_return_statement(), exprtk::parser< Type >::parse_string_range_statement(), exprtk::parser< Type >::parse_swap_statement(), exprtk::parser< Type >::parse_switch_statement(), exprtk::parser< Type >::parse_ternary_conditional_statement(), exprtk::parser< Type >::parse_uninitialised_var_statement(), exprtk::parser< Type >::parse_vararg_function(), exprtk::parser< Type >::parse_vararg_function_call(), exprtk::parser< Type >::parse_vector(), exprtk::parser< Type >::parse_vector_index(), exprtk::parser< Type >::parse_while_loop(), exprtk::parser< Type >::post_bracket_process(), expression_processor< T >::parse_function_definition_impl::process(), exprtk::parser< T >::parse_special_function_impl< Type, NumberOfParameters >::process(), and token_is_loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ token_is_arithmetic_opr()

bool exprtk::lexer::parser_helper::token_is_arithmetic_opr ( const token_advance_mode mode = e_advance)
inline

Definition at line 4524 of file exprtk.hpp.

4525 {
4526 switch (current_token().type)
4527 {
4528 case token_t::e_add :
4529 case token_t::e_sub :
4530 case token_t::e_div :
4531 case token_t::e_mul :
4532 case token_t::e_mod :
4533 case token_t::e_pow : break;
4534 default : return false;
4535 }
4536
4537 advance_token(mode);
4538
4539 return true;
4540 }

References advance_token(), current_token(), exprtk::lexer::token::e_add, e_advance, exprtk::lexer::token::e_div, exprtk::lexer::token::e_mod, exprtk::lexer::token::e_mul, exprtk::lexer::token::e_pow, and exprtk::lexer::token::e_sub.

Referenced by exprtk::parser< Type >::parse_conditional_statement_02().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ token_is_bracket()

bool exprtk::lexer::parser_helper::token_is_bracket ( const token_advance_mode mode = e_advance)
inline

Definition at line 4590 of file exprtk.hpp.

4591 {
4592 switch (current_token().type)
4593 {
4594 case token_t::e_rbracket :
4597 case token_t::e_lbracket :
4599 case token_t::e_lsqrbracket : break;
4600 default : return false;
4601 }
4602
4603 advance_token(mode);
4604
4605 return true;
4606 }

References advance_token(), current_token(), e_advance, exprtk::lexer::token::e_lbracket, exprtk::lexer::token::e_lcrlbracket, exprtk::lexer::token::e_lsqrbracket, exprtk::lexer::token::e_rbracket, exprtk::lexer::token::e_rcrlbracket, and exprtk::lexer::token::e_rsqrbracket.

Referenced by exprtk::parser< Type >::parse_corpus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ token_is_ineq_opr()

bool exprtk::lexer::parser_helper::token_is_ineq_opr ( const token_advance_mode mode = e_advance)
inline

Definition at line 4542 of file exprtk.hpp.

4543 {
4544 switch (current_token().type)
4545 {
4546 case token_t::e_eq :
4547 case token_t::e_lte :
4548 case token_t::e_ne :
4549 case token_t::e_gte :
4550 case token_t::e_lt :
4551 case token_t::e_gt : break;
4552 default : return false;
4553 }
4554
4555 advance_token(mode);
4556
4557 return true;
4558 }

References advance_token(), current_token(), e_advance, exprtk::lexer::token::e_eq, exprtk::lexer::token::e_gt, exprtk::lexer::token::e_gte, exprtk::lexer::token::e_lt, exprtk::lexer::token::e_lte, and exprtk::lexer::token::e_ne.

Referenced by exprtk::parser< Type >::parse_conditional_statement_02().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ token_is_left_bracket()

bool exprtk::lexer::parser_helper::token_is_left_bracket ( const token_advance_mode mode = e_advance)
inline

Definition at line 4560 of file exprtk.hpp.

4561 {
4562 switch (current_token().type)
4563 {
4564 case token_t::e_lbracket :
4566 case token_t::e_lsqrbracket : break;
4567 default : return false;
4568 }
4569
4570 advance_token(mode);
4571
4572 return true;
4573 }

References advance_token(), current_token(), e_advance, exprtk::lexer::token::e_lbracket, exprtk::lexer::token::e_lcrlbracket, and exprtk::lexer::token::e_lsqrbracket.

Here is the call graph for this function:

◆ token_is_loop()

bool exprtk::lexer::parser_helper::token_is_loop ( const token_advance_mode mode = e_advance)
inline

Definition at line 4608 of file exprtk.hpp.

4609 {
4610 return token_is("for" , mode) ||
4611 token_is("while" , mode) ||
4612 token_is("repeat", mode) ;
4613 }
bool token_is(const token_t::token_type &ttype, const token_advance_mode mode=e_advance)
Definition exprtk.hpp:4482

References e_advance, and token_is().

Referenced by exprtk::parser< Type >::parse_conditional_statement_02().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ token_is_right_bracket()

bool exprtk::lexer::parser_helper::token_is_right_bracket ( const token_advance_mode mode = e_advance)
inline

Definition at line 4575 of file exprtk.hpp.

4576 {
4577 switch (current_token().type)
4578 {
4579 case token_t::e_rbracket :
4581 case token_t::e_rsqrbracket : break;
4582 default : return false;
4583 }
4584
4585 advance_token(mode);
4586
4587 return true;
4588 }

References advance_token(), current_token(), e_advance, exprtk::lexer::token::e_rbracket, exprtk::lexer::token::e_rcrlbracket, and exprtk::lexer::token::e_rsqrbracket.

Referenced by exprtk::parser< Type >::parse_conditional_statement_02().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ current_token_

token_t exprtk::lexer::parser_helper::current_token_
private

Definition at line 4628 of file exprtk.hpp.

Referenced by current_token(), next_token(), restore_token(), and store_token().

◆ lexer_

generator_t exprtk::lexer::parser_helper::lexer_
private

◆ store_current_token_

token_t exprtk::lexer::parser_helper::store_current_token_
private

Definition at line 4629 of file exprtk.hpp.

Referenced by restore_token(), and store_token().


The documentation for this class was generated from the following file: