+/EE312
software design
git clone https://git.julia.blue/+/EE312
5dbb718
master
1#ifndef PARSE_H 2#define PARSE_H 3#include "lex.h" 4#include <map> 5#include <vector> 6 7class Statement ; 8 9struct Scope { 10std ::map < std ::string ,int > vars ; 11std ::map < std ::string ,Statement *> funcs ; 12Scope * outer ; 13Scope (Scope * s ) {outer = s ; } 14}; 15 16class Expression { 17Token tok ; 18Expression * lhs ,* rhs ; 19 20public : 21Expression (); 22Expression (Token );// Doesn't parse input 23 ~Expression (); 24int evaluate (); 25void debugPrint (); 26}; 27 28enum StatementType {TEXT = 0 ,OUTPUT ,VAR ,SET ,IF ,DO ,FUNC ,RETURN }; 29 30class Statement { 31StatementType type ; 32Token tok ; 33Expression * exp ; 34std ::vector < Statement *> elseContents ; 35void parseText (); 36void parseOutput (); 37void parseVar (); 38void parseSet (); 39void parseDo (); 40void parseIf (); 41void parseFunc (); 42void parseReturn (); 43 44public : 45// These could be private if it weren't for the disgusting hack that is 46// function calls 47Scope * local ; 48std ::vector < Token > args ; 49std ::vector < Statement *> contents ; 50 51Statement (); 52 ~Statement (); 53void execute (); 54void debugPrint (); 55}; 56 57#endif