* top.c (simplified_command_loop): Remove.
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index b56613fa98fbfb237da7664d1739b9f89089d73e..b5207212f7d2e2ff582632deb37568bcd5ec52d2 100644 (file)
@@ -1,6 +1,6 @@
 /* YACC parser for C expressions, for GDB.
    Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2003, 2004
+   1998, 1999, 2000, 2003, 2004, 2006, 2007, 2008
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -53,6 +53,7 @@ Boston, MA 02110-1301, USA.  */
 #include "charset.h"
 #include "block.h"
 #include "cp-support.h"
+#include "dfp.h"
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
@@ -131,6 +132,10 @@ void yyerror (char *);
       DOUBLEST dval;
       struct type *type;
     } typed_val_float;
+    struct {
+      gdb_byte val[16];
+      struct type *type;
+    } typed_val_decfloat;
     struct symbol *sym;
     struct type *tval;
     struct stoken sval;
@@ -163,6 +168,7 @@ static int parse_number (char *, int, int, YYSTYPE *);
 
 %token <typed_val_int> INT
 %token <typed_val_float> FLOAT
+%token <typed_val_decfloat> DECFLOAT
 
 /* Both NAME and TYPENAME tokens represent symbols in the input,
    and both convey their data as strings.
@@ -497,6 +503,13 @@ exp        :       FLOAT
                          write_exp_elt_opcode (OP_DOUBLE); }
        ;
 
+exp    :       DECFLOAT
+                       { write_exp_elt_opcode (OP_DECFLOAT);
+                         write_exp_elt_type ($1.type);
+                         write_exp_elt_decfloatcst ($1.val);
+                         write_exp_elt_opcode (OP_DECFLOAT); }
+       ;
+
 exp    :       variable
        ;
 
@@ -790,7 +803,7 @@ func_mod:   '(' ')'
                        { free ($2); $$ = 0; }
        ;
 
-/* We used to try to recognize more pointer to member types here, but
+/* We used to try to recognize pointer to member types here, but
    that didn't work (shift/reduce conflicts meant that these rules never
    got executed).  The problem is that
      int (foo::bar::baz::bizzle)
@@ -799,8 +812,6 @@ func_mod:   '(' ')'
    is a pointer to member type.  Stroustrup loses again!  */
 
 type   :       ptype
-       |       typebase COLONCOLON '*'
-                       { $$ = lookup_member_type (builtin_type (current_gdbarch)->builtin_int, $1); }
        ;
 
 typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
@@ -1080,7 +1091,41 @@ parse_number (p, len, parsed_float, putithere)
       char saved_char = p[len];
 
       p[len] = 0;      /* null-terminate the token */
-      num = sscanf (p, DOUBLEST_FORMAT "%s",
+
+      /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
+         point.  Return DECFLOAT.  */
+
+      if (p[len - 2] == 'd' && p[len - 1] == 'f')
+       {
+         p[len - 2] = '\0';
+         putithere->typed_val_decfloat.type
+           = builtin_type (current_gdbarch)->builtin_decfloat;
+         decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
+         p[len] = saved_char;
+         return (DECFLOAT);
+       }
+
+      if (p[len - 2] == 'd' && p[len - 1] == 'd')
+       {
+         p[len - 2] = '\0';
+         putithere->typed_val_decfloat.type
+           = builtin_type (current_gdbarch)->builtin_decdouble;
+         decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
+         p[len] = saved_char;
+         return (DECFLOAT);
+       }
+
+      if (p[len - 2] == 'd' && p[len - 1] == 'l')
+       {
+         p[len - 2] = '\0';
+         putithere->typed_val_decfloat.type
+           = builtin_type (current_gdbarch)->builtin_declong;
+         decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
+         p[len] = saved_char;
+         return (DECFLOAT);
+       }
+
+      num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%s",
                    &putithere->typed_val_float.dval, s);
       p[len] = saved_char;     /* restore the input stream */
 
@@ -1099,9 +1144,13 @@ parse_number (p, len, parsed_float, putithere)
            putithere->typed_val_float.type = 
              builtin_type (current_gdbarch)->builtin_long_double;
          else
-           return ERROR;
+           {
+             free (s);
+             return ERROR;
+           }
        }
 
+      free (s);
       return FLOAT;
     }
 
@@ -1197,16 +1246,16 @@ parse_number (p, len, parsed_float, putithere)
      shift it right and see whether anything remains.  Note that we
      can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
      operation, because many compilers will warn about such a shift
-     (which always produces a zero result).  Sometimes TARGET_INT_BIT
-     or TARGET_LONG_BIT will be that big, sometimes not.  To deal with
+     (which always produces a zero result).  Sometimes gdbarch_int_bit
+     or gdbarch_long_bit will be that big, sometimes not.  To deal with
      the case where it is we just always shift the value more than
      once, with fewer bits each time.  */
 
   un = (ULONGEST)n >> 2;
   if (long_p == 0
-      && (un >> (TARGET_INT_BIT - 2)) == 0)
+      && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
     {
-      high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
+      high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
 
       /* A large decimal (not hex or octal) constant (between INT_MAX
         and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1218,20 +1267,21 @@ parse_number (p, len, parsed_float, putithere)
       signed_type = builtin_type (current_gdbarch)->builtin_int;
     }
   else if (long_p <= 1
-          && (un >> (TARGET_LONG_BIT - 2)) == 0)
+          && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
     {
-      high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
+      high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
       unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long;
       signed_type = builtin_type (current_gdbarch)->builtin_long;
     }
   else
     {
       int shift;
-      if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
+      if (sizeof (ULONGEST) * HOST_CHAR_BIT 
+         < gdbarch_long_long_bit (current_gdbarch))
        /* A long long does not fit in a LONGEST.  */
        shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
       else
-       shift = (TARGET_LONG_LONG_BIT - 1);
+       shift = (gdbarch_long_long_bit (current_gdbarch) - 1);
       high_bit = (ULONGEST) 1 << shift;
       unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long;
       signed_type = builtin_type (current_gdbarch)->builtin_long_long;
@@ -1304,10 +1354,8 @@ yylex ()
   int tempbufindex;
   static char *tempbuf;
   static int tempbufsize;
-  struct symbol * sym_class = NULL;
   char * token_string = NULL;
   int class_prefix = 0;
-  int unquoted_expr;
    
  retry:
 
@@ -1323,7 +1371,6 @@ yylex ()
     }
 
   prev_lexptr = lexptr;
-  unquoted_expr = 1;
 
   tokstart = lexptr;
   /* See if it is a special token of length 3.  */
@@ -1395,7 +1442,6 @@ yylex ()
          if (namelen > 2)
            {
              lexptr = tokstart + namelen;
-              unquoted_expr = 0;
              if (lexptr[-1] != '\'')
                error ("Unmatched single quote.");
              namelen -= 2;
@@ -1694,30 +1740,6 @@ yylex ()
       return VARIABLE;
     }
   
-  /* Look ahead and see if we can consume more of the input
-     string to get a reasonable class/namespace spec or a
-     fully-qualified name.  This is a kludge to get around the
-     HP aCC compiler's generation of symbol names with embedded
-     colons for namespace and nested classes. */
-
-  /* NOTE: carlton/2003-09-24: I don't entirely understand the
-     HP-specific code, either here or in linespec.  Having said that,
-     I suspect that we're actually moving towards their model: we want
-     symbols whose names are fully qualified, which matches the
-     description above.  */
-  if (unquoted_expr)
-    {
-      /* Only do it if not inside single quotes */ 
-      sym_class = parse_nested_classes_for_hpacc (yylval.sval.ptr, yylval.sval.length,
-                                                  &token_string, &class_prefix, &lexptr);
-      if (sym_class)
-        {
-          /* Replace the current token with the bigger one we found */ 
-          yylval.sval.ptr = token_string;
-          yylval.sval.length = strlen (token_string);
-        }
-    }
-  
   /* Use token-type BLOCKNAME for symbols that happen to be defined as
      functions or symtabs.  If this is not so, then ...
      Use token-type TYPENAME for symbols that happen to be defined
This page took 0.030082 seconds and 4 git commands to generate.