internal static new bool ReadFromString(StringScanner scanner, out DataStringItem item) { using (var token = scanner.SaveIndex()) { if (scanner.CurrentChar == '0') { scanner.Increment(); bool literalIsBinary = scanner.CurrentChar == 'b', literalIsHexadecimal = scanner.CurrentChar == 'x'; if (literalIsBinary || literalIsHexadecimal) { scanner.Increment(); } using (var repStrToken = scanner.SaveIndex()) { while (literalIsBinary && GlobalConsts.BINARY_CHARSET.Contains(scanner.CurrentChar) || literalIsHexadecimal && GlobalConsts.HEXADECIMAL_CHARSET.Contains(scanner.CurrentChar) || !(literalIsHexadecimal || literalIsHexadecimal) && GlobalConsts.OCTAL_CHARSET.Contains(scanner.CurrentChar)) { scanner.Increment(); } string repStr = scanner.GetString(repStrToken); if (repStr.Length > 0) { if (literalIsBinary) { item = new DataStringLiteralBinary(BinaryConversion.FromRepresentation(repStr, 2), DataStringLiteralBinaryRepresentation.Binary); } else if (literalIsHexadecimal) { item = new DataStringLiteralBinary(BinaryConversion.FromRepresentation(repStr, 16), DataStringLiteralBinaryRepresentation.Hexadecimal); } else { item = new DataStringLiteralBinary(BinaryConversion.FromRepresentation(repStr, 8), DataStringLiteralBinaryRepresentation.Octal); } return(true); } } } scanner.RestoreIndex(token); item = null; return(false); } }
internal static new bool ReadFromString(StringScanner scanner, out DataStringItem item) { return(DataStringLiteralString.ReadFromString(scanner, out item) || DataStringLiteralBinary.ReadFromString(scanner, out item) || DataStringLiteralNumber.ReadFromString(scanner, out item)); }