private static void HandleCurrentPositionInString(OPathParseResult parseResult, char opathChar) { if (parseResult.IsStringDelimiter(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InExpression; } parseResult.AppendToXPath(opathChar); }
private static void HandleCurrentPositionInMember(OPathParseResult parseResult, char opathChar) { if (IsMemberChar(opathChar)) { parseResult.AppendToMember(opathChar); parseResult.ResetWhitespace(); } else if (IsOpeningBracket(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InMethodParameters; parseResult.ResetWhitespace(); } else if (IsMemberPrefixChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InMember; parseResult.AddOPathPropertyPart(); parseResult.ResetWhitespace(); } else if (IsIndexerStartChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.PreIndexerValue; parseResult.AddOPathPropertyPart(); parseResult.ResetWhitespace(); } else if (IsWhitespaceChar(opathChar)) { parseResult.AppendCharToWhitespace(); } else { parseResult.CurrentPosition = OPathParsePosition.InExpression; parseResult.AddOPathPropertyPart(); parseResult.AddVariable(); parseResult.AppendToXPath(parseResult.GetAndResetWhitespace()); parseResult.AppendToXPath(opathChar); } }
private static void HandleCurrentPositionInIdentifier(OPathParseResult parseResult, char opathChar, int opathCharIndex) { if (IsIdentifierChar(opathChar)) { if (parseResult.HasWhitespace) { string identifier = parseResult.GetIdentifier(); if (IsStandardSourceObjectIdentifier(identifier)) { parseResult.ResetIdentifier(); parseResult.AddVariable(identifier); parseResult.AppendWhitespaceCharToXPath(); } } parseResult.AppendToIdentifier(opathChar); } else if (IsWhitespaceChar(opathChar)) { string identifier = parseResult.GetIdentifier(); if (IsXPathOperator(identifier)) { parseResult.CurrentPosition = OPathParsePosition.InExpression; parseResult.ResetIdentifier(); parseResult.AppendOperatorToXPath(identifier); parseResult.AppendWhitespaceCharToXPath(); } else { parseResult.AppendCharToWhitespace(); } } else if (IsOpeningBracket(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InExpression; string identifier = parseResult.GetAndResetIdentifier(); parseResult.AppendFunctionToXPath(identifier); parseResult.AppendToXPath(opathChar); parseResult.ResetWhitespace(); } else if (IsMemberPrefixChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InMember; parseResult.CurrentVariableName = parseResult.GetAndResetIdentifier(); parseResult.MemberStartIndex = opathCharIndex; parseResult.ResetWhitespace(); } else if (IsIndexerStartChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.PreIndexerValue; parseResult.CurrentVariableName = parseResult.GetAndResetIdentifier(); parseResult.IndexerStartIndex = opathCharIndex; parseResult.ResetWhitespace(); } else if (IsStringDelimiterChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InString; parseResult.CurrentStringDelimiter = opathChar; parseResult.AppendToXPath(opathChar); parseResult.StringStartIndex = opathCharIndex; } else { parseResult.CurrentPosition = OPathParsePosition.InExpression; string identifier = parseResult.GetAndResetIdentifier(); if (IsXPathOperator(identifier)) { parseResult.AppendOperatorToXPath(identifier); } else { parseResult.AddVariable(identifier); } parseResult.AppendToXPath(parseResult.GetAndResetWhitespace()); parseResult.AppendToXPath(opathChar); } }
private static void HandleCurrentPositionInExpression(OPathParseResult parseResult, char opathChar, char nextOPathChar, int opathCharIndex) { if (IsWhitespaceChar(opathChar)) { parseResult.AppendWhitespaceCharToXPath(); } else if (IsAlphabeticChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InIdentifier; parseResult.AppendToIdentifier(opathChar); parseResult.IdentifierStartIndex = opathCharIndex; } else if (IsStringDelimiterChar(opathChar)) { parseResult.CurrentPosition = OPathParsePosition.InString; parseResult.CurrentStringDelimiter = opathChar; parseResult.AppendToXPath(opathChar); parseResult.StringStartIndex = opathCharIndex; } else if (IsOperatorChar(opathChar)) { if (nextOPathChar == opathChar) { // Ignore multiple operators, such as && and || } else { parseResult.AppendOperatorToXPath(opathChar); } } else if (IsNotChar(opathChar)) { if (IsEqualityChar(nextOPathChar)) { // Allow != through parseResult.AppendToXPath(opathChar); } else { parseResult.CurrentPosition = OPathParsePosition.InIdentifier; parseResult.AppendToIdentifier("not"); parseResult.IdentifierStartIndex = opathCharIndex; } } else if (IsEqualityChar(opathChar)) { if (nextOPathChar == opathChar) { // Ignore multiple equalities } else { parseResult.AppendToXPath(opathChar); } } else { parseResult.AppendToXPath(opathChar); } }