This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] Extend parse rules for const, volatile


Michael Snyder <msnyder@cygnus.com> writes:

> [Jim, tapping you as someone knowledgeable]
>
> The following change extends gdb's expression parser for types, 
> so that in addition to accepting casts of the form
> 	(char const *)
> it will also accept casts of the form
> 	(char * const)



>
> Note that it still doesn't do anything with the "const"
> or "volatile" information -- it merely accepts the expr.2001-09-17  Michael Snyder  <msnyder@redhat.com>
>
> 	* c-exp.y (ptype): New rules for CONST_KEYWORD,
> 	  VOLATILE_KEYWORD.

Why not just factor them, and get:

ptype	:	typebase
	/* "const" and "volatile" are curently ignored.  A type qualifier
	   before the type is currently handled in the typebase rule.
	   The reason for recognizing these here (shift/reduce conflicts)
	   might be obsolete now that some pointer to member rules have
	   been deleted.  */
	|	typebase const_or_volatile abs_decl const_or_volatile
		{ $$ = follow_types ($1); }
	;
const_and_volatile: 	CONST_KEYWORD VOLATILE_KEYWORD
	| 		VOLATILE_KEYWORD CONST_KEYWORD
	;
const_or_volatile:  	const_and_volatile 
	| 		CONST_KEYWORD
	| 		VOLATILE_KEYWORD
	|
	;


>
> Index: c-exp.y
> ===================================================================
> RCS file: /cvs/src/src/gdb/c-exp.y,v
> retrieving revision 1.4
> diff -c -3 -p -r1.4 c-exp.y
> *** c-exp.y	2001/03/06 08:21:06	1.4
> --- c-exp.y	2001/09/17 22:47:36
> *************** ptype	:	typebase
> *** 731,737 ****
> --- 731,741 ----
>   		{ $$ = follow_types ($1); }
>   	|	typebase CONST_KEYWORD abs_decl
>   		{ $$ = follow_types ($1); }
> + 	|	typebase abs_decl CONST_KEYWORD
> + 		{ $$ = follow_types ($1); }
>   	|	typebase VOLATILE_KEYWORD abs_decl
> + 		{ $$ = follow_types ($1); }
> + 	|	typebase abs_decl VOLATILE_KEYWORD
>   		{ $$ = follow_types ($1); }
>   	;
>   

-- 
"All the plants in my house are dead -- I shot them last night.
I was torturing them by watering them with ice cubes.
"-Steven Wright


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]