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

Member Typedef Documentation

◆ char_t

Definition at line 2410 of file exprtk.hpp.

◆ token_list_itr_t

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

Definition at line 2409 of file exprtk.hpp.

◆ token_list_t

Definition at line 2408 of file exprtk.hpp.

◆ token_t

Definition at line 2407 of file exprtk.hpp.

Constructor & Destructor Documentation

◆ generator()

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

Definition at line 2412 of file exprtk.hpp.

2413 : base_itr_(0)
2414 , s_itr_ (0)
2415 , s_end_ (0)
2416 {
2417 clear();
2418 }
details::char_cptr base_itr_
Definition exprtk.hpp:3091
details::char_cptr s_itr_
Definition exprtk.hpp:3092
details::char_cptr s_end_
Definition exprtk.hpp:3093

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ begin()

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

Definition at line 2460 of file exprtk.hpp.

2461 {
2462 token_itr_ = token_list_.begin();
2463 store_token_itr_ = token_list_.begin();
2464 }
token_list_itr_t store_token_itr_
Definition exprtk.hpp:3089
token_list_itr_t token_itr_
Definition exprtk.hpp:3088
token_list_t token_list_
Definition exprtk.hpp:3087

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

2421 {
2422 base_itr_ = 0;
2423 s_itr_ = 0;
2424 s_end_ = 0;
2425 token_list_.clear();
2426 token_itr_ = token_list_.end();
2428 }

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

2451 {
2452 return token_list_.empty();
2453 }

References token_list_.

◆ finished()

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

Definition at line 2516 of file exprtk.hpp.

2517 {
2518 return (token_list_.end() == token_itr_);
2519 }

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

2522 {
2523 if (
2524 !token_list_.empty() &&
2525 (token_list_.end() != token_itr_)
2526 )
2527 {
2528 token_t t = *token_itr_;
2529
2530 t.type = tk_type;
2531 token_itr_ = token_list_.insert(token_itr_,t);
2532 }
2533 }

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

2562 {
2563 const char_t c0 = *(itr + 0);
2564 const char_t c1 = *(itr + 1);
2565
2566 if ('#' == c0)
2567 return true;
2568 else if (!is_end(itr + 1))
2569 {
2570 if (('/' == c0) && ('/' == c1)) return true;
2571 if (('/' == c0) && ('*' == c1)) return true;
2572 }
2573 return false;
2574 }
details::char_t char_t
Definition exprtk.hpp:2410
bool is_end(details::char_cptr itr) const
Definition exprtk.hpp:2555

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

2556 {
2557 return (s_end_ == itr);
2558 }

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

2668 {
2669 return ((itr + 1) != s_end_) &&
2670 details::is_digit(*(itr + 1));
2671 }
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 2476 of file exprtk.hpp.

2477 {
2478 if (token_list_.end() != token_itr_)
2479 {
2480 return *token_itr_++;
2481 }
2482 else
2483 return eof_token_;
2484 }

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

2497 {
2498 if (index < token_list_.size())
2499 {
2500 return token_list_[index];
2501 }
2502 else
2503 return eof_token_;
2504 }

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

2507 {
2508 if (index < token_list_.size())
2509 {
2510 return token_list_[index];
2511 }
2512 else
2513 return eof_token_;
2514 }

References eof_token_, and token_list_.

◆ peek_next_token()

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

Definition at line 2486 of file exprtk.hpp.

2487 {
2488 if (token_list_.end() != token_itr_)
2489 {
2490 return *token_itr_;
2491 }
2492 else
2493 return eof_token_;
2494 }

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

2431 {
2432 base_itr_ = str.data();
2433 s_itr_ = str.data();
2434 s_end_ = str.data() + str.size();
2435
2438
2439 while (!is_end(s_itr_))
2440 {
2441 scan_token();
2442
2443 if (!token_list_.empty() && token_list_.back().is_error())
2444 return false;
2445 }
2446
2447 return true;
2448 }
token & set_operator(const token_type tt, const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2265

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

2544 {
2545 if (finished())
2546 return "";
2547 else if (token_list_.begin() != token_itr_)
2548 return std::string(base_itr_ + (token_itr_ - 1)->position, s_end_);
2549 else
2550 return std::string(base_itr_ + token_itr_->position, s_end_);
2551 }

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

2472 {
2474 }

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

2834 {
2835 /*
2836 Attempt to match a valid numeric value in one of the following formats:
2837 (01) 123456
2838 (02) 123456.
2839 (03) 123.456
2840 (04) 123.456e3
2841 (05) 123.456E3
2842 (06) 123.456e+3
2843 (07) 123.456E+3
2844 (08) 123.456e-3
2845 (09) 123.456E-3
2846 (00) .1234
2847 (11) .1234e3
2848 (12) .1234E+3
2849 (13) .1234e+3
2850 (14) .1234E-3
2851 (15) .1234e-3
2852 */
2853
2854 details::char_cptr initial_itr = s_itr_;
2855 bool dot_found = false;
2856 bool e_found = false;
2857 bool post_e_sign_found = false;
2858 bool post_e_digit_found = false;
2859 token_t t;
2860
2861 while (!is_end(s_itr_))
2862 {
2863 if ('.' == (*s_itr_))
2864 {
2865 if (dot_found)
2866 {
2868 token_list_.push_back(t);
2869
2870 return;
2871 }
2872
2873 dot_found = true;
2874 ++s_itr_;
2875
2876 continue;
2877 }
2878 else if ('e' == std::tolower(*s_itr_))
2879 {
2880 const char_t& c = *(s_itr_ + 1);
2881
2882 if (is_end(s_itr_ + 1))
2883 {
2885 token_list_.push_back(t);
2886
2887 return;
2888 }
2889 else if (
2890 ('+' != c) &&
2891 ('-' != c) &&
2893 )
2894 {
2896 token_list_.push_back(t);
2897
2898 return;
2899 }
2900
2901 e_found = true;
2902 ++s_itr_;
2903
2904 continue;
2905 }
2906 else if (e_found && details::is_sign(*s_itr_) && !post_e_digit_found)
2907 {
2908 if (post_e_sign_found)
2909 {
2911 token_list_.push_back(t);
2912
2913 return;
2914 }
2915
2916 post_e_sign_found = true;
2917 ++s_itr_;
2918
2919 continue;
2920 }
2921 else if (e_found && details::is_digit(*s_itr_))
2922 {
2923 post_e_digit_found = true;
2924 ++s_itr_;
2925
2926 continue;
2927 }
2928 else if (('.' != (*s_itr_)) && !details::is_digit(*s_itr_))
2929 break;
2930 else
2931 ++s_itr_;
2932 }
2933
2934 t.set_numeric(initial_itr, s_itr_, base_itr_);
2935 token_list_.push_back(t);
2936
2937 return;
2938 }
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:2287
token & set_error(const token_type et, const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2315

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

2737 {
2738 token_t t;
2739
2740 const char_t c0 = s_itr_[0];
2741
2742 if (!is_end(s_itr_ + 1))
2743 {
2744 const char_t c1 = s_itr_[1];
2745
2746 if (!is_end(s_itr_ + 2))
2747 {
2748 const char_t c2 = s_itr_[2];
2749
2750 if ((c0 == '<') && (c1 == '=') && (c2 == '>'))
2751 {
2753 token_list_.push_back(t);
2754 s_itr_ += 3;
2755 return;
2756 }
2757 }
2758
2760
2761 if ((c0 == '<') && (c1 == '=')) ttype = token_t::e_lte;
2762 else if ((c0 == '>') && (c1 == '=')) ttype = token_t::e_gte;
2763 else if ((c0 == '<') && (c1 == '>')) ttype = token_t::e_ne;
2764 else if ((c0 == '!') && (c1 == '=')) ttype = token_t::e_ne;
2765 else if ((c0 == '=') && (c1 == '=')) ttype = token_t::e_eq;
2766 else if ((c0 == ':') && (c1 == '=')) ttype = token_t::e_assign;
2767 else if ((c0 == '<') && (c1 == '<')) ttype = token_t::e_shl;
2768 else if ((c0 == '>') && (c1 == '>')) ttype = token_t::e_shr;
2769 else if ((c0 == '+') && (c1 == '=')) ttype = token_t::e_addass;
2770 else if ((c0 == '-') && (c1 == '=')) ttype = token_t::e_subass;
2771 else if ((c0 == '*') && (c1 == '=')) ttype = token_t::e_mulass;
2772 else if ((c0 == '/') && (c1 == '=')) ttype = token_t::e_divass;
2773 else if ((c0 == '%') && (c1 == '=')) ttype = token_t::e_modass;
2774
2775 if (token_t::e_none != ttype)
2776 {
2777 t.set_operator(ttype, s_itr_, s_itr_ + 2, base_itr_);
2778 token_list_.push_back(t);
2779 s_itr_ += 2;
2780 return;
2781 }
2782 }
2783
2784 if ('<' == c0)
2786 else if ('>' == c0)
2788 else if (';' == c0)
2790 else if ('&' == c0)
2792 else if ('|' == c0)
2794 else
2796
2797 token_list_.push_back(t);
2798 ++s_itr_;
2799 }
token & set_symbol(const Iterator begin, const Iterator end, const Iterator base_begin=Iterator(0))
Definition exprtk.hpp:2277

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

2941 {
2942 details::char_cptr initial_itr = s_itr_;
2943 token_t t;
2944
2945 // $fdd(x,x,x) = at least 11 chars
2946 if (std::distance(s_itr_,s_end_) < 11)
2947 {
2948 t.set_error(
2950 initial_itr, std::min(initial_itr + 11, s_end_),
2951 base_itr_);
2952 token_list_.push_back(t);
2953
2954 return;
2955 }
2956
2957 if (
2958 !(('$' == *s_itr_) &&
2959 (details::imatch ('f',*(s_itr_ + 1))) &&
2960 (details::is_digit(*(s_itr_ + 2))) &&
2961 (details::is_digit(*(s_itr_ + 3))))
2962 )
2963 {
2964 t.set_error(
2966 initial_itr, std::min(initial_itr + 4, s_end_),
2967 base_itr_);
2968 token_list_.push_back(t);
2969
2970 return;
2971 }
2972
2973 s_itr_ += 4; // $fdd = 4chars
2974
2975 t.set_symbol(initial_itr, s_itr_, base_itr_);
2976 token_list_.push_back(t);
2977
2978 return;
2979 }
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 2982 of file exprtk.hpp.

2983 {
2984 details::char_cptr initial_itr = s_itr_ + 1;
2985 token_t t;
2986
2987 if (std::distance(s_itr_,s_end_) < 2)
2988 {
2990 token_list_.push_back(t);
2991
2992 return;
2993 }
2994
2995 ++s_itr_;
2996
2997 bool escaped_found = false;
2998 bool escaped = false;
2999
3000 while (!is_end(s_itr_))
3001 {
3003 {
3005 token_list_.push_back(t);
3006
3007 return;
3008 }
3009 else if (!escaped && ('\\' == *s_itr_))
3010 {
3011 escaped_found = true;
3012 escaped = true;
3013 ++s_itr_;
3014
3015 continue;
3016 }
3017 else if (!escaped)
3018 {
3019 if ('\'' == *s_itr_)
3020 break;
3021 }
3022 else if (escaped)
3023 {
3024 if (
3025 !is_end(s_itr_) && ('0' == *(s_itr_)) &&
3026 ((s_itr_ + 4) <= s_end_)
3027 )
3028 {
3029 const bool x_separator = ('X' == std::toupper(*(s_itr_ + 1)));
3030
3031 const bool both_digits = details::is_hex_digit(*(s_itr_ + 2)) &&
3033
3034 if (!(x_separator && both_digits))
3035 {
3036 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3037 token_list_.push_back(t);
3038
3039 return;
3040 }
3041 else
3042 s_itr_ += 3;
3043 }
3044
3045 escaped = false;
3046 }
3047
3048 ++s_itr_;
3049 }
3050
3051 if (is_end(s_itr_))
3052 {
3053 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3054 token_list_.push_back(t);
3055
3056 return;
3057 }
3058
3059 if (!escaped_found)
3060 t.set_string(initial_itr, s_itr_, base_itr_);
3061 else
3062 {
3063 std::string parsed_string(initial_itr,s_itr_);
3064
3065 if (!details::cleanup_escapes(parsed_string))
3066 {
3067 t.set_error(token::e_err_string, initial_itr, s_itr_, base_itr_);
3068 token_list_.push_back(t);
3069
3070 return;
3071 }
3072
3073 t.set_string(
3074 parsed_string,
3075 static_cast<std::size_t>(std::distance(base_itr_,initial_itr)));
3076 }
3077
3078 token_list_.push_back(t);
3079 ++s_itr_;
3080
3081 return;
3082 }
bool is_hex_digit(const uchar_t digit)
Definition exprtk.hpp:306
bool is_valid_string_char(const char_t c)
Definition exprtk.hpp:175
bool cleanup_escapes(std::string &s)
Definition exprtk.hpp:345

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

2802 {
2803 details::char_cptr initial_itr = s_itr_;
2804
2805 while (!is_end(s_itr_))
2806 {
2807 if (!details::is_letter_or_digit(*s_itr_) && ('_' != (*s_itr_)))
2808 {
2809 if ('.' != (*s_itr_))
2810 break;
2811 /*
2812 Permit symbols that contain a 'dot'
2813 Allowed : abc.xyz, a123.xyz, abc.123, abc_.xyz a123_.xyz abc._123
2814 Disallowed: .abc, abc.<white-space>, abc.<eof>, abc.<operator +,-,*,/...>
2815 */
2816 if (
2817 (s_itr_ != initial_itr) &&
2818 !is_end(s_itr_ + 1) &&
2820 ('_' != (*(s_itr_ + 1)))
2821 )
2822 break;
2823 }
2824
2825 ++s_itr_;
2826 }
2827
2828 token_t t;
2829 t.set_symbol(initial_itr, s_itr_, base_itr_);
2830 token_list_.push_back(t);
2831 }
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 2673 of file exprtk.hpp.

2674 {
2675 const char_t c = *s_itr_;
2676
2678 {
2680 return;
2681 }
2682 else if (is_comment_start(s_itr_))
2683 {
2684 skip_comments();
2685 return;
2686 }
2687 else if (details::is_operator_char(c))
2688 {
2689 scan_operator();
2690 return;
2691 }
2692 else if (details::is_letter(c))
2693 {
2694 scan_symbol();
2695 return;
2696 }
2697 else if (('.' == c) && !next_is_digit(s_itr_))
2698 {
2699 scan_operator();
2700 return;
2701 }
2702 else if (details::is_digit(c) || ('.' == c))
2703 {
2704 scan_number();
2705 return;
2706 }
2707 else if ('$' == c)
2708 {
2710 return;
2711 }
2712 #ifndef exprtk_disable_string_capabilities
2713 else if ('\'' == c)
2714 {
2715 scan_string();
2716 return;
2717 }
2718 #endif
2719 else if ('~' == c)
2720 {
2721 token_t t;
2723 token_list_.push_back(t);
2724 ++s_itr_;
2725 return;
2726 }
2727 else
2728 {
2729 token_t t;
2731 token_list_.push_back(t);
2732 ++s_itr_;
2733 }
2734 }
bool is_comment_start(details::char_cptr itr) const
Definition exprtk.hpp:2561
bool next_is_digit(const details::char_cptr itr) const
Definition exprtk.hpp:2667
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 2455 of file exprtk.hpp.

2456 {
2457 return token_list_.size();
2458 }

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

2591 {
2592 #ifndef exprtk_disable_comments
2593 // The following comment styles are supported:
2594 // 1. // .... \n
2595 // 2. # .... \n
2596 // 3. /* .... */
2597 struct test
2598 {
2599 static inline bool comment_start(const char_t c0, const char_t c1, int& mode, int& incr)
2600 {
2601 mode = 0;
2602 if ('#' == c0) { mode = 1; incr = 1; }
2603 else if ('/' == c0)
2604 {
2605 if ('/' == c1) { mode = 1; incr = 2; }
2606 else if ('*' == c1) { mode = 2; incr = 2; }
2607 }
2608 return (0 != mode);
2609 }
2610
2611 static inline bool comment_end(const char_t c0, const char_t c1, int& mode)
2612 {
2613 if (
2614 ((1 == mode) && ('\n' == c0)) ||
2615 ((2 == mode) && ( '*' == c0) && ('/' == c1))
2616 )
2617 {
2618 mode = 0;
2619 return true;
2620 }
2621 else
2622 return false;
2623 }
2624 };
2625
2626 int mode = 0;
2627 int increment = 0;
2628
2629 if (is_end(s_itr_))
2630 return;
2631 else if (!test::comment_start(*s_itr_, *(s_itr_ + 1), mode, increment))
2632 return;
2633
2634 details::char_cptr cmt_start = s_itr_;
2635
2636 s_itr_ += increment;
2637
2638 while (!is_end(s_itr_))
2639 {
2640 if ((1 == mode) && test::comment_end(*s_itr_, 0, mode))
2641 {
2642 ++s_itr_;
2643 return;
2644 }
2645
2646 if ((2 == mode))
2647 {
2648 if (!is_end((s_itr_ + 1)) && test::comment_end(*s_itr_, *(s_itr_ + 1), mode))
2649 {
2650 s_itr_ += 2;
2651 return;
2652 }
2653 }
2654
2655 ++s_itr_;
2656 }
2657
2658 if (2 == mode)
2659 {
2660 token_t t;
2661 t.set_error(token::e_error, cmt_start, cmt_start + mode, base_itr_);
2662 token_list_.push_back(t);
2663 }
2664 #endif
2665 }

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

2583 {
2585 {
2586 ++s_itr_;
2587 }
2588 }

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

2467 {
2469 }

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

2536 {
2537 const details::char_cptr begin_itr = ((base_itr_ + begin) < s_end_) ? (base_itr_ + begin) : s_end_;
2538 const details::char_cptr end_itr = ((base_itr_ + end ) < s_end_) ? (base_itr_ + end ) : s_end_;
2539
2540 return std::string(begin_itr,end_itr);
2541 }

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

◆ token_joiner

friend class token_joiner
friend

Definition at line 3098 of file exprtk.hpp.

◆ token_modifier

friend class token_modifier
friend

Definition at line 3096 of file exprtk.hpp.

◆ token_scanner

friend class token_scanner
friend

Definition at line 3095 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 3090 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 3089 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: