public override IASTNode VisitTableFactor(SqlServerCommandParser.TableFactorContext context) { TableFactorSegment result = new TableFactorSegment(); if (null != context.subquery()) { var subquery = (SelectCommand)Visit(context.subquery()); var subquerySegment = new SubQuerySegment(context.subquery().Start.StartIndex, context.subquery().Stop.StopIndex, subquery); var subqueryTableSegment = new SubQueryTableSegment(subquerySegment); if (null != context.alias()) { subqueryTableSegment.SetAlias((AliasSegment)Visit(context.alias())); } result.SetTable(subqueryTableSegment); } if (null != context.tableName()) { SimpleTableSegment table = (SimpleTableSegment)Visit(context.tableName()); if (null != context.alias()) { table.SetAlias((AliasSegment)Visit(context.alias())); } result.SetTable(table); } if (null != context.tableReferences()) { var tableReferences = (CollectionValue <TableReferenceSegment>)Visit(context.tableReferences()); result.TableReferences.AddAll(tableReferences.GetValue()); } return(result); }
public override IASTNode VisitSingleTableClause(SqlServerCommandParser.SingleTableClauseContext context) { SimpleTableSegment result = (SimpleTableSegment)Visit(context.tableName()); if (null != context.alias()) { result.SetAlias((AliasSegment)Visit(context.alias())); } return(result); }