예제 #1
0
        private static StateMachine?ReflectSM(IParseQueue q)
        {
            string method = q.Scan();

            if (method == "file")
            {
                q.Advance();
                return(StateMachineManager.FromName(q.Next()));
            }
            else if (method == "null")
            {
                q.Advance();
                return(null);
            }
            else if (method == "stall")
            {
                q.Advance();
                return(WaitForPhaseSM);
            }
            else
            {
                var line = q.GetLastLine();
                try {
                    return(StateMachine.Create(q));
                } catch (Exception ex) {
                    throw new SMException($"Nested StateMachine construction starting on line {line} failed.", ex);
                }
            }
        }
예제 #2
0
            public ReflCtx(IParseQueue q)
            {
                List <ParsingProperty> properties = new List <ParsingProperty>();

                props = new ParsingProperties(new ParsingProperty[0]);
                while (q.MaybeScan() == SMParser.PROP2_KW)
                {
                    q.Advance();
                    properties.Add(q.NextChild().Into <ParsingProperty>());
                    if (!q.IsNewline)
                    {
                        throw new Exception(
                                  $"Line {q.GetLastLine()} is missing a newline at the end of the the property declaration. Instead, it found \"{q.Scan()}\".");
                    }
                }
                props = new ParsingProperties(properties);
            }
예제 #3
0
        private static List <StateMachine> CreateChildren(Type?myType, IParseQueue q, int childCt = -1)
        {
            var            children = new List <StateMachine>();
            SMConstruction childType;

            while (childCt-- != 0 && !q.Empty &&
                   (childType = CheckCreatableChild(myType, q.ScanNonProperty())) != SMConstruction.ILLEGAL)
            {
                StateMachine newsm = Create(q.NextChild(), childType);
                if (!q.IsNewlineOrEmpty)
                {
                    throw new Exception(
                              $"Line {q.GetLastLine()}: Expected a newline, but found \"{q.Print()}\".");
                }
                children.Add(newsm);
                if (newsm is BreakSM)
                {
                    break;
                }
            }
            return(children);
        }