#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+#ifdef __GNUC__
+#define INLINE __inline__
+#endif
+
typedef union
{
};
/* Forward declarations. */
-static void parse_expr ();
-static void parse_primval ();
-static void parse_untyped_expr ();
-static int parse_opt_untyped_expr ();
-static void parse_if_expression_body PARAMS((void));
+
static void write_lower_upper_value PARAMS ((enum exp_opcode, struct type *));
-static enum ch_terminal ch_lex ();
-static void calculate_array_length PARAMS ((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 ((void));
+static void parse_tuple_element PARAMS ((void));
+static void parse_named_record_element PARAMS ((void));
+static void parse_call PARAMS ((void));
+static struct type *parse_mode_or_normal_call PARAMS ((void));
+#if 0
+static struct type *parse_mode_call PARAMS ((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));
#define MAX_LOOK_AHEAD 2
static enum ch_terminal terminal_buffer[MAX_LOOK_AHEAD+1] = {
/*int current_token, lookahead_token;*/
-#ifdef __GNUC__
-__inline__
-#endif
-static enum ch_terminal
+INLINE static enum ch_terminal
PEEK_TOKEN()
{
if (terminal_buffer[0] == TOKEN_NOT_READ)
/* Skip the next token.
if it isn't TOKEN, the parser is broken. */
-void
+static void
require(token)
enum ch_terminal token;
{
FORWARD_TOKEN();
}
-int
+static int
check_token (token)
enum ch_terminal token;
{
/* return 0 if expected token was not found,
else return 1.
*/
-int
-expect(token, message)
+static int
+expect (token, message)
enum ch_terminal token;
char *message;
{
/* Parse NAME '(' MODENAME ')'. */
-struct type *
+#if 0
+
+static struct type *
parse_mode_call ()
{
struct type *type;
return type;
}
-struct type *
+#endif
+
+static struct type *
parse_mode_or_normal_call ()
{
struct type *type;
parse_named_record_element ()
{
struct stoken label;
+ char buf[256];
label = PEEK_LVAL ().sval;
- expect (FIELD_NAME, "expected a field name here `%s'", lexptr);
+ sprintf (buf, "expected a field name here `%s'", lexptr);
+ expect (FIELD_NAME, buf);
if (check_token (','))
parse_named_record_element ();
else if (check_token (':'))
break;
case GENERAL_PROCEDURE_NAME:
case LOCATION_NAME:
- {
- struct type *type;
-
- /* FIXME: look at calculate_array_length */
- type = PEEK_LVAL().ssym.sym->type;
- if (type && TYPE_CODE (type) == TYPE_CODE_ARRAY &&
- TYPE_LENGTH (type) == 0)
- calculate_array_length (type);
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- FORWARD_TOKEN ();
- }
+ write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (NULL);
+ write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
+ write_exp_elt_opcode (OP_VAR_VALUE);
+ FORWARD_TOKEN ();
break;
case GDB_VARIABLE: /* gdb specific */
FORWARD_TOKEN ();
write_exp_elt_opcode (opcode);
else
{
- extern LONGEST type_lower_upper ();
struct type *result_type;
LONGEST val = type_lower_upper (opcode, type, &result_type);
write_exp_elt_opcode (OP_LONG);
}
}
-/* In certain cases it could happen, that an array type doesn't
- have a length (this have to do with seizing). The reason is
- shown in the following stabs:
-
- .stabs "m_x:Tt81=s36i:1,0,32;ar:82=ar80;0;1;83=xsm_struct:,32,256;;",128,0,25,0
-
- .stabs "m_struct:Tt83=s16f1:9,0,16;f2:85=*84,32,32;f3:84,64,64;;",128,0,10,0
-
- When processing t81, the array ar80 doesn't have a length, cause
- struct m_struct is specified extern at thse moment. Afterwards m_struct
- gets specified and updated, but not the surrounding type.
-
- So we walk through array's till we find a type with a length and
- calculate the array length.
-
- FIXME: Where may this happen too ?
- */
-
-static void
-calculate_array_length (type)
- struct type *type;
-{
- struct type *target_type;
- struct type *range_type;
- LONGEST lower_bound, upper_bound;
-
- if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
- /* not an array, stop processing */
- return;
-
- target_type = TYPE_TARGET_TYPE (type);
- range_type = TYPE_FIELD_TYPE (type, 0);
- lower_bound = TYPE_FIELD_BITPOS (range_type, 0);
- upper_bound = TYPE_FIELD_BITPOS (range_type, 1);
-
- if (TYPE_LENGTH (target_type) == 0 &&
- TYPE_CODE (target_type) == TYPE_CODE_ARRAY)
- /* we've got another array */
- calculate_array_length (target_type);
-
- TYPE_LENGTH (type) = (upper_bound - lower_bound + 1) * TYPE_LENGTH (target_type);
-}
-
void
chill_error (msg)
char *msg;