Further fix the documentation in struct quick_symbol_functions
[deliverable/binutils-gdb.git] / gdb / m2-exp.y
index 420c287ba7c0eca441aa35c0935a186422f5e385..1809af8ee54d1b9a9b19fc87adef045512773e20 100644 (file)
@@ -1,25 +1,23 @@
 /* YACC grammar for Modula-2 expressions, for GDB.
    Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999,
-   2000, 2007, 2008 Free Software Foundation, Inc.
+   2000, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
    Generated from expread.y (now c-exp.y) and contributed by the Department
    of Computer Science at the State University of New York at Buffalo, 1991.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Parse a Modula-2 expression from text in a string,
    and return the result as a  struct expression  pointer.
@@ -36,7 +34,7 @@ Boston, MA 02110-1301, USA.  */
    generator.  Doing this with #defines and trying to control the interaction
    with include files (<malloc.h> and <stdlib.h> for example) just became
    too messy, particularly when such includes can be inserted at random
-   times by the parser generator. */
+   times by the parser generator.  */
    
 %{
 
@@ -52,12 +50,15 @@ Boston, MA 02110-1301, USA.  */
 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+#define parse_m2_type builtin_m2_type (parse_gdbarch)
+
 /* 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.  Note that 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. */
+   generators need to be fixed instead of adding those names to this list.  */
 
 #define        yymaxdepth m2_maxdepth
 #define        yyparse m2_parse
@@ -118,7 +119,7 @@ static char *make_qualname (char *, char *);
 
 static int parse_number (int);
 
-/* The sign of the number being parsed. */
+/* The sign of the number being parsed.  */
 static int number_sign = 1;
 
 /* The block that the module specified by the qualifer on an identifer is
@@ -264,7 +265,7 @@ exp         :       MIN_FUNC '(' type ')'
 exp    :       MAX_FUNC '(' type ')'
                        { write_exp_elt_opcode (UNOP_MAX);
                          write_exp_elt_type ($3);
-                         write_exp_elt_opcode (UNOP_MIN); }
+                         write_exp_elt_opcode (UNOP_MAX); }
        ;
 
 exp    :       FLOAT_FUNC '(' exp ')'
@@ -328,21 +329,21 @@ exp       :       set
        ;
 
 exp    :       exp IN set
-                       { error("Sets are not implemented.");}
+                       { error (_("Sets are not implemented."));}
        ;
 
 exp    :       INCL '(' exp ',' exp ')'
-                       { error("Sets are not implemented.");}
+                       { error (_("Sets are not implemented."));}
        ;
 
 exp    :       EXCL '(' exp ',' exp ')'
-                       { error("Sets are not implemented.");}
+                       { error (_("Sets are not implemented."));}
        ;
 
 set    :       '{' arglist '}'
-                       { error("Sets are not implemented.");}
+                       { error (_("Sets are not implemented."));}
        |       type '{' arglist '}'
-                       { error("Sets are not implemented.");}
+                       { error (_("Sets are not implemented."));}
        ;
 
 
@@ -497,7 +498,7 @@ exp :       M2_FALSE
 
 exp    :       INT
                        { write_exp_elt_opcode (OP_LONG);
-                         write_exp_elt_type (builtin_type_m2_int);
+                         write_exp_elt_type (parse_m2_type->builtin_int);
                          write_exp_elt_longcst ((LONGEST) $1);
                          write_exp_elt_opcode (OP_LONG); }
        ;
@@ -505,7 +506,7 @@ exp :       INT
 exp    :       UINT
                        {
                          write_exp_elt_opcode (OP_LONG);
-                         write_exp_elt_type (builtin_type_m2_card);
+                         write_exp_elt_type (parse_m2_type->builtin_card);
                          write_exp_elt_longcst ((LONGEST) $1);
                          write_exp_elt_opcode (OP_LONG);
                        }
@@ -513,7 +514,7 @@ exp :       UINT
 
 exp    :       CHAR
                        { write_exp_elt_opcode (OP_LONG);
-                         write_exp_elt_type (builtin_type_m2_char);
+                         write_exp_elt_type (parse_m2_type->builtin_char);
                          write_exp_elt_longcst ((LONGEST) $1);
                          write_exp_elt_opcode (OP_LONG); }
        ;
@@ -521,7 +522,7 @@ exp :       CHAR
 
 exp    :       FLOAT
                        { write_exp_elt_opcode (OP_DOUBLE);
-                         write_exp_elt_type (builtin_type_m2_real);
+                         write_exp_elt_type (parse_m2_type->builtin_real);
                          write_exp_elt_dblcst ($1);
                          write_exp_elt_opcode (OP_DOUBLE); }
        ;
@@ -531,7 +532,7 @@ exp :       variable
 
 exp    :       SIZE '(' type ')'       %prec UNARY
                        { write_exp_elt_opcode (OP_LONG);
-                         write_exp_elt_type (builtin_type_int);
+                         write_exp_elt_type (parse_type->builtin_int);
                          write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
                          write_exp_elt_opcode (OP_LONG); }
        ;
@@ -542,7 +543,7 @@ exp :       STRING
                          write_exp_elt_opcode (OP_M2_STRING); }
        ;
 
-/* This will be used for extensions later.  Like adding modules. */
+/* This will be used for extensions later.  Like adding modules.  */
 block  :       fblock  
                        { $$ = SYMBOL_BLOCK_VALUE($1); }
        ;
@@ -561,7 +562,7 @@ fblock      :       block COLONCOLON BLOCKNAME
                            = lookup_symbol (copy_name ($3), $1,
                                             VAR_DOMAIN, 0);
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
-                           error ("No function \"%s\" in specified context.",
+                           error (_("No function \"%s\" in specified context."),
                                   copy_name ($3));
                          $$ = tem;
                        }
@@ -585,7 +586,7 @@ variable:   block COLONCOLON NAME
                          sym = lookup_symbol (copy_name ($3), $1,
                                               VAR_DOMAIN, 0);
                          if (sym == 0)
-                           error ("No symbol \"%s\" in specified context.",
+                           error (_("No symbol \"%s\" in specified context."),
                                   copy_name ($3));
 
                          write_exp_elt_opcode (OP_VAR_VALUE);
@@ -595,7 +596,7 @@ variable:   block COLONCOLON NAME
                          write_exp_elt_opcode (OP_VAR_VALUE); }
        ;
 
-/* Base case for variables. */
+/* Base case for variables.  */
 variable:      NAME
                        { struct symbol *sym;
                          int is_a_field_of_this;
@@ -630,16 +631,11 @@ variable: NAME
                              msymbol =
                                lookup_minimal_symbol (arg, NULL, NULL);
                              if (msymbol != NULL)
-                               {
-                                 write_exp_msymbol
-                                   (msymbol,
-                                    lookup_function_type (builtin_type_int),
-                                    builtin_type_int);
-                               }
+                               write_exp_msymbol (msymbol);
                              else if (!have_full_symbols () && !have_partial_symbols ())
-                               error ("No symbol table is loaded.  Use the \"symbol-file\" command.");
+                               error (_("No symbol table is loaded.  Use the \"symbol-file\" command."));
                              else
-                               error ("No symbol \"%s\" in current context.",
+                               error (_("No symbol \"%s\" in current context."),
                                       copy_name ($1));
                            }
                        }
@@ -647,29 +643,14 @@ variable: NAME
 
 type
        :       TYPENAME
-                       { $$ = lookup_typename (copy_name ($1),
+                       { $$ = lookup_typename (parse_language, parse_gdbarch,
+                                               copy_name ($1),
                                                expression_context_block, 0); }
 
        ;
 
 %%
 
-#if 0  /* FIXME! */
-int
-overflow(a,b)
-   long a,b;
-{
-   return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a;
-}
-
-int
-uoverflow(a,b)
-   unsigned long a,b;
-{
-   return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a;
-}
-#endif /* FIXME */
-
 /* Take care of parsing a number (anything that starts with a digit).
    Set yylval and return the token type; update lexptr.
    LEN is the number of characters in it.  */
@@ -711,9 +692,9 @@ parse_number (olen)
        return FLOAT;
       }
     if (p[c] == '.' && base != 10)
-       error("Floating point numbers must be base 10.");
+       error (_("Floating point numbers must be base 10."));
     if (base == 10 && (p[c] < '0' || p[c] > '9'))
-       error("Invalid digit \'%c\' in number.",p[c]);
+       error (_("Invalid digit \'%c\' in number."),p[c]);
  }
 
   while (len-- > 0)
@@ -721,7 +702,7 @@ parse_number (olen)
       c = *p++;
       n *= base;
       if( base == 8 && (c == '8' || c == '9'))
-        error("Invalid digit \'%c\' in octal number.",c);
+        error (_("Invalid digit \'%c\' in octal number."),c);
       if (c >= '0' && c <= '9')
        i = c - '0';
       else
@@ -737,12 +718,12 @@ parse_number (olen)
       if(!unsigned_p && number_sign == 1 && (prevn >= n))
         unsigned_p=1;          /* Try something unsigned */
       /* Don't do the range check if n==i and i==0, since that special
-        case will give an overflow error. */
+        case will give an overflow error.  */
       if(RANGE_CHECK && n!=i && i)
       {
         if((unsigned_p && (unsigned)prevn >= (unsigned)n) ||
            ((!unsigned_p && number_sign==-1) && -prevn <= -n))
-           range_error("Overflow on numeric constant.");
+           range_error (_("Overflow on numeric constant."));
       }
         prevn=n;
     }
@@ -762,7 +743,7 @@ parse_number (olen)
      return UINT;
   }
   else if((unsigned_p && (n<0))) {
-     range_error("Overflow on numeric constant -- number too large.");
+     range_error (_("Overflow on numeric constant -- number too large."));
      /* But, this can return if range_check == range_warn.  */
   }
   yylval.lval = n;
@@ -827,7 +808,7 @@ static struct keyword keytab[] =
    compatible  */
 
 static int
-yylex ()
+yylex (void)
 {
   int c;
   int namelen;
@@ -924,7 +905,7 @@ yylex ()
              }
          }
       if(c != quote)
-        error("Unterminated string or character constant.");
+        error (_("Unterminated string or character constant."));
       yylval.sval.ptr = tokstart + 1;
       yylval.sval.length = namelen - 1;
       lexptr += namelen + 1;
@@ -971,7 +952,7 @@ yylex ()
 
            memcpy (err_copy, tokstart, p - tokstart);
            err_copy[p - tokstart] = 0;
-           error ("Invalid number \"%s\".", err_copy);
+           error (_("Invalid number \"%s\"."), err_copy);
          }
        lexptr = p;
        return toktype;
@@ -980,7 +961,7 @@ yylex ()
   if (!(c == '_' || c == '$'
        || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
     /* We must have come across a bad character (e.g. ';').  */
-    error ("Invalid character '%c' in expression.", c);
+    error (_("Invalid character '%c' in expression."), c);
 
   /* It's a name.  See how long it is.  */
   namelen = 0;
@@ -1025,32 +1006,29 @@ yylex ()
     char *tmp = copy_name (yylval.sval);
     struct symbol *sym;
 
-    if (lookup_partial_symtab (tmp))
+    if (lookup_symtab (tmp))
       return BLOCKNAME;
     sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, 0);
     if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
       return BLOCKNAME;
-    if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1))
+    if (lookup_typename (parse_language, parse_gdbarch,
+                        copy_name (yylval.sval), expression_context_block, 1))
       return TYPENAME;
 
     if(sym)
     {
-       switch(sym->aclass)
+      switch(SYMBOL_CLASS (sym))
        {
        case LOC_STATIC:
        case LOC_REGISTER:
        case LOC_ARG:
        case LOC_REF_ARG:
-       case LOC_REGPARM:
        case LOC_REGPARM_ADDR:
        case LOC_LOCAL:
-       case LOC_BASEREG:
-       case LOC_BASEREG_ARG:
        case LOC_CONST:
        case LOC_CONST_BYTES:
        case LOC_OPTIMIZED_OUT:
        case LOC_COMPUTED:
-       case LOC_COMPUTED_ARG:
          return NAME;
 
        case LOC_TYPEDEF:
@@ -1060,20 +1038,20 @@ yylex ()
          return BLOCKNAME;
 
        case LOC_UNDEF:
-         error("internal:  Undefined class in m2lex()");
+         error (_("internal:  Undefined class in m2lex()"));
 
        case LOC_LABEL:
        case LOC_UNRESOLVED:
-         error("internal:  Unforseen case in m2lex()");
+         error (_("internal:  Unforseen case in m2lex()"));
 
        default:
-         error ("unhandled token in m2lex()");
+         error (_("unhandled token in m2lex()"));
          break;
        }
     }
     else
     {
-       /* Built-in BOOLEAN type.  This is sort of a hack. */
+       /* Built-in BOOLEAN type.  This is sort of a hack.  */
        if (strncmp (tokstart, "TRUE", 4) == 0)
        {
          yylval.ulval = 1;
@@ -1086,7 +1064,7 @@ yylex ()
        }
     }
 
-    /* Must be another type of name... */
+    /* Must be another type of name...  */
     return NAME;
  }
 }
@@ -1112,5 +1090,5 @@ yyerror (msg)
   if (prev_lexptr)
     lexptr = prev_lexptr;
 
-  error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
+  error (_("A %s in expression, near `%s'."), (msg ? msg : "error"), lexptr);
 }
This page took 0.03181 seconds and 4 git commands to generate.