Target FP: Use target format throughout expression parsing
[deliverable/binutils-gdb.git] / gdb / ada-exp.y
index e64463eacb236f402448240802ab1c0e2d76a73f..3014a311075633d9865acb201c1f23c4f333a781 100644 (file)
@@ -1,5 +1,5 @@
 /* YACC parser for Ada expressions, for GDB.
-   Copyright (C) 1986-2015 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 #define parse_type(ps) builtin_type (parse_gdbarch (ps))
 
-/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
-   as well as gratuitiously global symbol names, so we can have multiple
-   yacc generated parsers in gdb.  These are only the variables
-   produced by yacc.  If other parser generators (bison, byacc, etc) produce
-   additional global names that conflict at link time, then those parser
-   generators need to be fixed instead of adding those names to this list.  */
-
-/* NOTE: This is clumsy, especially since BISON and FLEX provide --prefix
-   options.  I presume we are maintaining it to accommodate systems
-   without BISON?  (PNH) */
-
-#define        yymaxdepth ada_maxdepth
-/* ada_parse calls this after initialization */
-#define        yyparse ada_parse_internal
-#define        yylex   ada_lex
-#define        yyerror ada_error
-#define        yylval  ada_lval
-#define        yychar  ada_char
-#define        yydebug ada_debug
-#define        yypact  ada_pact
-#define        yyr1    ada_r1
-#define        yyr2    ada_r2
-#define        yydef   ada_def
-#define        yychk   ada_chk
-#define        yypgo   ada_pgo
-#define        yyact   ada_act
-#define        yyexca  ada_exca
-#define yyerrflag ada_errflag
-#define yynerrs        ada_nerrs
-#define        yyps    ada_ps
-#define        yypv    ada_pv
-#define        yys     ada_s
-#define        yy_yys  ada_yys
-#define        yystate ada_state
-#define        yytmp   ada_tmp
-#define        yyv     ada_v
-#define        yy_yyv  ada_yyv
-#define        yyval   ada_val
-#define        yylloc  ada_lloc
-#define yyreds ada_reds                /* With YYDEBUG defined */
-#define yytoks ada_toks                /* With YYDEBUG defined */
-#define yyname ada_name                /* With YYDEBUG defined */
-#define yyrule ada_rule                /* With YYDEBUG defined */
-#define yyss   ada_yyss
-#define yysslim        ada_yysslim
-#define yyssp  ada_yyssp
-#define yystacksize ada_yystacksize
-#define yyvs   ada_yyvs
-#define yyvsp  ada_yyvsp
-
-#ifndef YYDEBUG
-#define        YYDEBUG 1               /* Default to yydebug support */
-#endif
-
-#define YYFPRINTF parser_fprintf
+/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
+   etc).  */
+#define GDB_YY_REMAP_PREFIX ada_
+#include "yy-remap.h"
 
 struct name_info {
   struct symbol *sym;
@@ -128,7 +77,7 @@ int yyparse (void);
 
 static int yylex (void);
 
-void yyerror (char *);
+void yyerror (const char *);
 
 static void write_int (struct parser_state *, LONGEST, struct type *);
 
@@ -157,10 +106,6 @@ static struct type *type_long (struct parser_state *);
 
 static struct type *type_long_long (struct parser_state *);
 
-static struct type *type_float (struct parser_state *);
-
-static struct type *type_double (struct parser_state *);
-
 static struct type *type_long_double (struct parser_state *);
 
 static struct type *type_char (struct parser_state *);
@@ -179,7 +124,7 @@ static struct type *type_system_address (struct parser_state *);
       struct type *type;
     } typed_val;
     struct {
-      DOUBLEST dval;
+      gdb_byte val[16];
       struct type *type;
     } typed_val_float;
     struct type *tval;
@@ -604,10 +549,10 @@ primary   :       CHARLIT
        ;
 
 primary        :       FLOAT
-                       { write_exp_elt_opcode (pstate, OP_DOUBLE);
+                       { write_exp_elt_opcode (pstate, OP_FLOAT);
                          write_exp_elt_type (pstate, $1.type);
-                         write_exp_elt_dblcst (pstate, $1.dval);
-                         write_exp_elt_opcode (pstate, OP_DOUBLE);
+                         write_exp_elt_floatcst (pstate, $1.val);
+                         write_exp_elt_opcode (pstate, OP_FLOAT);
                        }
        ;
 
@@ -784,10 +729,8 @@ static struct obstack temp_parse_space;
 int
 ada_parse (struct parser_state *par_state)
 {
-  int result;
-  struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
-
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
@@ -796,13 +739,11 @@ ada_parse (struct parser_state *par_state)
   obstack_free (&temp_parse_space, NULL);
   obstack_init (&temp_parse_space);
 
-  result = yyparse ();
-  do_cleanups (c);
-  return result;
+  return yyparse ();
 }
 
 void
-yyerror (char *msg)
+yyerror (const char *msg)
 {
   error (_("Error in expression, near `%s'."), lexptr);
 }
@@ -1494,18 +1435,6 @@ type_long_long (struct parser_state *par_state)
   return parse_type (par_state)->builtin_long_long;
 }
 
-static struct type *
-type_float (struct parser_state *par_state)
-{
-  return parse_type (par_state)->builtin_float;
-}
-
-static struct type *
-type_double (struct parser_state *par_state)
-{
-  return parse_type (par_state)->builtin_double;
-}
-
 static struct type *
 type_long_double (struct parser_state *par_state)
 {
@@ -1535,9 +1464,6 @@ type_system_address (struct parser_state *par_state)
   return  type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
 }
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_ada_exp;
-
 void
 _initialize_ada_exp (void)
 {
This page took 0.026973 seconds and 4 git commands to generate.