This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[2/3] some parser completion renamings


The next patch augments the parser completion code to be able to
complete tag names.

That is, if you type "struct X<TAB>", then only struct tags starting
with "X" will be considered for completion.  This is a minor feature
I've wanted for several years...

This patch prepares the way by renaming a function and a global that are
used for completing via the expression parser.  Currently the names are
specific to completing field names, but it seemed to me that more
generic names are now warranted.

This has no functional changes; while it was regtested as part of the
next patch, just rebuilding it is sufficient.

Tom

	* expression.h (parse_expression_for_completion): Rename
	from parse_field_expression.
	(parse_completion): Rename from in_parse_field.
	* c-exp.y (lex_one_token): Update.
	* completer.c (expression_completer): Update.
	* go-exp.y (lex_one_token): Update.
	* p-exp.y (yylex): Update.
	* parse.c (parse_completion): Rename from in_parse_field.
	(parse_exp_in_context): Update.
	(parse_expression_for_completion): Rename from
	parse_field_expression.  Update.
---
 gdb/c-exp.y      |    6 +++---
 gdb/completer.c  |    2 +-
 gdb/expression.h |    6 +++---
 gdb/go-exp.y     |    4 ++--
 gdb/p-exp.y      |    8 ++++----
 gdb/parse.c      |   13 ++++++-------
 6 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 11eaadb..23195e8 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2354,7 +2354,7 @@ lex_one_token (void)
 
 	lexptr += 2;
 	yylval.opcode = tokentab2[i].opcode;
-	if (in_parse_field && tokentab2[i].token == ARROW)
+	if (parse_completion && tokentab2[i].token == ARROW)
 	  last_was_structop = 1;
 	return tokentab2[i].token;
       }
@@ -2417,7 +2417,7 @@ lex_one_token (void)
       /* Might be a floating point number.  */
       if (lexptr[1] < '0' || lexptr[1] > '9')
 	{
-	  if (in_parse_field)
+	  if (parse_completion)
 	    last_was_structop = 1;
 	  goto symbol;		/* Nope, must be a symbol. */
 	}
@@ -2669,7 +2669,7 @@ lex_one_token (void)
   if (*tokstart == '$')
     return VARIABLE;
 
-  if (in_parse_field && *lexptr == '\0')
+  if (parse_completion && *lexptr == '\0')
     saw_name_at_eof = 1;
   return NAME;
 }
diff --git a/gdb/completer.c b/gdb/completer.c
index 4d6b0d1..7954c2c 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -396,7 +396,7 @@ expression_completer (struct cmd_list_element *ignore,
   fieldname = NULL;
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
-      type = parse_field_expression (text, &fieldname);
+      type = parse_expression_for_completion (text, &fieldname);
     }
   if (except.reason < 0)
     return NULL;
diff --git a/gdb/expression.h b/gdb/expression.h
index 004a60e..1a90cc1 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -98,14 +98,14 @@ struct expression
 
 extern struct expression *parse_expression (char *);
 
-extern struct type *parse_field_expression (char *, char **);
+extern struct type *parse_expression_for_completion (char *, char **);
 
 extern struct expression *parse_exp_1 (char **, CORE_ADDR pc, struct block *,
 				       int);
 
 /* For use by parsers; set if we want to parse an expression and
-   attempt to complete a field name.  */
-extern int in_parse_field;
+   attempt completion.  */
+extern int parse_completion;
 
 /* The innermost context required by the stack and register variables
    we've encountered so far.  To use this, set it to NULL, then call
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index c3171c3..332f2e4 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1124,7 +1124,7 @@ lex_one_token (void)
       /* Might be a floating point number.  */
       if (lexptr[1] < '0' || lexptr[1] > '9')
 	{
-	  if (in_parse_field)
+	  if (parse_completion)
 	    last_was_structop = 1;
 	  goto symbol;		/* Nope, must be a symbol. */
 	}
@@ -1311,7 +1311,7 @@ lex_one_token (void)
   if (*tokstart == '$')
     return DOLLAR_VARIABLE;
 
-  if (in_parse_field && *lexptr == '\0')
+  if (parse_completion && *lexptr == '\0')
     saw_name_at_eof = 1;
   return NAME;
 }
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 5d344a4..4c0cc57 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -1237,7 +1237,7 @@ yylex (void)
       /* Might be a floating point number.  */
       if (lexptr[1] < '0' || lexptr[1] > '9')
 	{
-	  if (in_parse_field)
+	  if (parse_completion)
 	    last_was_structop = 1;
 	  goto symbol;		/* Nope, must be a symbol.  */
 	}
@@ -1529,7 +1529,7 @@ yylex (void)
 
     if (search_field && current_type)
       is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
-    if (is_a_field || in_parse_field)
+    if (is_a_field || parse_completion)
       sym = NULL;
     else
       sym = lookup_symbol (tmp, expression_context_block,
@@ -1544,7 +1544,7 @@ yylex (void)
          }
        if (search_field && current_type)
 	 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
-       if (is_a_field || in_parse_field)
+       if (is_a_field || parse_completion)
 	 sym = NULL;
        else
 	 sym = lookup_symbol (tmp, expression_context_block,
@@ -1572,7 +1572,7 @@ yylex (void)
           }
        if (search_field && current_type)
 	 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
-       if (is_a_field || in_parse_field)
+       if (is_a_field || parse_completion)
 	 sym = NULL;
        else
 	 sym = lookup_symbol (tmp, expression_context_block,
diff --git a/gdb/parse.c b/gdb/parse.c
index afe1c18..d927ca2 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -81,9 +81,8 @@ char *prev_lexptr;
 int paren_depth;
 int comma_terminates;
 
-/* True if parsing an expression to find a field reference.  This is
-   only used by completion.  */
-int in_parse_field;
+/* True if parsing an expression to attempt completion.  */
+int parse_completion;
 
 /* The index of the last struct expression directly before a '.' or
    '->'.  This is set when parsing and is only used when completing a
@@ -1190,7 +1189,7 @@ parse_exp_in_context (char **stringptr, CORE_ADDR pc, struct block *block,
     }
   if (except.reason < 0)
     {
-      if (! in_parse_field)
+      if (! parse_completion)
 	{
 	  xfree (expout);
 	  throw_exception (except);
@@ -1244,7 +1243,7 @@ parse_expression (char *string)
    *NAME must be freed by the caller.  */
 
 struct type *
-parse_field_expression (char *string, char **name)
+parse_expression_for_completion (char *string, char **name)
 {
   struct expression *exp = NULL;
   struct value *val;
@@ -1253,10 +1252,10 @@ parse_field_expression (char *string, char **name)
 
   TRY_CATCH (except, RETURN_MASK_ERROR)
     {
-      in_parse_field = 1;
+      parse_completion = 1;
       exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp);
     }
-  in_parse_field = 0;
+  parse_completion = 0;
   if (except.reason < 0 || ! exp)
     return NULL;
   if (expout_last_struct == -1)
-- 
1.7.7.6


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