view tests/agcl/oldagsrc/good/asiwdp.h @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

#ifndef ASIWDP_H
#define ASIWDP_H

typedef union {
  double alignment;
  char ag_vt_2[sizeof(int)];
  char ag_vt_4[sizeof(double)];
  char ag_vt_5[sizeof(Location)];
  char ag_vt_6[sizeof(double *)];
} asi_vs_type;

typedef enum {
  asi_white_space_token = 1, asi_input_string_token = 4,
  asi_statements_token, asi_eof_token = 7, asi_statement_token,
  asi_skip_statement_token, asi_skip_open_statement_token,
  asi_skip_closed_statement_token, asi_statement_text_token,
  asi_balanced_braces_token = 15, asi_balanced_parens_token = 17,
  asi_open_statement_token = 20, asi_closed_statement_token,
  asi_expression_token, asi_true_if_condition_token = 25,
  asi_false_if_condition_token, asi_closed_while_token,
  asi_execute_while_token, asi_open_while_token, asi_while_token = 32,
  asi_while_loop_token, asi_false_while_condition_token,
  asi_true_while_condition_token, asi_conditional_expression_token,
  asi_logical_or_expression_token = 42,
  asi_logical_and_expression_token = 45, asi_equality_expression_token = 47,
  asi_relational_expression_token = 49, asi_additive_expression_token = 52,
  asi_multiplicative_expression_token = 57, asi_unary_expression_token = 60,
  asi_factor_token = 63, asi_primary_token, asi_blank_token = 72,
  asi_statement_char_token = 83, asi_name_string_token = 87,
  asi_letter_token, asi_simple_real_token = 90, asi_exponent_token = 93,
  asi_integer_part_token, asi_fraction_part_token = 96,
  asi_name_token = 114, asi_real_token = 134, asi_digit_token = 143
} asi_token_type;

typedef struct asi_pcb_struct{
  asi_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];
  asi_vs_type vs[128];
  int ag_ap;
  const char *error_message;
  char read_flag;
  char exit_flag;
  int bts[128], btsx;
  unsigned char * pointer;
  unsigned char * la_ptr;
  const unsigned char *key_sp;
  int save_index, key_state;
  char ag_msg[82];
  const  int *ag_dtl;
  int ag_dsn;
/*  Line -, asiwdp.syn */
                                  // Add declarations to parser control block
    CharStack charStack;                        // Stack to accumulate variable names
		WhileStack whileStack;                      // Stack of active while loops
		SymbolTable *symbolTable;                   // Pointer to external symbol table

		void pushChar(int c);                       // Add character to character stack
		double *locateValue(int k);                 // Identify variable named on character stack
		void stackLoop(const Location &c);          // Provide for nested while loops
		Location location();                        // Capture current location of parse
		void setLocation(const Location &l);        // Set location of parse
		void loopContinue();                        // Set location to continue current while loop
		void loopExit();                            // Set location to exit current while loop
		double checkZero(double value);             // Check for zero divisor

		// External interface to the parser
    int interpret(char *text, SymbolTable *s);  // Parse instructions in text, using variables defined in s
	} asi_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
void init_asi(asi_pcb_type *);
void asi(asi_pcb_type *);
#endif