diff --git a/balloon_parse.h b/balloon_parse.h new file mode 100644 index 0000000..179848f --- /dev/null +++ b/balloon_parse.h @@ -0,0 +1,581 @@ +#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<>[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."<> Balloon interpreter by ValKmjolnir"<> Input [help] to find help."<> "; + std::getline(std::cin,command); + if(command=="help") + { + std::cout<<">> Balloon interpreter by ValKmjolnir"<> 1. [ ] |input file name to load the file."<> 2. [cls ] |clear the screen."<> 3. [exit ] |shut down the interpreter."<> 4. [lexer ] |run and show the lexer. (-lexer)"<> 5. [parser] |run parser and see parse stack & parse result(s). (-parser)"<> 6. [ast ] |print the abstract syntax tree."<> 7. [del ] |delete program in memory."<> 8. [run ] |run the programme in stack. (-lexer -parser)"<> 9. [rs ] |check the source program."<>[Delete] Complete."<>[Lexer] error(s) found,stop."<>[Lexer] error(s) found,stop."<>[Lexer] error(s) found,stop."<