view tests/agcl/ffcalc/good/ffcm.h @ 15:f5acaf0c8a29

Don't cast through "volatile int". Causes a gcc warning nowadays. XXX: should put something else back here to frighten the optimizer
author David A. Holland
date Tue, 31 May 2022 01:00:55 -0400
parents 13d2b8934445
children
line wrap: on
line source

#ifndef FFCM_H
#define FFCM_H

typedef union {
  double alignment;
  char ag_vt_2[sizeof(int)];
  char ag_vt_4[sizeof(double)];
} ffcm_vs_type;

typedef enum {
  ffcm_white_space_token = 1, ffcm_calculator_token = 3, ffcm_eof_token = 9,
  ffcm_calculation_token, ffcm_expression_token, ffcm_name_token,
  ffcm_error_token = 14, ffcm_term_token, ffcm_factor_token = 18,
  ffcm_identifier_token = 21, ffcm_integer_part_token = 31,
  ffcm_fraction_part_token = 33, ffcm_digit_token = 35,
  ffcm_statement_token = 43, ffcm_real_token = 49, ffcm_letter_token = 53
} ffcm_token_type;

typedef struct ffcm_pcb_struct{
  ffcm_token_type token_number, reduction_token, error_frame_token;
  int input_code;
  int input_value;
  int line, column;
  int ssx, sn, error_frame_ssx;
  int drt, dssx, dsn;
  int ss[128];
  ffcm_vs_type vs[128];
  int ag_ap;
  const char *error_message;
  char read_flag;
  char exit_flag;
  int bts[128], btsx;
  int lab[3], rx, fx;
  const unsigned char *key_sp;
  int save_index, key_state;
  char ag_msg[82];
} ffcm_pcb_type;

#ifndef PRULE_CONTEXT
#define PRULE_CONTEXT(pcb)  (&((pcb).cs[(pcb).ssx]))
#define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx])
#define PCONTEXT(pcb)       ((pcb).cs[(pcb).ssx])
#endif

#ifndef AG_RUNNING_CODE
/* PCB.exit_flag values */
#define AG_RUNNING_CODE         0
#define AG_SUCCESS_CODE         1
#define AG_SYNTAX_ERROR_CODE    2
#define AG_REDUCTION_ERROR_CODE 3
#define AG_STACK_ERROR_CODE     4
#define AG_SEMANTIC_ERROR_CODE  5
#endif

extern ffcm_pcb_type ffcm_pcb;
void init_ffcm(void);
void ffcm(void);
#endif