refactor(dedup): second pass at src/ duplication — clear 10 of 13 remaining blocks #21
@@ -104,76 +104,39 @@ public class StatementReader : SqlServerStatementReader
|
||||
|
||||
if (CurrentCharacter == '=')
|
||||
{
|
||||
// Handle => operator (used in PostgreSQL for hstore and other operations)
|
||||
// =, => (PostgreSQL hstore + other operations)
|
||||
MovePosition();
|
||||
if (CurrentCharacter == '>')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, "=>");
|
||||
return true;
|
||||
}
|
||||
// Single = is handled as regular operator
|
||||
if (TryMatchTwoCharOperator('>', "=>")) return true;
|
||||
_currentToken = new Token(TokenType.Operator, "=");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CurrentCharacter == '|')
|
||||
{
|
||||
// Handle || concatenation operator
|
||||
// |, ||
|
||||
MovePosition();
|
||||
if (CurrentCharacter == '|')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, "||");
|
||||
return true;
|
||||
}
|
||||
// Single | is also an operator
|
||||
if (TryMatchTwoCharOperator('|', "||")) return true;
|
||||
_currentToken = new Token(TokenType.Operator, "|");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CurrentCharacter == '<')
|
||||
{
|
||||
// Handle <, <=, <>, << operators
|
||||
// <, <=, <>, <<
|
||||
MovePosition();
|
||||
if (CurrentCharacter == '=')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, "<=");
|
||||
return true;
|
||||
}
|
||||
if (CurrentCharacter == '>')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, "<>");
|
||||
return true;
|
||||
}
|
||||
if (CurrentCharacter == '<')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, "<<");
|
||||
return true;
|
||||
}
|
||||
if (TryMatchTwoCharOperator('=', "<=")) return true;
|
||||
if (TryMatchTwoCharOperator('>', "<>")) return true;
|
||||
if (TryMatchTwoCharOperator('<', "<<")) return true;
|
||||
_currentToken = new Token(TokenType.Operator, "<");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CurrentCharacter == '>')
|
||||
{
|
||||
// Handle >, >=, >> operators
|
||||
// >, >=, >>
|
||||
MovePosition();
|
||||
if (CurrentCharacter == '=')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, ">=");
|
||||
return true;
|
||||
}
|
||||
if (CurrentCharacter == '>')
|
||||
{
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, ">>");
|
||||
return true;
|
||||
}
|
||||
if (TryMatchTwoCharOperator('=', ">=")) return true;
|
||||
if (TryMatchTwoCharOperator('>', ">>")) return true;
|
||||
_currentToken = new Token(TokenType.Operator, ">");
|
||||
return true;
|
||||
}
|
||||
@@ -244,6 +207,23 @@ public class StatementReader : SqlServerStatementReader
|
||||
|
||||
return stringValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the position is currently sitting on <paramref name="nextChar"/>, advances past it,
|
||||
/// emits <paramref name="twoCharOperator"/> as the current Operator token, and returns
|
||||
/// <c>true</c>. Otherwise leaves position untouched and returns <c>false</c>. Used by the
|
||||
/// multi-character operator dispatch (e.g. <c><</c>/<c><=</c>/<c><></c>/<c><<</c>).
|
||||
/// </summary>
|
||||
private bool TryMatchTwoCharOperator(char nextChar, string twoCharOperator)
|
||||
{
|
||||
if (CurrentCharacter != nextChar)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MovePosition();
|
||||
_currentToken = new Token(TokenType.Operator, twoCharOperator);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user