public ExpressionTree(ParseInfo parseInfo, Scope scope, DeltinScriptParser.E_expr_treeContext exprContext, bool usedAsValue)
        {
            ExprContextTree = Flatten(parseInfo.Script, exprContext);

            // Setup
            for (int i = 0; i < ExprContextTree.Length; i++)
            {
                ExprContextTree[i].Setup(new TreeContextParseInfo()
                {
                    ParseInfo        = i == 0 ? parseInfo : parseInfo.SetSourceExpression(ExprContextTree[i - 1]),
                    Getter           = scope,
                    Scope            = i == 0 ? scope : ExprContextTree[i - 1].GetScope() ?? new Scope(),
                    Parent           = i == 0 ? null : ExprContextTree[i - 1],
                    UsedAsExpression = usedAsValue || i < ExprContextTree.Length - 1,
                    IsLast           = i == ExprContextTree.Length - 1
                });
            }

            // Get expressions
            Tree = new IExpression[ExprContextTree.Length];
            IExpression current = ExprContextTree[0].GetExpression();

            Tree[0] = current;
            if (current != null)
            {
                for (int i = 1; i < ExprContextTree.Length; i++)
                {
                    current = ExprContextTree[i].GetExpression();

                    Tree[i] = current;

                    if (current == null)
                    {
                        Completed = false;
                        break;
                    }
                }
            }
            else
            {
                Completed = false;
            }

            if (Completed)
            {
                Result = Tree[Tree.Length - 1];
            }

            // Get the completion items for each expression in the path.
            GetCompletion(parseInfo.Script, scope);
        }