[PATCHv2,3/4] gdb: Add new parser rule for structure field names

Message ID cb6c1de899e25f5ec7c3283f7d495b84cb2e0fc4.1545172667.git.andrew.burgess@embecosm.com
State New, archived
Headers

Commit Message

Andrew Burgess Dec. 18, 2018, 10:40 p.m. UTC
  Introduces a new rule in c-exp.y for matching structure field names.

This is a restructure in preparation for the next commit, this commit
shouldn't result in any user visible changes.

gdb/ChangeLog:

	* c-exp.y (field_name): New %token, and new rule.
	(exp): Replace uses of 'name' with 'field_name' where appropriate.
---
 gdb/ChangeLog |  5 +++++
 gdb/c-exp.y   | 13 ++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)
  

Comments

Tom Tromey Dec. 21, 2018, 4:38 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> Introduces a new rule in c-exp.y for matching structure field names.
Andrew> This is a restructure in preparation for the next commit, this commit
Andrew> shouldn't result in any user visible changes.

Andrew> gdb/ChangeLog:

Andrew> 	* c-exp.y (field_name): New %token, and new rule.
Andrew> 	(exp): Replace uses of 'name' with 'field_name' where appropriate.

This is ok.  Thanks.

Tom
  

Patch

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index d2198b1fdf7..b6b57c8c4d4 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -156,7 +156,7 @@  static void c_print_token (FILE *file, int type, YYSTYPE value);
 %token <voidval> COMPLETE
 %token <tsym> TYPENAME
 %token <theclass> CLASSNAME	/* ObjC Class name */
-%type <sval> name
+%type <sval> name field_name
 %type <svec> string_exp
 %type <ssym> name_not_typename
 %type <tsym> type_name
@@ -312,13 +312,13 @@  exp	:	ALIGNOF '(' type_exp ')'	%prec UNARY
 			{ write_exp_elt_opcode (pstate, UNOP_ALIGNOF); }
 	;
 
-exp	:	exp ARROW name
+exp	:	exp ARROW field_name
 			{ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
 			  write_exp_string (pstate, $3);
 			  write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
 	;
 
-exp	:	exp ARROW name COMPLETE
+exp	:	exp ARROW field_name COMPLETE
 			{ mark_struct_expression (pstate);
 			  write_exp_elt_opcode (pstate, STRUCTOP_PTR);
 			  write_exp_string (pstate, $3);
@@ -360,13 +360,13 @@  exp	:	exp ARROW_STAR exp
 			{ write_exp_elt_opcode (pstate, STRUCTOP_MPTR); }
 	;
 
-exp	:	exp '.' name
+exp	:	exp '.' field_name
 			{ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
 			  write_exp_string (pstate, $3);
 			  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
 	;
 
-exp	:	exp '.' name COMPLETE
+exp	:	exp '.' field_name COMPLETE
 			{ mark_struct_expression (pstate);
 			  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
 			  write_exp_string (pstate, $3);
@@ -1644,6 +1644,9 @@  oper:	OPERATOR NEW
 	;
 
 
+field_name
+	:	name
+	;
 
 name	:	NAME { $$ = $1.stoken; }
 	|	BLOCKNAME { $$ = $1.stoken; }