Beispiel #1
0
            public void Parse(ref string[] program)
            {
                string ifstring = ParseUtils.GetToken(ref program);

                if (!ifstring.Equals("if", StringComparison.Ordinal))
                {
                    throw new ParseException("If Statement should always start with if, found " + ifstring + " instead.");
                }

                string openbracket = ParseUtils.GetToken(ref program);

                if (!openbracket.Equals("(", StringComparison.Ordinal))
                {
                    throw new ParseException("if statement must be followed by a condition in brackets, found " + openbracket + " instead.");
                }
                _Condition = ConditionBuilder.Parse(ref program);
                string closebracket = ParseUtils.GetToken(ref program);

                if (!closebracket.Equals(")", StringComparison.Ordinal))
                {
                    throw new ParseException("if statement found a conditional expression without a closing bracket, found " + closebracket + " instead.");
                }

                _Block = new RuleBlock();
                _Block.Parse(ref program);
            }
Beispiel #2
0
        public void Parse(ref string[] program)
        {
            IfConditionBlock ifConditionBlock = new IfConditionBlock();

            ifConditionBlock.Parse(ref program);
            _IfBlock.Add(ifConditionBlock);

            string token = ParseUtils.PeekToken(program);

            while (token.Equals("else", StringComparison.Ordinal))
            {
                string elsestring = ParseUtils.GetToken(ref program);
                if (!elsestring.Equals("else", StringComparison.Ordinal))
                {
                    throw new ParseException("missing else statement, found " + elsestring + " instead.");
                }

                string iftoken = ParseUtils.PeekToken(program);
                if (iftoken.Equals("if", StringComparison.Ordinal))
                {
                    IfConditionBlock ifCondBlock = new IfConditionBlock();
                    ifCondBlock.Parse(ref program);
                    _IfBlock.Add(ifCondBlock);
                }
                else
                {
                    _ElseBlock = new RuleBlock();
                    _ElseBlock.Parse(ref program);
                    return; // no more blocks allowed...
                }
                token = ParseUtils.PeekToken(program);
            }
        }
Beispiel #3
0
        public void Parse(ref string[] program)
        {
            string repeatstring = ParseUtils.GetToken(ref program);

            if (!repeatstring.Equals("repeat", StringComparison.Ordinal))
            {
                throw new ParseException("repeat Statement should always start with repeat, found " + repeatstring + " instead.");
            }

            string openbracket = ParseUtils.GetToken(ref program);

            if (!openbracket.Equals("(", StringComparison.Ordinal))
            {
                throw new ParseException("if statement must be followed by a condition in brackets, found " + openbracket + " instead.");
            }

            _Expression = ExpressionBuilder.Parse(ref program);
            if (_Expression.GetExpressionType() != VarType.varFloat)
            {
                throw new ParseException("repeat statement requires a float parameter");
            }

            string closebracket = ParseUtils.GetToken(ref program);

            if (!closebracket.Equals(")", StringComparison.Ordinal))
            {
                throw new ParseException("if statement found a conditional expression without a closing bracket, found " + closebracket + " instead.");
            }

            _RepeatBlock = new RuleBlock();
            _RepeatBlock.Parse(ref program);
        }
Beispiel #4
0
        public void Parse(ref string[] program)
        {
            IfConditionBlock ifConditionBlock = new IfConditionBlock();
            ifConditionBlock.Parse(ref program);
            _IfBlock.Add(ifConditionBlock);

            string token = ParseUtils.PeekToken(program);
            while (token.Equals("else", StringComparison.Ordinal))
            {
                string elsestring = ParseUtils.GetToken(ref program);
                if (!elsestring.Equals("else", StringComparison.Ordinal))
                    throw new ParseException("missing else statement, found " + elsestring + " instead.");

                string iftoken = ParseUtils.PeekToken(program);
                if (iftoken.Equals("if", StringComparison.Ordinal))
                {
                    IfConditionBlock ifCondBlock = new IfConditionBlock();
                    ifCondBlock.Parse(ref program);
                    _IfBlock.Add(ifCondBlock);
                }
                else
                {
                    _ElseBlock = new RuleBlock();
                    _ElseBlock.Parse(ref program);
                    return; // no more blocks allowed...
                }
                token = ParseUtils.PeekToken(program);
            }
        }
Beispiel #5
0
        public void Parse(ref string[] program)
        {
            string token = ParseUtils.PeekToken(program);

            if (token.Equals("(", StringComparison.Ordinal))
            {
                token = ParseUtils.GetToken(ref program);

                do
                {
                    Argument arg = new Argument();
                    token = ParseUtils.GetToken(ref program);
                    if (token.Equals("float", StringComparison.Ordinal))
                    {
                        arg._Type = VarType.varFloat;
                    }
                    else if (token.Equals("vec", StringComparison.Ordinal))
                    {
                        arg._Type = VarType.varVector;
                    }
                    else
                    {
                        throw new ParseException("Expected type of parameter (float OR vec), not" + token);
                    }

                    arg._Name = ParseUtils.GetToken(ref program);
                    WooScript.ValidateName(arg._Name);

                    _Arguments.Add(arg);
                    token = ParseUtils.GetToken(ref program);
                }while (token.Equals(",", StringComparison.Ordinal));

                if (!token.Equals(")", StringComparison.Ordinal))
                {
                    throw new ParseException("Expected \")\" but found \"" + token + "\" instead. :(");
                }
            }

            foreach (Argument a in _Arguments)
            {
                a.Add();
            }
            block.Parse(ref program);
            foreach (Argument a in _Arguments)
            {
                a.Remove();
            }
        }
Beispiel #6
0
            public void Parse(ref string[] program)
            {
                string ifstring = ParseUtils.GetToken(ref program);
                if (!ifstring.Equals("if", StringComparison.Ordinal))
                    throw new ParseException("If Statement should always start with if, found " + ifstring + " instead.");

                string openbracket = ParseUtils.GetToken(ref program);
                if (!openbracket.Equals("(", StringComparison.Ordinal))
                    throw new ParseException("if statement must be followed by a condition in brackets, found " + openbracket + " instead.");
                _Condition = ConditionBuilder.Parse(ref program);
                string closebracket = ParseUtils.GetToken(ref program);
                if (!closebracket.Equals(")", StringComparison.Ordinal))
                    throw new ParseException("if statement found a conditional expression without a closing bracket, found " + closebracket + " instead.");

                _Block = new RuleBlock();
                _Block.Parse(ref program);
            }
Beispiel #7
0
        public void Parse(ref string[] program)
        {
            string repeatstring = ParseUtils.GetToken(ref program);
            if (!repeatstring.Equals("repeat", StringComparison.Ordinal))
                throw new ParseException("repeat Statement should always start with repeat, found " + repeatstring + " instead.");
            
            string openbracket = ParseUtils.GetToken(ref program);
            if (!openbracket.Equals("(", StringComparison.Ordinal))
                throw new ParseException("if statement must be followed by a condition in brackets, found " + openbracket + " instead.");
            
            _Expression = ExpressionBuilder.Parse(ref program);
            if (_Expression.GetExpressionType() != VarType.varFloat)
                throw new ParseException("repeat statement requires a float parameter");
            
            string closebracket = ParseUtils.GetToken(ref program);            
            if (!closebracket.Equals(")", StringComparison.Ordinal))
                throw new ParseException("if statement found a conditional expression without a closing bracket, found " + closebracket + " instead.");

            _RepeatBlock = new RuleBlock();
            _RepeatBlock.Parse(ref program);
        }
Beispiel #8
0
 public void Parse(ref string[] program)
 {
     _RuleBlock = new RuleBlock();
     _RuleBlock.Parse(ref program);
 }
Beispiel #9
0
 public void Parse(ref string[] program)
 {
     _RuleBlock = new RuleBlock();
     _RuleBlock.Parse(ref program);
 }