Ejemplo n.º 1
0
        public Pair CreateMappedPair(ICharStream input, int nameQuotesType, Interval nameInterval, DelimiterEnum delimiter,
                                     Interval delimiterInterval, int valueQuotesType, Interval valueInterval, int valueIndent)
        {
            Pair pair;
            var  name  = PairFactoryForXml.GetNameText(input, nameQuotesType, nameInterval);
            var  value = PairFactoryForXml.GetValue(input, delimiter, valueQuotesType, valueInterval,
                                                    valueIndent, _context, (Module)_module);

            if (nameQuotesType > 0)
            {
                if (delimiter == DelimiterEnum.None)
                {
                    value = PairFactoryForXml.GetValue(input, delimiter, nameQuotesType, nameInterval,
                                                       0, _context, (Module)_module);
                    valueQuotesType = nameQuotesType;
                }
                pair = new Element
                {
                    Name               = name,
                    NameQuotesType     = nameQuotesType,
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };

                SetValueType((Element)pair, delimiter, value.Item1, valueQuotesType);
            }
            else if (name.StartsWith("@"))
            {
                pair = new DOM.Mapped.Attribute()
                {
                    Name               = name.Substring(1),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!$"))
            {
                pair = new DOM.Mapped.AliasDefinition
                {
                    Name               = VerifyName(name.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!#"))
            {
                pair = new DOM.Mapped.NamespaceDefinition
                {
                    Name               = VerifyNsName(name.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!%"))
            {
                pair = new DOM.Mapped.Parameter
                {
                    Name               = VerifyNsName(name.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("!"))
            {
                pair = new DOM.Mapped.Document
                {
                    Name               = VerifyName(name.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("$"))
            {
                pair = new DOM.Mapped.Alias()
                {
                    Name               = VerifyName(name.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (name.StartsWith("%"))
            {
                pair = new DOM.Mapped.Argument()
                {
                    Name               = VerifyName(name.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };

                SetValueType((IMappedPair)pair, delimiter, value.Item1, valueQuotesType);
            }
            else if (name.StartsWith("#"))
            {
                pair = new DOM.Mapped.Scope
                {
                    NsPrefix          = VerifyScopeName(name.Substring(1), nameInterval, _module),
                    NameInterval      = nameInterval,
                    Delimiter         = delimiter,
                    DelimiterInterval = delimiterInterval
                };
                SetValueType((IMappedPair)pair, delimiter, value.Item1, valueQuotesType);
            }
            else
            {
                pair = new Element
                {
                    Name               = name,
                    NameQuotesType     = nameQuotesType,
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
                if (delimiter == DelimiterEnum.None)
                {
                    value = PairFactoryForXml.GetValue(input, delimiter, nameQuotesType, nameInterval,
                                                       0, _context, (Module)_module);
                    valueQuotesType = nameQuotesType;
                }
            }
            SetValueType((IMappedPair)pair, delimiter, value.Item1, valueQuotesType);
            return(pair);
        }
Ejemplo n.º 2
0
        public DOM.Pair CreateMappedPair(ICharStream input, int nameQuotesType, DOM.Interval nameInterval, DOM.DelimiterEnum delimiter,
                                         Interval delimiterInterval, int valueQuotesType, DOM.Interval valueInterval, int valueIndent)
        {
            DOM.Mapped.IMappedPair pair;
            var nameText = GetNameText(input, nameQuotesType, nameInterval);
            var value    = GetValue(input, delimiter, valueQuotesType, valueInterval, valueIndent, _context, _module);

            if (nameQuotesType > 0)
            {
                pair = new Element
                {
                    Name               = VerifyElementName(nameText, nameInterval, _module),
                    NameQuotesType     = nameQuotesType,
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("@"))
            {
                var tuple = Element.GetNameAndNs(nameText.Substring(1), nameQuotesType);
                var ns    = string.IsNullOrEmpty(tuple.Item1) ? null : tuple.Item1;
                pair = new DOM.Mapped.Attribute
                {
                    NsPrefix           = ns,
                    Name               = VerifyName(tuple.Item2, nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("!$"))
            {
                pair = new DOM.Mapped.AliasDefinition
                {
                    Name               = VerifyName(nameText.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("!#"))
            {
                pair = new DOM.Mapped.NamespaceDefinition
                {
                    Name               = VerifyNsName(nameText.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("!%"))
            {
                pair = new Parameter
                {
                    Name               = VerifyNsName(nameText.Substring(2), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("!"))
            {
                pair = new DOM.Mapped.Document
                {
                    Name               = VerifyName(nameText.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("$"))
            {
                pair = new DOM.Mapped.Alias()
                {
                    Name               = VerifyName(nameText.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("%"))
            {
                pair = new DOM.Mapped.Argument()
                {
                    Name               = VerifyName(nameText.Substring(1), nameInterval, _module),
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            else if (nameText.StartsWith("#"))
            {
                var tuple = Element.GetNameAndNs(nameText.Substring(1), nameQuotesType);
                var ns    = string.IsNullOrEmpty(tuple.Item1) ? null : tuple.Item1;

                if (ns == null)
                {
                    pair = new DOM.Mapped.Scope
                    {
                        NsPrefix           = VerifyScopeName(nameText.Substring(1), nameInterval, _module),
                        NameInterval       = nameInterval,
                        Delimiter          = delimiter,
                        DelimiterInterval  = delimiterInterval,
                        Value              = value.Item1,
                        ValueQuotesType    = valueQuotesType,
                        ValueInterval      = valueInterval,
                        InterpolationItems = value.Item2,
                        ValueIndent        = valueIndent
                    };
                }
                else
                {
                    pair = new DOM.Mapped.Scope
                    {
                        NsPrefix           = VerifyScopeName(ns, nameInterval, _module),
                        Name               = VerifyElementName(tuple.Item2, nameInterval, _module),
                        NameInterval       = nameInterval,
                        Delimiter          = delimiter,
                        DelimiterInterval  = delimiterInterval,
                        Value              = value.Item1,
                        ValueQuotesType    = valueQuotesType,
                        ValueInterval      = valueInterval,
                        InterpolationItems = value.Item2,
                        ValueIndent        = valueIndent
                    };
                }
            }
            else
            {
                var tuple = Element.GetNameAndNs(nameText, nameQuotesType);
                var ns    = string.IsNullOrEmpty(tuple.Item1) ? null : tuple.Item1;

                pair = new Element
                {
                    NsPrefix           = VerifyScopeName(ns, nameInterval, _module),
                    Name               = VerifyElementName(tuple.Item2, nameInterval, _module),
                    NameQuotesType     = nameQuotesType,
                    NameInterval       = nameInterval,
                    Delimiter          = delimiter,
                    DelimiterInterval  = delimiterInterval,
                    Value              = value.Item1,
                    ValueQuotesType    = valueQuotesType,
                    ValueInterval      = valueInterval,
                    InterpolationItems = value.Item2,
                    ValueIndent        = valueIndent
                };
            }
            SetValueType(pair, delimiter, value.Item1, valueQuotesType);
            return((Pair)pair);
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public Pair CreateMappedPair(ITextSource textSource, int nameQuotesType, Interval nameInterval, AssignmentEnum assignment,
                                     Interval assignmentInterval, int valueQuotesType, Interval valueInterval, int valueIndent)
        {
            Pair pair;
            var  name  = PairFactoryForXml.GetNameText(textSource, nameQuotesType, nameInterval);
            var  value = PairFactoryForXml.GetValue(textSource, assignment, valueQuotesType, valueInterval,
                                                    valueIndent, _context, (Module)_module);

            if (nameQuotesType > 0)
            {
                if (assignment == AssignmentEnum.None)
                {
                    value = PairFactoryForXml.GetValue(textSource, assignment, nameQuotesType, nameInterval,
                                                       0, _context, (Module)_module);
                    valueQuotesType = nameQuotesType;
                }
                pair = new Element(
                    name,
                    nameQuotesType: nameQuotesType,
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                    );
            }
            else if (name.StartsWith("@"))
            {
                pair = new DOM.Mapped.Attribute(
                    name.Substring(1),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                    );
            }
            else if (name.StartsWith("!$"))
            {
                pair = new DOM.Mapped.AliasDefinition
                       (
                    VerifyName(name.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("!#"))
            {
                pair = new DOM.Mapped.NamespaceDefinition
                       (
                    VerifyNsName(name.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("!%"))
            {
                pair = new DOM.Mapped.Parameter
                       (
                    VerifyNsName(name.Substring(2), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("!"))
            {
                pair = new DOM.Mapped.Document
                       (
                    VerifyName(name.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("$"))
            {
                pair = new DOM.Mapped.Alias
                       (
                    VerifyName(name.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            else if (name.StartsWith("%"))
            {
                pair = new DOM.Mapped.Argument
                       (
                    VerifyName(name.Substring(1), nameInterval, _module),
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment, value.Item1, valueQuotesType)
                       );
            }
            //else if (name.StartsWith("#"))
            //{
            //    pair = new DOM.Mapped.Scope
            //    {
            //        NsPrefix = VerifyScopeName(name.Substring(1), nameInterval, _module),
            //        NameInterval = nameInterval,
            //        Assignment = assignment,
            //        AssignmentInterval = assignmentInterval
            //    };
            //    SetValueType((IMappedPair) pair, assignment, value.Item1, valueQuotesType);
            //}
            else
            {
                pair = new Element
                       (
                    name,
                    nameInterval: nameInterval,
                    assignment: assignment,
                    assignmentInterval: assignmentInterval,
                    value: value.Item1,
                    valueQuotesType: valueQuotesType,
                    valueInterval: valueInterval,
                    interpolationItems: value.Item2,
                    valueIndent: valueIndent,
                    valueType: GetValueType(assignment,
                                            (assignment == AssignmentEnum.None? PairFactoryForXml.GetValue(textSource, assignment, nameQuotesType, nameInterval,
                                                                                                           0, _context, (Module)_module).Item1:value.Item1),
                                            assignment == AssignmentEnum.None ? nameQuotesType: valueQuotesType)
                       );
            }

            return(pair);
        }