private List <MemberBinding> ParseBindingList(PrimaryExpressionBuilder builder, Member_initializer_listContext initList)
        {
            var bindingList = new List <MemberBinding>();

            if (initList != null)
            {
                foreach (var initContext in initList.member_initializer())
                {
                    var name            = initContext.identifier().GetText();
                    var valueExpression = Visit(initContext.initializer_value());
                    var binding         = builder.Bind(name, valueExpression);
                    bindingList.Add(binding);
                }
            }

            return(bindingList);
        }
        public override Expression VisitPrimary_expression(Primary_expressionContext context)
        {
            var builder = new PrimaryExpressionBuilder(_parserContext);
            var pe      = context.pe;

            builder.Context(pe);
            if (pe is LiteralExpressionContext l)
            {
                var literalParser = new LiteralParser();
                var literal       = literalParser.Visit(l);
                builder.ExpressionStart(literal);
            }
            else if (pe is LiteralAccessExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=literal access", context);
            }
            else if (pe is SimpleNameExpressionContext sn)
            {
                var identifier = VisitIdentifier(sn.identifier());
                if (identifier != null)
                {
                    builder.ExpressionStart(identifier);
                }
                else
                {
                    if (sn.type_argument_list() != null)
                    {
                        throw new CompilationException("Unsupported expression. ExpressionType=type arguments", context);
                    }

                    builder.NamePart(sn.GetText());
                }
            }
            else if (pe is ParenthesisExpressionContext pre)
            {
                var innerExpression = Visit(pre.expression());
                builder.ExpressionStart(innerExpression);
            }
            else if (pe is ObjectCreationExpressionContext oce)
            {
                var typeName = oce.type().GetText();
                builder.TypeName(typeName);

                if (oce.object_creation_expression() != null ||
                    oce.object_or_collection_initializer() != null)
                {
                    var argList      = oce.object_creation_expression()?.argument_list();
                    var argumentList = ParseArgumentsList(argList);

                    var initializer = oce.object_or_collection_initializer()
                                      ?? oce.object_creation_expression()?.object_or_collection_initializer();
                    var initList = initializer
                                   ?.object_initializer()
                                   ?.member_initializer_list();
                    var bindingList = ParseBindingList(builder, initList);

                    var ctor = builder.Constructor(argumentList);
                    builder.MemberInit(ctor, bindingList);
                }
                else
                {
                    throw new CompilationException("Unsupported expression. ExpressionType=object creation", context);
                }
            }
            else if (pe is MemberAccessExpressionContext pt)
            {
                builder.NamePart(pt.GetText());
            }
            else if (pe is ThisReferenceExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=this reference", context);
            }
            else if (pe is BaseAccessExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=base access", context);
            }
            else if (pe is TypeofExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=typeof", context);
            }
            else if (pe is SizeofExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=sizeof", context);
            }
            else if (pe is NameofExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=nameof", context);
            }
            else if (pe is CheckedExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=checked", context);
            }
            else if (pe is UncheckedExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=unchecked", context);
            }
            else if (pe is DefaultValueExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=default", context);
            }
            else if (pe is AnonymousMethodExpressionContext)
            {
                throw new CompilationException("Unsupported expression. ExpressionType=anonymous method", context);
            }
            else
            {
                throw new CompilationException("Unsupported expression", context);
            }

            foreach (var child in context.children.Skip(1))
            {
                builder.Context(child);
                if (child is Member_accessContext)
                {
                    var memberName = child.GetText().TrimStart('.');
                    builder.Member(memberName);
                }
                else if (child is Method_invocationContext mi)
                {
                    var argumentsList = ParseArgumentsList(mi.argument_list());
                    builder.Method(argumentsList);
                }
                else if (child is Bracket_expressionContext be)
                {
                    var indexList = new List <Expression>();
                    foreach (var indexContext in be.indexer_argument())
                    {
                        var index = Visit(indexContext);
                        indexList.Add(index);
                    }
                    builder.Index(indexList);
                }
                else if (child is ITerminalNode tn)
                {
                    var op = tn.Symbol.Text; //++, --
                    throw new CompilationException($"Unsupported operation. Operation={op}", context);
                }
                else
                {
                    throw new CompilationException("Unsupported expression", context);
                }
            }

            var expression = builder.GetExpression();

            return(expression);
        }