Ejemplo n.º 1
0
        public static FSMRepresentationBuilder GetDefaultTestConfig(
            bool usesExceptions = true, string version = "")
        {
            var builder = new FSMRepresentationBuilder();

            builder.AddPragma("namespace TurnStyleExample");
            builder.SetName("TurnStyle");
            builder.SetContextName("TurnStyleContext");
            builder.SetVersion(version);

            if (usesExceptions)
            {
                builder.SetException("Exception");
            }

            builder.AddBuiltConcreteState(new ConcreteStateImpl("Locked"));
            builder.AddBuiltConcreteState(new ConcreteStateImpl("Unlocked"));

            builder.SetInitialState("Locked");

            builder.AddTransition("Coin", "Unlocked", null);
            builder.AddTransition("Pass", "Locked", null);

            builder.AddAction("Unlock");
            builder.AddAction("Lock");
            builder.AddAction("Alarm");
            builder.AddAction("Thankyou");

            return(builder);
        }
Ejemplo n.º 2
0
        private FSMRepresentationBuilder InitBuilderState()
        {
            var builder = new FSMRepresentationBuilder();

            builder.AddBuiltConcreteState(new ConcreteStateImpl("Locked"));
            builder.AddBuiltConcreteState(new ConcreteStateImpl("Unlocked"));

            builder.Build();
            return(builder);
        }
Ejemplo n.º 3
0
        public override State Build(FSMRepresentationBuilder fb)
        {
            ConcreteSubStateImpl retval = null;
            var sr = fb.GetStateRep(this.SuperStateName);

            if (sr != null)
            {
                sr.Build(fb);
                SuperState superState = fb.GetBuiltSuperState(this.SuperStateName);
                if (superState != null)
                {
                    retval = new ConcreteSubStateImpl(this.StateName, superState);
                    fb.AddBuiltConcreteState(retval);
                }
                else
                {
                    var e = $"Could not build sub state ({this.StateName}) because super state ({this.SuperStateName}) had an error.";
                    fb.SetError();
                    fb.Error(sr.SyntaxLocation, e);
                }
            }
            else
            {
                var e = $"Super state ({this.SuperStateName}) was not declared.";
                fb.SetError();
                fb.Error(null, e);
            }
            return(retval);
        }
Ejemplo n.º 4
0
        public override State Build(FSMRepresentationBuilder fb)
        {
            var retval = new ConcreteStateImpl(this.StateName);

            fb.AddBuiltConcreteState(retval);
            return(retval);
        }