/* 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.
/* 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] =
/*int current_token, lookahead_token; */
INLINE static enum ch_terminal
-PEEK_TOKEN ()
+PEEK_TOKEN (void)
{
if (terminal_buffer[0] == TOKEN_NOT_READ)
{
#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 ();
#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];
#endif
static void
-forward_token_ ()
+forward_token_ (void)
{
int i;
for (i = 0; i < MAX_LOOK_AHEAD; i++)
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;
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)
{
}
#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;
}
static tree
-parse_simple_name_string ()
+parse_simple_name_string (void)
{
int token = PEEK_TOKEN ();
tree name;
}
static tree
-parse_name_string ()
+parse_name_string (void)
{
tree name = parse_opt_name_string (0);
if (name)
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)
#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);
/* Matches: <case label> */
static void
-parse_case_label ()
+parse_case_label (void)
{
if (check_token (ELSE))
error ("ELSE in tuples labels not implemented");
}
static int
-parse_opt_untyped_expr ()
+parse_opt_untyped_expr (void)
{
switch (PEEK_TOKEN ())
{
}
static void
-parse_unary_call ()
+parse_unary_call (void)
{
FORWARD_TOKEN ();
expect ('(', NULL);
#if 0
static struct type *
-parse_mode_call ()
+parse_mode_call (void)
{
struct type *type;
FORWARD_TOKEN ();
#endif
static struct type *
-parse_mode_or_normal_call ()
+parse_mode_or_normal_call (void)
{
struct type *type;
FORWARD_TOKEN ();
Assume we have parsed the function, and are at the '('. */
static void
-parse_call ()
+parse_call (void)
{
int arg_count;
require ('(');
}
static void
-parse_named_record_element ()
+parse_named_record_element (void)
{
struct stoken label;
char buf[256];
/* 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)
{
/* 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 () == ']')
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)
}
static void
-parse_primval ()
+parse_primval (void)
{
struct type *type;
enum exp_opcode op;
}
static void
-parse_operand6 ()
+parse_operand6 (void)
{
if (check_token (RECEIVE))
{
}
static void
-parse_operand5 ()
+parse_operand5 (void)
{
enum exp_opcode op;
/* We are supposed to be looking for a <string repetition operator>,
}
static void
-parse_operand4 ()
+parse_operand4 (void)
{
enum exp_opcode op;
parse_operand5 ();
}
static void
-parse_operand3 ()
+parse_operand3 (void)
{
enum exp_opcode op;
parse_operand4 ();
}
static void
-parse_operand2 ()
+parse_operand2 (void)
{
enum exp_opcode op;
parse_operand3 ();
}
static void
-parse_operand1 ()
+parse_operand1 (void)
{
enum exp_opcode op;
parse_operand2 ();
}
static void
-parse_operand0 ()
+parse_operand0 (void)
{
enum exp_opcode op;
parse_operand1 ();
}
static void
-parse_expr ()
+parse_expr (void)
{
parse_operand0 ();
if (check_token (GDB_ASSIGNMENT))
}
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 ();
/* Matches: <boolean expression> <then alternative> <else alternative> */
static void
-parse_if_expression_body ()
+parse_if_expression_body (void)
{
parse_expr ();
parse_then_alternative ();
}
static void
-parse_if_expression ()
+parse_if_expression (void)
{
require (IF);
parse_if_expression_body ();
You should call convert() to fix up the <untyped_expr>. */
static void
-parse_untyped_expr ()
+parse_untyped_expr (void)
{
switch (PEEK_TOKEN ())
{
}
int
-chill_parse ()
+chill_parse (void)
{
terminal_buffer[0] = TOKEN_NOT_READ;
if (PEEK_TOKEN () == TYPENAME && PEEK_TOKEN1 () == END_TOKEN)
on demand. */
static void
-growbuf_by_size (count)
- int count;
+growbuf_by_size (int count)
{
int growby;
in symbol table lookups. If not successful, returns NULL. */
static char *
-match_simple_name_string ()
+match_simple_name_string (void)
{
char *tokptr = lexptr;
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;
}
static int
-decode_integer_literal (valptr, tokptrptr)
- LONGEST *valptr;
- char **tokptrptr;
+decode_integer_literal (LONGEST *valptr, char **tokptrptr)
{
char *tokptr = *tokptrptr;
int base = 0;
legal floating point value. */
static enum ch_terminal
-match_float_literal ()
+match_float_literal (void)
{
char *tokptr = lexptr;
char *buf;
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;
*/
static enum ch_terminal
-match_character_literal ()
+match_character_literal (void)
{
char *tokptr = lexptr;
LONGEST ival = 0;
in any integer literal. */
static enum ch_terminal
-match_integer_literal ()
+match_integer_literal (void)
{
char *tokptr = lexptr;
LONGEST ival;
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
in any bit-string literal. */
static enum ch_terminal
-match_bitstring_literal ()
+match_bitstring_literal (void)
{
register char *tokptr = lexptr;
int bitoffset = 0;
operators used are compatible. */
static enum ch_terminal
-ch_lex ()
+ch_lex (void)
{
unsigned int i;
enum ch_terminal token;
case LOC_OPTIMIZED_OUT:
error ("Symbol \"%s\" names no location.", inputname);
break;
- case LOC_UNRESOLVED:
- error ("unhandled SYMBOL_CLASS in ch_lex()");
+ default:
+ internal_error (__FILE__, __LINE__,
+ "unhandled SYMBOL_CLASS in ch_lex()");
break;
}
}
}
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);
}
void
-chill_error (msg)
- char *msg;
+chill_error (char *msg)
{
/* Never used. */
}