comparison tests/agcl/examples/good/krc.h @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 #ifndef KRC_H
2 #define KRC_H
3
4 typedef union {
5 long alignment;
6 char ag_vt_2[sizeof(int)];
7 char ag_vt_4[sizeof(token)];
8 } cc_vs_type;
9
10 typedef enum {
11 cc_program_token = 1, cc_statement_token, cc_translation_unit_token,
12 cc_eof_token, cc_external_declaration_token, cc_function_definition_token,
13 cc_declaration_token, cc_declarator_token, cc_compound_statement_token,
14 cc_declaration_list_token, cc_declaration_specifiers_token,
15 cc_init_declarator_list_token, cc_storage_class_specifier_token = 15,
16 cc_type_specifier_token, cc_type_qualifier_token, cc_AUTO_token,
17 cc_REGISTER_token, cc_STATIC_token, cc_EXTERN_token, cc_TYPEDEF_token,
18 cc_VOIDkey_token, cc_CHAR_token, cc_SHORT_token, cc_INT_token,
19 cc_LONG_token, cc_FLOAT_token, cc_DOUBLE_token, cc_SIGNED_token,
20 cc_UNSIGNED_token, cc_struct_or_union_specifier_token,
21 cc_enum_specifier_token, cc_typedef_name_token, cc_CONSTANT_token,
22 cc_VOLATILE_token, cc_struct_or_union_token, cc_identifier_token,
23 cc_struct_declaration_list_token = 42, cc_STRUCT_token = 44,
24 cc_UNION_token, cc_struct_declaration_token, cc_init_declarator_token,
25 cc_initializer_token = 50, cc_specifier_qualifier_list_token,
26 cc_struct_declarator_list_token, cc_struct_declarator_token,
27 cc_constant_expression_token = 56, cc_ENUM_token,
28 cc_enumerator_list_token, cc_enumerator_token, cc_direct_declarator_token,
29 cc_pointer_token, cc_parameter_type_list_token = 67,
30 cc_identifier_list_token, cc_type_qualifier_list_token = 71,
31 cc_parameter_list_token = 73, cc_ELLIPSIS_token,
32 cc_parameter_declaration_token, cc_abstract_declarator_token,
33 cc_assignment_expression_token = 78, cc_initializer_list_token,
34 cc_type_name_token, cc_direct_abstract_declarator_token,
35 cc_NAME_token = 83, cc_labeled_statement_token,
36 cc_expression_statement_token, cc_selection_statement_token,
37 cc_iteration_statement_token, cc_jump_statement_token, cc_CASE_token,
38 cc_DEFAULT_token, cc_expression_token, cc_statement_list_token = 93,
39 cc_IF_token = 95, cc_ELSE_token, cc_SWITCH_token, cc_WHILE_token,
40 cc_DO_token, cc_FOR_token, cc_GOTO_token, cc_CONTINUE_token,
41 cc_BREAK_token, cc_RETURN_token, cc_conditional_expression_token,
42 cc_unary_expression_token, cc_assignment_operator_token,
43 cc_MULTassign_token, cc_DIVassign_token, cc_MODassign_token,
44 cc_PLUSassign_token, cc_MINUSassign_token, cc_LSassign_token,
45 cc_RSassign_token, cc_ANDassign_token, cc_ORassign_token,
46 cc_ERassign_token, cc_logical_or_expression_token,
47 cc_logical_and_expression_token = 120, cc_OROR_token,
48 cc_inclusive_or_expression_token, cc_ANDAND_token,
49 cc_exclusive_or_expression_token, cc_and_expression_token = 126,
50 cc_equality_expression_token = 128, cc_relational_expression_token = 130,
51 cc_EQ_token, cc_NE_token, cc_shift_expression_token, cc_LE_token = 136,
52 cc_GE_token, cc_additive_expression_token, cc_LS_token, cc_RS_token,
53 cc_multiplicative_expression_token, cc_cast_expression_token = 144,
54 cc_postfix_expression_token = 147, cc_ICR_token, cc_DECR_token,
55 cc_unary_operator_token, cc_SIZEOF_token,
56 cc_primary_expression_token = 154, cc_argument_expression_list_token,
57 cc_ARROW_token = 158, cc_constant_token, cc_STRINGliteral_token,
58 cc_HEXconstant_token, cc_OCTconstant_token, cc_DECconstant_token,
59 cc_FLOATconstant_token, cc_CHARACTERconstant_token
60 } cc_token_type;
61
62 typedef struct cc_pcb_struct{
63 cc_token_type token_number, reduction_token, error_frame_token;
64 int input_code;
65 token input_value;
66 int line, column;
67 int ssx, sn, error_frame_ssx;
68 int drt, dssx, dsn;
69 int ss[128];
70 cc_vs_type vs[128];
71 int ag_ap;
72 const char *error_message;
73 char read_flag;
74 char exit_flag;
75 int bts[128], btsx;
76 char ag_msg[82];
77 const int *ag_dtl;
78 int ag_dsn;
79 } cc_pcb_type;
80
81 #ifndef PRULE_CONTEXT
82 #define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx]))
83 #define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx])
84 #define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx])
85 #endif
86
87 #ifndef AG_RUNNING_CODE
88 /* PCB.exit_flag values */
89 #define AG_RUNNING_CODE 0
90 #define AG_SUCCESS_CODE 1
91 #define AG_SYNTAX_ERROR_CODE 2
92 #define AG_REDUCTION_ERROR_CODE 3
93 #define AG_STACK_ERROR_CODE 4
94 #define AG_SEMANTIC_ERROR_CODE 5
95 #endif
96
97 extern cc_pcb_type cc_pcb;
98 void init_cc(void);
99 void cc(void);
100 #endif
101