public static ArrayCreationNode Parse(ContextNode context, IAbstractSyntaxTree lexerNode)
        {
            Contract.Requires(lexerNode.Type == Lexer.TokenType.ArrayLiteral);
            Contract.Ensures(Contract.Result <ArrayCreationNode>() != null);
            var point = context.Parser.GetSequencePoint(lexerNode);

            if (lexerNode.Children.Count == 1)
            {
                var initializer = InitializerList.Parse(context, lexerNode.Children[0]);
                return(Create(context, initializer, point));
            }
            else
            {
                var builder   = new TypeNode.TypeBuilder(context);
                var lexerType = lexerNode.Children[0];
                for (int i = 0; i < lexerType.Children.Count - 1; i++)
                {
                    builder.Append(lexerType.Children[i]);
                }
                //.Last() returns parameter list
                var last        = lexerType.Children.Last().Children[0];
                var elementType = builder.Type;
                IReadOnlyList <ExpressionNode> dims;
                if (ArrayAccessNode.IsEmptyIndexer(last))
                {
                    dims = Enumerable.Repeat((ExpressionNode)null, ArrayAccessNode.CountEmptyIndexerDims(last)).ToArray();
                }
                else
                {
                    dims = ArrayAccessNode.ParseIndex(context, last);
                }
                var initializer = InitializerList.Parse(context, lexerNode.Children[1]);
                return(Create(context, elementType, dims, initializer, point));
            }
        }
        public static TypeReference ParseFunctorType(ContextNode context, IAbstractSyntaxTree lexerNode)
        {
            var builder = new TypeNode.TypeBuilder(context);
            int count   = lexerNode.Children.Count;

            for (int i = 0; i < count - 1; i++)
            {
                builder.Append(lexerNode.Children[i]);
            }
            builder.Append(ParseParams(context.Parser, lexerNode.Children[count - 1]).Select(p => TypeNode.Parse(context, p.Type)));

            return(builder.Type);
        }
        private void ParseHeader(Modifiers mods, IAbstractSyntaxTree lexerNode, string methodName)
        {
            Contract.Requires(lexerNode.Type == Lexer.TokenType.Type);
            var point   = Parser.GetSequencePoint(lexerNode);
            var builder = new TypeNode.TypeBuilder(Parent);
            int count   = lexerNode.Children.Count;
            var paramz  = ParseParams(Parser, lexerNode.Children[count - 1]);

            for (int i = 0; i < count - 1; i++)
            {
                builder.Append(lexerNode.Children[i]);
            }

            MethodReturnType = builder.Type;
            emitter          = new MethodEmitter(GetClass().TypeEmitter, methodName, MethodReturnType, AttributesFromModifiers(Parser.GetSequencePoint(lexerNode), mods));

            foreach (var p in paramz)
            {
                var param = ParseParameter(Parent, p.Type, p.Name);
                if (param.ParameterType.IsVoid())
                {
                    ErrorCode.IllegalMethodParam.ReportAndThrow(point, "Illegal method parameter type void");
                }
                if (symbols.ContainsKey(param.Name))
                {
                    ErrorCode.ParamAlreadyDeclared.ReportAndThrow(point, "Parameter with name {0} is already declared", param.Name);
                }
                emitter.AddArgument(param);
                symbols.Add(param.Name, param);
            }
            ParamTypes = symbols.Values.Select(p => p.ParameterType);

            if (mods.HasFlag(Modifiers.Entry))
            {
                if (MethodReturnType != Parser.Int32 && MethodReturnType != Parser.UInt32 && MethodReturnType != Parser.Void)
                {
                    InvalidEntryReturn(SequencePoint, MethodReturnType);
                }
                emitter.SetAsEntryPoint();

                if (!ValidParametersForMain(ParamTypes))
                {
                    InvalidEntryParams(point, ParamTypes);
                }
            }
        }