#ifndef PARSE_H #define PARSE_H #include "lex.h" #include #include class Statement; struct Scope { std::map vars; std::map funcs; Scope* outer; Scope(Scope* s) { outer = s; } }; class Expression { Token tok; Expression *lhs, *rhs; public: Expression(); Expression(Token); // Doesn't parse input ~Expression(); int evaluate(); void debugPrint(); }; enum StatementType { TEXT = 0, OUTPUT, VAR, SET, IF, DO, FUNC, RETURN }; class Statement { StatementType type; Token tok; Expression* exp; std::vector elseContents; void parseText(); void parseOutput(); void parseVar(); void parseSet(); void parseDo(); void parseIf(); void parseFunc(); void parseReturn(); public: // These could be private if it weren't for the disgusting hack that is // function calls Scope* local; std::vector args; std::vector contents; Statement(); ~Statement(); void execute(); void debugPrint(); }; #endif