C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
exprtk::lexer::generator Class Reference

#include <exprtk.hpp>

Collaboration diagram for exprtk::lexer::generator:
[legend]

Public Types

typedef token token_t
 
typedef std::vector< token_ttoken_list_t
 
typedef token_list_t::iterator token_list_itr_t
 
typedef details::char_t char_t
 

Public Member Functions

 generator ()
 
void clear ()
 
bool process (const std::string &str)
 
bool empty () const
 
std::size_t size () const
 
void begin ()
 
void store ()
 
void restore ()
 
token_tnext_token ()
 
token_tpeek_next_token ()
 
token_toperator[] (const std::size_t &index)
 
token_t operator[] (const std::size_t &index) const
 
bool finished () const
 
void insert_front (token_t::token_type tk_type)
 
std::string substr (const std::size_t &begin, const std::size_t &end) const
 
std::string remaining () const
 

Private Member Functions

bool is_end (details::char_cptr itr) const
 
bool is_comment_start (details::char_cptr itr) const
 
void skip_whitespace ()
 
void skip_comments ()
 
bool next_is_digit (const details::char_cptr itr) const
 
void scan_token ()
 
void scan_operator ()
 
void scan_symbol ()
 
void scan_number ()
 
void scan_special_function ()
 
void scan_string ()
 

Private Attributes

token_list_t token_list_
 
token_list_itr_t token_itr_
 
token_list_itr_t store_token_itr_
 
token_t eof_token_
 
details::char_cptr base_itr_
 
details::char_cptr s_itr_
 
details::char_cptr s_end_
 

Friends

class token_scanner
 
class token_modifier
 
class token_inserter
 
class token_joiner
 

Detailed Description

Definition at line 2457 of file exprtk.hpp.

Member Typedef Documentation

◆ char_t

Definition at line 2464 of file exprtk.hpp.

◆ token_list_itr_t

typedef token_list_t::iterator exprtk::lexer::generator::token_list_itr_t

Definition at line 2463 of file exprtk.hpp.

◆ token_list_t

Definition at line 2462 of file exprtk.hpp.

◆ token_t

Definition at line 2461 of file exprtk.hpp.

Constructor & Destructor Documentation

◆ generator()

exprtk::lexer::generator::generator ( )
inline

Definition at line 2466 of file exprtk.hpp.

2467 : base_itr_(0)
2468 , s_itr_ (0)
2469 , s_end_ (0)
2470 {
2471 clear();
2472 }
details::char_cptr base_itr_
Definition exprtk.hpp:3145
details::char_cptr s_itr_
Definition exprtk.hpp:3146
details::char_cptr s_end_
Definition exprtk.hpp:3147

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ begin()

void exprtk::lexer::generator::begin ( )
inline

Definition at line 2514 of file exprtk.hpp.

2515 {
2516 token_itr_ = token_list_.begin();
2517 store_token_itr_ = token_list_.begin();
2518 }
token_list_itr_t store_token_itr_
Definition exprtk.hpp:3143
token_list_itr_t token_itr_
Definition exprtk.hpp:3142
token_list_t token_list_
Definition exprtk.hpp:3141

References store_token_itr_, token_itr_, and token_list_.

Referenced by exprtk::parser< T >::compile(), exprtk::lexer::parser_helper::init(), and substr().

Here is the caller graph for this function:

◆ clear()

void exprtk::lexer::generator::clear ( )
inline

Definition at line 2474 of file exprtk.hpp.

2475 {
2476 base_itr_ = 0;
2477 s_itr_ = 0;
2478 s_end_ = 0;
2479 token_list_.clear();
2480 token_itr_ = token_list_.end();
2482 }

References base_itr_, s_end_, s_itr_, store_token_itr_, token_itr_, and token_list_.

Referenced by generator().

Here is the caller graph for this function:

◆ empty()

bool exprtk::lexer::generator::empty ( ) const
inline

Definition at line 2504 of file exprtk.hpp.

2505 {
2506 return token_list_.empty();
2507 }

References token_list_.

◆ finished()

bool exprtk::lexer::generator::finished ( ) const
inline

Definition at line 2570 of file exprtk.hpp.

2571 {
2572 return (token_list_.end() == token_itr_);
2573 }

References token_itr_, and token_list_.

Referenced by remaining().

Here is the caller graph for this function:

◆ insert_front()

void exprtk::lexer::generator::insert_front ( token_t::token_type  tk_type)
inline

Definition at line 2575 of file exprtk.hpp.

2576 {
2577 if (
2578 !token_list_.empty() &&
2579 (token_list_.end() != token_itr_)
2580 )
2581 {
2582 token_t t = *token_itr_;
2583
2584 t.type = tk_type;
2585 token_itr_ = token_list_.insert(token_itr_,t);
2586 }
2587 }

References token_itr_, token_list_, and exprtk::lexer::token::type.

Referenced by exprtk::parser< T >::post_bracket_process(), and exprtk::parser< T >::post_variable_process().

Here is the caller graph for this function:

◆ is_comment_start()

bool exprtk::lexer::generator::is_comment_start ( details::char_cptr  itr) const
inlineprivate

Definition at line 2615 of file exprtk.hpp.

2616 {
2617 const char_t c0 = *(itr + 0);
2618 const char_t c1 = *(itr + 1);
2619
2620 if ('#' == c0)
2621 return true;
2622 else if (!is_end(itr + 1))
2623 {
2624 if (('/' == c0) && ('/' == c1)) return true;
2625 if (('/' == c0) && ('*' == c1)) return true;
2626 }
2627 return false;
2628 }
details::char_t char_t
Definition exprtk.hpp:2464
bool is_end(details::char_cptr itr) const
Definition exprtk.hpp:2609

References is_end().

Referenced by scan_token().

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

◆ is_end()

bool exprtk::lexer::generator::is_end ( details::char_cptr  itr) const
inlineprivate

Definition at line 2609 of file exprtk.hpp.

2610 {
2611 return (s_end_ == itr);
2612 }

References s_end_.

Referenced by is_comment_start(), process(), scan_number(), scan_operator(), scan_string(), scan_symbol(), skip_comments(), and skip_whitespace().

Here is the caller graph for this function:

◆ next_is_digit()

bool exprtk::lexer::generator::next_is_digit ( const details::char_cptr  itr) const
inlineprivate

Definition at line 2721 of file exprtk.hpp.

2722 {
2723 return ((itr + 1) != s_end_) &&
2724 details::is_digit(*(itr + 1));
2725 }
bool is_digit(const char_t c)
Definition exprtk.hpp:132

References exprtk::details::is_digit(), and s_end_.

Referenced by scan_token().

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

◆ next_token()

token_t & exprtk::lexer::generator::next_token ( )
inline

Definition at line 2530 of file exprtk.hpp.

2531 {
2532 if (token_list_.end() != token_itr_)
2533 {
2534 return *token_itr_++;
2535 }
2536 else
2537 return eof_token_;
2538 }

References eof_token_, token_itr_, and token_list_.

Referenced by exprtk::lexer::parser_helper::next_token().

Here is the caller graph for this function:

◆ operator[]() [1/2]

token_t & exprtk::lexer::generator::operator[] ( const std::size_t &  index)
inline

Definition at line 2550 of file exprtk.hpp.

2551 {
2552 if (index < token_list_.size())
2553 {
2554 return token_list_[index];
2555 }
2556 else
2557 return eof_token_;
2558 }

References eof_token_, and token_list_.

◆ operator[]() [2/2]

token_t exprtk::lexer::generator::operator[] ( const std::size_t &  index) const
inline

Definition at line 2560 of file exprtk.hpp.

2561 {
2562 if (index < token_list_.size())
2563 {
2564 return token_list_[index];
2565 }
2566 else
2567 return eof_token_;
2568 }

References eof_token_, and token_list_.

◆ peek_next_token()

token_t & exprtk::lexer::generator::peek_next_token ( )
inline

Definition at line 2540 of file exprtk.hpp.

2541 {
2542 if (token_list_.end() != token_itr_)
2543 {
2544 return *token_itr_;
2545 }
2546 else
2547 return eof_token_;
2548 }

References eof_token_, token_itr_, and token_list_.

Referenced by exprtk::lexer::parser_helper::peek_next_token(), exprtk::lexer::parser_helper::peek_token_is(), and exprtk::lexer::parser_helper::peek_token_is().

Here is the caller graph for this function:

◆ process()

bool exprtk::lexer::generator::process ( const std::string &  str)
inline

Definition at line 2484 of file exprtk.hpp.

2485 {
2486 base_itr_ = str.data();
2487 s_itr_ = str.data();
2488 s_end_ = str.data() + str.size();
2489
2492
2493 while (!is_end(s_itr_))
2494 {
2495 scan_token();
2496
2497 if (!token_list_.empty() && token_list_.back().is_error())
2498 return false;
2499 }
2500
2501 return true;
2502 }
token & set_operator(const token_type tt, const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2306

References base_itr_, exprtk::lexer::token::clear(), exprtk::lexer::token::e_eof, eof_token_, is_end(), s_end_, s_itr_, scan_token(), exprtk::lexer::token::set_operator(), and token_list_.

Referenced by exprtk::lexer::parser_helper::init().

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

◆ remaining()

std::string exprtk::lexer::generator::remaining ( ) const
inline

Definition at line 2597 of file exprtk.hpp.

2598 {
2599 if (finished())
2600 return "";
2601 else if (token_list_.begin() != token_itr_)
2602 return std::string(base_itr_ + (token_itr_ - 1)->position, s_end_);
2603 else
2604 return std::string(base_itr_ + token_itr_->position, s_end_);
2605 }

References base_itr_, finished(), s_end_, token_itr_, and token_list_.

Here is the call graph for this function:

◆ restore()

void exprtk::lexer::generator::restore ( )
inline

Definition at line 2525 of file exprtk.hpp.

2526 {
2528 }

References store_token_itr_, and token_itr_.

Referenced by exprtk::lexer::parser_helper::restore_token().

Here is the caller graph for this function:

◆ scan_number()

void exprtk::lexer::generator::scan_number ( )
inlineprivate

Definition at line 2887 of file exprtk.hpp.

2888 {
2889 /*
2890 Attempt to match a valid numeric value in one of the following formats:
2891 (01) 123456
2892 (02) 123456.
2893 (03) 123.456
2894 (04) 123.456e3
2895 (05) 123.456E3
2896 (06) 123.456e+3
2897 (07) 123.456E+3
2898 (08) 123.456e-3
2899 (09) 123.456E-3
2900 (00) .1234
2901 (11) .1234e3
2902 (12) .1234E+3
2903 (13) .1234e+3
2904 (14) .1234E-3
2905 (15) .1234e-3
2906 */
2907
2908 details::char_cptr initial_itr = s_itr_;
2909 bool dot_found = false;
2910 bool e_found = false;
2911 bool post_e_sign_found = false;
2912 bool post_e_digit_found = false;
2913 token_t t;
2914
2915 while (!is_end(s_itr_))
2916 {
2917 if ('.' == (*s_itr_))
2918 {
2919 if (dot_found)
2920 {
2922 token_list_.push_back(t);
2923
2924 return;
2925 }
2926
2927 dot_found = true;
2928 ++s_itr_;
2929
2930 continue;
2931 }
2932 else if ('e' == std::tolower(*s_itr_))
2933 {
2934 const char_t& c = *(s_itr_ + 1);
2935
2936 if (is_end(s_itr_ + 1))
2937 {
2939 token_list_.push_back(t);
2940
2941 return;
2942 }
2943 else if (
2944 ('+' != c) &&
2945 ('-' != c) &&
2947 )
2948 {
2950 token_list_.push_back(t);
2951
2952 return;
2953 }
2954
2955 e_found = true;
2956 ++s_itr_;
2957
2958 continue;
2959 }
2960 else if (e_found && details::is_sign(*s_itr_) && !post_e_digit_found)
2961 {
2962 if (post_e_sign_found)
2963 {
2965 token_list_.push_back(t);
2966
2967 return;
2968 }
2969
2970 post_e_sign_found = true;
2971 ++s_itr_;
2972
2973 continue;
2974 }
2975 else if (e_found && details::is_digit(*s_itr_))
2976 {
2977 post_e_digit_found = true;
2978 ++s_itr_;
2979
2980 continue;
2981 }
2982 else if (('.' != (*s_itr_)) && !details::is_digit(*s_itr_))
2983 break;
2984 else
2985 ++s_itr_;
2986 }
2987
2988 t.set_numeric(initial_itr, s_itr_, base_itr_);
2989 token_list_.push_back(t);
2990
2991 return;
2992 }
bool is_sign(const char_t c)
Definition exprtk.hpp:157
char_t const * char_cptr
Definition exprtk.hpp:96
token & set_numeric(const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2328
token & set_error(const token_type et, const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2356

References base_itr_, exprtk::lexer::token::e_err_number, exprtk::details::is_digit(), is_end(), exprtk::details::is_sign(), s_itr_, exprtk::lexer::token::set_error(), exprtk::lexer::token::set_numeric(), and token_list_.

Referenced by scan_token().

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

◆ scan_operator()

void exprtk::lexer::generator::scan_operator ( )
inlineprivate

Definition at line 2790 of file exprtk.hpp.

2791 {
2792 token_t t;
2793
2794 const char_t c0 = s_itr_[0];
2795
2796 if (!is_end(s_itr_ + 1))
2797 {
2798 const char_t c1 = s_itr_[1];
2799
2800 if (!is_end(s_itr_ + 2))
2801 {
2802 const char_t c2 = s_itr_[2];
2803
2804 if ((c0 == '<') && (c1 == '=') && (c2 == '>'))
2805 {
2807 token_list_.push_back(t);
2808 s_itr_ += 3;
2809 return;
2810 }
2811 }
2812
2814
2815 if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte;
2816 else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte;
2817 else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne;
2818 else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne;
2819 else if ((c0 == '=') && (c1 == '=')) ttype = token_t::e_eq;
2820 else if ((c0 == ':') && (c1 == '=')) ttype = token_t::e_assign;
2821 else if ((c0 == '<') && (c1 == '<')) ttype = token_t::e_shl;
2822 else if ((c0 == '>') && (c1 == '>')) ttype = token_t::e_shr;
2823 else if ((c0 == '+') && (c1 == '=')) ttype = token_t::e_addass;
2824 else if ((c0 == '-') && (c1 == '=')) ttype = token_t::e_subass;
2825 else if ((c0 == '*') && (c1 == '=')) ttype = token_t::e_mulass;
2826 else if ((c0 == '/') && (c1 == '=')) ttype = token_t::e_divass;
2827 else if ((c0 == '%') && (c1 == '=')) ttype = token_t::e_modass;
2828
2829 if (token_t::e_none != ttype)
2830 {
2831 t.set_operator(ttype, s_itr_, s_itr_ + 2, base_itr_);
2832 token_list_.push_back(t);
2833 s_itr_ += 2;
2834 return;
2835 }
2836 }
2837
2838 if ('<' == c0)
2840 else if ('>' == c0)
2842 else if (';' == c0)
2844 else if ('&' == c0)
2846 else if ('|' == c0)
2848 else
2850
2851 token_list_.push_back(t);
2852 ++s_itr_;
2853 }
token & set_symbol(const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2318

References base_itr_, exprtk::lexer::token::e_addass, exprtk::lexer::token::e_assign, exprtk::lexer::token::e_divass, exprtk::lexer::token::e_eof, 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, exprtk::lexer::token::e_modass, exprtk::lexer::token::e_mulass, exprtk::lexer::token::e_ne, exprtk::lexer::token::e_none, exprtk::lexer::token::e_shl, exprtk::lexer::token::e_shr, exprtk::lexer::token::e_subass, exprtk::lexer::token::e_swap, is_end(), s_itr_, exprtk::lexer::token::set_operator(), exprtk::lexer::token::set_symbol(), and token_list_.

Referenced by scan_token().

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

◆ scan_special_function()

void exprtk::lexer::generator::scan_special_function ( )
inlineprivate

Definition at line 2994 of file exprtk.hpp.

2995 {
2996 details::char_cptr initial_itr = s_itr_;
2997 token_t t;
2998
2999 // $fdd(x,x,x) = at least 11 chars
3000 if (std::distance(s_itr_,s_end_) < 11)
3001 {
3002 t.set_error(
3004 initial_itr, std::min(initial_itr + 11, s_end_),
3005 base_itr_);
3006 token_list_.push_back(t);
3007
3008 return;
3009 }
3010
3011 if (
3012 !(('$' == *s_itr_) &&
3013 (details::imatch ('f',*(s_itr_ + 1))) &&
3014 (details::is_digit(*(s_itr_ + 2))) &&
3015 (details::is_digit(*(s_itr_ + 3))))
3016 )
3017 {
3018 t.set_error(
3020 initial_itr, std::min(initial_itr + 4, s_end_),
3021 base_itr_);
3022 token_list_.push_back(t);
3023
3024 return;
3025 }
3026
3027 s_itr_ += 4; // $fdd = 4chars
3028
3029 t.set_symbol(initial_itr, s_itr_, base_itr_);
3030 token_list_.push_back(t);
3031
3032 return;
3033 }
bool imatch(const char_t c1, const char_t c2)
Definition exprtk.hpp:190

References base_itr_, exprtk::lexer::token::e_err_sfunc, exprtk::details::imatch(), exprtk::details::is_digit(), s_end_, s_itr_, exprtk::lexer::token::set_error(), exprtk::lexer::token::set_symbol(), and token_list_.

Referenced by scan_token().

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

◆ scan_string()

void exprtk::lexer::generator::scan_string ( )
inlineprivate

Definition at line 3036 of file exprtk.hpp.

3037 {
3038 details::char_cptr initial_itr = s_itr_ + 1;
3039 token_t t;
3040
3041 if (std::distance(s_itr_,s_end_) < 2)
3042 {
3044 token_list_.push_back(t);
3045
3046 return;
3047 }
3048
3049 ++s_itr_;
3050
3051 bool escaped_found = false;
3052 bool escaped = false;
3053
3054 while (!is_end(s_itr_))
3055 {
3057 {
3059 token_list_.push_back(t);
3060
3061 return;
3062 }
3063 else if (!escaped && ('\\' == *s_itr_))
3064 {
3065 escaped_found = true;
3066 escaped = true;
3067 ++s_itr_;
3068
3069 continue;
3070 }
3071 else if (!escaped)
3072 {
3073 if ('\'' == *s_itr_)
3074 break;
3075 }
3076 else if (escaped)
3077 {
3078 if (
3079 !is_end(s_itr_) && ('0' == *(s_itr_)) &&
3080 ((s_itr_ + 4) <= s_end_)
3081 )
3082 {
3083 const bool x_separator = ('X' == std::toupper(*(s_itr_ + 1)));
3084
3085 const bool both_digits = details::is_hex_digit(*(s_itr_ + 2)) &&
3087
3088 if (!(x_separator && both_digits))
3089 {
3090 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3091 token_list_.push_back(t);
3092
3093 return;
3094 }
3095 else
3096 s_itr_ += 3;
3097 }
3098
3099 escaped = false;
3100 }
3101
3102 ++s_itr_;
3103 }
3104
3105 if (is_end(s_itr_))
3106 {
3107 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3108 token_list_.push_back(t);
3109
3110 return;
3111 }
3112
3113 if (!escaped_found)
3114 t.set_string(initial_itr, s_itr_, base_itr_);
3115 else
3116 {
3117 std::string parsed_string(initial_itr,s_itr_);
3118
3119 if (!details::cleanup_escapes(parsed_string))
3120 {
3121 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3122 token_list_.push_back(t);
3123
3124 return;
3125 }
3126
3127 t.set_string(
3128 parsed_string,
3129 static_cast<std::size_t>(std::distance(base_itr_,initial_itr)));
3130 }
3131
3132 token_list_.push_back(t);
3133 ++s_itr_;
3134
3135 return;
3136 }
bool is_hex_digit(const uchar_t digit)
Definition exprtk.hpp:312
bool is_valid_string_char(const char_t c)
Definition exprtk.hpp:175
bool cleanup_escapes(std::string &s)
Definition exprtk.hpp:352

References base_itr_, exprtk::details::cleanup_escapes(), exprtk::lexer::token::e_err_string, is_end(), exprtk::details::is_hex_digit(), exprtk::details::is_valid_string_char(), s_end_, s_itr_, exprtk::lexer::token::set_error(), exprtk::lexer::token::set_string(), and token_list_.

Referenced by scan_token().

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

◆ scan_symbol()

void exprtk::lexer::generator::scan_symbol ( )
inlineprivate

Definition at line 2855 of file exprtk.hpp.

2856 {
2857 details::char_cptr initial_itr = s_itr_;
2858
2859 while (!is_end(s_itr_))
2860 {
2861 if (!details::is_letter_or_digit(*s_itr_) && ('_' != (*s_itr_)))
2862 {
2863 if ('.' != (*s_itr_))
2864 break;
2865 /*
2866 Permit symbols that contain a 'dot'
2867 Allowed : abc.xyz, a123.xyz, abc.123, abc_.xyz a123_.xyz abc._123
2868 Disallowed: .abc, abc.<white-space>, abc.<eof>, abc.<operator +,-,*,/...>
2869 */
2870 if (
2871 (s_itr_ != initial_itr) &&
2872 !is_end(s_itr_ + 1) &&
2874 ('_' != (*(s_itr_ + 1)))
2875 )
2876 break;
2877 }
2878
2879 ++s_itr_;
2880 }
2881
2882 token_t t;
2883 t.set_symbol(initial_itr, s_itr_, base_itr_);
2884 token_list_.push_back(t);
2885 }
bool is_letter_or_digit(const char_t c)
Definition exprtk.hpp:137

References base_itr_, is_end(), exprtk::details::is_letter_or_digit(), s_itr_, exprtk::lexer::token::set_symbol(), and token_list_.

Referenced by scan_token().

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

◆ scan_token()

void exprtk::lexer::generator::scan_token ( )
inlineprivate

Definition at line 2727 of file exprtk.hpp.

2728 {
2729 const char_t c = *s_itr_;
2730
2732 {
2734 return;
2735 }
2736 else if (is_comment_start(s_itr_))
2737 {
2738 skip_comments();
2739 return;
2740 }
2741 else if (details::is_operator_char(c))
2742 {
2743 scan_operator();
2744 return;
2745 }
2746 else if (details::is_letter(c))
2747 {
2748 scan_symbol();
2749 return;
2750 }
2751 else if (('.' == c) && !next_is_digit(s_itr_))
2752 {
2753 scan_operator();
2754 return;
2755 }
2756 else if (details::is_digit(c) || ('.' == c))
2757 {
2758 scan_number();
2759 return;
2760 }
2761 else if ('$' == c)
2762 {
2764 return;
2765 }
2766 #ifndef exprtk_disable_string_capabilities
2767 else if ('\'' == c)
2768 {
2769 scan_string();
2770 return;
2771 }
2772 #endif
2773 else if ('~' == c)
2774 {
2775 token_t t;
2777 token_list_.push_back(t);
2778 ++s_itr_;
2779 return;
2780 }
2781 else
2782 {
2783 token_t t;
2785 token_list_.push_back(t);
2786 ++s_itr_;
2787 }
2788 }
bool is_comment_start(details::char_cptr itr) const
Definition exprtk.hpp:2615
bool next_is_digit(const details::char_cptr itr) const
Definition exprtk.hpp:2721
bool is_whitespace(const char_t c)
Definition exprtk.hpp:103
bool is_operator_char(const char_t c)
Definition exprtk.hpp:111
bool is_letter(const char_t c)
Definition exprtk.hpp:126

References base_itr_, exprtk::lexer::token::e_error, is_comment_start(), exprtk::details::is_digit(), exprtk::details::is_letter(), exprtk::details::is_operator_char(), exprtk::details::is_whitespace(), next_is_digit(), s_itr_, scan_number(), scan_operator(), scan_special_function(), scan_string(), scan_symbol(), exprtk::lexer::token::set_error(), exprtk::lexer::token::set_symbol(), skip_comments(), skip_whitespace(), and token_list_.

Referenced by process().

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

◆ size()

std::size_t exprtk::lexer::generator::size ( ) const
inline

Definition at line 2509 of file exprtk.hpp.

2510 {
2511 return token_list_.size();
2512 }

References token_list_.

Referenced by exprtk::lexer::helper::dump(), and exprtk::parser< T >::process_lexer_errors().

Here is the caller graph for this function:

◆ skip_comments()

void exprtk::lexer::generator::skip_comments ( )
inlineprivate

Definition at line 2644 of file exprtk.hpp.

2645 {
2646 #ifndef exprtk_disable_comments
2647 // The following comment styles are supported:
2648 // 1. // .... \n
2649 // 2. # .... \n
2650 // 3. /* .... */
2651 struct test
2652 {
2653 static inline bool comment_start(const char_t c0, const char_t c1, int& mode, int& incr)
2654 {
2655 mode = 0;
2656 if ('#' == c0) { mode = 1; incr = 1; }
2657 else if ('/' == c0)
2658 {
2659 if ('/' == c1) { mode = 1; incr = 2; }
2660 else if ('*' == c1) { mode = 2; incr = 2; }
2661 }
2662 return (0 != mode);
2663 }
2664
2665 static inline bool comment_end(const char_t c0, const char_t c1, int& mode)
2666 {
2667 if (
2668 ((1 == mode) && ('\n' == c0)) ||
2669 ((2 == mode) && ( '*' == c0) && ('/' == c1))
2670 )
2671 {
2672 mode = 0;
2673 return true;
2674 }
2675 else
2676 return false;
2677 }
2678 };
2679
2680 int mode = 0;
2681 int increment = 0;
2682
2683 if (is_end(s_itr_))
2684 return;
2685 else if (!test::comment_start(*s_itr_, *(s_itr_ + 1), mode, increment))
2686 return;
2687
2688 details::char_cptr cmt_start = s_itr_;
2689
2690 s_itr_ += increment;
2691
2692 while (!is_end(s_itr_))
2693 {
2694 if ((1 == mode) && test::comment_end(*s_itr_, 0, mode))
2695 {
2696 ++s_itr_;
2697 return;
2698 }
2699
2700 if ((2 == mode))
2701 {
2702 if (!is_end((s_itr_ + 1)) && test::comment_end(*s_itr_, *(s_itr_ + 1), mode))
2703 {
2704 s_itr_ += 2;
2705 return;
2706 }
2707 }
2708
2709 ++s_itr_;
2710 }
2711
2712 if (2 == mode)
2713 {
2714 token_t t;
2715 t.set_error(token::e_error, cmt_start, cmt_start + mode, base_itr_);
2716 token_list_.push_back(t);
2717 }
2718 #endif
2719 }

References base_itr_, exprtk::lexer::token::e_error, is_end(), s_itr_, exprtk::lexer::token::set_error(), and token_list_.

Referenced by scan_token().

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

◆ skip_whitespace()

void exprtk::lexer::generator::skip_whitespace ( )
inlineprivate

Definition at line 2636 of file exprtk.hpp.

2637 {
2639 {
2640 ++s_itr_;
2641 }
2642 }

References is_end(), exprtk::details::is_whitespace(), and s_itr_.

Referenced by scan_token().

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

◆ store()

void exprtk::lexer::generator::store ( )
inline

Definition at line 2520 of file exprtk.hpp.

2521 {
2523 }

References store_token_itr_, and token_itr_.

Referenced by exprtk::lexer::parser_helper::store_token().

Here is the caller graph for this function:

◆ substr()

std::string exprtk::lexer::generator::substr ( const std::size_t &  begin,
const std::size_t &  end 
) const
inline

Definition at line 2589 of file exprtk.hpp.

2590 {
2591 const details::char_cptr begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_;
2592 const details::char_cptr end_itr = ((base_itr_ + end ) < s_end_) ? (base_itr_ + end ) : s_end_;
2593
2594 return std::string(begin_itr,end_itr);
2595 }

References base_itr_, begin(), and s_end_.

Referenced by exprtk::parser< T >::construct_subexpr(), and exprtk::parser< T >::parse_assert_statement().

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

Friends And Related Symbol Documentation

◆ token_inserter

friend class token_inserter
friend

Definition at line 3151 of file exprtk.hpp.

◆ token_joiner

friend class token_joiner
friend

Definition at line 3152 of file exprtk.hpp.

◆ token_modifier

friend class token_modifier
friend

Definition at line 3150 of file exprtk.hpp.

◆ token_scanner

friend class token_scanner
friend

Definition at line 3149 of file exprtk.hpp.

Member Data Documentation

◆ base_itr_

details::char_cptr exprtk::lexer::generator::base_itr_
private

◆ eof_token_

token_t exprtk::lexer::generator::eof_token_
private

Definition at line 3144 of file exprtk.hpp.

Referenced by next_token(), operator[](), operator[](), peek_next_token(), and process().

◆ s_end_

details::char_cptr exprtk::lexer::generator::s_end_
private

◆ s_itr_

details::char_cptr exprtk::lexer::generator::s_itr_
private

◆ store_token_itr_

token_list_itr_t exprtk::lexer::generator::store_token_itr_
private

Definition at line 3143 of file exprtk.hpp.

Referenced by begin(), clear(), restore(), and store().

◆ token_itr_

token_list_itr_t exprtk::lexer::generator::token_itr_
private

◆ token_list_

token_list_t exprtk::lexer::generator::token_list_
private

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