public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix completion for pascal language
@ 2013-11-28  2:42 Pierre Muller
  2013-12-06  8:43 ` Pierre Muller
  0 siblings, 1 reply; 2+ messages in thread
From: Pierre Muller @ 2013-11-28  2:42 UTC (permalink / raw)
  To: gdb-patches

  Pascal language completer is broken 
since a long time...

  This patch allows me to get it to work again.

  If there are no objections, I will commit this is a few days,
as pascal language maintainer.
  But of course, all comments are welcome.

Pierre Muller

PS: Is there a 'standard' way to specify lexical rules
in Changelog's?

ChangeLog entry:

2013-11-27  Pierre Muller  <muller@sourceware.org>

        Fix completion for pascal language.
        * p-exp.y (exp : field_exp name): Do not call
mark_struct_expression.
        (exp : field_exp name COMPLETE): New rule.
        (exp : SIZEOF): Set correct current_type.
        (last_was_structop): Remove static variable.
        (yylex): Remove saw_structop local variable.
        Adapt code to removal of variables above.

diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 0120e22..7b15dce 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -316,8 +316,7 @@ exp :       field_exp FIELDNAME


 exp    :       field_exp name
-                       { mark_struct_expression ();
-                         write_exp_elt_opcode (STRUCTOP_STRUCT);
+                       { write_exp_elt_opcode (STRUCTOP_STRUCT);
                          write_exp_string ($2);
                          write_exp_elt_opcode (STRUCTOP_STRUCT);
                          search_field = 0;
@@ -332,7 +331,12 @@ exp        :       field_exp name
                            }
                        }
        ;
-
+exp    :       field_exp  name COMPLETE
+                       { mark_struct_expression ();
+                         write_exp_elt_opcode (STRUCTOP_STRUCT);
+                         write_exp_string ($2);
+                         write_exp_elt_opcode (STRUCTOP_STRUCT); }
+       ;
 exp    :       field_exp COMPLETE
                        { struct stoken s;
                          mark_struct_expression ();
@@ -581,13 +585,15 @@ exp       :       VARIABLE
 exp    :       SIZEOF '(' type ')'     %prec UNARY
                        { write_exp_elt_opcode (OP_LONG);
                          write_exp_elt_type (parse_type->builtin_int);
+                         current_type = parse_type->builtin_int;
                          CHECK_TYPEDEF ($3);
                          write_exp_elt_longcst ((LONGEST) TYPE_LENGTH
($3));
                          write_exp_elt_opcode (OP_LONG); }
        ;

 exp    :       SIZEOF  '(' exp ')'      %prec UNARY
-                       { write_exp_elt_opcode (UNOP_SIZEOF); }
+                       { write_exp_elt_opcode (UNOP_SIZEOF);
+                         current_type = parse_type->builtin_int; }

 exp    :       STRING
                        { /* C strings are converted into array constants
with
@@ -1120,11 +1126,6 @@ uptok (const char *tokstart, int namelen)
   return uptokstart;
 }

-/* This is set if the previously-returned token was a structure
-   operator  '.'.  This is used only when parsing to
-   do field name completion.  */
-static int last_was_structop;
-
 /* Read one token, getting characters through lexptr.  */

 static int
@@ -1139,9 +1140,7 @@ yylex (void)
   int explen, tempbufindex;
   static char *tempbuf;
   static int tempbufsize;
-  int saw_structop = last_was_structop;

-  last_was_structop = 0;
  retry:

   prev_lexptr = lexptr;
@@ -1178,7 +1177,7 @@ yylex (void)
   switch (c = *tokstart)
     {
     case 0:
-      if (saw_structop && search_field)
+      if (search_field && parse_completion)
        return COMPLETE;
       else
        return 0;
@@ -1243,8 +1242,6 @@ yylex (void)
       /* Might be a floating point number.  */
       if (lexptr[1] < '0' || lexptr[1] > '9')
        {
-         if (parse_completion)
-           last_was_structop = 1;
          goto symbol;          /* Nope, must be a symbol.  */
        }

@@ -1535,7 +1532,7 @@ yylex (void)

     if (search_field && current_type)
       is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
-    if (is_a_field || parse_completion)
+    if (is_a_field)
       sym = NULL;
     else
       sym = lookup_symbol (tmp, expression_context_block,
@@ -1550,7 +1547,7 @@ yylex (void)
          }
        if (search_field && current_type)
         is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) !=
NULL);
-       if (is_a_field || parse_completion)
+       if (is_a_field)
         sym = NULL;
        else
         sym = lookup_symbol (tmp, expression_context_block,
@@ -1572,7 +1569,7 @@ yylex (void)
           }
        if (search_field && current_type)
         is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) !=
NULL);
-       if (is_a_field || parse_completion)
+       if (is_a_field)
         sym = NULL;
        else
         sym = lookup_symbol (tmp, expression_context_block,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] Fix completion for pascal language
  2013-11-28  2:42 [PATCH] Fix completion for pascal language Pierre Muller
@ 2013-12-06  8:43 ` Pierre Muller
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre Muller @ 2013-12-06  8:43 UTC (permalink / raw)
  To: gdb-patches



> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pierre Muller
> Envoyé : jeudi 28 novembre 2013 02:23
> À : gdb-patches@sourceware.org
> Objet : [PATCH] Fix completion for pascal language
> 
>   Pascal language completer is broken
> since a long time...
> 
>   This patch allows me to get it to work again.
> 
>   If there are no objections, I will commit this is a few days,
> as pascal language maintainer.
>   But of course, all comments are welcome.
> 
> Pierre Muller
> 
> PS: Is there a 'standard' way to specify lexical rules
> in Changelog's?
> 
> ChangeLog entry:
> 
> 2013-11-27  Pierre Muller  <muller@sourceware.org>
> 
>         Fix completion for pascal language.
>         * p-exp.y (exp : field_exp name): Do not call
mark_struct_expression.
>         (exp : field_exp name COMPLETE): New rule.
>         (exp : SIZEOF): Set correct current_type.
>         (last_was_structop): Remove static variable.
>         (yylex): Remove saw_structop local variable.
>         Adapt code to removal of variables above.


  As there was no reaction to that email,
I have just committed this patch.

  This is the first time I push a patch using git,
I hope I did nothing wrong...


Pierre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-06  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-28  2:42 [PATCH] Fix completion for pascal language Pierre Muller
2013-12-06  8:43 ` Pierre Muller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).