- When parsing two-character operators ('or') from a string ('ordinary'), the
  lack of boundary between the 'r' and the 'd' now prevents the operator 'or'
  from being recognized.
This commit is contained in:
Paul Beckingham 2014-07-03 16:26:17 -04:00
parent b6fee35213
commit 9778100d29
2 changed files with 13 additions and 13 deletions

View file

@ -135,7 +135,7 @@ bool Lexer::token (std::string& result, Type& type)
shift ();
return true;
}
else if (is_double_op (_n0, _n1))
else if (is_double_op (_n0, _n1, _n2))
{
type = typeOperator;
result += utf8_character (_n0);
@ -591,9 +591,9 @@ bool Lexer::is_ws (int c)
bool Lexer::boundary (int left, int right)
{
// XOR
if (!isdigit (left) != !isdigit (right)) return true;
if (!isalpha (left) != !isalpha (right)) return true;
if (!isspace (left) != !isspace (right)) return true;
if (isalpha (left) != isalpha (right)) return true;
if (isdigit (left) != isdigit (right)) return true;
if (isspace (left) != isspace (right)) return true;
// OR
if (ispunct (left) || ispunct (right)) return true;
@ -745,15 +745,15 @@ bool Lexer::is_triple_op (int c0, int c1, int c2) const
}
////////////////////////////////////////////////////////////////////////////////
bool Lexer::is_double_op (int c0, int c1) const
bool Lexer::is_double_op (int c0, int c1, int c2) const
{
return (c0 == '=' && c1 == '=') ||
(c0 == '!' && c1 == '=') ||
(c0 == '<' && c1 == '=') ||
(c0 == '>' && c1 == '=') ||
(c0 == 'o' && c1 == 'r') ||
(c0 == '|' && c1 == '|') ||
(c0 == '&' && c1 == '&') ||
return (c0 == '=' && c1 == '=') ||
(c0 == '!' && c1 == '=') ||
(c0 == '<' && c1 == '=') ||
(c0 == '>' && c1 == '=') ||
(c0 == 'o' && c1 == 'r' && _boundary12) ||
(c0 == '|' && c1 == '|') ||
(c0 == '&' && c1 == '&') ||
(c0 == '!' && c1 == '~');
}

View file

@ -78,7 +78,7 @@ private:
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) 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;