Пример #1
0
        // The extended element is the trickiest one becuase the operator gets nested in an extended tag, and
        // can be preceded by another element as well.  Here's a simple rule:
        // &a < b  => <reset>a</reset><p>b</p>
        // And the extended one for comparison:
        // &a < b | c / d => <reset>a</reset><x><context>b</context><p>c</p><extend>d</extend></x>
        // The operator tag is inserted inside the "x" tag, and comes after the "context" tag (represented by '|')
        private void OnExtendedDifference(object sender, ActionEventArgs args)
        {
            // There should always at least be 2 nodes by this point - reset and either prefix or expansion
            Debug.Assert(_currentNodes.Count >= 2);
            IcuDataObject differenceNode = IcuDataObject.CreateElement("x");
            IcuDataObject dataNode       = IcuDataObject.CreateElement(_currentOperators.Pop());

            dataNode.AppendChild(_currentDataObjects.Pop());
            IcuDataObject prefixNode    = _currentNodes[_currentNodes.Count - 2];
            IcuDataObject expansionNode = _currentNodes[_currentNodes.Count - 1];
            int           deleteCount   = 0;

            if (expansionNode.Name != "extend")
            {
                prefixNode    = expansionNode;
                expansionNode = null;
            }
            if (prefixNode.Name == "context")
            {
                differenceNode.AppendChild(prefixNode);
                deleteCount++;
            }
            differenceNode.AppendChild(dataNode);
            if (expansionNode != null)
            {
                differenceNode.AppendChild(expansionNode);
                deleteCount++;
            }
            _currentNodes.RemoveRange(_currentNodes.Count - deleteCount, deleteCount);
            _currentNodes.Add(differenceNode);
        }
Пример #2
0
        private void AddXmlNodeWithData(string name)
        {
            IcuDataObject ido = IcuDataObject.CreateElement(name);

            ido.AppendChild(_currentDataObjects.Pop());
            _currentNodes.Add(ido);
        }
Пример #3
0
        private void OnOptionOptimize(object sender, ActionEventArgs args)
        {
            Debug.Assert(_currentCharacterSet != null);
            var element = IcuDataObject.CreateElement("optimize");

            element.AppendChild(IcuDataObject.CreateText(_currentCharacterSet));
            _optionElements.Add(element);
            _currentCharacterSet = null;
        }
Пример #4
0
        private void OnReset(object sender, ActionEventArgs args)
        {
            IcuDataObject ido = IcuDataObject.CreateElement(((Spart.Parsers.NonTerminal.Rule)sender).ID);

            foreach (IcuDataObject attr in _attributesForReset)
            {
                ido.AppendChild(attr);
            }
            ido.AppendChild(_currentDataObjects.Pop());
            _currentNodes.Add(ido);
            _attributesForReset = new Queue <IcuDataObject>();
        }
Пример #5
0
        private void AddSettingsAttribute(IcuDataObject attr)
        {
            IcuDataObject settings = null;

            foreach (var option in _optionElements)
            {
                if (option.Name == "settings")
                {
                    settings = option;
                    break;
                }
            }
            if (settings == null)
            {
                settings = IcuDataObject.CreateElement("settings");
                _optionElements.Insert(0, settings);
            }
            settings.InsertChild(attr);
        }
Пример #6
0
        private IcuDataObject CreateOptimizedNode(List <IcuDataObject> nodeGroup)
        {
            Debug.Assert(nodeGroup != null);
            Debug.Assert(nodeGroup.Count > 0);
            // one node is already optimized
            if (nodeGroup.Count == 1)
            {
                return(nodeGroup[0]);
            }
            // luckily the optimized names are the same as the unoptimized with 'c' appended
            // so <p> becomes <pc>, <s> to <sc>, et al.
            IcuDataObject optimizedNode = IcuDataObject.CreateElement(nodeGroup[0].Name + "c");

            foreach (IcuDataObject node in nodeGroup)
            {
                optimizedNode.AppendChild(IcuDataObject.CreateText(node.InnerText));
            }
            return(optimizedNode);
        }
Пример #7
0
 private void OnTop(object sender, ActionEventArgs args)
 {
     // [top] is deprecated in ICU and not directly allowed in LDML
     // [top] is probably best rendered the same as [last regular]
     _currentDataObjects.Push(IcuDataObject.CreateElement("last_non_ignorable"));
 }
Пример #8
0
 private void OnIndirectPosition(object sender, ActionEventArgs args)
 {
     _currentDataObjects.Push(IcuDataObject.CreateElement(_currentIndirectPosition.ToString()));
     _currentIndirectPosition = new StringBuilder();
 }