Beispiel #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);
                }
            }
        }
Beispiel #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);
            }
Beispiel #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);
        }
Beispiel #4
0
        private static object?[] _FillInvokeArray(object?[] invoke_args, int starti, NamedParam[] prms, IParseQueue q,
                                                  Type nameType, string?methodName)
        {
            string MethodName() => string.IsNullOrWhiteSpace(methodName) ?
            nameType.RName() :
            $"{nameType.RName()}.{methodName}";

            int nargs = 0;

            for (int ii = starti; ii < prms.Length; ++ii)
            {
                if (!prms[ii].nonExplicit)
                {
                    ++nargs;
                }
            }
            if (nargs == 0)
            {
                if (!(q is ParenParseQueue) && !q.Empty)
                {
                    //Zero-arg functions may absorb empty parentheses
                    if (q._SoftScan(out _)?.Item1 is SMParser.ParsedUnit.P p)
                    {
                        if (p.Item.Length == 0)
                        {
                            q.NextChild();
                        }
                    }
                }
                return(invoke_args);
            }
            if (!(q is ParenParseQueue))
            {
                var c = q.ScanChild();
                // + (x) 3
                if (c is ParenParseQueue p && p.paren.Length == 1 && nargs != 1)
                {
                }
                else
                {
                    q = q.NextChild();
                }
            }
Beispiel #5
0
 public static void FillInvokeArray(object?[] invoke_args, int starti, NamedParam[] prms, IParseQueue q,
                                    Type nameType, string methodName)
 {
     try {
         _FillInvokeArray(invoke_args, starti, prms, q, nameType, methodName);
     } catch (Exception e) {
         throw Log.StackInnerException(e);
     }
 }
Beispiel #6
0
 public static StateMachine Create(IParseQueue p) => Create(p, SMConstruction.ANY);
Beispiel #7
0
 public static string Enforce(this LPU lpu, int index, IParseQueue q) =>
 lpu.Item1 switch
 {