*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / ch-exp.c
index 78924756ef383e01d58d48ceb2ff6fdbe6397252..e96a6f8e5f89375cc01fdb16894e2990e8919feb 100644 (file)
@@ -1,5 +1,6 @@
 /* Parser for GNU CHILL (CCITT High-Level Language)  -*- C -*-
-   Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1995, 1996, 1997, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -141,54 +142,49 @@ enum ch_terminal
 
 /* Forward declarations. */
 
-static void write_lower_upper_value PARAMS ((enum exp_opcode, struct type *));
-static enum ch_terminal match_bitstring_literal PARAMS ((void));
-static enum ch_terminal match_integer_literal PARAMS ((void));
-static enum ch_terminal match_character_literal PARAMS ((void));
-static enum ch_terminal match_string_literal PARAMS ((void));
-static enum ch_terminal match_float_literal PARAMS ((void));
-static enum ch_terminal match_float_literal PARAMS ((void));
-static int decode_integer_literal PARAMS ((LONGEST *, char **));
-static int decode_integer_value PARAMS ((int, char **, LONGEST *));
-static char *match_simple_name_string PARAMS ((void));
-static void growbuf_by_size PARAMS ((int));
-static void parse_untyped_expr PARAMS ((void));
-static void parse_if_expression PARAMS ((void));
-static void parse_else_alternative PARAMS ((void));
-static void parse_then_alternative PARAMS ((void));
-static void parse_expr PARAMS ((void));
-static void parse_operand0 PARAMS ((void));
-static void parse_operand1 PARAMS ((void));
-static void parse_operand2 PARAMS ((void));
-static void parse_operand3 PARAMS ((void));
-static void parse_operand4 PARAMS ((void));
-static void parse_operand5 PARAMS ((void));
-static void parse_operand6 PARAMS ((void));
-static void parse_primval PARAMS ((void));
-static void parse_tuple PARAMS ((struct type *));
-static void parse_opt_element_list PARAMS ((struct type *));
-static void parse_tuple_element PARAMS ((struct type *));
-static void parse_named_record_element PARAMS ((void));
-static void parse_call PARAMS ((void));
-static struct type *parse_mode_or_normal_call PARAMS ((void));
+static void write_lower_upper_value (enum exp_opcode, struct type *);
+static enum ch_terminal match_bitstring_literal (void);
+static enum ch_terminal match_integer_literal (void);
+static enum ch_terminal match_character_literal (void);
+static enum ch_terminal match_string_literal (void);
+static enum ch_terminal match_float_literal (void);
+static int decode_integer_literal (LONGEST *, char **);
+static int decode_integer_value (int, char **, LONGEST *);
+static char *match_simple_name_string (void);
+static void growbuf_by_size (int);
+static void parse_case_label (void);
+static void parse_untyped_expr (void);
+static void parse_if_expression (void);
+static void parse_if_expression_body (void);
+static void parse_else_alternative (void);
+static void parse_then_alternative (void);
+static void parse_expr (void);
+static void parse_operand0 (void);
+static void parse_operand1 (void);
+static void parse_operand2 (void);
+static void parse_operand3 (void);
+static void parse_operand4 (void);
+static void parse_operand5 (void);
+static void parse_operand6 (void);
+static void parse_primval (void);
+static void parse_tuple (struct type *);
+static void parse_opt_element_list (struct type *);
+static void parse_tuple_element (struct type *);
+static void parse_named_record_element (void);
+static void parse_call (void);
+static struct type *parse_mode_or_normal_call (void);
 #if 0
-static struct type *parse_mode_call PARAMS ((void));
+static struct type *parse_mode_call (void);
 #endif
-static void parse_unary_call PARAMS ((void));
-static int parse_opt_untyped_expr PARAMS ((void));
-static void parse_case_label PARAMS ((void));
-static int expect PARAMS ((enum ch_terminal, char *));
-static void parse_expr PARAMS ((void));
-static void parse_primval PARAMS ((void));
-static void parse_untyped_expr PARAMS ((void));
-static int parse_opt_untyped_expr PARAMS ((void));
-static void parse_if_expression_body PARAMS ((void));
-static enum ch_terminal ch_lex PARAMS ((void));
-INLINE static enum ch_terminal PEEK_TOKEN PARAMS ((void));
-static enum ch_terminal peek_token_ PARAMS ((int));
-static void forward_token_ PARAMS ((void));
-static void require PARAMS ((enum ch_terminal));
-static int check_token PARAMS ((enum ch_terminal));
+static void parse_unary_call (void);
+static int parse_opt_untyped_expr (void);
+static int expect (enum ch_terminal, char *);
+static enum ch_terminal ch_lex (void);
+INLINE static enum ch_terminal PEEK_TOKEN (void);
+static enum ch_terminal peek_token_ (int);
+static void forward_token_ (void);
+static void require (enum ch_terminal);
+static int check_token (enum ch_terminal);
 
 #define MAX_LOOK_AHEAD 2
 static enum ch_terminal terminal_buffer[MAX_LOOK_AHEAD + 1] =
@@ -200,7 +196,7 @@ static YYSTYPE val_buffer[MAX_LOOK_AHEAD + 1];
 /*int current_token, lookahead_token; */
 
 INLINE static enum ch_terminal
-PEEK_TOKEN ()
+PEEK_TOKEN (void)
 {
   if (terminal_buffer[0] == TOKEN_NOT_READ)
     {
@@ -213,11 +209,11 @@ PEEK_TOKEN ()
 #define PEEK_TOKEN1() peek_token_(1)
 #define PEEK_TOKEN2() peek_token_(2)
 static enum ch_terminal
-peek_token_ (i)
-     int i;
+peek_token_ (int i)
 {
   if (i > MAX_LOOK_AHEAD)
-    internal_error ("ch-exp.c - too much lookahead");
+    internal_error (__FILE__, __LINE__,
+                   "too much lookahead");
   if (terminal_buffer[i] == TOKEN_NOT_READ)
     {
       terminal_buffer[i] = ch_lex ();
@@ -229,13 +225,12 @@ peek_token_ (i)
 #if 0
 
 static void
-pushback_token (code, node)
-     enum ch_terminal code;
-     YYSTYPE node;
+pushback_token (enum ch_terminal code, YYSTYPE node)
 {
   int i;
   if (terminal_buffer[MAX_LOOK_AHEAD] != TOKEN_NOT_READ)
-    internal_error ("ch-exp.c - cannot pushback token");
+    internal_error (__FILE__, __LINE__,
+                   "cannot pushback token");
   for (i = MAX_LOOK_AHEAD; i > 0; i--)
     {
       terminal_buffer[i] = terminal_buffer[i - 1];
@@ -248,7 +243,7 @@ pushback_token (code, node)
 #endif
 
 static void
-forward_token_ ()
+forward_token_ (void)
 {
   int i;
   for (i = 0; i < MAX_LOOK_AHEAD; i++)
@@ -264,19 +259,18 @@ forward_token_ ()
    if it isn't TOKEN, the parser is broken. */
 
 static void
-require (token)
-     enum ch_terminal token;
+require (enum ch_terminal token)
 {
   if (PEEK_TOKEN () != token)
     {
-      internal_error ("ch-exp.c - expected token %d", (int) token);
+      internal_error (__FILE__, __LINE__,
+                     "expected token %d", (int) token);
     }
   FORWARD_TOKEN ();
 }
 
 static int
-check_token (token)
-     enum ch_terminal token;
+check_token (enum ch_terminal token)
 {
   if (PEEK_TOKEN () != token)
     return 0;
@@ -288,9 +282,7 @@ check_token (token)
    else return 1.
  */
 static int
-expect (token, message)
-     enum ch_terminal token;
-     char *message;
+expect (enum ch_terminal token, char *message)
 {
   if (PEEK_TOKEN () != token)
     {
@@ -308,9 +300,10 @@ expect (token, message)
 }
 
 #if 0
+/* Parse a name string.  If ALLOW_ALL is 1, ALL is allowed as a postfix. */
+
 static tree
-parse_opt_name_string (allow_all)
-     int allow_all;            /* 1 if ALL is allowed as a postfix */
+parse_opt_name_string (int allow_all)
 {
   int token = PEEK_TOKEN ();
   tree name;
@@ -347,7 +340,7 @@ parse_opt_name_string (allow_all)
 }
 
 static tree
-parse_simple_name_string ()
+parse_simple_name_string (void)
 {
   int token = PEEK_TOKEN ();
   tree name;
@@ -362,7 +355,7 @@ parse_simple_name_string ()
 }
 
 static tree
-parse_name_string ()
+parse_name_string (void)
 {
   tree name = parse_opt_name_string (0);
   if (name)
@@ -377,7 +370,7 @@ parse_name_string ()
    Returns if pass 2: a decl or value for identifier. */
 
 static tree
-parse_name ()
+parse_name (void)
 {
   tree name = parse_name_string ();
   if (pass == 1 || ignoring)
@@ -404,8 +397,7 @@ parse_name ()
 
 #if 0
 static void
-pushback_paren_expr (expr)
-     tree expr;
+pushback_paren_expr (tree expr)
 {
   if (pass == 1 && !ignoring)
     expr = build1 (PAREN_EXPR, NULL_TREE, expr);
@@ -416,7 +408,7 @@ pushback_paren_expr (expr)
 /* Matches: <case label> */
 
 static void
-parse_case_label ()
+parse_case_label (void)
 {
   if (check_token (ELSE))
     error ("ELSE in tuples labels not implemented");
@@ -430,7 +422,7 @@ parse_case_label ()
 }
 
 static int
-parse_opt_untyped_expr ()
+parse_opt_untyped_expr (void)
 {
   switch (PEEK_TOKEN ())
     {
@@ -445,7 +437,7 @@ parse_opt_untyped_expr ()
 }
 
 static void
-parse_unary_call ()
+parse_unary_call (void)
 {
   FORWARD_TOKEN ();
   expect ('(', NULL);
@@ -458,7 +450,7 @@ parse_unary_call ()
 #if 0
 
 static struct type *
-parse_mode_call ()
+parse_mode_call (void)
 {
   struct type *type;
   FORWARD_TOKEN ();
@@ -474,7 +466,7 @@ parse_mode_call ()
 #endif
 
 static struct type *
-parse_mode_or_normal_call ()
+parse_mode_or_normal_call (void)
 {
   struct type *type;
   FORWARD_TOKEN ();
@@ -497,7 +489,7 @@ parse_mode_or_normal_call ()
    Assume we have parsed the function, and are at the '('. */
 
 static void
-parse_call ()
+parse_call (void)
 {
   int arg_count;
   require ('(');
@@ -534,7 +526,7 @@ parse_call ()
 }
 
 static void
-parse_named_record_element ()
+parse_named_record_element (void)
 {
   struct stoken label;
   char buf[256];
@@ -556,8 +548,7 @@ parse_named_record_element ()
 /* Returns one or more TREE_LIST nodes, in reverse order. */
 
 static void
-parse_tuple_element (type)
-     struct type *type;
+parse_tuple_element (struct type *type)
 {
   if (PEEK_TOKEN () == DOT_FIELD_NAME)
     {
@@ -622,8 +613,7 @@ parse_tuple_element (type)
 /* Matches:  a COMMA-separated list of tuple elements.
    Returns a list (of TREE_LIST nodes). */
 static void
-parse_opt_element_list (type)
-     struct type *type;
+parse_opt_element_list (struct type *type)
 {
   arglist_len = 0;
   if (PEEK_TOKEN () == ']')
@@ -643,8 +633,7 @@ parse_opt_element_list (type)
    If modename is non-NULL it prefixed the tuple.  */
 
 static void
-parse_tuple (mode)
-     struct type *mode;
+parse_tuple (struct type *mode)
 {
   struct type *type;
   if (mode)
@@ -672,7 +661,7 @@ parse_tuple (mode)
 }
 
 static void
-parse_primval ()
+parse_primval (void)
 {
   struct type *type;
   enum exp_opcode op;
@@ -942,7 +931,7 @@ parse_primval ()
 }
 
 static void
-parse_operand6 ()
+parse_operand6 (void)
 {
   if (check_token (RECEIVE))
     {
@@ -959,7 +948,7 @@ parse_operand6 ()
 }
 
 static void
-parse_operand5 ()
+parse_operand5 (void)
 {
   enum exp_opcode op;
   /* We are supposed to be looking for a <string repetition operator>,
@@ -990,7 +979,7 @@ parse_operand5 ()
 }
 
 static void
-parse_operand4 ()
+parse_operand4 (void)
 {
   enum exp_opcode op;
   parse_operand5 ();
@@ -1020,7 +1009,7 @@ parse_operand4 ()
 }
 
 static void
-parse_operand3 ()
+parse_operand3 (void)
 {
   enum exp_opcode op;
   parse_operand4 ();
@@ -1047,7 +1036,7 @@ parse_operand3 ()
 }
 
 static void
-parse_operand2 ()
+parse_operand2 (void)
 {
   enum exp_opcode op;
   parse_operand3 ();
@@ -1091,7 +1080,7 @@ parse_operand2 ()
 }
 
 static void
-parse_operand1 ()
+parse_operand1 (void)
 {
   enum exp_opcode op;
   parse_operand2 ();
@@ -1115,7 +1104,7 @@ parse_operand1 ()
 }
 
 static void
-parse_operand0 ()
+parse_operand0 (void)
 {
   enum exp_opcode op;
   parse_operand1 ();
@@ -1142,7 +1131,7 @@ parse_operand0 ()
 }
 
 static void
-parse_expr ()
+parse_expr (void)
 {
   parse_operand0 ();
   if (check_token (GDB_ASSIGNMENT))
@@ -1153,14 +1142,14 @@ parse_expr ()
 }
 
 static void
-parse_then_alternative ()
+parse_then_alternative (void)
 {
   expect (THEN, "missing 'THEN' in 'IF' expression");
   parse_expr ();
 }
 
 static void
-parse_else_alternative ()
+parse_else_alternative (void)
 {
   if (check_token (ELSIF))
     parse_if_expression_body ();
@@ -1173,7 +1162,7 @@ parse_else_alternative ()
 /* Matches: <boolean expression> <then alternative> <else alternative> */
 
 static void
-parse_if_expression_body ()
+parse_if_expression_body (void)
 {
   parse_expr ();
   parse_then_alternative ();
@@ -1182,7 +1171,7 @@ parse_if_expression_body ()
 }
 
 static void
-parse_if_expression ()
+parse_if_expression (void)
 {
   require (IF);
   parse_if_expression_body ();
@@ -1196,7 +1185,7 @@ parse_if_expression ()
    You should call convert() to fix up the <untyped_expr>. */
 
 static void
-parse_untyped_expr ()
+parse_untyped_expr (void)
 {
   switch (PEEK_TOKEN ())
     {
@@ -1226,7 +1215,7 @@ parse_untyped_expr ()
 }
 
 int
-chill_parse ()
+chill_parse (void)
 {
   terminal_buffer[0] = TOKEN_NOT_READ;
   if (PEEK_TOKEN () == TYPENAME && PEEK_TOKEN1 () == END_TOKEN)
@@ -1271,8 +1260,7 @@ static int tempbufindex;  /* Current index into buffer */
    on demand. */
 
 static void
-growbuf_by_size (count)
-     int count;
+growbuf_by_size (int count)
 {
   int growby;
 
@@ -1293,7 +1281,7 @@ growbuf_by_size (count)
    in symbol table lookups.  If not successful, returns NULL. */
 
 static char *
-match_simple_name_string ()
+match_simple_name_string (void)
 {
   char *tokptr = lexptr;
 
@@ -1321,10 +1309,7 @@ match_simple_name_string ()
    digits we have encountered. */
 
 static int
-decode_integer_value (base, tokptrptr, ivalptr)
-     int base;
-     char **tokptrptr;
-     LONGEST *ivalptr;
+decode_integer_value (int base, char **tokptrptr, LONGEST *ivalptr)
 {
   char *tokptr = *tokptrptr;
   int temp;
@@ -1395,9 +1380,7 @@ decode_integer_value (base, tokptrptr, ivalptr)
 }
 
 static int
-decode_integer_literal (valptr, tokptrptr)
-     LONGEST *valptr;
-     char **tokptrptr;
+decode_integer_literal (LONGEST *valptr, char **tokptrptr)
 {
   char *tokptr = *tokptrptr;
   int base = 0;
@@ -1480,7 +1463,7 @@ decode_integer_literal (valptr, tokptrptr)
    legal floating point value. */
 
 static enum ch_terminal
-match_float_literal ()
+match_float_literal (void)
 {
   char *tokptr = lexptr;
   char *buf;
@@ -1610,7 +1593,7 @@ convert_float:
    a string, it is simply doubled (I.E. "this""is""one""string") */
 
 static enum ch_terminal
-match_string_literal ()
+match_string_literal (void)
 {
   char *tokptr = lexptr;
   int in_ctrlseq = 0;
@@ -1706,7 +1689,7 @@ match_string_literal ()
  */
 
 static enum ch_terminal
-match_character_literal ()
+match_character_literal (void)
 {
   char *tokptr = lexptr;
   LONGEST ival = 0;
@@ -1788,7 +1771,7 @@ match_character_literal ()
    in any integer literal. */
 
 static enum ch_terminal
-match_integer_literal ()
+match_integer_literal (void)
 {
   char *tokptr = lexptr;
   LONGEST ival;
@@ -1800,7 +1783,7 @@ match_integer_literal ()
   else
     {
       yylval.typed_val.val = ival;
-#if defined(CC_HAS_LONG_LONG) && defined(__STDC__)
+#if defined(CC_HAS_LONG_LONG)
       if (ival > (LONGEST) 2147483647U || ival < -(LONGEST) 2147483648U)
        yylval.typed_val.type = builtin_type_long_long;
       else
@@ -1817,7 +1800,7 @@ match_integer_literal ()
    in any bit-string literal. */
 
 static enum ch_terminal
-match_bitstring_literal ()
+match_bitstring_literal (void)
 {
   register char *tokptr = lexptr;
   int bitoffset = 0;
@@ -1900,15 +1883,15 @@ match_bitstring_literal ()
       else
        {
          /* Extract bits from digit, packing them into the bitstring byte. */
-         int k = TARGET_BYTE_ORDER == BIG_ENDIAN ? bits_per_char - 1 : 0;
-         for (; TARGET_BYTE_ORDER == BIG_ENDIAN ? k >= 0 : k < bits_per_char;
-              TARGET_BYTE_ORDER == BIG_ENDIAN ? k-- : k++)
+         int k = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? bits_per_char - 1 : 0;
+         for (; TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? k >= 0 : k < bits_per_char;
+              TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? k-- : k++)
            {
              bitcount++;
              if (digit & (1 << k))
                {
                  tempbuf[tempbufindex] |=
-                   (TARGET_BYTE_ORDER == BIG_ENDIAN)
+                   (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
                    ? (1 << (HOST_CHAR_BIT - 1 - bitoffset))
                    : (1 << bitoffset);
                }
@@ -1989,7 +1972,7 @@ static const struct token tokentab2[] =
    operators used are compatible.  */
 
 static enum ch_terminal
-ch_lex ()
+ch_lex (void)
 {
   unsigned int i;
   enum ch_terminal token;
@@ -2193,7 +2176,8 @@ ch_lex ()
              error ("Symbol \"%s\" names no location.", inputname);
              break;
            default:
-             internal_error ("unhandled SYMBOL_CLASS in ch_lex()");
+             internal_error (__FILE__, __LINE__,
+                             "unhandled SYMBOL_CLASS in ch_lex()");
              break;
            }
        }
@@ -2226,9 +2210,8 @@ ch_lex ()
 }
 
 static void
-write_lower_upper_value (opcode, type)
-     enum exp_opcode opcode;   /* Either UNOP_LOWER or UNOP_UPPER */
-     struct type *type;
+write_lower_upper_value (enum exp_opcode opcode,       /* Either UNOP_LOWER or UNOP_UPPER */
+                        struct type *type)
 {
   if (type == NULL)
     write_exp_elt_opcode (opcode);
@@ -2244,8 +2227,7 @@ write_lower_upper_value (opcode, type)
 }
 
 void
-chill_error (msg)
-     char *msg;
+chill_error (char *msg)
 {
   /* Never used. */
 }
This page took 0.032228 seconds and 4 git commands to generate.