Пример #1
0
 public LoopBlock(Runnable parent, string source) : base(parent, source.PoExtract('{', '}'), "loop")
 {
     IsContinuous = true;
 }
Пример #2
0
 public Term(Runnable parent, string source) : base(parent, source)
 {
 }
Пример #3
0
 public While(Runnable parent, string source) : base(parent, source)
 {
     _conditionSource = source.PoRemove(' ').PoExtract('(', ')');
 }
Пример #4
0
 public Caller(Runnable parent, string source) : base(parent, source)
 {
     Name = source.PoRemove(' ').PoCut('(');
     Args = source.PoRemove(' ').PoExtract('(', ')').PoSplit(',');
 }
Пример #5
0
        public Block(Runnable parent, string text, string name = "") : base(parent, text)
        {
            if (name.Length > 0)
            {
                Name = name;
            }
            var sources = text.PoSplitSource();

            foreach (var source in sources)
            {
                if (source.PoMatchHead("func"))
                {
                    Functions.Add(new Function(this, source));
                }
                else if (source.PoMatchHead("test"))
                {
                    Tests.Add(new Function(this, source));
                }
                else if (source.PoMatchHead("class"))
                {
                    var def      = new Class(this, source);
                    var fullName = string.Format("{0}.{1}", FullName, def.Name);
                    if (!Class.ExistsStaticClass(fullName))
                    {
                        Class.AddStaticClass(fullName, def);
                    }
                    else
                    {
                        Class.GetStaticClass(fullName).Using(def);
                    }
                }
                else if (source.PoMatchHead("extension"))
                {
                    var def = new Class(this, source);
                    if (!Class.ExistsStaticExtension(def.Name))
                    {
                        Class.AddStaticExtension(def);
                    }
                    else
                    {
                        Class.GetStaticExtension(def.Name).Using(def);
                    }
                }
                else if (source.PoMatchHead("if") ||
                         source.PoMatchHead("else if") ||
                         source.PoMatchHead("else"))
                {
                    Runnables.Add(new If(this, source));
                }
                else if (source.PoMatchHead("count"))
                {
                    Runnables.Add(new Count(this, source));
                }
                else if (source.PoMatchHead("while"))
                {
                    Runnables.Add(new While(this, source));
                }
                else if (source.PoMatchHead("foreach"))
                {
                    Runnables.Add(new Foreach(this, source));
                }
                else if (source.PoMatchHead("for"))
                {
                    Runnables.Add(new For(this, source));
                }
                else if (source.PoMatchHead("return"))
                {
                    Runnables.Add(new Return(this, source));
                }
                else if (source.PoMatchHead("continue"))
                {
                    Runnables.Add(new Continue(this, source));
                }
                else if (source.PoMatchHead("break"))
                {
                    Runnables.Add(new Break(this, source));
                }
                else if (source.PoMatchHead("{"))
                {
                    Runnables.Add(new Block(this, source.PoExtract('{', '}')));
                }
                else
                {
                    Runnables.Add(new Term(this, source));
                }
            }
        }
Пример #6
0
 public Runnable(Runnable parent, string source)
 {
     Parent = parent;
     Source = source;
 }