comparison tests/agcl/parsifal/good/cpp.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 CPP_H
2 #define CPP_H
3
4 typedef union {
5 long alignment;
6 char ag_vt_2[sizeof(int)];
7 char ag_vt_4[sizeof(InputToken)];
8 char ag_vt_5[sizeof(TypeDefinition)];
9 char ag_vt_6[sizeof(Scope *)];
10 } parse_vs_type;
11
12 typedef enum {
13 parse_line_number_token = 1, parse_statement_token,
14 parse_type_specifier_seq_token, parse_ptr_operator_token,
15 parse_class_name_token, parse_explicitly_typed_identifier_token = 7,
16 parse_nested_name_specifier_token, parse_translation_unit_token = 13,
17 parse_declaration_list_token, parse_eof_token, parse_literal_token,
18 parse_template_id_token = 25, parse_primary_expression_token,
19 parse_operator_function_id_token = 29, parse_qualified_id_token,
20 parse_expression_hack_1_token = 32, parse_unqualified_id_token = 34,
21 parse_id_expression_token, parse_conversion_function_id_token,
22 parse_namespace_name_token = 38, parse_postfix_expression_token,
23 parse_expression_token = 41, parse_expression_list_token = 43,
24 parse_simple_type_specifier_token = 45,
25 parse_pseudo_destructor_name_token = 48, parse_type_id_token = 53,
26 parse_assignment_expression_token = 59,
27 parse_nonclass_type_name_token = 61, parse_unary_expression_token = 63,
28 parse_cast_expression_token, parse_unary_operator_token,
29 parse_new_expression_token = 67, parse_delete_expression_token,
30 parse_new_token = 74, parse_new_type_id_token,
31 parse_new_initializer_token, parse_new_placement_token = 78,
32 parse_expression_list_hack_2_token, parse_retry_token,
33 parse_resynch_token, parse_new_declarator_token,
34 parse_direct_new_declarator_token, parse_constant_expression_token,
35 parse_delete_token, parse_error_token,
36 parse_restricted_assignment_expression_hack_5_token,
37 parse_restricted_assignment_expression_token, parse_pm_expression_token,
38 parse_multiplicative_expression_token = 92,
39 parse_additive_expression_token = 95, parse_shift_expression_token,
40 parse_relational_expression_token = 99,
41 parse_equality_expression_token = 102, parse_and_expression_token = 105,
42 parse_exclusive_or_expression_token,
43 parse_inclusive_or_expression_token = 108,
44 parse_logical_and_expression_token = 110,
45 parse_logical_or_expression_token = 112,
46 parse_conditional_expression_token = 114,
47 parse_assignment_operator_token = 117, parse_throw_expression_token,
48 parse_labeled_statement_token = 130, parse_compound_statement_token,
49 parse_selection_statement_token, parse_iteration_statement_token,
50 parse_jump_statement_token, parse_try_block_token,
51 parse_block_declaration_token, parse_variable_declaration_token,
52 parse_function_definition_2_token, parse_statement_try_2_token,
53 parse_type_qualifier_token, parse_declarator_list_token = 142,
54 parse_function_definition_1_token = 144, parse_statement_try_3_token,
55 parse_expression_statement_token, parse_begin_block_token = 149,
56 parse_statement_seq_token, parse_condition_token = 155,
57 parse_condition_kernel_token = 158, parse_declarator_token,
58 parse_condition_kernel_2_token, parse_for_header_token = 163,
59 parse_for_init_statement_token, parse_for_init_token = 169,
60 parse_for_variable_declaration_token, parse_for_init_2_token,
61 parse_decl_specifier_seq_token, parse_init_declarator_list_token,
62 parse_declaration_seq_token = 178, parse_declaration_hack_token,
63 parse_declaration_token, parse_simple_declaration_token,
64 parse_explicit_instantiation_token, parse_explicit_specialization_token,
65 parse_linkage_specification_token, parse_namespace_definition_token,
66 parse_asm_definition_token, parse_namespace_alias_definition_token,
67 parse_using_declaration_token, parse_using_directive_token,
68 parse_template_header_token, parse_attempt_declarator_list_token = 192,
69 parse_resynch_text_token, parse_balanced_braces_token,
70 parse_resynch_item_token, parse_balanced_parens_token = 197,
71 parse_balanced_brackets_token, parse_not_right_paren_token,
72 parse_not_right_bracket_token, parse_not_right_brace_token,
73 parse_fundamental_type_token = 206, parse_predefined_specifier_token,
74 parse_user_defined_specifier_token = 211,
75 parse_restricted_decl_specifier_seq_token = 213,
76 parse_restricted_specifier_token, parse_qualified_type_name_token,
77 parse_storage_class_specifier_token, parse_function_specifier_token = 222,
78 parse_cv_qualifier_token = 228, parse_class_specifier_token = 240,
79 parse_enum_specifier_token, parse_elaborated_type_specifier_token,
80 parse_user_type_specifier_token, parse_class_key_token = 246,
81 parse_name_qualifier_token, parse_template_argument_list_token = 249,
82 parse_enumerator_list_token = 251,
83 parse_enumerator_definition_token = 253,
84 parse_named_namespace_definition_token = 256,
85 parse_unnamed_namespace_definition_token,
86 parse_original_namespace_definition_token,
87 parse_extension_namespace_definition_token,
88 parse_namespace_body_token = 261,
89 parse_qualified_namespace_specifier_token,
90 parse_init_declarator_token = 265, parse_direct_declarator_token,
91 parse_initializer_token, parse_declarator_id_token,
92 parse_parameter_declaration_clause_hack_4_token,
93 parse_cv_qualifier_seq_token, parse_exception_specification_token = 272,
94 parse_declarator_hack_token = 275, parse_direct_declarator_hack_token,
95 parse_declarator_hack_3_token, parse_abstract_declarator_token = 281,
96 parse_abstract_declarator_hack_token = 285,
97 parse_direct_abstract_declarator_hack_token = 287,
98 parse_parameter_declaration_clause_hack_3_token,
99 parse_parameter_declaration_clause_token,
100 parse_direct_abstract_declarator_token = 291,
101 parse_parameter_declaration_list_token,
102 parse_parameter_declaration_token = 294,
103 parse_expression_list_hack_4_token = 296,
104 parse_constructor_identifier_token = 300, parse_ctor_initializer_token,
105 parse_function_body_token = 303, parse_constructor_try_block_token,
106 parse_handler_seq_token = 306, parse_function_identifier_token,
107 parse_function_try_block_token, parse_initializer_clause_token,
108 parse_initializer_list_token, parse_class_head_token = 312,
109 parse_member_specification_token, parse_base_clause_token = 315,
110 parse_specifier_lookahead_token,
111 parse_member_declaration_hack_token = 321, parse_member_declaration_token,
112 parse_member_restore_token, parse_member_declarator_list_token,
113 parse_access_specifier_token = 326, parse_member_declarator_token,
114 parse_pure_specifier_token, parse_constant_intializer_token,
115 parse_base_specifier_list_token = 331, parse_base_specifier_token,
116 parse_qualified_class_name_token, parse_conversion_type_id_token = 340,
117 parse_conversion_declarator_token, parse_mem_initializer_list_token = 343,
118 parse_mem_initializer_token, parse_mem_initializer_id_token,
119 parse_operator_token, parse_template_parameter_list_token = 348,
120 parse_template_parameter_token, parse_type_parameter_token,
121 parse_template_parameter_declaration_token,
122 parse_restricted_conditional_expression_token,
123 parse_restricted_throw_expression_token,
124 parse_template_argument_token = 357, parse_handler_token,
125 parse_exception_declaration_token = 360, parse_type_id_list_token = 362,
126 parse_HEXconstant_token = 367, parse_OCTconstant_token,
127 parse_DECconstant_token, parse_FLOATconstant_token,
128 parse_CHARACTERconstant_token, parse_STRINGliteral_token,
129 parse_CLASS_NAME_token, parse_THIS_token, parse_IDENTIFIER_token,
130 parse_QUAL_token, parse_TEMPLATE_token = 379, parse_ARROW_token = 383,
131 parse_INCR_token, parse_DECR_token, parse_DYNAMIC_CAST_token = 388,
132 parse_STATIC_CAST_token, parse_REINTERPRET_CAST_token,
133 parse_CONST_CAST_token, parse_TYPEID_token, parse_SIZEOF_token = 395,
134 parse_NEW_token = 401, parse_DELETE_token, parse_DOT_STAR_token,
135 parse_ARROW_STAR_token, parse_LS_token = 407, parse_RS_token,
136 parse_LE_token, parse_GE_token, parse_EQ_token, parse_NE_token,
137 parse_AND_token = 415, parse_OR_token, parse_MULT_EQ_token = 420,
138 parse_DIV_EQ_token, parse_MOD_EQ_token, parse_ADD_EQ_token,
139 parse_SUB_EQ_token, parse_LS_EQ_token, parse_RS_EQ_token,
140 parse_AND_EQ_token, parse_OR_EQ_token, parse_XOR_EQ_token,
141 parse_CASE_token = 431, parse_DEFAULT_token, parse_IF_token = 435,
142 parse_ELSE_token, parse_SWITCH_token, parse_WHILE_token, parse_DO_token,
143 parse_FOR_token, parse_BREAK_token, parse_CONTINUE_token,
144 parse_RETURN_token, parse_GOTO_token, parse_EXPORT_token,
145 parse_AUTO_token, parse_REGISTER_token, parse_STATIC_token,
146 parse_EXTERN_token, parse_MUTABLE_token, parse_INLINE_token,
147 parse_VIRTUAL_token, parse_EXPLICIT_token, parse_FRIEND_token,
148 parse_TYPEDEF_token, parse_CHAR_token, parse_WCHAR_T_token,
149 parse_BOOL_token, parse_SHORT_token, parse_INT_token, parse_LONG_token,
150 parse_SIGNED_token, parse_UNSIGNED_token, parse_FLOAT_token,
151 parse_DOUBLE_token, parse_VOID_token, parse_ENUM_NAME_token,
152 parse_TYPEDEF_NAME_token, parse_ENUM_token, parse_TYPENAME_token,
153 parse_NAMESPACE_NAME_token, parse_NAMESPACE_ALIAS_token,
154 parse_NAMESPACE_token, parse_USING_token, parse_ASM_token,
155 parse_CONSTANT_token, parse_VOLATILE_token, parse_TEMPLATE_NAME_token,
156 parse_ELLIPSIS_token, parse_TRY_token, parse_CLASS_token,
157 parse_STRUCT_token, parse_UNION_token, parse_PRIVATE_token = 485,
158 parse_PROTECTED_token, parse_PUBLIC_token, parse_OPERATOR_token,
159 parse_THROW_token, parse_CATCH_token, parse_LINE_token = 492
160 } parse_token_type;
161
162 typedef struct parse_pcb_struct{
163 parse_token_type token_number, reduction_token, error_frame_token;
164 int input_code;
165 InputToken input_value;
166 int line, column;
167 int ssx, sn, error_frame_ssx;
168 int drt, dssx, dsn;
169 int ss[128];
170 parse_vs_type vs[128];
171 int ag_ap;
172 const char *error_message;
173 char read_flag;
174 char exit_flag;
175 ParserState input_context;
176 ParserState cs[128];
177 int bts[128], btsx;
178 InputToken * pointer;
179 InputToken * la_ptr;
180 char ag_msg[82];
181 } parse_pcb_type;
182
183 #ifndef PRULE_CONTEXT
184 #define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx]))
185 #define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx])
186 #define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx])
187 #endif
188
189 #ifndef AG_RUNNING_CODE
190 /* PCB.exit_flag values */
191 #define AG_RUNNING_CODE 0
192 #define AG_SUCCESS_CODE 1
193 #define AG_SYNTAX_ERROR_CODE 2
194 #define AG_REDUCTION_ERROR_CODE 3
195 #define AG_STACK_ERROR_CODE 4
196 #define AG_SEMANTIC_ERROR_CODE 5
197 #endif
198 void init_parse(void);
199 void parse(void);
200 #endif
201