view tests/agcl/contrib/good/plm.h @ 11:3aa0f5a02342

Remove unused variable; fix what it was supposed to be doing. (and document it a bit for the next time through here)
author David A. Holland
date Tue, 31 May 2022 00:54:12 -0400
parents 13d2b8934445
children
line wrap: on
line source

#ifndef PLM_H
#define PLM_H

typedef enum {
  plm_compilation_token = 57, plm_white_space_token,
  plm_actual_parameters_token = 68, plm_expression_list_token = 70,
  plm_adding_operator_token = 72, plm_MINUS_SIGN_token,
  plm_and_operator_token = 75, plm_arithmetic_expression_token,
  plm_term_token, plm_array_specifier_token, plm_explicit_dimension_token,
  plm_implicit_dimension_token, plm_assignment_statement_token,
  plm_left_part_token, plm_expression_token = 84,
  plm_base_specifier_token = 86, plm_basic_statement_token = 88,
  plm_call_statement_token, plm_goto_statement_token,
  plm_microprocessor_dependent_statement_token, plm_null_statement_token,
  plm_return_statement_token, plm_basic_type_token,
  plm_bound_expression_token, plm_by_part_token, plm_step_expression_token,
  plm_simple_variable_token, plm_cast_type_token,
  plm_cause_interrupt_statement_token, plm_module_token = 102,
  plm_eof_token, plm_conditional_clause_token, plm_if_condition_token,
  plm_true_unit_token, plm_true_element_token, plm_false_element_token,
  plm_constant_token, plm_constant_attribute_token, plm_constant_list_token,
  plm_declaration_token = 113, plm_declare_statement_token,
  plm_procedure_definition_token, plm_declaration_sequence_token,
  plm_declare_element_token, plm_factored_element_token,
  plm_unfactored_element_token, plm_declare_element_list_token,
  plm_disable_statement_token, plm_do_block_token, plm_do_case_block_token,
  plm_do_while_block_token, plm_iterative_do_block_token,
  plm_simple_do_block_token, plm_do_case_statement_token, plm_ending_token,
  plm_unit_sequence_token, plm_do_while_statement_token,
  plm_embedded_assignment_token, plm_variable_reference_token,
  plm_logical_expression_token, plm_enable_statement_token,
  plm_end_statement_token, plm_opt_identifier_token,
  plm_label_definition_sequence_token, plm_factored_label_element_token,
  plm_factored_variable_element_token,
  plm_variable_name_specifier_list_token, plm_opt_public_or_external_token,
  plm_factored_member_token, plm_member_name_list_token,
  plm_opt_explicit_dimension_token, plm_variable_type_token,
  plm_opt_variable_attributes_token, plm_unit_token,
  plm_formal_parameter_token, plm_formal_parameter_list_token,
  plm_formal_parameter_specifier_token, plm_go_to_token,
  plm_halt_statement_token, plm_id_colon_token, plm_index_part_token = 156,
  plm_index_variable_token, plm_start_expression_token,
  plm_initial_value_token, plm_initial_value_list_token,
  plm_initialization_token, plm_binary_number_token,
  plm_decimal_number_token, plm_hex_number_token, plm_octal_number_token,
  plm_interrupt_token, plm_opt_interrupt_number_token,
  plm_interrupt_number_token, plm_iterative_do_statement_token,
  plm_to_part_token, plm_opt_by_part_token, plm_label_definition_token,
  plm_label_element_token, plm_variable_reference_list_token,
  plm_literal_element_token, plm_location_reference_token,
  plm_locator_token = 178, plm_locator_initialization_token,
  plm_logical_factor_token, plm_or_operator_token,
  plm_logical_secondary_token, plm_logical_primary_token,
  plm_relation_operator_token, plm_member_element_token,
  plm_structure_type_token, plm_unfactored_member_token,
  plm_member_element_list_token, plm_member_name_token,
  plm_member_specifier_token, plm_subscript_token,
  plm_member_specifier_sequence_token, plm_module_name_token,
  plm_multiplying_operator_token, plm_floating_point_number_token = 196,
  plm_opt_array_specifier_token, plm_opt_formal_parameter_specifier_token,
  plm_opt_procedure_attribute_sequence_token,
  plm_procedure_attribute_sequence_token, plm_opt_procedure_type_token,
  plm_procedure_type_token, plm_variable_attributes_token,
  plm_primary_token, plm_subexpression_token, plm_procedure_attribute_token,
  plm_procedure_statement_token, plm_typed_return_token = 210,
  plm_untyped_return_token, plm_secondary_token, plm_unary_sign_token,
  plm_simple_do_statement_token, plm_subscript_or_actual_parameters_token,
  plm_true_statement_token, plm_unary_minus_token, plm_unary_plus_token,
  plm_variable_element_token, plm_unit_element_token,
  plm_variable_name_specifier_token, plm_decimal_number_tail_token,
  plm_binary_number_tail_token = 226, plm_octal_number_tail_token = 229,
  plm_hex_number_tail_token = 232,
  plm_floating_point_number_tail_token = 235, plm_fraction_part_token,
  plm_exponent_token, plm_RPAREN_token = 258, plm_LPAREN_token,
  plm_MINUS_token, plm_PLUS_token, plm_PLUS_SIGN_token, plm_AND_token,
  plm_SEMI_token, plm_EQ_token, plm_IDENTIFIER_token, plm_DOT_token,
  plm_ADDRESS_token, plm_BYTE_token, plm_CHARINT_token, plm_DWORD_token,
  plm_HWORD_token, plm_INTEGER_token, plm_LONGINT_token, plm_OFFSET_token,
  plm_POINTER_token, plm_QWORD_token, plm_REAL_token, plm_SELECTOR_token,
  plm_SHORTINT_token, plm_WORD_token, plm_BY_token, plm_CALL_token,
  plm_CAUSE_INTERRUPT_token, plm_EOF_KW_token, plm_ELSE_token,
  plm_STRING_token, plm_numeric_constant_token, plm_DATA_token,
  plm_COMMA_token, plm_DECLARE_token, plm_DISABLE_token, plm_CASE_token,
  plm_DO_token, plm_WHILE_token, plm_ASSIGN_OP_token, plm_ENABLE_token,
  plm_END_token, plm_LABEL_token, plm_GOTO_token, plm_TO_token,
  plm_GO_token, plm_HALT_token, plm_COLON_token, plm_THEN_token,
  plm_IF_token, plm_STAR_token, plm_INITIAL_KW_token, plm_INTERRUPT_token,
  plm_LITERALLY_token, plm_AT_SIGN_token, plm_AT_token, plm_NOT_token,
  plm_MOD_token, plm_SLASH_token, plm_EXTERNAL_token, plm_PUBLIC_token,
  plm_OR_token, plm_XOR_token, plm_REENTRANT_token, plm_PROCEDURE_token,
  plm_GE_token, plm_GT_token, plm_LE_token, plm_LT_token, plm_NE_token,
  plm_STRUCTURE_token, plm_RETURN_token, plm_BASED_token,
  plm_integer_constant_token = 331
} plm_token_type;

typedef struct plm_pcb_struct{
  plm_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];
  int vs[128];
  int ag_ap;
  const char *error_message;
  char read_flag;
  char exit_flag;
  int bts[128], btsx;
  int lab[15], rx, fx;
  const unsigned char *key_sp;
  int save_index, key_state;
  char ag_msg[82];
} plm_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 plm_pcb_type plm_pcb;
void init_plm(void);
void plm(void);
#endif