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

typedef enum {
  y2ag_name_token = 1, y2ag_grammar_token, y2ag_elc_token,
  y2ag_definition_block_token = 5, y2ag_mark_token, y2ag_c_code_block_token,
  y2ag_rule_section_token = 9, y2ag_tail_token, y2ag_eof_token,
  y2ag_definitions_token = 13, y2ag_white_token, y2ag_comment_token = 16,
  y2ag_comment_text_token, y2ag_anything_token = 20, y2ag_blc_token = 24,
  y2ag_clc_token, y2ag_definition_token, y2ag_start_token,
  y2ag_identifier_token, y2ag_union_token, y2ag_union_text_token,
  y2ag_token_token, y2ag_print_token_list_token, y2ag_left_token,
  y2ag_print_prec_list_token, y2ag_right_token = 36, y2ag_nonassoc_token,
  y2ag_type_token, y2ag_type_name_token, y2ag_expect_statement_token,
  y2ag_decl_token = 42, y2ag_decl_name_token = 44, y2ag_decl_white_token,
  y2ag_decl_star_token, y2ag_decl_term_token, y2ag_number_token = 59,
  y2ag_tag_token = 80, y2ag_c_text_token = 84, y2ag_action_token = 86,
  y2ag_embedded_c_token, y2ag_c_char_token = 89, y2ag_simple_c_char_token,
  y2ag_c_code_comment_token = 92, y2ag_nested_c_text_token,
  y2ag_c_literal_character_token = 95, y2ag_literal_string_token,
  y2ag_c_code_comment_text_token = 98, y2ag_digit_token,
  y2ag_octal_digits_token = 102, y2ag_string_character_token = 104,
  y2ag_production_token = 107, y2ag_production_head_token = 111,
  y2ag_complete_rules_token, y2ag_complete_rule_token = 114,
  y2ag_rule_set_continuation_token, y2ag_rule_token = 117,
  y2ag_explicit_precedence_token, y2ag_rule_name_continuation_token = 120,
  y2ag_rule_literal_continuation_token, y2ag_literal_token,
  y2ag_explicit_precedence_head_token, y2ag_prec_token,
  y2ag_literal_character_token = 128, y2ag_octal_number_token = 135,
  y2ag_dot_token = 138, y2ag_tail_code_token
} y2ag_token_type;

typedef struct y2ag_pcb_struct{
  y2ag_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[10], rx, fx;
  const unsigned char *key_sp;
  int save_index, key_state;
  char ag_msg[82];
} y2ag_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 y2ag_pcb_type y2ag_pcb;
void init_y2ag(void);
void y2ag(void);
#endif