Example #1
0
 internal void ResolveModes(NvdlCompileContext ctx, SimpleMode current)
 {
     foreach (SimpleAction a in actions)
     {
         a.ResolveModes(ctx, current);
     }
 }
Example #2
0
        private void PopulateInterp(
            NvdlDispatcher d, NvdlInterpretation i,
            NvdlSection parentState)
        {
            SimpleMode m    = FindContextMode(i.Action, parentState);
            SimpleRule rule = FindElementRule(m, dispatcher.Reader);

            NvdlDebug.Writer.WriteLine("***** populate interp from action {0} whose mode is {1}. Rule is {2} whose actions are {3}", i.Action.Location, m.Location, rule.Location, rule.Actions.Length);
            foreach (SimpleAction a in rule.Actions)
            {
                NvdlInterpretation cur = i;
                for (; cur != null; cur = cur.Parent)
                {
                    if (cur.CreatedMode == m && cur.Action == a)
                    {
                        NvdlDebug.Writer.WriteLine("------- corresponding PlanElem already exists.");
                        break;
                    }
                }
                if (cur == null)
                {
                    cur = CreateInterp(d, m, a, i);
                }
                ilist.Add(cur);
            }
        }
Example #3
0
        internal void ResolveModes(NvdlCompileContext ctx, SimpleMode current)
        {
            if (source.UseMode != null)
            {
                mode = ctx.GetCompiledMode(source.UseMode);
            }
            else if (source.NestedMode != null)
            {
                mode = ctx.GetCompiledMode(source);
            }
            else
            {
                mode = current;
            }

            for (int i = 0; i < contexts.Length; i++)
            {
                contexts [i].ResolveModes(ctx, mode);
            }

            // FIXME: get location by some way
            if (mode == null)
            {
                throw new NvdlCompileException(
                          "mode does not contain either referenced modeUsage or nested mode.", null);
            }
        }
Example #4
0
        private SimpleRule FindElementRule(SimpleMode mode, XmlReader reader)
        {
            SimpleRule any = null;

            foreach (SimpleRule rule in mode.ElementRules)
            {
                if (rule.MatchNS(reader.NamespaceURI))
                {
                    if (!rule.IsAny)
                    {
                        return(rule);
                    }
                    else
                    {
                        any = rule;
                    }
                }
            }
            NvdlDebug.Writer.WriteLine(" : : : : anyNamespace rule being applied.");
            if (any != null)
            {
                return(any);
            }
            throw new NvdlValidationException("NVDL internal error: should not happen. No matching rule was found.", Reader as IXmlLineInfo);
        }
Example #5
0
 public NvdlInterpretation(NvdlDispatcher dispatcher,
                           SimpleMode createdMode, SimpleAction action,
                           NvdlInterpretation parent)
 {
     this.dispatcher  = dispatcher;
     this.createdMode = createdMode;
     this.action      = action;
     this.parent      = parent;
 }
Example #6
0
        public NvdlValidateInterp(NvdlDispatcher dispatcher,
                                  SimpleMode createdMode, SimpleValidate validate,
                                  NvdlInterpretation parent)
            : base(dispatcher, createdMode, validate, parent)
        {
            this.reader   = new NvdlFilteredXmlReader(dispatcher.Reader, this);
            this.validate = validate;
            validator     = validate.CreateValidator(this.reader);

            dispatcher.Validator.OnMessage(validate.Messages);
        }
Example #7
0
        private NvdlInterpretation CreateInterp(NvdlDispatcher d,
                                                SimpleMode m, SimpleAction a, NvdlInterpretation p)
        {
            SimpleValidate v = a as SimpleValidate;

            if (v != null)
            {
                return(new NvdlValidateInterp(d, m, v, p));
            }
            return(new NvdlResultInterp(d, m, (SimpleResultAction)a, p));
        }
Example #8
0
 internal void ResolveModes(NvdlCompileContext ctx, SimpleMode current)
 {
     if (modeUsage != null)
     {
         modeUsage.ResolveModes(ctx, current);
         mode = modeUsage.UseMode;
     }
     if (mode == null)
     {
         mode = current;
     }
 }
Example #9
0
        private NvdlInterpretation CreateInterp(NvdlDispatcher d,
                                                SimpleMode m, SimpleAction a, NvdlInterpretation p)
        {
            NvdlDebug.Writer.WriteLine("***** new interp from action {0} from mode {1}", a.Location, m.Location);
            SimpleValidate v = a as SimpleValidate;

            if (v != null)
            {
                return(new NvdlValidateInterp(d, m, v, p));
            }
            return(new NvdlResultInterp(d, m, (SimpleResultAction)a, p));
        }
Example #10
0
        public NvdlResultInterp(NvdlDispatcher dispatcher,
                                SimpleMode createdMode,
                                SimpleResultAction resultAction,
                                NvdlInterpretation parent)
            : base(dispatcher, createdMode, resultAction, parent)
        {
            NvdlDebug.Writer.WriteLine("++++++ new resultAction " + resultAction.Location);
            type = resultAction.ResultType;

            if (type == NvdlResultType.AttachPlaceholder && parent != null)
            {
                parent.AttachPlaceholder();
            }
        }
Example #11
0
        internal void ResolveModes(NvdlCompileContext ctx, SimpleMode current)
        {
            if (useModeName != null)
            {
                useMode = ctx.GetCompiledMode(useModeName);
            }
            else if (source.NestedMode != null)
            {
                useMode = ctx.GetCompiledMode(source);
            }
            else
            {
                useMode = current;
            }

            if (useMode == null)
            {
                throw new NvdlCompileException(String.Format("Specified mode '{0}' was not found.",
                                                             useModeName), this);
            }
        }
Example #12
0
        private void SimplifyModeUsage(
            NvdlNoCancelAction nca, NvdlCompileContext ctx)
        {
            NvdlModeUsage usage = nca.ModeUsage;

            if (usage.NestedMode != null && ctx.GetCompiledMode(usage) == null)
            {
                SimpleMode sm = new SimpleMode(String.Empty,
                                               usage.NestedMode, ctx);
                ctx.AddCompiledMode(usage, sm);
            }
            foreach (NvdlContext c in usage.Contexts)
            {
                if (c.NestedMode != null)
                {
                    SimpleMode sm = new SimpleMode(
                        String.Empty, c.NestedMode, ctx);
                    ctx.AddCompiledMode(c, sm);
                }
            }
        }
Example #13
0
        private SimpleRule FindAttributeRule(string ns, SimpleMode mode)
        {
            SimpleRule any = null;

            foreach (SimpleRule rule in mode.AttributeRules)
            {
                if (!rule.MatchNS(ns))
                {
                    continue;
                }
                if (!rule.IsAny)
                {
                    return(rule);
                }
                any = rule;
            }
            if (any != null)
            {
                return(any);
            }
            throw new NvdlValidationException("NVDL internal error: should not happen. No matching rule was found.", reader as IXmlLineInfo);
        }
Example #14
0
        private void PopulateInterp(
            NvdlDispatcher d, NvdlInterpretation i,
            NvdlSection parentState)
        {
            SimpleMode m    = FindContextMode(i.Action, parentState);
            SimpleRule rule = FindElementRule(m, dispatcher.Reader);

            foreach (SimpleAction a in rule.Actions)
            {
                NvdlInterpretation cur = i;
                for (; cur != null; cur = cur.Parent)
                {
                    if (cur.CreatedMode == m && cur.Action == a)
                    {
                        break;
                    }
                }
                if (cur == null)
                {
                    cur = CreateInterp(d, m, a, i);
                }
                ilist.Add(cur);
            }
        }
Example #15
0
		internal void AddModeContext (SimpleMode m,
			NvdlModeCompileContext mctx)
		{
			modeContexts.Add (m, mctx);
		}
Example #16
0
		internal NvdlModeCompileContext GetModeContext (SimpleMode m)
		{
			return modeContexts [m] as NvdlModeCompileContext;
		}
Example #17
0
		internal void AddCompiledMode (NvdlContext c, SimpleMode m)
		{
			compiledModes.Add (c, m);
		}
Example #18
0
		internal void AddCompiledMode (NvdlModeUsage u, SimpleMode m)
		{
			compiledModes.Add (u, m);
		}
Example #19
0
		public NvdlInterpretation (NvdlDispatcher dispatcher,
			SimpleMode createdMode, SimpleAction action,
			NvdlInterpretation parent)
		{
			this.dispatcher = dispatcher;
			this.createdMode = createdMode;
			this.action = action;
			this.parent = parent;
		}
Example #20
0
		internal void ResolveModes (NvdlCompileContext ctx, SimpleMode current)
		{
			foreach (SimpleAction a in actions)
				a.ResolveModes (ctx, current);
		}
Example #21
0
		internal void ResolveModes (NvdlCompileContext ctx, SimpleMode current)
		{
			if (source.UseMode != null) {
				mode = ctx.GetCompiledMode (source.UseMode);
			}
			else if (source.NestedMode != null)
				mode = ctx.GetCompiledMode (source);
			else
				mode = current;

			for (int i = 0; i < contexts.Length; i++)
				contexts [i].ResolveModes (ctx, mode);

			// FIXME: get location by some way
			if (mode == null)
				throw new NvdlCompileException (
					"mode does not contain either referenced modeUsage or nested mode.", null);
		}
Example #22
0
		private NvdlInterpretation CreateInterp (NvdlDispatcher d,
			SimpleMode m, SimpleAction a, NvdlInterpretation p)
		{
NvdlDebug.Writer.WriteLine ("***** new interp from action {0} from mode {1}", a.Location, m.Location);
			SimpleValidate v = a as SimpleValidate;
			if (v != null)
				return new NvdlValidateInterp (d, m, v, p);
			return new NvdlResultInterp (d, m, (SimpleResultAction) a, p);
		}
Example #23
0
 internal NvdlModeCompileContext GetModeContext(SimpleMode m)
 {
     return(modeContexts.ContainsKey(m) ? modeContexts [m] : null);
 }
Example #24
0
		public NvdlValidateInterp (NvdlDispatcher dispatcher,
			SimpleMode createdMode, SimpleValidate validate,
			NvdlInterpretation parent)
			: base (dispatcher, createdMode, validate, parent)
		{
NvdlDebug.Writer.WriteLine ("++++++ new validate " + validate.Location);
			this.reader = new NvdlFilteredXmlReader (dispatcher.Reader, this);
			this.validate = validate;
			validator = validate.CreateValidator (this.reader);

			dispatcher.Validator.OnMessage (validate.Messages);
		}
Example #25
0
		public NvdlResultInterp (NvdlDispatcher dispatcher,
			SimpleMode createdMode,
			SimpleResultAction resultAction,
			NvdlInterpretation parent)
			: base (dispatcher, createdMode, resultAction, parent)
		{
NvdlDebug.Writer.WriteLine ("++++++ new resultAction " + resultAction.Location);
			type = resultAction.ResultType;

			if (type == NvdlResultType.AttachPlaceholder && parent != null)
				parent.AttachPlaceholder ();
		}
Example #26
0
 internal void AddCompiledMode(NvdlModeUsage u, SimpleMode m)
 {
     compiledModes.Add(u, m);
 }
Example #27
0
		internal void ResolveModes (NvdlCompileContext ctx, SimpleMode current)
		{
			if (modeUsage != null) {
				modeUsage.ResolveModes (ctx, current);
				mode = modeUsage.UseMode;
			}
			if (mode == null)
				mode = current;
		}
Example #28
0
		internal void ResolveModes (NvdlCompileContext ctx, SimpleMode current)
		{
			if (useModeName != null)
				useMode = ctx.GetCompiledMode (useModeName);
			else if (source.NestedMode != null)
				useMode = ctx.GetCompiledMode (source);
			else
				useMode = current;

			if (useMode == null)
				throw new NvdlCompileException (String.Format ("Specified mode '{0}' was not found.",
					useModeName), this);
		}
Example #29
0
        private void SimplifyPhase1(NvdlCompileContext ctx)
        {
            NvdlRules rules = ctx.Rules;
            // 6.4.1 : just ignore "Foreign" property.
            // 6.4.2 : already ignored on reading nvdl.
            // 6.4.3 : done in SOM
            // 6.4.4 : FIXME: must be done.
            // 6.4.5 : FIXME: considered in compiler.
            // 6.4.6 : FIXME: considered in compiler.
            // 6.4.7 : FIXME: considered in compiler.

            // 6.4.8 : here
            NvdlModeList list      = rules.Modes;
            NvdlMode     startMode = null;

            if (rules.Modes.Count > 0)
            {
                if (rules.Rules.Count > 0)
                {
                    throw new NvdlCompileException("Modes and rules cannot coexist in 'rules' element.", rules);
                }
                else if (rules.StartMode == null)
                {
                    throw new NvdlCompileException("startMode is missing in 'rules' element when modes are specified.", rules);
                }
                foreach (NvdlMode m in rules.Modes)
                {
                    if (m.Name == rules.StartMode)
                    {
                        startMode = m;
                        break;
                    }
                }
                if (startMode == null)
                {
                    throw new NvdlCompileException("Matching 'mode' element specified by 'startMode' does not exist.", rules);
                }
            }
            else
            {
                if (rules.Rules.Count == 0)
                {
                    throw new NvdlCompileException("Neither modes nor rules exists in 'rules' element.", rules);
                }
                list                   = new NvdlModeList();
                startMode              = new NvdlMode();
                startMode.SourceUri    = rules.SourceUri;
                startMode.LineNumber   = rules.LineNumber;
                startMode.LinePosition = rules.LinePosition;
                startMode.Name         = "(startMode)";
                list.Add(startMode);
                foreach (NvdlRule rule in rules.Rules)
                {
                    startMode.Rules.Add(rule);
                }
            }

            // 6.4.9 : done in SimpleMode.ctor() and
            // SimpleRule.ctor(), using ctx.CompiledModes.
            foreach (NvdlMode m in list)
            {
                SimpleMode sm = new SimpleMode(m, ctx);
                ctx.AddCompiledMode(sm.Name, sm);
                if (m == startMode)
                {
                    this.startMode = sm;
                }
            }

            // 6.4.10 : done in SimpleRule.Simplify

            ArrayList tl = new ArrayList();

            for (int i = 0; i < rules.Triggers.Count; i++)
            {
                tl.Add(new SimpleTrigger(rules.Triggers [i]));
            }
            triggers = (SimpleTrigger [])tl.ToArray(
                typeof(SimpleTrigger));

            modes = (SimpleMode [])
                    new ArrayList(ctx.GetCompiledModes())
                    .ToArray(typeof(SimpleMode));
        }
Example #30
0
		internal void AddCompiledMode (string name, SimpleMode m)
		{
			compiledModes.Add (m.Name, m);
		}
Example #31
0
 internal NvdlModeCompileContext GetModeContext(SimpleMode m)
 {
     return(modeContexts [m] as NvdlModeCompileContext);
 }
Example #32
0
		private SimpleRule FindElementRule (SimpleMode mode, XmlReader reader)
		{
			SimpleRule any = null;
			foreach (SimpleRule rule in mode.ElementRules) {
				if (rule.MatchNS (reader.NamespaceURI)) {
					if (!rule.IsAny)
						return rule;
					else
						any = rule;
				}
			}
NvdlDebug.Writer.WriteLine (" : : : : anyNamespace rule being applied.");
			if (any != null)
				return any;
			throw new NvdlValidationException ("NVDL internal error: should not happen. No matching rule was found.", Reader as IXmlLineInfo);
		}
Example #33
0
 internal void AddCompiledMode(string name, SimpleMode m)
 {
     compiledModes.Add(m.Name, m);
 }
Example #34
0
		private void SimplifyModeUsage (
			NvdlNoCancelAction nca, NvdlCompileContext ctx)
		{
			NvdlModeUsage usage = nca.ModeUsage;
			if (usage.NestedMode != null && ctx.GetCompiledMode (usage) == null) {
				SimpleMode sm = new SimpleMode (String.Empty,
					usage.NestedMode, ctx);
				ctx.AddCompiledMode (usage, sm);
			}
			foreach (NvdlContext c in usage.Contexts) {
				if (c.NestedMode != null) {
					SimpleMode sm = new SimpleMode (
						String.Empty, c.NestedMode, ctx);
					ctx.AddCompiledMode (c, sm);
				}
			}
		}
Example #35
0
 internal void AddCompiledMode(NvdlContext c, SimpleMode m)
 {
     compiledModes.Add(c, m);
 }
Example #36
0
		private void SimplifyPhase1 (NvdlCompileContext ctx)
		{
			NvdlRules rules = ctx.Rules;
			// 6.4.1 : just ignore "Foreign" property.
			// 6.4.2 : already ignored on reading nvdl.
			// 6.4.3 : done in SOM
			// 6.4.4 : FIXME: must be done.
			// 6.4.5 : FIXME: considered in compiler.
			// 6.4.6 : FIXME: considered in compiler.
			// 6.4.7 : FIXME: considered in compiler.

			// 6.4.8 : here
			NvdlModeList list = rules.Modes;
			NvdlMode startMode = null;

			if (rules.Modes.Count > 0) {
				if (rules.Rules.Count > 0)
					throw new NvdlCompileException ("Modes and rules cannot coexist in 'rules' element.", rules);
				else if (rules.StartMode == null)
					throw new NvdlCompileException ("startMode is missing in 'rules' element when modes are specified.", rules);
				foreach (NvdlMode m in rules.Modes) {
					if (m.Name == rules.StartMode) {
						startMode = m;
						break;
					}
				}
				if (startMode == null)
					throw new NvdlCompileException ("Matching 'mode' element specified by 'startMode' does not exist.", rules);
			} else {
				if (rules.Rules.Count == 0)
					throw new NvdlCompileException ("Neither modes nor rules exists in 'rules' element.", rules);
				list = new NvdlModeList ();
				startMode = new NvdlMode ();
				startMode.SourceUri = rules.SourceUri;
				startMode.LineNumber = rules.LineNumber;
				startMode.LinePosition = rules.LinePosition;
				startMode.Name = "(startMode)";
				list.Add (startMode);
				foreach (NvdlRule rule in rules.Rules)
					startMode.Rules.Add (rule);
			}

			// 6.4.9 : done in SimpleMode.ctor() and
			// SimpleRule.ctor(), using ctx.CompiledModes.
			foreach (NvdlMode m in list) {
				SimpleMode sm = new SimpleMode (m, ctx);
				ctx.AddCompiledMode (sm.Name, sm);
				if (m == startMode)
					this.startMode = sm;
			}

			// 6.4.10 : done in SimpleRule.Simplify

			ArrayList tl = new ArrayList ();
			for (int i = 0; i < rules.Triggers.Count; i++)
				tl.Add (new SimpleTrigger (rules.Triggers [i]));
			triggers = (SimpleTrigger []) tl.ToArray (
				typeof (SimpleTrigger));

			modes = (SimpleMode [])
				new ArrayList (ctx.GetCompiledModes ())
				.ToArray (typeof (SimpleMode));
		}
Example #37
0
 internal void AddModeContext(SimpleMode m,
                              NvdlModeCompileContext mctx)
 {
     modeContexts.Add(m, mctx);
 }
		private SimpleRule FindAttributeRule (string ns, SimpleMode mode)
		{
			SimpleRule any = null;
			foreach (SimpleRule rule in mode.AttributeRules) {
				if (!rule.MatchNS (ns))
					continue;
				if (!rule.IsAny)
					return rule;
				any = rule;
			}
			if (any != null)
				return any;
			throw new NvdlValidationException ("NVDL internal error: should not happen. No matching rule was found.", reader as IXmlLineInfo);
		}