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 order_by_condition_or_empty limit_condition_or_empty { def query_type :select end def tree result = {} selectables = select.eval where_tree_val = where_tree.eval result[:where] = where_tree_val unless where_tree_val.nil? order_by_val = order_by_condition_or_empty.eval result[:order_by] = order_by_val unless order_by_val.nil? limit_val = limit_condition_or_empty.eval result[:limit] = limit_val unless limit_val.nil? result[:select] = selectables unless all_selectables_nil?(selectables) result[:aliases] = selectables[:aliases] unless selectables[:aliases].nil? result[:from] = from_or_empty.tables if defined? from_or_empty.tables result end def all_selectables_nil?(selectables) selectables[:columns].nil? && selectables[:numbers].nil? end } end end