- Exposed more primitives as static methods.
This commit is contained in:
Paul Beckingham 2014-11-04 22:51:25 -05:00
parent 4ec1f17557
commit 38359b779a
2 changed files with 45 additions and 45 deletions

View file

@ -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
{

View file

@ -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 <std::string>&, const std::string&);
static void token_split (std::vector <std::string>&, 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;