Beispiel #1
0
        private NvdlMode ReadMode()
        {
            NvdlMode el = new NvdlMode();

            FillLocation(el);
            el.Name = reader.GetAttribute("name");
            ReadModeCommon(el);
            return(el);
        }
Beispiel #2
0
        public SimpleMode(NvdlMode mode, NvdlCompileContext ctx)
        {
            FillLocation(mode);

            if (mode.Name == null)
            {
                throw new NvdlCompileException(
                          "'mode' element must have a name.", mode);
            }
            this.name = mode.Name;
            SimplifyPhase1(mode, ctx);
        }
Beispiel #3
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));
        }
Beispiel #4
0
		private NvdlMode ReadMode ()
		{
			NvdlMode el = new NvdlMode ();
			FillLocation (el);
			el.Name = reader.GetAttribute ("name");
			ReadModeCommon (el);
			return el;
		}
Beispiel #5
0
		public SimpleMode (NvdlMode mode, NvdlCompileContext ctx)
		{
			FillLocation (mode);

			if (mode.Name == null)
				throw new NvdlCompileException (
					"'mode' element must have a name.", mode);
			this.name = mode.Name;
			SimplifyPhase1 (mode, ctx);
		}