Example #1
0
        private List <ArgumentDefinition> ParseArgList()
        {
            List <ArgumentDefinition> Arguments = new List <ArgumentDefinition>();
            ArgumentDefinition        Ret;

            ConsumeWS();
            if (Peek(2) != "()")
            {
                while (!EOL)
                {
                    ConsumeWS();
                    if (Peek() == ")")
                    {
                        break;
                    }
                    else if (Peek() != "," && Peek() != "(")
                    {
                        throw new AutoitException(AutoitExceptionType.EXPECTSYMBOL, LineNumber, Cursor, ",");
                    }
                    Consume();
                    ConsumeWS();

                    Ret = new ArgumentDefinition();
                    if (Getstr(Reg_AlphaNum).ToUpper() == "BYREF")
                    {
                        Ret.IsByRef = true;
                    }
                    ConsumeWS();
                    if (Read() != "$")
                    {
                        throw new AutoitException(AutoitExceptionType.EXPECTSYMBOL, LineNumber, Cursor, "$");
                    }
                    Ret.ArgName = Getstr(Reg_AlphaNum);
                    if (!TryParseCast(out Ret.MyType))
                    {
                        Ret.MyType = typeof(object);
                    }
                    //if (Ret.MyType.IsArray) Ret.ArgName += string.Join("", Enumerable.Repeat("[]", Ret.MyType.GetArrayRank()));
                    ConsumeWS();
                    if (Peek() == "=")
                    {
                        Consume();
                        Ret.DefaultValue = ParseBoolean(false);
                    }
                    else
                    {
                        Ret.DefaultValue = Expression.Constant(Ret.MyType.DefaultValue(), Ret.MyType);
                    }
                    Arguments.Add(Ret);
                }
            }
            else
            {
                Consume();
            }
            Consume();
            return(Arguments);
        }
        private List<ArgumentDefinition> ParseArgList()
        {
            List<ArgumentDefinition> Arguments = new List<ArgumentDefinition>();
            ArgumentDefinition Ret;
            ConsumeWS();
            if (Peek(2) != "()") 
                while (!EOL)
                {
                    ConsumeWS();
                    if (Peek() == ")") break;
                    else if (Peek() != "," && Peek() != "(") throw new AutoitException(AutoitExceptionType.EXPECTSYMBOL, LineNumber, Cursor, ",");
                    Consume();
                    ConsumeWS();

                    Ret = new ArgumentDefinition();
                    if (Getstr(Reg_AlphaNum).ToUpper() == "BYREF") Ret.IsByRef = true;
                    ConsumeWS();
                    if (Read() != "$") throw new AutoitException(AutoitExceptionType.EXPECTSYMBOL, LineNumber, Cursor, "$");
                    Ret.ArgName = Getstr(Reg_AlphaNum);
                    if (!TryParseCast(out Ret.MyType)) Ret.MyType = typeof(object);
                    //if (Ret.MyType.IsArray) Ret.ArgName += string.Join("", Enumerable.Repeat("[]", Ret.MyType.GetArrayRank()));
                    ConsumeWS();
                    if (Peek() == "=")
                    {
                        Consume();
                        Ret.DefaultValue = ParseBoolean(false);
                    }
                    else Ret.DefaultValue = Expression.Constant(Ret.MyType.DefaultValue(), Ret.MyType);
                    Arguments.Add(Ret);
                }
            else Consume();
            Consume();
            return Arguments;
        }