TreeNode * for_stmt(void) //for_stmt -> FOR '('expression';'expression';'expression')''{'statement_list'}' { TreeNode * t = newStmtNode(ForK); match(FOR); match(LPAREN); if(t!=NULL) t->child[0] = assign_list(); match(SEMI); if(t!=NULL) t->child[1] = exp(); match(SEMI); if(t!=NULL) t->child[2] = assign_list(); match(RPAREN); match(LBRACE); if(t!=NULL) t->child[3]=statement_list(); //match(RBRACE); return t; }
void rcp_parse(struct rc_t *R, ScannerInput *I) { scan_input = I; next_token(); assign_list(); }
/* MAIN PROGRAM */ int main() { Node_ptr my_list = NULL; assign_list(my_list); cout << "\nTHE LIST IS NOW:\n"; print_list(my_list); cout << "forwards: "; print_forwards(my_list); cout << endl; cout << "backwards: "; print_backwards(my_list); cout << endl; char word[20], lookfor[20]; cout << endl << "word to insert: "; cin.getline(word,20); cout << endl << "to be inserted after (' ' for right at beginning): "; cin.getline(lookfor,20); add_after(my_list, lookfor, word); cout << endl << "\nTHE LIST IS NOW:\n"; print_list(my_list); cout << endl << "word to delete: "; cin.getline(word,20); delete_node(my_list, word); cout << endl << "\nTHE LIST IS NOW:\n"; print_list(my_list); return 0; }
TreeNode * assign_stmt(void) //(后有分号的算数表达式) { TreeNode * t = assign_list(); match(SEMI); return t; }