#ifndef __BALLOON_PARSE_H__ #define __BALLOON_PARSE_H__ class balloon_parse { private: std::stack parse; token this_token; int error; int warning; abstract_syntax_tree root; public: void get_token() { if(!parse.empty()) { this_token=parse.top(); parse.pop(); } else this_token.type=0; return; } void get_detail_token_stream(std::list& tk_list) { root.set_clear(); while(!parse.empty()) parse.pop(); if(tk_list.empty()) return; std::stack temp; for(std::list::iterator i=tk_list.begin();i!=tk_list.end();++i) temp.push(*i); while(!temp.empty()) { parse.push(temp.top()); temp.pop(); } return; } void print_parse_stack() { if(parse.empty()) return; std::stack temp; int line=parse.top().line; std::cout<>[Abstract-syntax-tree]"<>[Runtime] process begins at addr:"<<(void*)(&root)<<"."<generate semi: check if the statements is ended with semi parse_main: main process */ abstract_syntax_tree ret(); abstract_syntax_tree choose(); abstract_syntax_tree loop(); abstract_syntax_tree definition(); abstract_syntax_tree assignment(); abstract_syntax_tree block(); abstract_syntax_tree array_generate(); abstract_syntax_tree hash_generate(); abstract_syntax_tree func_generate(); abstract_syntax_tree check_number(); abstract_syntax_tree check_string(); abstract_syntax_tree scalar(); abstract_syntax_tree call_identifier(); abstract_syntax_tree check_unary(); abstract_syntax_tree calculation(); abstract_syntax_tree calculation_or(); abstract_syntax_tree calculation_and(); abstract_syntax_tree calculation_cmp(); abstract_syntax_tree calculation_additive(); abstract_syntax_tree calculation_multive(); void check_semi(); void parse_main(); }; abstract_syntax_tree balloon_parse::ret() { abstract_syntax_tree new_node; new_node.set_type(__return); get_token(); if(this_token.type!=__return) { ++error; std::cout<<">>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-warning] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse-error] line "<>[Parse] complete generating."<