C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
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_t > token_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_t & next_token ()
token_t & peek_next_token ()
token_t & operator[] (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:3153
details::char_cptr s_itr_
Definition exprtk.hpp:3154
details::char_cptr s_end_
Definition exprtk.hpp:3155

References base_itr_, clear(), s_end_, and s_itr_.

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:3151
token_list_itr_t token_itr_
Definition exprtk.hpp:3150
token_list_t token_list_
Definition exprtk.hpp:3149

References store_token_itr_, token_itr_, and token_list_.

Referenced by exprtk::parser< Type >::compile(), 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< Type >::post_bracket_process(), and exprtk::parser< Type >::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 2729 of file exprtk.hpp.

2730 {
2731 return ((itr + 1) != s_end_) &&
2732 details::is_digit(*(itr + 1));
2733 }
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_.

◆ 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_.

◆ 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
2491 token_list_.clear();
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 }

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

Here is the call 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_.

◆ scan_number()

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

Definition at line 2895 of file exprtk.hpp.

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

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

2799 {
2800 token_t t;
2801
2802 const char_t c0 = s_itr_[0];
2803
2804 if (!is_end(s_itr_ + 1))
2805 {
2806 const char_t c1 = s_itr_[1];
2807
2808 if (!is_end(s_itr_ + 2))
2809 {
2810 const char_t c2 = s_itr_[2];
2811
2812 if ((c0 == '<') && (c1 == '=') && (c2 == '>'))
2813 {
2814 t.set_operator(token_t::e_swap, s_itr_, s_itr_ + 3, base_itr_);
2815 token_list_.push_back(t);
2816 s_itr_ += 3;
2817 return;
2818 }
2819 }
2820
2822
2823 if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte;
2824 else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte;
2825 else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne;
2826 else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne;
2827 else if ((c0 == '=') && (c1 == '=')) ttype = token_t::e_eq;
2828 else if ((c0 == ':') && (c1 == '=')) ttype = token_t::e_assign;
2829 else if ((c0 == '<') && (c1 == '<')) ttype = token_t::e_shl;
2830 else if ((c0 == '>') && (c1 == '>')) ttype = token_t::e_shr;
2831 else if ((c0 == '+') && (c1 == '=')) ttype = token_t::e_addass;
2832 else if ((c0 == '-') && (c1 == '=')) ttype = token_t::e_subass;
2833 else if ((c0 == '*') && (c1 == '=')) ttype = token_t::e_mulass;
2834 else if ((c0 == '/') && (c1 == '=')) ttype = token_t::e_divass;
2835 else if ((c0 == '%') && (c1 == '=')) ttype = token_t::e_modass;
2836
2837 if (token_t::e_none != ttype)
2838 {
2839 t.set_operator(ttype, s_itr_, s_itr_ + 2, base_itr_);
2840 token_list_.push_back(t);
2841 s_itr_ += 2;
2842 return;
2843 }
2844 }
2845
2846 if ('<' == c0)
2847 t.set_operator(token_t::e_lt , s_itr_, s_itr_ + 1, base_itr_);
2848 else if ('>' == c0)
2849 t.set_operator(token_t::e_gt , s_itr_, s_itr_ + 1, base_itr_);
2850 else if (';' == c0)
2851 t.set_operator(token_t::e_eof, s_itr_, s_itr_ + 1, base_itr_);
2852 else if ('&' == c0)
2853 t.set_symbol(s_itr_, s_itr_ + 1, base_itr_);
2854 else if ('|' == c0)
2855 t.set_symbol(s_itr_, s_itr_ + 1, base_itr_);
2856 else
2857 t.set_operator(token_t::token_type(c0), s_itr_, s_itr_ + 1, base_itr_);
2858
2859 token_list_.push_back(t);
2860 ++s_itr_;
2861 }

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

3003 {
3004 details::char_cptr initial_itr = s_itr_;
3005 token_t t;
3006
3007 // $fdd(x,x,x) = at least 11 chars
3008 if (std::distance(s_itr_,s_end_) < 11)
3009 {
3010 t.set_error(
3012 initial_itr, std::min(initial_itr + 11, s_end_),
3013 base_itr_);
3014 token_list_.push_back(t);
3015
3016 return;
3017 }
3018
3019 if (
3020 !(('$' == *s_itr_) &&
3021 (details::imatch ('f',*(s_itr_ + 1))) &&
3022 (details::is_digit(*(s_itr_ + 2))) &&
3023 (details::is_digit(*(s_itr_ + 3))))
3024 )
3025 {
3026 t.set_error(
3028 initial_itr, std::min(initial_itr + 4, s_end_),
3029 base_itr_);
3030 token_list_.push_back(t);
3031
3032 return;
3033 }
3034
3035 s_itr_ += 4; // $fdd = 4chars
3036
3037 t.set_symbol(initial_itr, s_itr_, base_itr_);
3038 token_list_.push_back(t);
3039
3040 return;
3041 }
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 3044 of file exprtk.hpp.

3045 {
3046 details::char_cptr initial_itr = s_itr_ + 1;
3047 token_t t;
3048
3049 if (std::distance(s_itr_,s_end_) < 2)
3050 {
3052 token_list_.push_back(t);
3053
3054 return;
3055 }
3056
3057 ++s_itr_;
3058
3059 bool escaped_found = false;
3060 bool escaped = false;
3061
3062 while (!is_end(s_itr_))
3063 {
3065 {
3066 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3067 token_list_.push_back(t);
3068
3069 return;
3070 }
3071 else if (!escaped && ('\\' == *s_itr_))
3072 {
3073 escaped_found = true;
3074 escaped = true;
3075 ++s_itr_;
3076
3077 continue;
3078 }
3079 else if (!escaped)
3080 {
3081 if ('\'' == *s_itr_)
3082 break;
3083 }
3084 else if (escaped)
3085 {
3086 if (
3087 !is_end(s_itr_) && ('0' == *(s_itr_)) &&
3088 ((s_itr_ + 4) <= s_end_)
3089 )
3090 {
3091 const bool x_separator = ('X' == std::toupper(*(s_itr_ + 1)));
3092
3093 const bool both_digits = details::is_hex_digit(*(s_itr_ + 2)) &&
3095
3096 if (!(x_separator && both_digits))
3097 {
3098 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3099 token_list_.push_back(t);
3100
3101 return;
3102 }
3103 else
3104 s_itr_ += 3;
3105 }
3106
3107 escaped = false;
3108 }
3109
3110 ++s_itr_;
3111 }
3112
3113 if (is_end(s_itr_))
3114 {
3115 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3116 token_list_.push_back(t);
3117
3118 return;
3119 }
3120
3121 if (!escaped_found)
3122 t.set_string(initial_itr, s_itr_, base_itr_);
3123 else
3124 {
3125 std::string parsed_string(initial_itr,s_itr_);
3126
3127 if (!details::cleanup_escapes(parsed_string))
3128 {
3129 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3130 token_list_.push_back(t);
3131
3132 return;
3133 }
3134
3135 t.set_string(
3136 parsed_string,
3137 static_cast<std::size_t>(std::distance(base_itr_,initial_itr)));
3138 }
3139
3140 token_list_.push_back(t);
3141 ++s_itr_;
3142
3143 return;
3144 }
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 2863 of file exprtk.hpp.

2864 {
2865 details::char_cptr initial_itr = s_itr_;
2866
2867 while (!is_end(s_itr_))
2868 {
2869 if (!details::is_letter_or_digit(*s_itr_) && ('_' != (*s_itr_)))
2870 {
2871 if ('.' != (*s_itr_))
2872 break;
2873 /*
2874 Permit symbols that contain a 'dot'
2875 Allowed : abc.xyz, a123.xyz, abc.123, abc_.xyz a123_.xyz abc._123
2876 Disallowed: .abc, abc.<white-space>, abc.<eof>, abc.<operator +,-,*,/...>
2877 */
2878 if (
2879 (s_itr_ != initial_itr) &&
2880 !is_end(s_itr_ + 1) &&
2882 ('_' != (*(s_itr_ + 1)))
2883 )
2884 break;
2885 }
2886
2887 ++s_itr_;
2888 }
2889
2890 token_t t;
2891 t.set_symbol(initial_itr, s_itr_, base_itr_);
2892 token_list_.push_back(t);
2893 }
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 2735 of file exprtk.hpp.

2736 {
2737 const char_t c = *s_itr_;
2738
2740 {
2742 return;
2743 }
2744 else if (is_comment_start(s_itr_))
2745 {
2746 skip_comments();
2747 return;
2748 }
2749 else if (details::is_operator_char(c))
2750 {
2751 scan_operator();
2752 return;
2753 }
2754 else if (details::is_letter(c))
2755 {
2756 scan_symbol();
2757 return;
2758 }
2759 else if (('.' == c) && !next_is_digit(s_itr_))
2760 {
2761 scan_operator();
2762 return;
2763 }
2764 else if (details::is_digit(c) || ('.' == c))
2765 {
2766 scan_number();
2767 return;
2768 }
2769 else if ('$' == c)
2770 {
2772 return;
2773 }
2774 #ifndef exprtk_disable_string_capabilities
2775 else if ('\'' == c)
2776 {
2777 scan_string();
2778 return;
2779 }
2780 #endif
2781 else if ('~' == c)
2782 {
2783 token_t t;
2784 t.set_symbol(s_itr_, s_itr_ + 1, base_itr_);
2785 token_list_.push_back(t);
2786 ++s_itr_;
2787 return;
2788 }
2789 else
2790 {
2791 token_t t;
2792 t.set_error(token::e_error, s_itr_, s_itr_ + 2, base_itr_);
2793 token_list_.push_back(t);
2794 ++s_itr_;
2795 }
2796 }
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:2729
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< Type >::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 {
2695 {
2696 token_t t;
2697 t.set_error(token::e_error, s_itr_, s_itr_ + 1, base_itr_);
2698 token_list_.push_back(t);
2699 return;
2700 }
2701
2702 if ((1 == mode) && test::comment_end(*s_itr_, 0, mode))
2703 {
2704 ++s_itr_;
2705 return;
2706 }
2707
2708 if ((2 == mode))
2709 {
2710 if (!is_end((s_itr_ + 1)) && test::comment_end(*s_itr_, *(s_itr_ + 1), mode))
2711 {
2712 s_itr_ += 2;
2713 return;
2714 }
2715 }
2716
2717 ++s_itr_;
2718 }
2719
2720 if (2 == mode)
2721 {
2722 token_t t;
2723 t.set_error(token::e_error, cmt_start, cmt_start + mode, base_itr_);
2724 token_list_.push_back(t);
2725 }
2726 #endif
2727 }
bool is_invalid(const char_t c)
Definition exprtk.hpp:162

References base_itr_, exprtk::lexer::token::e_error, is_end(), exprtk::details::is_invalid(), 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_.

◆ 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< Type >::construct_subexpr(), and exprtk::parser< Type >::parse_assert_statement().

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

◆ token_inserter

friend class token_inserter
friend

Definition at line 3159 of file exprtk.hpp.

References token_inserter.

Referenced by token_inserter.

◆ token_joiner

friend class token_joiner
friend

Definition at line 3160 of file exprtk.hpp.

References token_joiner.

Referenced by token_joiner.

◆ token_modifier

friend class token_modifier
friend

Definition at line 3158 of file exprtk.hpp.

References token_modifier.

Referenced by token_modifier.

◆ token_scanner

friend class token_scanner
friend

Definition at line 3157 of file exprtk.hpp.

References token_scanner.

Referenced by token_scanner.

Member Data Documentation

◆ base_itr_

◆ eof_token_

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

Definition at line 3152 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_

◆ store_token_itr_

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

Definition at line 3151 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_


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