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
34 enum class TypeModifierType {
\r
38 struct TypeModifier {
\r
39 TypeModifierType type;
\r
46 std::vector<TypeModifier> modifiers;
\r
55 std::vector<Variable> variables;
\r
56 std::vector<Stmt> statements;
\r
62 std::vector<Variable> parameters;
\r
68 std::vector<Variable> members;
\r
69 std::vector<Function> methods;
\r
73 std::vector<Variable> variables;
\r
74 std::vector<Struct> structs;
\r
75 std::vector<Function> functions;
\r
78 enum class ExprType {
\r
79 Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot
\r
83 std::string functionName;
\r
84 std::vector<Expr> arguments;
\r
87 enum class LitType {
\r
88 Int, Decimal, String, Bool
\r
96 std::string _string;
\r
100 // TODO: accessExpr
\r
101 struct IdentifierExpr {
\r
105 struct BracketsExpr {
\r
106 std::shared_ptr<Expr> lexpr;
\r
107 std::shared_ptr<Expr> rexpr;
\r
110 enum class UnaryOperatorType {
\r
111 Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost,
\r
112 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
116 enum class BinaryOperatorType {
\r
117 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
118 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
119 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
120 LeftShiftEquals, RightShiftEquals,
\r
123 static std::string UnaryOperatorTypeStrings[] = {
\r
124 "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };
\r
126 static std::string BinaryOperatorTypeStrings[] = {
\r
127 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
128 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
129 "+=","-=","*=","/=","%=",
\r
132 struct UnaryOperatorExpr {
\r
133 UnaryOperatorType type;
\r
134 std::shared_ptr<Expr> expr;
\r
137 struct BinaryOperatorExpr {
\r
138 BinaryOperatorType type;
\r
139 std::shared_ptr<Expr> lexpr;
\r
140 std::shared_ptr<Expr> rexpr;
\r
143 struct TernaryOperatorExpr {
\r
144 std::shared_ptr<Expr> lexpr;
\r
145 std::shared_ptr<Expr> rexprTrue;
\r
146 std::shared_ptr<Expr> rexprFalse;
\r
150 std::shared_ptr<Expr> expr;
\r
151 IdentifierExpr ident;
\r
154 // TODO: paren expr
\r
160 IdentifierExpr _identifier;
\r
161 BracketsExpr _brackets;
\r
162 UnaryOperatorExpr _unaryOperator;
\r
163 BinaryOperatorExpr _binaryOperator;
\r
164 TernaryOperatorExpr _ternaryOperator;
\r
168 enum class StmtType {
\r
169 If, Switch, For, While, Assign, Return, Expr
\r
174 std::shared_ptr<Expr> expr;
\r
180 std::vector<ElseStmt> elses;
\r
183 struct SwitchCase {
\r
184 std::shared_ptr<Expr> expr;
\r
188 struct SwitchStmt {
\r
189 IdentifierExpr ident;
\r
190 std::vector<SwitchCase> cases;
\r
193 // TODO: int i = 0 (var decl)
\r
195 std::string varName;
\r
196 std::shared_ptr<Expr> initValue;
\r
197 std::shared_ptr<Expr> condition;
\r
198 std::shared_ptr<Expr> action;
\r
207 struct AssignStmt {
\r
212 struct ReturnStmt {
\r
220 SwitchStmt _switch;
\r
223 AssignStmt _assign;
\r
224 ReturnStmt _return;
\r