Example #1
0
        private void ProcessCustomWidgetScope(string Line, Statment Stat, string[] details)
        {
            RSSInstance CustomInstance;

            if (!Parser.TryGetWidget(details[0], out CustomInstance))
            {
                throw new ParserException($"No custom widget named {details[0]}");
            }

            RSSInstance Instance = new RSSInstance(CustomInstance.ClassName, details[0], CustomInstance.Name);

            WidgetScope sc = (WidgetScope)Stat.Generate(Line, (Scopes.Count == 0 ? this : Scopes.Peek()));

            sc.Instance = Instance;

            Scopes.Push(sc);
        }
Example #2
0
        internal void AddStatment(Statment Stat, string line)
        {
            if (Stat == null)
            {
                // Console.WriteLine($"Unkown statment '{line}'");
                return;
            }

            //Check for the mismatch of a type.
            if (Scopes.Count > 0)
            {
                if (Stat.ID != StatmentType.ScopeEnding && Stat.ID != StatmentType.Any)
                {
                    if (!Scopes.Peek().AcceptsStatmentType(Stat.ID))
                    {
                        throw new ParserException("Attempted to open an unaccepted scope");
                    }
                }
            }



            string[] details = Stat.GetDetails(line);

            switch (Stat.ID)
            {
            case StatmentType.Variable:
                ProcessVariable(Stat.GetDetails(line));
                break;

            case StatmentType.ScopeEnding:
                CloseScope();
                break;

            case StatmentType.PropertyAssignment:
                ProcessPropertyAssignment(details, Scopes.Peek());
                break;

            case StatmentType.CustomWidgetScopeOpening:
                ProcessCustomWidgetScope(line, Stat, details);
                //Check the custom class exsists.
                break;

            case StatmentType.StyleScopeOpening:
                ProcessStyleScope(line, details, Stat);
                break;

            case StatmentType.StyleIdOpening:
                ProcessStyleId(details, Stat);
                break;

            default:
                bool        isCustom = line.StartsWith("widget");
                RSSInstance Instance = new RSSInstance(details[0], details[1], isCustom);

                WidgetScope sc = (WidgetScope)Stat.Generate(line, (Scopes.Count == 0 ? this : Scopes.Peek()));

                sc.Instance = Instance;

                Scopes.Push(sc);
                break;
            }
        }