2001-08-18 H.J. Lu <hjl@gnu.org>
[deliverable/binutils-gdb.git] / gas / expr.c
index 8313d95a17b740e4ac46f494bb4a252bb2b73b07..4258868f81c1f23628f844b1c253650e9582b758 100644 (file)
@@ -1,5 +1,6 @@
 /* expr.c -operands, expressions-
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -41,7 +42,7 @@ static void mri_char_constant PARAMS ((expressionS *));
 static void current_location PARAMS ((expressionS *));
 static void clean_up_expression PARAMS ((expressionS * expressionP));
 static segT operand PARAMS ((expressionS *));
-static operatorT operator PARAMS ((void));
+static operatorT operator PARAMS ((int *));
 
 extern const char EXP_CHARS[], FLT_CHARS[];
 
@@ -80,9 +81,9 @@ make_expr_symbol (expressionP)
          generic_floating_point_number or generic_bignum, and we are
          going to lose it if we haven't already.  */
       if (expressionP->X_add_number > 0)
-       as_bad (_("bignum invalid; zero assumed"));
+       as_bad (_("bignum invalid"));
       else
-       as_bad (_("floating point number invalid; zero assumed"));
+       as_bad (_("floating point number invalid"));
       zero.X_op = O_constant;
       zero.X_add_number = 0;
       zero.X_unsigned = 0;
@@ -104,7 +105,7 @@ make_expr_symbol (expressionP)
   symbol_set_value_expression (symbolP, expressionP);
 
   if (expressionP->X_op == O_constant)
-    resolve_symbol_value (symbolP, 1);
+    resolve_symbol_value (symbolP);
 
   n = (struct expr_symbol_line *) xmalloc (sizeof *n);
   n->sym = symbolP;
@@ -242,11 +243,12 @@ floating_constant (expressionP)
     {
       if (error_code == ERROR_EXPONENT_OVERFLOW)
        {
-         as_bad (_("bad floating-point constant: exponent overflow, probably assembling junk"));
+         as_bad (_("bad floating-point constant: exponent overflow"));
        }
       else
        {
-         as_bad (_("bad floating-point constant: unknown error code=%d."), error_code);
+         as_bad (_("bad floating-point constant: unknown error code=%d"),
+                 error_code);
        }
     }
   expressionP->X_op = O_big;
@@ -426,7 +428,7 @@ integer_constant (radix, expressionP)
 
          /* Check for 8 digit per word max.  */
          if (ndigit > 8)
-           as_bad (_("A bignum with underscores may not have more than 8 hex digits in any word."));
+           as_bad (_("a bignum with underscores may not have more than 8 hex digits in any word"));
 
          /* Add this chunk to the bignum.
             Shift things down 2 little digits.  */
@@ -449,7 +451,7 @@ integer_constant (radix, expressionP)
       assert (num_little_digits >= 4);
 
       if (num_little_digits != 8)
-       as_bad (_("A bignum with underscores must have exactly 4 words."));
+       as_bad (_("a bignum with underscores must have exactly 4 words"));
 
       /* We might have some leading zeros.  These can be trimmed to give
         us a change to fit this constant into a small number.  */
@@ -572,7 +574,7 @@ integer_constant (radix, expressionP)
              /* Either not seen or not defined.  */
              /* @@ Should print out the original string instead of
                 the parsed number.  */
-             as_bad (_("backw. ref to unknown label \"%d:\", 0 assumed."),
+             as_bad (_("backward ref to unknown label \"%d:\""),
                      (int) number);
              expressionP->X_op = O_constant;
            }
@@ -695,7 +697,7 @@ mri_char_constant (expressionP)
 
   if (i < 0)
     {
-      as_bad (_("Character constant too large"));
+      as_bad (_("character constant too large"));
       i = 0;
     }
 
@@ -809,6 +811,9 @@ operand (expressionP)
 
 #ifdef LITERAL_PREFIXDOLLAR_HEX
     case '$':
+      /* $L is the start of a local label, not a hex constant.  */
+      if (* input_line_pointer == 'L')
+      goto isname;
       integer_constant (16, expressionP);
       break;
 #endif
@@ -1009,7 +1014,7 @@ operand (expressionP)
 #ifdef RELAX_PAREN_GROUPING
          if (c != '(')
 #endif
-           as_bad (_("Missing '%c' assumed"), c == '(' ? ')' : ']');
+           as_bad (_("missing '%c'"), c == '(' ? ')' : ']');
        }
       else
        input_line_pointer++;
@@ -1230,7 +1235,7 @@ operand (expressionP)
              specially in certain contexts.  If a name always has a
              specific value, it can often be handled by simply
              entering it in the symbol table.  */
-         if (md_parse_name (name, expressionP))
+         if (md_parse_name (name, expressionP, &c))
            {
              *input_line_pointer = c;
              break;
@@ -1311,7 +1316,7 @@ operand (expressionP)
          if (expressionP->X_op == O_absent)
            {
              ++input_line_pointer;
-             as_bad (_("Bad expression"));
+             as_bad (_("bad expression"));
              expressionP->X_op = O_constant;
              expressionP->X_add_number = 0;
            }
@@ -1455,7 +1460,7 @@ static const operatorT op_encoding[256] = {
    0   operand, (expression)
    1   ||
    2   &&
-   3   = <> < <= >= >
+   3   == <> < <= >= >
    4   + -
    5   used for * / % in MRI mode
    6   & ^ ! |
@@ -1469,7 +1474,7 @@ static operator_rankT op_rank[] = {
   0,   /* O_symbol */
   0,   /* O_symbol_rva */
   0,   /* O_register */
-  0,   /* O_bit */
+  0,   /* O_big */
   9,   /* O_uminus */
   9,   /* O_bit_not */
   9,   /* O_logical_not */
@@ -1517,8 +1522,8 @@ static operator_rankT op_rank[] = {
    mode.  Also, MRI uses a different bit_not operator, and this fixes
    that as well.  */
 
-#define STANDARD_MUL_PRECEDENCE (7)
-#define MRI_MUL_PRECEDENCE (5)
+#define STANDARD_MUL_PRECEDENCE 8
+#define MRI_MUL_PRECEDENCE 6
 
 void
 expr_set_precedence ()
@@ -1552,17 +1557,19 @@ expr_begin ()
   }
 }
 \f
-/* Return the encoding for the operator at INPUT_LINE_POINTER.
-   Advance INPUT_LINE_POINTER to the last character in the operator
-   (i.e., don't change it for a single character operator).  */
+/* Return the encoding for the operator at INPUT_LINE_POINTER, and
+   sets NUM_CHARS to the number of characters in the operator.
+   Does not advance INPUT_LINE_POINTER.  */
 
 static inline operatorT
-operator ()
+operator (num_chars)
+     int *num_chars;
 {
   int c;
   operatorT ret;
 
   c = *input_line_pointer & 0xff;
+  *num_chars = 1;
 
   if (is_end_of_line[c])
     return O_illegal;
@@ -1587,14 +1594,14 @@ operator ()
          ret = O_le;
          break;
        }
-      ++input_line_pointer;
+      *num_chars = 2;
       return ret;
 
     case '=':
       if (input_line_pointer[1] != '=')
        return op_encoding[c];
 
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_eq;
 
     case '>':
@@ -1609,7 +1616,7 @@ operator ()
          ret = O_ge;
          break;
        }
-      ++input_line_pointer;
+      *num_chars = 2;
       return ret;
 
     case '!':
@@ -1620,21 +1627,21 @@ operator ()
            return O_bit_inclusive_or;
          return op_encoding[c];
        }
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_bit_exclusive_or;
 
     case '|':
       if (input_line_pointer[1] != '|')
        return op_encoding[c];
 
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_logical_or;
 
     case '&':
       if (input_line_pointer[1] != '&')
        return op_encoding[c];
 
-      ++input_line_pointer;
+      *num_chars = 2;
       return O_logical_and;
     }
 
@@ -1653,6 +1660,7 @@ expr (rankarg, resultP)
   expressionS right;
   operatorT op_left;
   operatorT op_right;
+  int op_chars;
 
   know (rank >= 0);
 
@@ -1661,12 +1669,12 @@ expr (rankarg, resultP)
   /* operand () gobbles spaces.  */
   know (*input_line_pointer != ' ');
 
-  op_left = operator ();
+  op_left = operator (&op_chars);
   while (op_left != O_illegal && op_rank[(int) op_left] > rank)
     {
       segT rightseg;
 
-      input_line_pointer++;    /* -> after 1st character of operator.  */
+      input_line_pointer += op_chars;  /* -> after operator.  */
 
       rightseg = expr (op_rank[(int) op_left], &right);
       if (right.X_op == O_absent)
@@ -1706,7 +1714,7 @@ expr (rankarg, resultP)
               )
        as_bad (_("operation combines symbols in different segments"));
 
-      op_right = operator ();
+      op_right = operator (&op_chars);
 
       know (op_right == O_illegal
            || op_rank[(int) op_right] <= op_rank[(int) op_left]);
This page took 0.027 seconds and 4 git commands to generate.