view tests/agcl/examples/good/jrc.h @ 24:a4899cdfc2d6 default tip

Obfuscate the regexps to strip off the IBM compiler's copyright banners. I don't want bots scanning github to think they're real copyright notices because that could cause real problems.
author David A. Holland
date Mon, 13 Jun 2022 00:40:23 -0400
parents 13d2b8934445
children
line wrap: on
line source

#ifndef JRC_H
#define JRC_H

typedef union {
  long alignment;
  char ag_vt_2[sizeof(int)];
  char ag_vt_4[sizeof(token)];
} cc_vs_type;

typedef enum {
  cc_prog_start_token = 1, cc_statement_token, cc_translation_unit_token,
  cc_eof_token = 5, cc_constant_token, cc_FLOATINGconstant_token,
  cc_INTEGERconstant_token, cc_OCTALconstant_token, cc_HEXconstant_token,
  cc_CHARACTERconstant_token, cc_string_literal_list_token,
  cc_STRINGliteral_token, cc_primary_expression_token, cc_IDENTIFIER_token,
  cc_expression_token = 17, cc_postfix_expression_token = 19,
  cc_argument_expression_list_token = 22,
  cc_identifier_or_typedef_name_token = 24, cc_ARROW_token, cc_ICR_token,
  cc_DECR_token, cc_assignment_expression_token,
  cc_unary_expression_token = 30, cc_unary_operator_token,
  cc_cast_expression_token, cc_SIZEOF_token, cc_type_name_token,
  cc_multiplicative_expression_token = 41,
  cc_additive_expression_token = 44, cc_shift_expression_token, cc_LS_token,
  cc_RS_token, cc_relational_expression_token, cc_LE_token = 51,
  cc_GE_token, cc_equality_expression_token, cc_EQ_token, cc_NE_token,
  cc_AND_expression_token, cc_exclusive_OR_expression_token,
  cc_inclusive_OR_expression_token = 59,
  cc_logical_AND_expression_token = 61, cc_ANDAND_token,
  cc_logical_OR_expression_token, cc_OROR_token,
  cc_conditional_expression_token, cc_assignment_operator_token = 68,
  cc_MULTassign_token = 70, cc_DIVassign_token, cc_MODassign_token,
  cc_PLUSassign_token, cc_MINUSassign_token, cc_LSassign_token,
  cc_RSassign_token, cc_ANDassign_token, cc_ERassign_token,
  cc_ORassign_token, cc_constant_expression_token, cc_expression_opt_token,
  cc_declaration_token, cc_sue_declaration_specifier_token,
  cc_sue_type_specifier_token = 85, cc_declaring_list_token,
  cc_default_declaring_list_token, cc_declaration_qualifier_list_token,
  cc_identifier_declarator_token, cc_initializer_opt_token,
  cc_type_qualifier_list_token, cc_declaration_specifier_token,
  cc_declarator_token, cc_type_specifier_token,
  cc_basic_declaration_specifier_token,
  cc_typedef_declaration_specifier_token, cc_basic_type_specifier_token,
  cc_typedef_type_specifier_token, cc_storage_class_token,
  cc_declaration_qualifier_token, cc_type_qualifier_token, cc_CONST_token,
  cc_VOLATILE_token, cc_basic_type_name_token,
  cc_elaborated_type_name_token, cc_TYPEDEFname_token, cc_TYPEDEF_token,
  cc_EXTERN_token, cc_STATIC_token, cc_AUTO_token, cc_REGISTER_token,
  cc_VOID_token, cc_CHAR_token, cc_SHORT_token, cc_INT_token, cc_LONG_token,
  cc_FLOAT_token, cc_DOUBLE_token, cc_SIGNED_token, cc_UNSIGNED_token,
  cc_save_flag_token, cc_struct_or_union_specifier_token,
  cc_enum_specifier_token, cc_struct_or_union_token,
  cc_struct_declaration_list_token = 126, cc_STRUCT_token = 128,
  cc_UNION_token, cc_struct_declaration_token,
  cc_struct_declaring_list_token, cc_struct_default_declaring_list_token,
  cc_struct_identifier_declarator_token, cc_struct_declarator_token,
  cc_bit_field_size_opt_token, cc_bit_field_size_token, cc_ENUM_token,
  cc_enumerator_list_token, cc_enumerator_value_opt_token,
  cc_parameter_type_list_token, cc_parameter_list_token, cc_ELLIPSIS_token,
  cc_parameter_declaration_token, cc_abstract_declarator_token,
  cc_parameter_typedef_declarator_token, cc_identifier_list_token,
  cc_initializer_token, cc_initializer_list_token,
  cc_labeled_statement_token, cc_compound_statement_token,
  cc_expression_statement_token, cc_selection_statement_token,
  cc_iteration_statement_token, cc_jump_statement_token, cc_CASE_token,
  cc_DEFAULT_token, cc_declaration_list_token, cc_statement_list_token,
  cc_IF_token, cc_ELSE_token, cc_SWITCH_token, cc_WHILE_token, cc_DO_token,
  cc_FOR_token, cc_GOTO_token, cc_CONTINUE_token, cc_BREAK_token,
  cc_RETURN_token, cc_external_definition_token,
  cc_function_definition_token, cc_old_function_declarator_token,
  cc_typedef_declarator_token, cc_paren_typedef_declarator_token,
  cc_postfixing_abstract_declarator_token,
  cc_clean_typedef_declarator_token,
  cc_clean_postfix_typedef_declarator_token,
  cc_paren_postfix_typedef_declarator_token,
  cc_simple_paren_typedef_declarator_token,
  cc_unary_identifier_declarator_token,
  cc_paren_identifier_declarator_token,
  cc_postfix_identifier_declarator_token,
  cc_postfix_old_function_declarator_token,
  cc_unary_abstract_declarator_token, cc_postfix_abstract_declarator_token,
  cc_array_abstract_declarator_token, cc_NAME_token
} cc_token_type;

typedef struct cc_pcb_struct{
  cc_token_type token_number, reduction_token, error_frame_token;
  int input_code;
  token input_value;
  int line, column;
  int ssx, sn, error_frame_ssx;
  int drt, dssx, dsn;
  int ss[128];
  cc_vs_type vs[128];
  int ag_ap;
  const char *error_message;
  char read_flag;
  char exit_flag;
  int bts[128], btsx;
  char ag_msg[82];
  const  int *ag_dtl;
  int ag_dsn;
} cc_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 cc_pcb_type cc_pcb;
void init_cc(void);
void cc(void);
#endif