7 #include "TocParser.h"
\r
19 struct IdentifierExpr;
\r
20 struct BracketsExpr;
\r
21 struct UnaryOperatorExpr;
\r
22 struct BinaryOperatorExpr;
\r
23 struct TernaryOperatorExpr;
\r
35 enum class TypeModifierType {
\r
39 struct TypeModifier {
\r
40 TypeModifierType type;
\r
48 std::vector<TypeModifier> modifiers;
\r
57 std::vector<Variable> variables;
\r
58 std::vector<Stmt> statements;
\r
64 std::vector<Variable> parameters;
\r
70 std::vector<Variable> members;
\r
71 std::vector<Function> methods;
\r
75 std::vector<Variable> variables;
\r
76 std::vector<Struct> structs;
\r
77 std::vector<Function> functions;
\r
80 enum class ExprType {
\r
81 Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot
\r
85 std::string functionName;
\r
86 std::vector<Expr> arguments;
\r
89 enum class LitType {
\r
90 Int, Decimal, String, Bool
\r
98 std::string _string;
\r
102 // TODO: accessExpr
\r
103 struct IdentifierExpr {
\r
107 struct BracketsExpr {
\r
108 std::shared_ptr<Expr> lexpr;
\r
109 std::shared_ptr<Expr> rexpr;
\r
112 enum class UnaryOperatorType {
\r
113 Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost,
\r
114 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
118 enum class BinaryOperatorType {
\r
119 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
120 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
121 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
122 LeftShiftEquals, RightShiftEquals,
\r
125 static std::string UnaryOperatorTypeStrings[] = {
\r
126 "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };
\r
128 static std::string BinaryOperatorTypeStrings[] = {
\r
129 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
130 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
131 "+=","-=","*=","/=","%=",
\r
134 struct UnaryOperatorExpr {
\r
135 UnaryOperatorType type;
\r
136 std::shared_ptr<Expr> expr;
\r
139 struct BinaryOperatorExpr {
\r
140 BinaryOperatorType type;
\r
141 std::shared_ptr<Expr> lexpr;
\r
142 std::shared_ptr<Expr> rexpr;
\r
145 struct TernaryOperatorExpr {
\r
146 std::shared_ptr<Expr> lexpr;
\r
147 std::shared_ptr<Expr> rexprTrue;
\r
148 std::shared_ptr<Expr> rexprFalse;
\r
152 std::shared_ptr<Expr> expr;
\r
153 IdentifierExpr ident;
\r
156 // TODO: paren expr
\r
160 bool parenthesized;
\r
164 IdentifierExpr _identifier;
\r
165 BracketsExpr _brackets;
\r
166 UnaryOperatorExpr _unaryOperator;
\r
167 BinaryOperatorExpr _binaryOperator;
\r
168 TernaryOperatorExpr _ternaryOperator;
\r
172 enum class StmtType {
\r
173 If, Switch, For, While, Assign, Return, Expr
\r
178 std::shared_ptr<Expr> expr;
\r
184 std::vector<ElseStmt> elses;
\r
187 struct SwitchCase {
\r
188 std::shared_ptr<Expr> expr;
\r
192 struct SwitchStmt {
\r
193 IdentifierExpr ident;
\r
194 std::vector<SwitchCase> cases;
\r
197 // TODO: int i = 0 (var decl)
\r
199 std::string varName;
\r
200 std::shared_ptr<Expr> initValue;
\r
201 std::shared_ptr<Expr> condition;
\r
202 std::shared_ptr<Expr> action;
\r
211 struct AssignStmt {
\r
216 struct ReturnStmt {
\r
224 SwitchStmt _switch;
\r
227 AssignStmt _assign;
\r
228 ReturnStmt _return;
\r