static void e5(rdp_tree_node_data* rdp_tree) { char* name; { if (scan_test(NULL, SCAN_P_ID, NULL)) { if (rdp_tree_update) memcpy(rdp_tree, text_scan_data, sizeof(scan_data)); scan_test(NULL, SCAN_P_ID, &e5_stop); name = SCAN_CAST->id; scan_(); check_declared; } else if (scan_test(NULL, SCAN_P_INTEGER, NULL)) { if (rdp_tree_update) memcpy(rdp_tree, text_scan_data, sizeof(scan_data)); scan_test(NULL, SCAN_P_INTEGER, &e5_stop); scan_(); } else if (scan_test(NULL, RDP_T_40 /* ( */, NULL)) { scan_test(NULL, RDP_T_40 /* ( */, &e5_stop); scan_(); if(rdp_tree_update) {rdp_tree->id = "e1"; rdp_tree->token = 0;} e1(rdp_tree); scan_test(NULL, RDP_T_41 /* ) */, &e5_stop); scan_(); } else scan_test_set(NULL, &e5_first, &e5_stop) ; scan_test_set(NULL, &e5_stop, &e5_stop); } }
static void e3(void) { { if (scan_test_set(NULL, &rdp_e3_0_first, NULL)) { e4(); } else if (scan_test(NULL, RDP_T_43 /* + */, NULL)) { scan_test(NULL, RDP_T_43 /* + */, &e3_stop); scan_(); e3(); } else if (scan_test(NULL, RDP_T_45 /* - */, NULL)) { scan_test(NULL, RDP_T_45 /* - */, &e3_stop); scan_(); e3(); } else scan_test_set(NULL, &e3_first, &e3_stop) ; scan_test_set(NULL, &e3_stop, &e3_stop); } }
static void statement(void) { char* name; integer val; char* str; { if (scan_test(NULL, SCAN_P_ID, NULL)) { scan_test(NULL, SCAN_P_ID, &statement_stop); name = SCAN_CAST->id; scan_(); if (symbol_lookup_key(mini, &name, NULL) == NULL)\ {\ text_message(TEXT_ERROR, "Undeclared variable '%s'\n", name);\ symbol_insert_key(mini, &name, sizeof(char*), sizeof(mini_data));\ }\ scan_test(NULL, RDP_T_61 /* = */, &statement_stop); scan_(); val = e1(); mini_cast(symbol_lookup_key(mini, &name, NULL))->i = val; } else if (scan_test(NULL, RDP_T_print, NULL)) { scan_test(NULL, RDP_T_print, &statement_stop); scan_(); scan_test(NULL, RDP_T_40 /* ( */, &statement_stop); scan_(); { /* Start of rdp_statement_3 */ while (1) { scan_test_set(NULL, &rdp_statement_3_first, &statement_stop); { if (scan_test_set(NULL, &rdp_statement_1_first, NULL)) { val = e1(); printf("%li", val); } else if (scan_test(NULL, RDP_T_34 /* " */, NULL)) { str = String(); printf("%s", str); } else scan_test_set(NULL, &rdp_statement_3_first, &statement_stop) ; } if (SCAN_CAST->token != RDP_T_44 /* , */) break; scan_(); } } /* end of rdp_statement_3 */ scan_test(NULL, RDP_T_41 /* ) */, &statement_stop); scan_(); } else scan_test_set(NULL, &statement_first, &statement_stop) ; scan_test_set(NULL, &statement_stop, &statement_stop); } }
static void e3(rdp_tree_node_data* rdp_tree) { { if (scan_test_set(NULL, &rdp_e3_0_first, NULL)) { if(rdp_tree_update) {rdp_tree->id = "e4"; rdp_tree->token = 0;} e4(rdp_tree); } else if (scan_test(NULL, RDP_T_43 /* + */, NULL)) { scan_test(NULL, RDP_T_43 /* + */, &e3_stop); scan_(); e3(rdp_add_child("e3", rdp_tree)); } else if (scan_test(NULL, RDP_T_45 /* - */, NULL)) { if (rdp_tree_update) memcpy(rdp_tree, text_scan_data, sizeof(scan_data)); scan_test(NULL, RDP_T_45 /* - */, &e3_stop); scan_(); e3(rdp_add_child("e3", rdp_tree)); } else scan_test_set(NULL, &e3_first, &e3_stop) ; scan_test_set(NULL, &e3_stop, &e3_stop); } }
static void e1(void) { { e2(); if (scan_test_set(NULL, &rdp_e1_2_first, NULL)) { /* Start of rdp_e1_2 */ while (1) { { if (scan_test(NULL, RDP_T_43 /* + */, NULL)) { scan_test(NULL, RDP_T_43 /* + */, &e1_stop); scan_(); e2(); } else if (scan_test(NULL, RDP_T_45 /* - */, NULL)) { scan_test(NULL, RDP_T_45 /* - */, &e1_stop); scan_(); e2(); } else scan_test_set(NULL, &rdp_e1_2_first, &e1_stop) ; } if (!scan_test_set(NULL, &rdp_e1_2_first, NULL)) break; } } /* end of rdp_e1_2 */ scan_test_set(NULL, &e1_stop, &e1_stop); } }
static integer e5(void) { integer result; char* name; { if (scan_test(NULL, SCAN_P_ID, NULL)) { scan_test(NULL, SCAN_P_ID, &e5_stop); name = SCAN_CAST->id; scan_(); _lookup(name, result); } else if (scan_test(NULL, SCAN_P_INTEGER, NULL)) { scan_test(NULL, SCAN_P_INTEGER, &e5_stop); result = SCAN_CAST->data.i; scan_(); } else if (scan_test(NULL, RDP_T_40 /* ( */, NULL)) { scan_test(NULL, RDP_T_40 /* ( */, &e5_stop); scan_(); result = e1(); scan_test(NULL, RDP_T_41 /* ) */, &e5_stop); scan_(); } else scan_test_set(NULL, &e5_first, &e5_stop) ; scan_test_set(NULL, &e5_stop, &e5_stop); } return result; }
static void e2(void) { { e3(); if (scan_test_set(NULL, &rdp_e2_2_first, NULL)) { /* Start of rdp_e2_2 */ while (1) { { if (scan_test(NULL, RDP_T_42 /* * */, NULL)) { scan_test(NULL, RDP_T_42 /* * */, &e2_stop); scan_(); e3(); } else if (scan_test(NULL, RDP_T_47 /* / */, NULL)) { scan_test(NULL, RDP_T_47 /* / */, &e2_stop); scan_(); e3(); } else scan_test_set(NULL, &rdp_e2_2_first, &e2_stop) ; } if (!scan_test_set(NULL, &rdp_e2_2_first, NULL)) break; } } /* end of rdp_e2_2 */ scan_test_set(NULL, &e2_stop, &e2_stop); } }
static void reg(rdp_tree_node_data* rdp_tree) { { if (scan_test(NULL, SCAN_P_ID, NULL)) { if (rdp_tree_update) rdp_add_child(NULL, rdp_tree); scan_test(NULL, SCAN_P_ID, ®_stop); scan_(); } else if (scan_test(NULL, RDP_T_35 /* # */, NULL)) { if (rdp_tree_update) rdp_add_child(NULL, rdp_tree); scan_test(NULL, RDP_T_35 /* # */, ®_stop); scan_(); } else if (scan_test(NULL, RDP_T_40 /* ( */, NULL)) { if (rdp_tree_update) rdp_add_child(NULL, rdp_tree); scan_test(NULL, RDP_T_40 /* ( */, ®_stop); scan_(); alt(rdp_add_child("alt", rdp_tree)); if (rdp_tree_update) rdp_add_child(NULL, rdp_tree); scan_test(NULL, RDP_T_41 /* ) */, ®_stop); scan_(); } else scan_test_set(NULL, ®_first, ®_stop) ; scan_test_set(NULL, ®_stop, ®_stop); } }
static integer e3(void) { integer result; { if (scan_test(NULL, RDP_T_43 /* + */, NULL)) { scan_test(NULL, RDP_T_43 /* + */, &e3_stop); scan_(); result = e3(); } else if (scan_test(NULL, RDP_T_45 /* - */, NULL)) { scan_test(NULL, RDP_T_45 /* - */, &e3_stop); scan_(); result = e3(); result = -result; } else if (scan_test_set(NULL, &rdp_e3_2_first, NULL)) { result = e4(); } else scan_test_set(NULL, &e3_first, &e3_stop) ; scan_test_set(NULL, &e3_stop, &e3_stop); } return result; }
static void e5(void) { { if (scan_test(NULL, SCAN_P_ID, NULL)) { scan_test(NULL, SCAN_P_ID, &e5_stop); scan_(); } else if (scan_test(NULL, SCAN_P_INTEGER, NULL)) { scan_test(NULL, SCAN_P_INTEGER, &e5_stop); scan_(); } else if (scan_test(NULL, RDP_T_40 /* ( */, NULL)) { scan_test(NULL, RDP_T_40 /* ( */, &e5_stop); scan_(); e1(); scan_test(NULL, RDP_T_41 /* ) */, &e5_stop); scan_(); } else scan_test_set(NULL, &e5_first, &e5_stop) ; scan_test_set(NULL, &e5_stop, &e5_stop); } }
static void var_dec(void) { { scan_test(NULL, RDP_T_int, &var_dec_stop); scan_(); { /* Start of rdp_var_dec_3 */ while (1) { scan_test(NULL, SCAN_P_ID, &var_dec_stop); { scan_test(NULL, SCAN_P_ID, &var_dec_stop); scan_(); if (scan_test(NULL, RDP_T_61 /* = */, NULL)) { /* Start of rdp_var_dec_1 */ while (1) { { scan_test(NULL, RDP_T_61 /* = */, &var_dec_stop); scan_(); e1(); } break; /* hi limit is 1! */ } } /* end of rdp_var_dec_1 */ } if (SCAN_CAST->token != RDP_T_44 /* , */) break; scan_(); } } /* end of rdp_var_dec_3 */ scan_test_set(NULL, &var_dec_stop, &var_dec_stop); } }
/* Parser functions */ void alt(rdp_tree_node_data* rdp_tree) { { con(rdp_add_child("con", rdp_tree)); if (scan_test(NULL, RDP_T_124 /* | */, NULL)) { /* Start of rdp_alt_1 */ while (1) { { if (rdp_tree_update) rdp_add_child(NULL, rdp_tree); scan_test(NULL, RDP_T_124 /* | */, &alt_stop); scan_(); con(rdp_add_child("con", rdp_tree)); } break; /* hi limit is 1! */ } } /* end of rdp_alt_1 */ else { /* default action processing for rdp_alt_1*/ if (rdp_tree_update) {rdp_tree_node_data *temp = rdp_add_child(NULL, rdp_tree); temp->id = NULL; temp->token = SCAN_P_ID;} } scan_test_set(NULL, &alt_stop, &alt_stop); } }
static void e4(rdp_tree_node_data* rdp_tree) { { e5(rdp_add_child("e5", rdp_tree)); if (scan_test(NULL, RDP_T_4242 /* ** */, NULL)) { /* Start of rdp_e4_1 */ while (1) { { if (rdp_tree_update) memcpy(rdp_tree, text_scan_data, sizeof(scan_data)); scan_test(NULL, RDP_T_4242 /* ** */, &e4_stop); scan_(); e4(rdp_add_child("e4", rdp_tree)); } break; /* hi limit is 1! */ } } /* end of rdp_e4_1 */ else { /* default action processing for rdp_e4_1*/ if (rdp_tree_update) {rdp_tree->id = NULL; rdp_tree->token = SCAN_P_ID;} } scan_test_set(NULL, &e4_stop, &e4_stop); } }
static void dec_body(rdp_tree_node_data* rdp_tree) { char* name; { if (rdp_tree_update) memcpy(rdp_tree, text_scan_data, sizeof(scan_data)); scan_test(NULL, SCAN_P_ID, &dec_body_stop); name = SCAN_CAST->id; scan_(); if (scan_test(NULL, RDP_T_61 /* = */, NULL)) { /* Start of rdp_dec_body_1 */ while (1) { { scan_test(NULL, RDP_T_61 /* = */, &dec_body_stop); scan_(); e0(rdp_add_child("e0", rdp_tree)); } break; /* hi limit is 1! */ } } /* end of rdp_dec_body_1 */ else { /* default action processing for rdp_dec_body_1*/ } symbol_insert_key(mini, &name, sizeof(char*), sizeof(mini_data)); \ if (*name == '_' && *(name+1) == '_')\ text_message(TEXT_ERROR_ECHO, "variable names must not begin with two underscores\n");\ scan_test_set(NULL, &dec_body_stop, &dec_body_stop); } }
static void statement(void) { { if (scan_test(NULL, SCAN_P_ID, NULL)) { scan_test(NULL, SCAN_P_ID, &statement_stop); scan_(); scan_test(NULL, RDP_T_61 /* = */, &statement_stop); scan_(); e1(); } else if (scan_test(NULL, RDP_T_print, NULL)) { scan_test(NULL, RDP_T_print, &statement_stop); scan_(); scan_test(NULL, RDP_T_40 /* ( */, &statement_stop); scan_(); { /* Start of rdp_statement_3 */ while (1) { scan_test_set(NULL, &rdp_statement_3_first, &statement_stop); { if (scan_test_set(NULL, &rdp_statement_1_first, NULL)) { e1(); } else if (scan_test(NULL, RDP_T_34 /* " */, NULL)) { String(); } else scan_test_set(NULL, &rdp_statement_3_first, &statement_stop) ; } if (SCAN_CAST->token != RDP_T_44 /* , */) break; scan_(); } } /* end of rdp_statement_3 */ scan_test(NULL, RDP_T_41 /* ) */, &statement_stop); scan_(); } else scan_test_set(NULL, &statement_first, &statement_stop) ; scan_test_set(NULL, &statement_stop, &statement_stop); } }
/* Parser functions */ static void String(void) { { scan_test(NULL, RDP_T_34 /* " */, &String_stop); scan_(); scan_test_set(NULL, &String_stop, &String_stop); } }
/* Parser functions */ static void String(rdp_tree_node_data* rdp_tree) { { if (rdp_tree_update) rdp_add_child(NULL, rdp_tree); scan_test(NULL, RDP_T_34 /* " */, &String_stop); scan_(); scan_test_set(NULL, &String_stop, &String_stop); } }
static void sym(void) { { if (scan_test(NULL, SCAN_P_ID, NULL)) { scan_test(NULL, SCAN_P_ID, &sym_stop); scan_(); } else if (scan_test(NULL, RDP_T_35 /* # */, NULL)) { scan_test(NULL, RDP_T_35 /* # */, &sym_stop); scan_(); } else scan_test_set(NULL, &sym_first, &sym_stop) ; scan_test_set(NULL, &sym_stop, &sym_stop); } }
/* Parser functions */ static char* String(void) { char* result; { scan_test(NULL, RDP_T_34 /* " */, &String_stop); result = SCAN_CAST->id; scan_(); scan_test_set(NULL, &String_stop, &String_stop); } return result; }
static integer e5(void) { integer result; char* name; { if (scan_test(NULL, SCAN_P_ID, NULL)) { scan_test(NULL, SCAN_P_ID, &e5_stop); name = SCAN_CAST->id; scan_(); if (symbol_lookup_key(mini, &name, NULL) == NULL)\ {\ text_message(TEXT_ERROR, "Undeclared variable '%s'\n", name);\ symbol_insert_key(mini, &name, sizeof(char*), sizeof(mini_data));\ }\ result = mini_cast(symbol_lookup_key(mini, &name, NULL))->i; } else if (scan_test(NULL, SCAN_P_INTEGER, NULL)) { scan_test(NULL, SCAN_P_INTEGER, &e5_stop); result = SCAN_CAST->data.i; scan_(); } else if (scan_test(NULL, RDP_T_40 /* ( */, NULL)) { scan_test(NULL, RDP_T_40 /* ( */, &e5_stop); scan_(); result = e1(); scan_test(NULL, RDP_T_41 /* ) */, &e5_stop); scan_(); } else scan_test_set(NULL, &e5_first, &e5_stop) ; scan_test_set(NULL, &e5_stop, &e5_stop); } return result; }
static void con(rdp_tree_node_data* rdp_tree) { { kle(rdp_add_child("kle", rdp_tree)); if (scan_test_set(NULL, &rdp_con_1_first, NULL)) { /* Start of rdp_con_1 */ while (1) { { kle(rdp_add_child("kle", rdp_tree)); } break; /* hi limit is 1! */ } } /* end of rdp_con_1 */ else { /* default action processing for rdp_con_1*/ if (rdp_tree_update) {rdp_tree_node_data *temp = rdp_add_child(NULL, rdp_tree); temp->id = NULL; temp->token = SCAN_P_ID;} } scan_test_set(NULL, &con_stop, &con_stop); } }
static integer e2(void) { integer result; integer right; { result = e3(); if (scan_test_set(NULL, &rdp_e2_2_first, NULL)) { /* Start of rdp_e2_2 */ while (1) { { if (scan_test(NULL, RDP_T_42 /* * */, NULL)) { scan_test(NULL, RDP_T_42 /* * */, &e2_stop); scan_(); right = e3(); result *= right; } else if (scan_test(NULL, RDP_T_47 /* / */, NULL)) { scan_test(NULL, RDP_T_47 /* / */, &e2_stop); scan_(); right = e3(); if (result == 0) \ text_message(TEXT_FATAL_ECHO, "Divide by zero attempted\n"); \ else result /= right; \ } else scan_test_set(NULL, &rdp_e2_2_first, &e2_stop) ; } if (!scan_test_set(NULL, &rdp_e2_2_first, NULL)) break; } } /* end of rdp_e2_2 */ scan_test_set(NULL, &e2_stop, &e2_stop); } return result; }
static void e2(rdp_tree_node_data* rdp_tree) { { if(rdp_tree_update) {rdp_tree->id = "e3"; rdp_tree->token = 0;} e3(rdp_tree); if (scan_test_set(NULL, &rdp_e2_2_first, NULL)) { /* Start of rdp_e2_2 */ while (1) { { if (scan_test(NULL, RDP_T_42 /* * */, NULL)) { if (rdp_tree_update) rdp_add_parent(NULL, rdp_tree); scan_test(NULL, RDP_T_42 /* * */, &e2_stop); scan_(); e3(rdp_add_child("e3", rdp_tree)); } else if (scan_test(NULL, RDP_T_47 /* / */, NULL)) { if (rdp_tree_update) rdp_add_parent(NULL, rdp_tree); scan_test(NULL, RDP_T_47 /* / */, &e2_stop); scan_(); e3(rdp_add_child("e3", rdp_tree)); } else scan_test_set(NULL, &rdp_e2_2_first, &e2_stop) ; } if (!scan_test_set(NULL, &rdp_e2_2_first, NULL)) break; } } /* end of rdp_e2_2 */ else { /* default action processing for rdp_e2_2*/ if (rdp_tree_update) {rdp_tree_node_data *temp = rdp_add_child(NULL, rdp_tree); temp->id = NULL; temp->token = SCAN_P_ID;} } scan_test_set(NULL, &e2_stop, &e2_stop); } }
static integer e1(void) { integer result; integer right; { result = e2(); if (scan_test_set(NULL, &rdp_e1_2_first, NULL)) { /* Start of rdp_e1_2 */ while (1) { { if (scan_test(NULL, RDP_T_43 /* + */, NULL)) { scan_test(NULL, RDP_T_43 /* + */, &e1_stop); scan_(); right = e2(); result += right; } else if (scan_test(NULL, RDP_T_45 /* - */, NULL)) { scan_test(NULL, RDP_T_45 /* - */, &e1_stop); scan_(); right = e2(); result -= right; } else scan_test_set(NULL, &rdp_e1_2_first, &e1_stop) ; } if (!scan_test_set(NULL, &rdp_e1_2_first, NULL)) break; } } /* end of rdp_e1_2 */ scan_test_set(NULL, &e1_stop, &e1_stop); } return result; }
static void e4(void) { { e5(); if (scan_test(NULL, RDP_T_4242 /* ** */, NULL)) { /* Start of rdp_e4_1 */ while (1) { { scan_test(NULL, RDP_T_4242 /* ** */, &e4_stop); scan_(); e4(); } break; /* hi limit is 1! */ } } /* end of rdp_e4_1 */ scan_test_set(NULL, &e4_stop, &e4_stop); } }
static void var_dec(rdp_tree_node_data* rdp_tree) { { if (rdp_tree_update) memcpy(rdp_tree, text_scan_data, sizeof(scan_data)); scan_test(NULL, RDP_T_int, &var_dec_stop); scan_(); { /* Start of rdp_var_dec_1 */ while (1) { scan_test(NULL, SCAN_P_ID, &var_dec_stop); { dec_body(rdp_add_child("dec_body", rdp_tree)); } if (SCAN_CAST->token != RDP_T_44 /* , */) break; scan_(); } } /* end of rdp_var_dec_1 */ scan_test_set(NULL, &var_dec_stop, &var_dec_stop); } }
void program(rdp_tree_node_data* rdp_tree) { { if (scan_test_set(NULL, &rdp_program_4_first, NULL)) { /* Start of rdp_program_4 */ while (1) { { if (scan_test_set(NULL, &rdp_program_2_first, NULL)) { /* Start of rdp_program_2 */ while (1) { { if (scan_test(NULL, RDP_T_int, NULL)) { var_dec(rdp_add_child("var_dec", rdp_tree)); } else if (scan_test_set(NULL, &rdp_program_1_first, NULL)) { statement(rdp_add_child("statement", rdp_tree)); } else scan_test_set(NULL, &rdp_program_2_first, &program_stop) ; } break; /* hi limit is 1! */ } } /* end of rdp_program_2 */ else { /* default action processing for rdp_program_2*/ if (rdp_tree_update) {rdp_tree_node_data *temp = rdp_add_child(NULL, rdp_tree); temp->id = NULL; temp->token = SCAN_P_ID;} } scan_test(NULL, RDP_T_59 /* ; */, &program_stop); scan_(); } if (!scan_test_set(NULL, &rdp_program_4_first, NULL)) break; } } /* end of rdp_program_4 */ else { /* default action processing for rdp_program_4*/ if (rdp_tree_update) {rdp_tree_node_data *temp = rdp_add_child(NULL, rdp_tree); temp->id = NULL; temp->token = SCAN_P_ID;} } scan_test_set(NULL, &program_stop, &program_stop); } }
static void var_dec(void) { char* name; integer val; { scan_test(NULL, RDP_T_int, &var_dec_stop); scan_(); { /* Start of rdp_var_dec_3 */ while (1) { scan_test(NULL, SCAN_P_ID, &var_dec_stop); { scan_test(NULL, SCAN_P_ID, &var_dec_stop); name = SCAN_CAST->id; scan_(); if (scan_test(NULL, RDP_T_61 /* = */, NULL)) { /* Start of rdp_var_dec_1 */ while (1) { { scan_test(NULL, RDP_T_61 /* = */, &var_dec_stop); scan_(); val = e1(); } break; /* hi limit is 1! */ } } /* end of rdp_var_dec_1 */ mini_cast(symbol_insert_key(mini, &name, sizeof(char*), sizeof(mini_data)))\ ->i = val; \ } if (SCAN_CAST->token != RDP_T_44 /* , */) break; scan_(); } } /* end of rdp_var_dec_3 */ scan_test_set(NULL, &var_dec_stop, &var_dec_stop); } }
static integer e4(void) { integer result; integer right; { result = e5(); if (scan_test(NULL, RDP_T_4242 /* ** */, NULL)) { /* Start of rdp_e4_1 */ while (1) { { scan_test(NULL, RDP_T_4242 /* ** */, &e4_stop); scan_(); right = e4(); result = (integer) pow((double) result, (double) right); } break; /* hi limit is 1! */ } } /* end of rdp_e4_1 */ scan_test_set(NULL, &e4_stop, &e4_stop); } return result; }
static void var_dec(integer interpret) { char* name; integer val; { scan_test(NULL, RDP_T_int, &var_dec_stop); scan_(); { /* Start of rdp_var_dec_3 */ while (1) { scan_test(NULL, SCAN_P_ID, &var_dec_stop); { scan_test(NULL, SCAN_P_ID, &var_dec_stop); name = SCAN_CAST->id; scan_(); _insert(name); if (scan_test(NULL, RDP_T_61 /* = */, NULL)) { /* Start of rdp_var_dec_1 */ while (1) { { scan_test(NULL, RDP_T_61 /* = */, &var_dec_stop); scan_(); val = e0(); _update(name, val); } break; /* hi limit is 1! */ } } /* end of rdp_var_dec_1 */ } if (SCAN_CAST->token != RDP_T_44 /* , */) break; scan_(); } } /* end of rdp_var_dec_3 */ scan_test_set(NULL, &var_dec_stop, &var_dec_stop); } }