Example #1
0
 internal SemanticTag(ParseElement parent, Backend backend)
     : base(parent._rule)
 {
 }
Example #2
0
 internal Tag(Backend be, CfgSemanticTag cfgTag)
 {
     _be     = be;
     _cfgTag = cfgTag;
 }
Example #3
0
 internal Tag(Backend be, CfgGrammar.CfgProperty property)
 {
     _be     = be;
     _cfgTag = new CfgSemanticTag(be.Symbols, property);
 }
Example #4
0
File: Arc.cs Project: z77ma/runtime
        internal void CloneTags(Arc arc, List <Tag> _tags, Dictionary <Tag, Tag> endArcs, Backend be)
        {
            if (arc._startTags != null)
            {
                if (_startTags == null)
                {
                    _startTags = new Collection <Tag>();
                }
                foreach (Tag tag in arc._startTags)
                {
                    Tag newTag = new(tag);
                    _tags.Add(newTag);
                    _startTags.Add(newTag);
                    endArcs.Add(tag, newTag);
#if DEBUG
                    newTag._be = be;
#endif
                    if (be != null)
                    {
                        int idTagName;
                        newTag._cfgTag._nameOffset = be.Symbols.Add(tag._be.Symbols.FromOffset(tag._cfgTag._nameOffset), out idTagName);
#pragma warning disable 0618 // VarEnum is obsolete
                        if (tag._cfgTag._valueOffset != 0 && tag._cfgTag.PropVariantType == System.Runtime.InteropServices.VarEnum.VT_EMPTY)
                        {
                            newTag._cfgTag._valueOffset = be.Symbols.Add(tag._be.Symbols.FromOffset(tag._cfgTag._valueOffset), out idTagName);
                        }
#pragma warning restore 0618
                    }
                }
            }

            if (arc._endTags != null)
            {
                if (_endTags == null)
                {
                    _endTags = new Collection <Tag>();
                }
                foreach (Tag tag in arc._endTags)
                {
                    Tag newTag = endArcs[tag];
                    _endTags.Add(newTag);
                    endArcs.Remove(tag);
                }
            }
        }
Example #5
0
 internal void CloneTags(Arc arc, List <Tag> _tags, Dictionary <Tag, Tag> endArcs, Backend be)
 {
     if (arc._startTags != null)
     {
         if (_startTags == null)
         {
             _startTags = new Collection <Tag>();
         }
         foreach (Tag startTag in arc._startTags)
         {
             Tag tag = new Tag(startTag);
             _tags.Add(tag);
             _startTags.Add(tag);
             endArcs.Add(startTag, tag);
             if (be != null)
             {
                 int idWord;
                 tag._cfgTag._nameOffset = be.Symbols.Add(startTag._be.Symbols.FromOffset(startTag._cfgTag._nameOffset), out idWord);
                 if (startTag._cfgTag._valueOffset != 0 && startTag._cfgTag.PropVariantType == VarEnum.VT_EMPTY)
                 {
                     tag._cfgTag._valueOffset = be.Symbols.Add(startTag._be.Symbols.FromOffset(startTag._cfgTag._valueOffset), out idWord);
                 }
             }
         }
     }
     if (arc._endTags != null)
     {
         if (_endTags == null)
         {
             _endTags = new Collection <Tag>();
         }
         foreach (Tag endTag in arc._endTags)
         {
             Tag item = endArcs[endTag];
             _endTags.Add(item);
             endArcs.Remove(endTag);
         }
     }
 }
Example #6
0
 internal Rule(Backend backend, string name, int offsetName, SPCFGRULEATTRIBUTES attributes, int id, int iSerialize, GrammarOptions SemanticFormat, ref int cImportedRules)
     : base(backend, null)
 {
     _rule = this;
     Init(name, new CfgRule(id, offsetName, attributes), iSerialize, SemanticFormat, ref cImportedRules);
 }
Example #7
0
 internal Rule(Backend backend, string name, CfgRule cfgRule, int iSerialize, GrammarOptions SemanticFormat, ref int cImportedRules)
     : base(backend, null)
 {
     _rule = this;
     Init(name, cfgRule, iSerialize, SemanticFormat, ref cImportedRules);
 }
 internal GrammarElement(Backend backend, CustomGrammar cg)
     : base(null)
 {
     _cg      = cg;
     _backend = backend;
 }
Example #9
0
        internal void CloneSubGraph(Rule rule, Backend org, Backend extra, Dictionary <State, State> srcToDestHash, bool fromOrg)
        {
            Backend               backend = fromOrg ? org : extra;
            List <State>          list    = new List <State>();
            Dictionary <Tag, Tag> endArcs = new Dictionary <Tag, Tag>();

            CloneState(rule._firstState, list, srcToDestHash);
            while (list.Count > 0)
            {
                State state = list[0];
                list.RemoveAt(0);
                State start = srcToDestHash[state];
                foreach (Arc outArc in state.OutArcs)
                {
                    State end  = outArc.End;
                    State end2 = null;
                    if (end != null)
                    {
                        if (!srcToDestHash.ContainsKey(end))
                        {
                            CloneState(end, list, srcToDestHash);
                        }
                        end2 = srcToDestHash[end];
                    }
                    int idWord = outArc.WordId;
                    if (backend != null && outArc.WordId > 0)
                    {
                        _words.Add(backend.Words[outArc.WordId], out idWord);
                    }
                    Arc arc2 = new Arc(outArc, start, end2, idWord);
                    arc2.CloneTags(outArc, _tags, endArcs, this);
                    if (outArc.RuleRef != null)
                    {
                        string text;
                        if (outArc.RuleRef.Name.IndexOf("URL:DYNAMIC#", StringComparison.Ordinal) == 0)
                        {
                            text = outArc.RuleRef.Name.Substring(12);
                            if (fromOrg && FindInRules(text) == null)
                            {
                                Rule rule2 = extra.FindInRules(text);
                                if (rule2 == null)
                                {
                                    XmlParser.ThrowSrgsException(SRID.DynamicRuleNotFound, text);
                                }
                                CloneSubGraph(rule2, org, extra, srcToDestHash, false);
                            }
                        }
                        else if (outArc.RuleRef.Name.IndexOf("URL:STATIC#", StringComparison.Ordinal) == 0)
                        {
                            text = outArc.RuleRef.Name.Substring(11);
                            if (!fromOrg && FindInRules(text) == null)
                            {
                                Rule rule3 = org.FindInRules(text);
                                if (rule3 == null)
                                {
                                    XmlParser.ThrowSrgsException(SRID.DynamicRuleNotFound, text);
                                }
                                CloneSubGraph(rule3, org, extra, srcToDestHash, true);
                            }
                        }
                        else
                        {
                            text = outArc.RuleRef.Name;
                            Rule rule4 = org.FindInRules(text);
                            if (!fromOrg)
                            {
                                CloneSubGraph(outArc.RuleRef, org, extra, srcToDestHash, true);
                            }
                        }
                        Rule rule5 = FindInRules(text);
                        if (rule5 == null)
                        {
                            rule5 = CloneState(outArc.RuleRef._firstState, list, srcToDestHash);
                        }
                        arc2.RuleRef = rule5;
                    }
                    arc2.ConnectStates();
                }
            }
        }
Example #10
0
 internal PropertyTag(ParseElement parent, Backend backend)
     : base(parent._rule)
 {
 }