/// <summary> /// Determines whether a particular character is valid within a relative identifier. /// </summary> public static bool IsValidRelativeIdChar(char value) { return(SymbolCharacters.IsValidChar(value)); }
/// <summary> /// Determines whether a particular character is valid within an atom. /// </summary> public static bool IsValidIdentifierAtomChar(char value) { return(SymbolCharacters.IsValidChar(value)); }
private static ParseResult TryParseIdentifier <TChars>( ExpandedTokenData <TChars> token, PipExecutionContext context, ref int position, out TChars identifier, bool logErrors = true) where TChars : struct, ICharSpan <TChars> { Contract.Requires(token.IsValid); Contract.RequiresNotNull(context); var pathTable = context.PathTable; var text = token.Text; if (text.Length == 0 || position == text.Length) { var updateToken = token.UpdateLineInformationForPosition(position); identifier = default(TChars); return(new ParseResult() { Status = ParseStatus.UnexpectedEmptyIdentifier, Path = updateToken.Path.ToString(pathTable), Line = updateToken.Line, Position = updateToken.Position, }); } int firstPosition = position; char firstChar = text[position]; if (!SymbolCharacters.IsValidStartChar(firstChar)) { var updateToken = token.UpdateLineInformationForPosition(position); identifier = default(TChars); return(new ParseResult() { Status = ParseStatus.UnexpectedCharacterAtStartOfIdentifier, Path = updateToken.Path.ToString(pathTable), Line = updateToken.Line, Position = updateToken.Position, Text = firstChar.ToString(), }); } position++; for (; position < text.Length; position++) { char ch = text[position]; if (!SymbolCharacters.IsValidChar(ch)) { break; } } identifier = text.Subsegment(firstPosition, position - firstPosition); return(new ParseResult { Status = ParseStatus.Success }); }