コード例 #1
0
ファイル: Rule.cs プロジェクト: dom767/woofractal
        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();
            }
        }