grammar SQLSelect include SQLRowSupport include SQLSelectClause include SQLFromClause include SQLWhereCondition include SQLOrderByClause include SQLLimit include SQLHelpers rule select_expression select from_or_empty where_tree limit_condition_or_empty order_by_condition_or_empty { def query_type :select end def tree result = {} selectables = select.eval result[:limit] = limit_condition_or_empty.eval unless limit_condition_or_empty.eval.nil? result[:order_by] = order_by_condition_or_empty.eval unless order_by_condition_or_empty.eval.nil? result[:from] = from_or_empty.tables if defined? from_or_empty.tables result[:where] = where_tree.eval unless where_tree.eval.nil? result[:columns] = selectables[:columns] unless selectables[:columns].nil? result[:numbers] = selectables[:numbers] unless selectables[:numbers].nil? result[:aliases] = selectables[:aliases] unless selectables[:aliases].nil? result end } end end