view tests/agcl/oldagsrc/good/pgg24ts.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 PGG24TS_H
#define PGG24TS_H

#ifndef AG_OBJECT_WRAPPER_DEFINED
#define AG_OBJECT_WRAPPER_DEFINED

#ifndef AG_PLACEMENT_DELETE_REQUIRED
#if _MSC_VER >= 1200 || __INTEL_COMPILER
#define AG_PLACEMENT_DELETE_REQUIRED 1
#endif
#endif

template <class Object>
class AgObjectWrapper {
  Object object;
public:
  void operator delete(void *) {}
  void *operator new(size_t, void *p) { return p;}
#if AG_PLACEMENT_DELETE_REQUIRED
  void operator delete(void *, void *) { }
#endif
  AgObjectWrapper(const Object &o) : object(o) {}
  ~AgObjectWrapper() {}
  operator Object &() {return object;}
};

#endif

typedef union {
  long alignment;
  char ag_vt_2[sizeof(int)];
  char ag_vt_4[sizeof(AgObjectWrapper<Expression >)];
  char ag_vt_5[sizeof(unsigned char *)];
} pgg_vs_type;

typedef enum {
  pgg_arrow_token = 1, pgg_blank_token = 3, pgg_comma_token = 6,
  pgg_space_token = 8, pgg_ellipsis_token = 10, pgg_equals_token = 12,
  pgg_bang_token = 14, pgg_left_brace_token = 16,
  pgg_left_bracket_token = 18, pgg_left_parenthesis_token = 20,
  pgg_minus_token = 22, pgg_plus_token = 24, pgg_right_bracket_token = 26,
  pgg_right_brace_token = 28, pgg_right_parenthesis_token = 30,
  pgg_right_quote_token = 32, pgg_single_quote_token, pgg_tilde_token,
  pgg_vertical_bar_token = 36, pgg_syntax_definition_token = 38,
  pgg_end_of_line_token, pgg_complete_statements_token = 41,
  pgg_statement_token, pgg_eof_token = 44, pgg_production_token,
  pgg_definition_token, pgg_embedded_c_token,
  pgg_configuration_section_token, pgg_complete_statement_token,
  pgg_simple_statement_token, pgg_left_hand_side_token,
  pgg_right_hand_side_token, pgg_additional_rule_spec_token,
  pgg_rule_specs_token = 55, pgg_token_name_list_token,
  pgg_type_definition_token, pgg_token_name_token, pgg_name_token,
  pgg_data_type_token = 61, pgg_proper_vp_rule_specs_token,
  pgg_vp_rule_spec_token, pgg_additional_vp_rule_spec_token,
  pgg_vp_rule_specs_token, pgg_reduction_procedure_token,
  pgg_vp_rules_token, pgg_grammar_rule_token, pgg_rule_spec_token,
  pgg_init_grammar_rule_token, pgg_rule_element_token,
  pgg_parameter_name_token, pgg_c_expression_token,
  pgg_type_name_token = 75, pgg_template_field_token,
  pgg_abstract_declarator_token = 78, pgg_indirect_data_type_token = 82,
  pgg_direct_abstract_declarator_token, pgg_template_field_head_token,
  pgg_star_token = 88, pgg_pointer_token = 90, pgg_name_string_token,
  pgg_letter_token, pgg_enum_fix_token = 94, pgg_blank_char_token = 96,
  pgg_c_comment_token, pgg_continuation_token, pgg_comment_token,
  pgg_next_line_token, pgg_carriage_return_token, pgg_newline_token = 103,
  pgg_white_token, pgg_vertical_space_token, pgg_character_token = 110,
  pgg_signed_number_token, pgg_quoted_character_token = 114,
  pgg_char_const_token, pgg_sign_token, pgg_simple_number_token,
  pgg_decimal_number_token = 119, pgg_octal_number_token = 121,
  pgg_hex_number_token = 125, pgg_hex_digit_token = 129,
  pgg_token_token = 131, pgg_mid_rule_action_token, pgg_union_token,
  pgg_virtual_production_token, pgg_intersection_token, pgg_negation_token,
  pgg_simple_set_token = 138, pgg_escape_sequence_token = 140,
  pgg_octal_escape_token, pgg_three_octal_token, pgg_hex_escape_token,
  pgg_character_range_token, pgg_enum_definition_token = 146,
  pgg_enum_statement_token, pgg_keyword_string_token,
  pgg_keyword_string_head_token, pgg_string_token, pgg_double_quote_token,
  pgg_string_A_token, pgg_string_B_token, pgg_string_C_token,
  pgg_string_char_token, pgg_simple_string_char_token,
  pgg_one_octal_token = 168, pgg_backslash_token, pgg_two_octal_token,
  pgg_any_digit_token = 172, pgg_nonoctal_digit_token,
  pgg_c_name_token = 175, pgg_simple_name_token,
  pgg_configuration_parameters_token,
  pgg_configuration_parameter_list_token,
  pgg_configuration_parameter_token = 180, pgg_attribute_statement_token,
  pgg_keyword_kluge_token, pgg_token_list_token = 185,
  pgg_new_reserve_statement_token = 191, pgg_list_end_token,
  pgg_macro_name_token = 199, pgg_tokens_token = 201,
  pgg_embedded_c_head_token = 208, pgg_c_code_token,
  pgg_c_code_first_token = 213, pgg_c_text_token,
  pgg_c_character_constant_token = 216, pgg_c_string_constant_token,
  pgg_c_char_token, pgg_simple_c_char_token, pgg_c_expression_head_token,
  pgg_c_chars_token, pgg_c_expression_char_token,
  pgg_c_comment_head_token = 225, pgg_c_literal_elem_token = 229,
  pgg_anything_token
} pgg_token_type;

typedef struct pgg_pcb_struct{
  pgg_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];
  pgg_vs_type vs[128];
  int ag_ap;
  const char *error_message;
  char read_flag;
  char exit_flag;
  cint input_context;
  cint cs[128];
  int bts[128], btsx;
  int (* const  *gt_procs)(void);
  int (* const *r_procs)(void);
  int (* const *s_procs)(void);
  unsigned char * pointer;
  unsigned char * la_ptr;
  const unsigned char *key_sp;
  int save_index, key_state;
  int ag_error_depth, ag_min_depth, ag_tmp_depth;
  int ag_rss[2*128], ag_lrss;
  char ag_msg[82];
  const  int *ag_dtl;
  int ag_dsn;
  int ag_resynch_active;
/*  Line -, pgg24ts.syn */
    IPrivateResource mutex;
    int x;
    int y;
    int widget(int x) {
      return x;
    }
  } pgg_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_pgg(void);
void pgg(void);
#endif