Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        internal static new bool ReadFromString(StringScanner scanner, out DataStringItem item)
        {
            if (StringUtils.ReadDecimalString(scanner, out string decimalStr, out bool isFloatingPoint, out bool hasExponent))
            {
                if (isFloatingPoint)
                {
                    item = new DataStringLiteralFloatingPoint(double.Parse(decimalStr, Conventions.STANDARD_CULTURE));
                }
                else
                {
                    item = new DataStringLiteralInteger(int.Parse(decimalStr, Conventions.STANDARD_CULTURE));
                }

                return(true);
            }
Esempio n. 3
0
        internal static new bool ReadFromString(StringScanner scanner, out DataStringItem item)
        {
            using (var token = scanner.SaveIndex())
            {
                if (scanner.CurrentChar == GlobalConsts.STRING_ENCLOSING_CHAR)
                {
                    while (scanner.CurrentChar != GlobalConsts.STRING_ENCLOSING_CHAR)
                    {
                        scanner.Increment();
                    }

                    item = new DataStringLiteralString(scanner.GetString(token));
                }

                scanner.RestoreIndex(token);
                item = null;
                return(false);
            }
        }
Esempio n. 4
0
        private void writeAllItems(DataStringItem parameter, ref string result)
        {
            for (int i = 0; i < parameter.Items.Count; i++)
            {
                DataStringItem child = parameter.Items[i];

                if (i > 0)
                {
                    result += GlobalConsts.SEPARATOR_CHARACTER;
                }

                if (child is DataStringFunction)
                {
                    var functionItem = child as DataStringFunction;
                    result += functionItem.Name + GlobalConsts.FUNC_PARAMS_OPENING_CHAR;

                    writeAllItems(child, ref result);

                    result += GlobalConsts.FUNC_PARAMS_CLOSING_CHAR;
                }
                else if (child is DataStringLiteralFloatingPoint)
                {
                    var floatLiteralItem = child as DataStringLiteralFloatingPoint;
                    result += floatLiteralItem.Value.ToString();
                }
                else if (child is DataStringLiteralString)
                {
                    var stringLiteralItem = child as DataStringLiteralString;
                    result += GlobalConsts.STRING_ENCLOSING_CHAR + stringLiteralItem.Value + GlobalConsts.STRING_ENCLOSING_CHAR;
                }
                else if (child is DataStringSymbol)
                {
                    var symbolItem = child as DataStringSymbol;
                    result += symbolItem.Name;
                }
            }
        }
Esempio n. 5
0
 internal void DataStringItemAdded(DataStringItem parent)
 {
     Parent = parent;
 }
Esempio n. 6
0
 internal static bool ReadFromString(StringScanner scanner, out DataStringItem item)
 {
     return(DataStringFunction.ReadFromString(scanner, out item) ||
            DataStringSymbol.ReadFromString(scanner, out item) ||
            DataStringLiteral.ReadFromString(scanner, out item));
 }
Esempio n. 7
0
 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));
 }