Ejemplo n.º 1
0
        public void Parse(ref string[] program)
        {
            string ruleName = ParseUtils.GetToken(ref program);

            _RulePrototype = WooScript.GetRulePrototype(ruleName);
            WooScript._Log.AddMsg("Call Rule : " + ruleName);

            string openbracket = ParseUtils.PeekToken(program);

            if (openbracket.Equals("(", StringComparison.Ordinal) || _RulePrototype._Args.Count() > 0)
            {
                openbracket = ParseUtils.GetToken(ref program);
                if (!openbracket.Equals("(", StringComparison.Ordinal))
                {
                    throw new ParseException("rule called without required arguments, or syntax error. Found " + openbracket + ", expeceted \"(\" instead.");
                }

                for (int i = 0; i < _RulePrototype._Args.Count(); i++)
                {
                    _ArgValue.Add(ExpressionBuilder.Parse(ref program));
                    if (i + 1 < _RulePrototype._Args.Count())
                    {
                        string comma = ParseUtils.GetToken(ref program);
                        if (!comma.Equals(",", StringComparison.Ordinal))
                        {
                            throw new ParseException("Found " + comma + " but expected another argument after a \",\"");
                        }
                    }
                }

                string closebracket = ParseUtils.GetToken(ref program);
                if (!closebracket.Equals(")", StringComparison.Ordinal))
                {
                    throw new ParseException("rules not currently supported with arguments, missing ), found " + closebracket + " instead.");
                }
            }
        }