* target.c (debug_print_register): New function. Handle oversize
[binutils-gdb.git] / gdb / p-exp.y
index d786af9f6e0efb5374458d2c2316e8d7ac8ca250..8efb45019f491efa55b5d5260fce4ac23d155fce 100644 (file)
@@ -37,8 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    too messy, particularly when such includes can be inserted at random
    times by the parser generator.  */
 
-/* FIXME: there are still 21 shift/reduce conflicts
-   Other known bugs or limitations:
+/* Known bugs or limitations:
     - pascal string operations are not supported at all.
     - there are some problems with boolean types.
     - Pascal type hexadecimal constants are not supported
@@ -212,6 +211,7 @@ parse_number (char *, int, int, YYSTYPE *);
 %left '*' '/'
 %right UNARY INCREMENT DECREMENT
 %right ARROW '.' '[' '('
+%left '^'
 %token <ssym> BLOCKNAME
 %type <bval> block
 %left COLONCOLON
@@ -947,6 +947,8 @@ yylex ()
 
  retry:
 
+  prev_lexptr = lexptr;
+
   tokstart = lexptr;
   explen = strlen (lexptr);
   /* See if it is a special token of length 3.  */
@@ -1299,21 +1301,55 @@ yylex ()
                         VAR_NAMESPACE,
                         &is_a_field_of_this,
                         (struct symtab **) NULL);
-    /* second chance uppercased ! */
-    if (!sym)
+    /* second chance uppercased (as Free Pascal does).  */
+    if (!sym && !is_a_field_of_this)
       {
-       for (i = 0;i <= namelen;i++)
+       for (i = 0; i <= namelen; i++)
          {
-           if ((tmp[i]>='a' && tmp[i]<='z'))
+           if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
              tmp[i] -= ('a'-'A');
-           /* I am not sure that copy_name gives excatly the same result ! */
-           if ((tokstart[i]>='a' && tokstart[i]<='z'))
-             tokstart[i] -= ('a'-'A');
          }
-        sym = lookup_symbol (tmp, expression_context_block,
-                        VAR_NAMESPACE,
-                        &is_a_field_of_this,
-                        (struct symtab **) NULL);
+       sym = lookup_symbol (tmp, expression_context_block,
+                        VAR_NAMESPACE,
+                        &is_a_field_of_this,
+                        (struct symtab **) NULL);
+       if (sym || is_a_field_of_this)
+         for (i = 0; i <= namelen; i++)
+           {
+             if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
+               tokstart[i] -= ('a'-'A');
+           }
+      }
+    /* Third chance Capitalized (as GPC does).  */
+    if (!sym && !is_a_field_of_this)
+      {
+       for (i = 0; i <= namelen; i++)
+         {
+           if (i == 0)
+             {
+              if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
+                tmp[i] -= ('a'-'A');
+             }
+           else
+           if ((tmp[i] >= 'A' && tmp[i] <= 'Z'))
+             tmp[i] -= ('A'-'a');
+          }
+       sym = lookup_symbol (tmp, expression_context_block,
+                         VAR_NAMESPACE,
+                         &is_a_field_of_this,
+                         (struct symtab **) NULL);
+        if (sym || is_a_field_of_this)
+          for (i = 0; i <= namelen; i++)
+            {
+              if (i == 0)
+                {
+                  if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
+                    tokstart[i] -= ('a'-'A');
+                }
+              else
+                if ((tokstart[i] >= 'A' && tokstart[i] <= 'Z'))
+                  tokstart[i] -= ('A'-'a');
+            }
       }
     /* Call lookup_symtab, not lookup_partial_symtab, in case there are
        no psymtabs (coff, xcoff, or some future change to blow away the
@@ -1447,5 +1483,8 @@ void
 yyerror (msg)
      char *msg;
 {
+  if (prev_lexptr)
+    lexptr = prev_lexptr;
+
   error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }