Mercurial > ~dholland > hg > ag > index.cgi
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/agcl/oldagsrc/good/bciastp.h Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,109 @@ +#ifndef BCIASTP_H +#define BCIASTP_H + +#ifndef AG_OBJECT_WRAPPER_DEFINED +#define AG_OBJECT_WRAPPER_DEFINED + +#ifndef AG_PLACEMENT_DELETE_REQUIRED +#if _MSC_VER >= 1200 || __INTEL_COMPILER +#define AG_PLACEMENT_DELETE_REQUIRED 1 +#endif +#endif + +template <class Object> +class AgObjectWrapper { + Object object; +public: + void operator delete(void *) {} + void *operator new(size_t, void *p) { return p;} +#if AG_PLACEMENT_DELETE_REQUIRED + void operator delete(void *, void *) { } +#endif + AgObjectWrapper(const Object &o) : object(o) {} + ~AgObjectWrapper() {} + operator Object &() {return object;} +}; + +#endif + +typedef union { + double alignment; + char ag_vt_2[sizeof(int)]; + char ag_vt_4[sizeof(AgObjectWrapper<AgStack<Statement *> >)]; + char ag_vt_5[sizeof(AgObjectWrapper<AgString >)]; + char ag_vt_6[sizeof(Program *)]; + char ag_vt_7[sizeof(Statement *)]; + char ag_vt_8[sizeof(Expression *)]; + char ag_vt_9[sizeof(double)]; +} astParse_vs_type; + +typedef enum { + astParse_white_space_token = 1, astParse_input_string_token = 4, + astParse_statements_token, astParse_eof_token, astParse_statement_token, + astParse_closed_statement_token, astParse_open_statement_token, + astParse_expression_token = 12, astParse_simple_statement_token = 18, + astParse_assignment_expression_token = 22, + astParse_conditional_expression_token = 24, + astParse_logical_or_expression_token = 30, + astParse_logical_and_expression_token = 33, + astParse_equality_expression_token = 35, + astParse_relational_expression_token = 37, + astParse_additive_expression_token = 40, + astParse_multiplicative_expression_token = 45, + astParse_unary_expression_token = 48, astParse_factor_token = 51, + astParse_primary_token = 53, astParse_simple_real_token = 69, + astParse_exponent_token = 72, astParse_integer_part_token, + astParse_fraction_part_token = 75, astParse_digit_token = 77, + astParse_letter_token, astParse_name_token = 97, + astParse_real_token = 118 +} astParse_token_type; + +typedef struct astParse_pcb_struct{ + astParse_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]; + astParse_vs_type vs[128]; + int ag_ap; + const char *error_message; + char read_flag; + char exit_flag; + int bts[128], btsx; + unsigned char * pointer; + unsigned char * la_ptr; + const unsigned char *key_sp; + int save_index, key_state; + char ag_msg[82]; +/* Line -, bciastp.syn */ + // Maps symbol names to variables + // AgSharedStringDictionary symbolDictionary; + AbstractSyntaxTree *ast; + + // Temporary space to accumulate identifiers while parsing + AgString charStack; + } astParse_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 +void init_astParse(astParse_pcb_type *); +void astParse(astParse_pcb_type *); + +Program * astParse_value(astParse_pcb_type *); +#endif +