* ch-exp.y (decode_integer_value, match_character_literal,
[deliverable/binutils-gdb.git] / gdb / ch-exp.y
index c544a4e899172e7c29a360e2db1221788570b823..ded20b5ca93735be3d84685ab0bbba2616b4b563 100644 (file)
@@ -1,5 +1,5 @@
 /* YACC grammar for Chill expressions, for GDB.
-   Copyright 1992, 1993 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -54,6 +54,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 %{
 
 #include "defs.h"
+#include <string.h>
 #include <ctype.h>
 #include "expression.h"
 #include "language.h"
@@ -294,7 +295,7 @@ yyerror PARAMS ((char *));
 %type <voidval>                lower_element
 %type <voidval>                upper_element
 %type <voidval>                first_element
-%type <voidval>                mode_argument
+%type <tval>           mode_argument
 %type <voidval>                upper_lower_argument
 %type <voidval>                length_argument
 %type <voidval>                array_mode_name
@@ -774,7 +775,7 @@ operand_2   :       operand_3
                        }
                |       operand_2 IN operand_3
                        {
-                         $$ = 0;       /* FIXME */
+                         write_exp_elt_opcode (BINOP_IN);
                        }
                ;
 
@@ -902,14 +903,13 @@ chill_value_built_in_routine_call :
                        {
                          $$ = 0;       /* FIXME */
                        }
-               |       SIZE '(' location ')'
-                       {
-                         $$ = 0;       /* FIXME */
-                       }
+               |       SIZE '(' expression ')'
+                       { write_exp_elt_opcode (UNOP_SIZEOF); }
                |       SIZE '(' mode_argument ')'
-                       {
-                         $$ = 0;       /* FIXME */
-                       }
+                       { write_exp_elt_opcode (OP_LONG);
+                         write_exp_elt_type (builtin_type_int);
+                         write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
+                         write_exp_elt_opcode (OP_LONG); }
                |       UPPER '(' upper_lower_argument ')'
                        {
                          $$ = 0;       /* FIXME */
@@ -926,7 +926,7 @@ chill_value_built_in_routine_call :
 
 mode_argument :                mode_name
                        {
-                         $$ = 0;       /* FIXME */
+                         $$ = $1.type;
                        }
                |       array_mode_name '(' expression ')'
                        {
@@ -1043,7 +1043,7 @@ match_simple_name_string ()
 {
   char *tokptr = lexptr;
 
-  if (isalpha (*tokptr))
+  if (isalpha (*tokptr) || *tokptr == '_')
     {
       char *result;
       do {
@@ -1079,7 +1079,9 @@ decode_integer_value (base, tokptrptr, ivalptr)
 
   while (*tokptr != '\0')
     {
-      temp = tolower (*tokptr);
+      temp = *tokptr;
+      if (isupper (temp))
+        temp = tolower (temp);
       tokptr++;
       switch (temp)
        {
@@ -1335,7 +1337,7 @@ match_float_literal ()
   return (0);
 }
 
-/* Recognize a string literal.  A string literal is a nonzero sequence
+/* Recognize a string literal.  A string literal is a sequence
    of characters enclosed in matching single or double quotes, except that
    a single character inside single quotes is a character literal, which
    we reject as a string literal.  To embed the terminator character inside
@@ -1363,7 +1365,6 @@ match_string_literal ()
       tempbuf[tempbufindex++] = *tokptr;
     }
   if (*tokptr == '\0'                                  /* no terminator */
-      || tempbufindex == 0                             /* no string */
       || (tempbufindex == 1 && *tokptr == '\''))       /* char literal */
     {
       return (0);
@@ -1406,7 +1407,7 @@ match_character_literal ()
   char *tokptr = lexptr;
   int ival = 0;
   
-  if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
+  if ((*tokptr == 'c' || *tokptr == 'C') && (*(tokptr + 1) == '\''))
     {
       /* We have a GNU chill extension form, so skip the leading "C'",
         decode the hex value, and then ensure that we have a trailing
@@ -1537,7 +1538,9 @@ match_bitstring_literal ()
   
   while (*tokptr != '\0' && *tokptr != '\'')
     {
-      digit = tolower (*tokptr);
+      digit = *tokptr;
+      if (isupper (digit))
+        digit = tolower (digit);
       tokptr++;
       switch (digit)
        {
@@ -1657,7 +1660,7 @@ match_dollar_tokens ()
              && !isalnum (tokptr[namelength]))
            {
              yylval.lval = regno;
-             lexptr += namelength + 1;
+             lexptr += namelength;
              return (GDB_REGNAME);
            }
        }
@@ -1806,7 +1809,7 @@ yylex ()
       {
        case '\'':
        case '\"':
-         /* First try to match a string literal, which is any nonzero
+         /* First try to match a string literal, which is any
             sequence of characters enclosed in matching single or double
             quotes, except that a single character inside single quotes
             is a character literal, so we have to catch that case also. */
@@ -1988,7 +1991,7 @@ void
 yyerror (msg)
      char *msg;        /* unused */
 {
-  printf ("Parsing:  %s\n", lexptr);
+  printf_unfiltered ("Parsing:  %s\n", lexptr);
   if (yychar < 256)
     {
       error ("Invalid syntax in expression near character '%c'.", yychar);
This page took 0.03068 seconds and 4 git commands to generate.