Inheritance: AliasableTableReference
コード例 #1
0
 public virtual void Visit(SubqueryFactor node)
 {
     VisitInternal(node.Subquery);
 }
コード例 #2
0
        /// <returns>
        ///     type of
        ///     <see cref="Tup.Cobar4Net.Parser.Ast.Expression.Misc.IQueryExpression" />
        ///     or
        ///     <see cref="TableReferences" />
        /// </returns>
        /// <exception cref="System.SqlSyntaxErrorException" />
        private object TrsOrQuery()
        {
            object @ref;
            switch (lexer.Token())
            {
                case MySqlToken.KwSelect:
                {
                    var select = SelectPrimary();
                    return BuildUnionSelect(select);
                }

                case MySqlToken.PuncLeftParen:
                {
                    lexer.NextToken();
                    @ref = TrsOrQuery();
                    Match(MySqlToken.PuncRightParen);
                    if (@ref is IQueryExpression)
                    {
                        if (@ref is DmlSelectStatement)
                        {
                            IQueryExpression rst = BuildUnionSelect((DmlSelectStatement)@ref);
                            if (rst != @ref)
                            {
                                return rst;
                            }
                        }
                        var alias = As();
                        if (alias != null)
                        {
                            @ref = new SubqueryFactor((IQueryExpression)@ref, alias);
                        }
                        else
                        {
                            return @ref;
                        }
                    }
                    // ---- build factor complete---------------
                    @ref = BuildTableReference((TableReference)@ref);
                    // ---- build ref complete---------------
                    break;
                }

                default:
                {
                    @ref = TableReference();
                    break;
                }
            }
            IList<TableReference> list;
            if (lexer.Token() == MySqlToken.PuncComma)
            {
                list = new List<TableReference>();
                list.Add((TableReference)@ref);
                for (; lexer.Token() == MySqlToken.PuncComma;)
                {
                    lexer.NextToken();
                    @ref = TableReference();
                    list.Add((TableReference)@ref);
                }
                return new TableReferences(list);
            }
            list = new List<TableReference>(1);
            list.Add((TableReference)@ref);
            return new TableReferences(list);
        }