comparison tests/agcl/oldagsrc/good/asiwdp.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 ASIWDP_H
2 #define ASIWDP_H
3
4 typedef union {
5 double alignment;
6 char ag_vt_2[sizeof(int)];
7 char ag_vt_4[sizeof(double)];
8 char ag_vt_5[sizeof(Location)];
9 char ag_vt_6[sizeof(double *)];
10 } asi_vs_type;
11
12 typedef enum {
13 asi_white_space_token = 1, asi_input_string_token = 4,
14 asi_statements_token, asi_eof_token = 7, asi_statement_token,
15 asi_skip_statement_token, asi_skip_open_statement_token,
16 asi_skip_closed_statement_token, asi_statement_text_token,
17 asi_balanced_braces_token = 15, asi_balanced_parens_token = 17,
18 asi_open_statement_token = 20, asi_closed_statement_token,
19 asi_expression_token, asi_true_if_condition_token = 25,
20 asi_false_if_condition_token, asi_closed_while_token,
21 asi_execute_while_token, asi_open_while_token, asi_while_token = 32,
22 asi_while_loop_token, asi_false_while_condition_token,
23 asi_true_while_condition_token, asi_conditional_expression_token,
24 asi_logical_or_expression_token = 42,
25 asi_logical_and_expression_token = 45, asi_equality_expression_token = 47,
26 asi_relational_expression_token = 49, asi_additive_expression_token = 52,
27 asi_multiplicative_expression_token = 57, asi_unary_expression_token = 60,
28 asi_factor_token = 63, asi_primary_token, asi_blank_token = 72,
29 asi_statement_char_token = 83, asi_name_string_token = 87,
30 asi_letter_token, asi_simple_real_token = 90, asi_exponent_token = 93,
31 asi_integer_part_token, asi_fraction_part_token = 96,
32 asi_name_token = 114, asi_real_token = 134, asi_digit_token = 143
33 } asi_token_type;
34
35 typedef struct asi_pcb_struct{
36 asi_token_type token_number, reduction_token, error_frame_token;
37 int input_code;
38 int input_value;
39 int line, column;
40 int ssx, sn, error_frame_ssx;
41 int drt, dssx, dsn;
42 int ss[128];
43 asi_vs_type vs[128];
44 int ag_ap;
45 const char *error_message;
46 char read_flag;
47 char exit_flag;
48 int bts[128], btsx;
49 unsigned char * pointer;
50 unsigned char * la_ptr;
51 const unsigned char *key_sp;
52 int save_index, key_state;
53 char ag_msg[82];
54 const int *ag_dtl;
55 int ag_dsn;
56 /* Line -, asiwdp.syn */
57 // Add declarations to parser control block
58 CharStack charStack; // Stack to accumulate variable names
59 WhileStack whileStack; // Stack of active while loops
60 SymbolTable *symbolTable; // Pointer to external symbol table
61
62 void pushChar(int c); // Add character to character stack
63 double *locateValue(int k); // Identify variable named on character stack
64 void stackLoop(const Location &c); // Provide for nested while loops
65 Location location(); // Capture current location of parse
66 void setLocation(const Location &l); // Set location of parse
67 void loopContinue(); // Set location to continue current while loop
68 void loopExit(); // Set location to exit current while loop
69 double checkZero(double value); // Check for zero divisor
70
71 // External interface to the parser
72 int interpret(char *text, SymbolTable *s); // Parse instructions in text, using variables defined in s
73 } asi_pcb_type;
74
75 #ifndef PRULE_CONTEXT
76 #define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx]))
77 #define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx])
78 #define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx])
79 #endif
80
81 #ifndef AG_RUNNING_CODE
82 /* PCB.exit_flag values */
83 #define AG_RUNNING_CODE 0
84 #define AG_SUCCESS_CODE 1
85 #define AG_SYNTAX_ERROR_CODE 2
86 #define AG_REDUCTION_ERROR_CODE 3
87 #define AG_STACK_ERROR_CODE 4
88 #define AG_SEMANTIC_ERROR_CODE 5
89 #endif
90 void init_asi(asi_pcb_type *);
91 void asi(asi_pcb_type *);
92 #endif
93