Ejemplo n.º 1
0
    public static void PrintPath(List<XNode> results, string text, Dictionary<ParsedSequenceAndSubrule, bool> deletedToken, ParsedSequenceAndSubrules path)
    {
      var isPrevInsertion = false;

      foreach (var node in path.Reverse())
      {
        var tokenChanges = node.TokenChanges;
        var seq = node.Seq;
        var subrule = node.Subrule;
        
        bool isGarbage;
        if (deletedToken.TryGetValue(new ParsedSequenceAndSubrule(seq, subrule), out isGarbage))// TODO: Возможно здесь надо проверять значение tokenChanges.Deleted
        {
          isPrevInsertion = false;
          var title = new XAttribute("title", "Deleted token;  Subrule: " + subrule + ";  Sequence: " + seq + ";");
          results.Add(new XElement("span", isGarbage ? _garbageClass : _deletedClass,
            title, text.Substring(subrule.Begin, subrule.End - subrule.Begin)));
        }
        else if (tokenChanges.HasChanges)
        {
          var desc = seq.ParsingSequence.States[subrule.State].Description;
          if (!subrule.IsEmpty)
          { }
          var title = new XAttribute("title", "Inserted tokens: " + tokenChanges + ";  Subrule: " + subrule + ";  Sequence: " + seq + ";");
          results.Add(new XElement("span", _skipedStateClass, title, isPrevInsertion ? " " + desc : desc));
          isPrevInsertion = true;
        }
        else
        {
          var desc = seq.ParsingSequence.States[subrule.State].Description;
          var title = new XAttribute("title", "Description: " + desc + ";  Subrule: " + subrule + ";  Sequence: " + seq + ";");
          results.Add(new XElement("span", title, text.Substring(subrule.Begin, subrule.End - subrule.Begin)));

          isPrevInsertion = false;
        }
      }

      results.Add(new XText("\r\n"));
    }
Ejemplo n.º 2
0
        public static void PrintPath(List <XNode> results, string text, Dictionary <ParsedSequenceAndSubrule, bool> deletedToken, ParsedSequenceAndSubrules path)
        {
            var isPrevInsertion = false;

            foreach (var node in path.Reverse())
            {
                var tokenChanges = node.TokenChanges;
                var seq          = node.Seq;
                var subrule      = node.Subrule;

                bool isGarbage;
                if (deletedToken.TryGetValue(new ParsedSequenceAndSubrule(seq, subrule), out isGarbage))// TODO: Возможно здесь надо проверять значение tokenChanges.Deleted
                {
                    isPrevInsertion = false;
                    var title = new XAttribute("title", "Deleted token;  Subrule: " + subrule + ";  Sequence: " + seq + ";");
                    results.Add(new XElement("span", isGarbage ? _garbageClass : _deletedClass,
                                             title, text.Substring(subrule.Begin, subrule.End - subrule.Begin)));
                }
                else if (tokenChanges.HasChanges)
                {
                    var desc = seq.ParsingSequence.States[subrule.State].Description;
                    if (!subrule.IsEmpty)
                    {
                    }
                    var title = new XAttribute("title", "Inserted tokens: " + tokenChanges + ";  Subrule: " + subrule + ";  Sequence: " + seq + ";");
                    results.Add(new XElement("span", _skipedStateClass, title, isPrevInsertion ? " " + desc : desc));
                    isPrevInsertion = true;
                }
                else
                {
                    var desc  = seq.ParsingSequence.States[subrule.State].Description;
                    var title = new XAttribute("title", "Description: " + desc + ";  Subrule: " + subrule + ";  Sequence: " + seq + ";");
                    results.Add(new XElement("span", title, text.Substring(subrule.Begin, subrule.End - subrule.Begin)));

                    isPrevInsertion = false;
                }
            }

            results.Add(new XText("\r\n"));
        }