comparison tests/agcl/oldagsrc/good/bciastp.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 BCIASTP_H
2 #define BCIASTP_H
3
4 #ifndef AG_OBJECT_WRAPPER_DEFINED
5 #define AG_OBJECT_WRAPPER_DEFINED
6
7 #ifndef AG_PLACEMENT_DELETE_REQUIRED
8 #if _MSC_VER >= 1200 || __INTEL_COMPILER
9 #define AG_PLACEMENT_DELETE_REQUIRED 1
10 #endif
11 #endif
12
13 template <class Object>
14 class AgObjectWrapper {
15 Object object;
16 public:
17 void operator delete(void *) {}
18 void *operator new(size_t, void *p) { return p;}
19 #if AG_PLACEMENT_DELETE_REQUIRED
20 void operator delete(void *, void *) { }
21 #endif
22 AgObjectWrapper(const Object &o) : object(o) {}
23 ~AgObjectWrapper() {}
24 operator Object &() {return object;}
25 };
26
27 #endif
28
29 typedef union {
30 double alignment;
31 char ag_vt_2[sizeof(int)];
32 char ag_vt_4[sizeof(AgObjectWrapper<AgStack<Statement *> >)];
33 char ag_vt_5[sizeof(AgObjectWrapper<AgString >)];
34 char ag_vt_6[sizeof(Program *)];
35 char ag_vt_7[sizeof(Statement *)];
36 char ag_vt_8[sizeof(Expression *)];
37 char ag_vt_9[sizeof(double)];
38 } astParse_vs_type;
39
40 typedef enum {
41 astParse_white_space_token = 1, astParse_input_string_token = 4,
42 astParse_statements_token, astParse_eof_token, astParse_statement_token,
43 astParse_closed_statement_token, astParse_open_statement_token,
44 astParse_expression_token = 12, astParse_simple_statement_token = 18,
45 astParse_assignment_expression_token = 22,
46 astParse_conditional_expression_token = 24,
47 astParse_logical_or_expression_token = 30,
48 astParse_logical_and_expression_token = 33,
49 astParse_equality_expression_token = 35,
50 astParse_relational_expression_token = 37,
51 astParse_additive_expression_token = 40,
52 astParse_multiplicative_expression_token = 45,
53 astParse_unary_expression_token = 48, astParse_factor_token = 51,
54 astParse_primary_token = 53, astParse_simple_real_token = 69,
55 astParse_exponent_token = 72, astParse_integer_part_token,
56 astParse_fraction_part_token = 75, astParse_digit_token = 77,
57 astParse_letter_token, astParse_name_token = 97,
58 astParse_real_token = 118
59 } astParse_token_type;
60
61 typedef struct astParse_pcb_struct{
62 astParse_token_type token_number, reduction_token, error_frame_token;
63 int input_code;
64 int input_value;
65 int line, column;
66 int ssx, sn, error_frame_ssx;
67 int drt, dssx, dsn;
68 int ss[128];
69 astParse_vs_type vs[128];
70 int ag_ap;
71 const char *error_message;
72 char read_flag;
73 char exit_flag;
74 int bts[128], btsx;
75 unsigned char * pointer;
76 unsigned char * la_ptr;
77 const unsigned char *key_sp;
78 int save_index, key_state;
79 char ag_msg[82];
80 /* Line -, bciastp.syn */
81 // Maps symbol names to variables
82 // AgSharedStringDictionary symbolDictionary;
83 AbstractSyntaxTree *ast;
84
85 // Temporary space to accumulate identifiers while parsing
86 AgString charStack;
87 } astParse_pcb_type;
88
89 #ifndef PRULE_CONTEXT
90 #define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx]))
91 #define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx])
92 #define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx])
93 #endif
94
95 #ifndef AG_RUNNING_CODE
96 /* PCB.exit_flag values */
97 #define AG_RUNNING_CODE 0
98 #define AG_SUCCESS_CODE 1
99 #define AG_SYNTAX_ERROR_CODE 2
100 #define AG_REDUCTION_ERROR_CODE 3
101 #define AG_STACK_ERROR_CODE 4
102 #define AG_SEMANTIC_ERROR_CODE 5
103 #endif
104 void init_astParse(astParse_pcb_type *);
105 void astParse(astParse_pcb_type *);
106
107 Program * astParse_value(astParse_pcb_type *);
108 #endif
109