Esempio n. 1
0
            public override Token Evaluate(string stream, ref int pos)
            {
                if (m_Initialised == false)
                {
                    RuleAlternative x = new RuleAlternative(m_Parent);
                    if (s_SkipBody)
                    {
                        addRule(x, new RuleRegex(m_Parent, "[^{}]+", this)); //anything that is not { }   Todo  thats not working if there ARE {} inside body
                    }
                    else
                    {
                        addRule(x, new RuleDecl(m_Parent));
                        addRule(x, new RuleAssign(m_Parent));
                        addRule(x, new RuleEOLComment(m_Parent));
                        addRule(x, new RuleWhile(m_Parent));
                        addRule(x, new RuleIf(m_Parent));
                        addRule(x, new RuleSwitch(m_Parent));
                        addRule(x, new RuleBreak(m_Parent));
                        addRule(x, new RuleReturn(m_Parent));
                        addRule(x, new RuleWait(m_Parent));
                        addRule(x, new RuleException(m_Parent));
                        addRule(x, new RuleCommanderCall(m_Parent));
                        addRule(x, new RuleFunctionCall(m_Parent));
                    }
                    this.AddNode(x);
                    this.m_Initialised = true;
                }

                return(base.Evaluate(stream, ref pos));
            }
Esempio n. 2
0
        public class RuleRetDecl : RuleSequence {  //-> BASETYPE [S NAME ] (, BASETYPE [S NAME])*
            public RuleRetDecl(Rule Parent)
                : base(Parent)
            {
                RuleAlternative w = new RuleAlternative(this);
                RuleSequence    u = new RuleSequence(this);

                u.AddNode(new RuleBaseType(this));
                u.AddNode(new RuleSpace(this));
                u.AddNode(new RuleName(this));
                w.AddNode(u);
                u = new RuleSequence(this);
                u.AddNode(new RuleBaseType(this));
                w.AddNode(u);

                this.AddNode(new RuleRegex(this, "->" + s_ManyWhitespace, this));
                this.AddNode(w);
                RuleSequence x = new RuleSequence(this);

                x.AddNode(new RuleSeparator(this));
                x.AddNode(w);
                RuleMultiple y = new RuleMultiple(this, 0);

                y.AddNode(x);
                this.AddNode(y);
            }
Esempio n. 3
0
        public class RuleParams : RuleMultiple {   // NAME S (, S NAME S )*
            public RuleParams(Rule Parent)
                : base(Parent, 0)
            {
                RuleAlternative par = new RuleAlternative(m_Parent);

                par.AddNode(new RuleName(m_Parent));
                par.AddNode(new RuleNumber(m_Parent));
                par.AddNode(new RuleString(m_Parent));
                par.AddNode(new RuleBool(m_Parent));

                RuleSequence z = new RuleSequence(this);

                z.AddNode(par);
                RuleSequence x = new RuleSequence(this);

                x.AddNode(new RuleSeparator(this));
                x.AddNode(z);
                RuleMultiple y = new RuleMultiple(this, 0);

                y.AddNode(x);
                RuleSequence w = new RuleSequence(this);

                w.AddNode(z);
                w.AddNode(y);
                this.AddNode(w);
            }
Esempio n. 4
0
            private Rule addRule(RuleAlternative Collection, Rule ToAdd)
            {
                RuleSequence y = new RuleSequence(ToAdd.GetParent());

                y.AddNode(ToAdd);
                Collection.AddNode(y);
                return(Collection);
            }
Esempio n. 5
0
        public class RulePlusExpr : RuleSequence {   //('+' / '-')? S(NAME /  number / '(' S expression S ')')
            public RulePlusExpr(Rule Parent)
                : base(Parent)
            {
                this.AddNode(new RuleRegex(m_Parent, "(\\+|\\-)?", this));
                RuleAlternative x = new RuleAlternative(Parent);

                x.AddNode(new RuleName(Parent));
                x.AddNode(new RuleNumber(Parent));
                this.AddNode(x);
            }
Esempio n. 6
0
        public class RuleBoolVarExpr : RuleSequence {   //('!')? S(NAME /  BOOL / '(' S Comparission S ')')
            public RuleBoolVarExpr(Rule Parent)
                : base(Parent)
            {
                this.AddNode(new RuleRegex(m_Parent, "(!)?", this));
                RuleAlternative x = new RuleAlternative(Parent);

                x.AddNode(new RuleCompareExpr(Parent));
                x.AddNode(new RuleName(Parent));
                x.AddNode(new RuleBool(Parent));
                this.AddNode(x);
            }
Esempio n. 7
0
        public class RuleCompareExpr : RuleSequence {   // (NAME /  BOOL / NUMBER / STRING )S ( >=/ <= / == / !=)S (NAME /  BOOL / NUMBER / STRING )
            public RuleCompareExpr(Rule Parent)
                : base(Parent)
            {
                RuleAlternative x = new RuleAlternative(Parent);

                x.AddNode(new RuleName(Parent));
                x.AddNode(new RuleBool(Parent));
                x.AddNode(new RuleNumber(Parent));
                x.AddNode(new RuleString(Parent));
                this.AddNode(x);
                this.AddNode(new RuleRegex(m_Parent, "(\\=\\=|\\>\\=|\\<\\=|\\>|\\<|\\!\\=)", this));
                this.AddNode(x);
            }
Esempio n. 8
0
        public class RuleSwitchCase : RuleSequence {  //('case ' (NUMBER | STRING) ':' EOL
            //    ...
            //    BREAK )?
            // 'default:' EOL
            //    ...
            //'}'
            public RuleSwitchCase(Rule Parent)
                : base(Parent)
            {
                m_Parent = this;
                this.AddNode(new RuleRegex(m_Parent, s_ManyWhitespace + "\\bcase\\b" + s_ManyWhitespace, this));
                RuleAlternative x = new RuleAlternative(m_Parent);

                x.AddNode(new RuleNumber(m_Parent));
                x.AddNode(new RuleString(m_Parent));
                this.AddNode(x);
                this.AddNode(new RuleRegex(m_Parent, s_ManyWhitespace + ":" + s_ManyWhitespace, this));
                this.AddNode(new RuleEOLComment(m_Parent));
                this.AddNode(new RuleBody(m_Parent));
            }
Esempio n. 9
0
            public RuleAssign(Rule Parent)
                : base(Parent)
            {
                m_Parent = this;
                this.AddNode(new RuleSpaceOptional(m_Parent));
                this.AddNode(new RuleName(m_Parent));
                this.AddNode(new RuleRegex(m_Parent, s_ManyWhitespace + "=" + s_ManyWhitespace, this));
                RuleAlternative x = new RuleAlternative(m_Parent);

                x.AddNode(new RuleString(m_Parent));
                x.AddNode(new RuleBool(m_Parent));
                x.AddNode(new RuleName(m_Parent));
                x.AddNode(new RuleExpr(m_Parent));
                this.AddNode(x);
                this.AddNode(new RuleEOLComment(m_Parent));
            }
Esempio n. 10
0
            public RuleDecl(Rule Parent) : base(Parent)
            {
                m_Parent = this;
                this.AddNode(new RuleSpaceOptional(m_Parent));
                this.AddNode(new RuleBaseType(m_Parent));
                this.AddNode(new RuleSpace(m_Parent));
                this.AddNode(new RuleName(m_Parent));
                RuleSequence z = new RuleSequence(m_Parent);

                z.AddNode(new RuleRegex(m_Parent, s_ManyWhitespace + "=" + s_ManyWhitespace, this));
                RuleAlternative x = new RuleAlternative(m_Parent);

                x.AddNode(new RuleString(m_Parent));
                x.AddNode(new RuleBool(m_Parent));
                x.AddNode(new RuleName(m_Parent));
                x.AddNode(new RuleExpr(m_Parent));
                z.AddNode(x);
                RuleOption y = new RuleOption(m_Parent);

                y.AddNode(z);
                this.AddNode(y);
                this.AddNode(new RuleEOLComment(m_Parent));
            }
Esempio n. 11
0
        public class RuleNameInstance : RuleAlternative {     // Station. but also Station[X].   Station["5"].  Station[5].
            public RuleNameInstance(Rule Parent) : base(Parent)
            {
                RuleAlternative x = new RuleAlternative(m_Parent);

                x.AddNode(new RuleName(m_Parent));
                x.AddNode(new RuleNumber(m_Parent));
                x.AddNode(new RuleString(m_Parent));

                RuleSequence y = new RuleSequence(m_Parent);

                y.AddNode(new RuleSpaceOptional(m_Parent));
                y.AddNode(new RuleName(m_Parent));
                y.AddNode(new RuleRegex(m_Parent, "\\[", this));
                y.AddNode(x);
                y.AddNode(new RuleRegex(m_Parent, "\\]", this));
                y.AddNode(new RuleRegex(m_Parent, "\\.", this));
                this.AddNode(y);

                y = new RuleSequence(m_Parent);
                y.AddNode(new RuleSpaceOptional(m_Parent));
                y.AddNode(new RuleName(m_Parent));
                y.AddNode(new RuleRegex(m_Parent, "\\.", this));
                this.AddNode(y);
            }