Exemple #1
0
        private void ConsumeIncludes(ArrayList al,
                                     NvdlCompileContext ctx)
        {
            // The reason why we limit the check to current count
            // is to add invalid siblings (according to 6.4.12).
            int checkMax = al.Count;
            NvdlModeCompileContext mctx = ctx.GetModeContext(this);

            foreach (SimpleRule rule in rules)
            {
                // Don't skip cancelled rules here. They are
                // needed to filter overriden rules out
                // (according to 6.4.10)
                //if (ctx.CancelledRules [rule] != null)
                //	continue;

                bool exclude = false;
                for (int i = 0; i < checkMax; i++)
                {
                    SimpleRule r = (SimpleRule)al [i];
                    if (rule.IsAny == r.IsAny &&
                        rule.MatchAttributes == r.MatchAttributes &&
                        rule.NS == r.NS &&
                        rule.Wildcard == r.Wildcard)
                    {
                        exclude = true;
                        break;
                    }
                }
                if (exclude)
                {
                    break;
                }
                al.Add(rule);
            }
            foreach (SimpleMode mode in mctx.Included)
            {
                mode.ConsumeIncludes(al, ctx);
            }

            // remove cancelled rules at this stage.
            for (int i = 0; i < al.Count;)
            {
                if (ctx.CancelledRules [(SimpleRule)al [i]] != null)
                {
                    al.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
        }
Exemple #2
0
        private void SimplifyPhase1(NvdlModeBase mode,
                                    NvdlCompileContext ctx)
        {
            NvdlModeCompileContext mctx =
                new NvdlModeCompileContext(mode);

            ctx.AddModeContext(this, mctx);
            ArrayList al = new ArrayList();

            foreach (NvdlRule r in mode.Rules)
            {
                switch (r.Match)
                {
                case NvdlRuleTarget.Both:
                    al.Add(new SimpleRule(r, true, ctx));
                    al.Add(new SimpleRule(r, false, ctx));
                    break;

                case NvdlRuleTarget.None:
                case NvdlRuleTarget.Elements:
                    al.Add(new SimpleRule(r, false, ctx));
                    break;

                case NvdlRuleTarget.Attributes:
                    al.Add(new SimpleRule(r, true, ctx));
                    break;
                }
            }
            foreach (NvdlIncludedMode inc in mode.IncludedModes)
            {
                mctx.Included.Add(new SimpleMode(inc, ctx));
            }
            // The rule table is just a dummy store that might
            // erase because of removal of inclusion.
            rules = (SimpleRule [])al.ToArray(typeof(SimpleRule));
        }
 internal void AddModeContext(SimpleMode m,
                              NvdlModeCompileContext mctx)
 {
     modeContexts.Add(m, mctx);
 }
		internal void AddModeContext (SimpleMode m,
			NvdlModeCompileContext mctx)
		{
			modeContexts.Add (m, mctx);
		}
Exemple #5
0
		private void SimplifyPhase1 (NvdlModeBase mode,
			NvdlCompileContext ctx)
		{
			NvdlModeCompileContext mctx =
				new NvdlModeCompileContext (mode);
			ctx.AddModeContext (this, mctx);
			ArrayList al = new ArrayList ();
			foreach (NvdlRule r in mode.Rules) {
				switch (r.Match) {
				case NvdlRuleTarget.Both:
					al.Add (new SimpleRule (r, true, ctx));
					al.Add (new SimpleRule (r, false, ctx));
					break;
				case NvdlRuleTarget.None:
				case NvdlRuleTarget.Elements:
					al.Add (new SimpleRule (r, false, ctx));
					break;
				case NvdlRuleTarget.Attributes:
					al.Add (new SimpleRule (r, true, ctx));
					break;
				}
			}
			foreach (NvdlIncludedMode inc in mode.IncludedModes)
				mctx.Included.Add (new SimpleMode (inc, ctx));
			// The rule table is just a dummy store that might
			// erase because of removal of inclusion.
			rules = (SimpleRule []) al.ToArray (typeof (SimpleRule));
		}