[GRASS-dev] adding 'desc' to dbf sql driver

Glynn Clements glynn at gclements.plus.com
Tue Oct 10 00:51:57 EDT 2006


Moritz Lennert wrote:

> > Looks good to me. In the yac.y patch, you don't need to duplicate the
> > code for ORDER BY NAME and ORDER BY NAME ASC.
> 
> How do I take care of the case where neither asc nor desc are given in 
> the sql ? This should default to asc, but this:
> 
> +y_order_asc:
> +               NAME | NAME ASC                         { 
> sqpOrderColumn( $1, SORT_ASC ); }
> 
> does not work, i.e. results of 'order by' without asc are not sorted.
> 
> So how does this need to be formulated ?

y_order_asc:
		NAME		{ sqpOrderColumn( $1, SORT_ASC ); }
	|	NAME ASC	{ sqpOrderColumn( $1, SORT_ASC ); }
	;

The | splits a definition into separate rules. Each rule has its own
action; if none is given, the default action is "{ $$ = $1; }". So, in
your original version, the specified action only applied to the
"NAME ASC" rule, while "NAME" got the default action.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list