diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 067c27818..2729c9415 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -615,6 +615,47 @@ bool Lexer::is_ws (int c) c == 0x3000); // ideographic space Common Separator, space } +//////////////////////////////////////////////////////////////////////////////// +bool Lexer::is_ident_start (int c) +{ + return c && // Include null character check. + ! is_ws (c) && + ! is_dec_digit (c) && + ! is_single_op (c); +} + +//////////////////////////////////////////////////////////////////////////////// +bool Lexer::is_ident (int c) +{ + return c && // Include null character check. + ! is_ws (c) && + ! is_single_op (c); +} + +//////////////////////////////////////////////////////////////////////////////// +bool Lexer::is_single_op (int c) +{ + return c == '+' || + c == '-' || + c == '*' || + c == '/' || + c == '(' || + c == ')' || + c == '<' || + c == '>' || + c == '^' || + c == '!' || + c == '%' || + c == '=' || + c == '~'; +} + +//////////////////////////////////////////////////////////////////////////////// +bool Lexer::is_dec_digit (int c) +{ + return c >= '0' && c <= '9'; +} + //////////////////////////////////////////////////////////////////////////////// bool Lexer::boundary (int left, int right) { @@ -747,23 +788,6 @@ bool Lexer::is_num (int c) const return false; } -//////////////////////////////////////////////////////////////////////////////// -bool Lexer::is_ident_start (int c) const -{ - return c && // Include null character check. - ! is_ws (c) && - ! is_dec_digit (c) && - ! is_single_op (c); -} - -//////////////////////////////////////////////////////////////////////////////// -bool Lexer::is_ident (int c) const -{ - return c && // Include null character check. - ! is_ws (c) && - ! is_single_op (c); -} - //////////////////////////////////////////////////////////////////////////////// bool Lexer::is_triple_op (int c0, int c1, int c2) const { @@ -785,30 +809,6 @@ bool Lexer::is_double_op (int c0, int c1, int c2) const (c0 == '!' && c1 == '~'); } -//////////////////////////////////////////////////////////////////////////////// -bool Lexer::is_single_op (int c) const -{ - return c == '+' || - c == '-' || - c == '*' || - c == '/' || - c == '(' || - c == ')' || - c == '<' || - c == '>' || - c == '^' || - c == '!' || - c == '%' || - c == '=' || - c == '~'; -} - -//////////////////////////////////////////////////////////////////////////////// -bool Lexer::is_dec_digit (int c) const -{ - return c >= '0' && c <= '9'; -} - //////////////////////////////////////////////////////////////////////////////// bool Lexer::is_hex_digit (int c) const { diff --git a/src/Lexer.h b/src/Lexer.h index b4ad05eab..a7ba74bc6 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -76,6 +76,10 @@ public: static const std::string type_name (const Type&); static bool is_ws (int); + static bool is_ident_start (int); + static bool is_ident (int); + static bool is_single_op (int); + static bool is_dec_digit (int); static bool boundary (int, int); static void word_split (std::vector &, const std::string&); static void token_split (std::vector &, const std::string&); @@ -86,12 +90,8 @@ private: bool is_duration (std::string&); bool is_punct (int) const; bool is_num (int) const; - bool is_ident_start (int) const; - bool is_ident (int) const; bool is_triple_op (int, int, int) const; bool is_double_op (int, int, int) const; - bool is_single_op (int) const; - bool is_dec_digit (int) const; bool is_hex_digit (int) const; int decode_escape (int) const; int hex_to_int (int) const;