7 #include "TocParser.h"
\r
19 struct IdentifierExpr;
\r
21 struct BracketsExpr;
\r
22 struct UnaryOperatorExpr;
\r
23 struct BinaryOperatorExpr;
\r
24 struct TernaryOperatorExpr;
\r
36 enum class TypeModifierType
\r
43 TypeModifierType type;
\r
52 std::vector<TypeModifier> modifiers;
\r
63 std::vector<Variable> variables;
\r
64 std::vector<Stmt> statements;
\r
71 std::vector<Variable> parameters;
\r
78 std::vector<Variable> members;
\r
79 std::vector<Function> methods;
\r
84 std::vector<Variable> variables;
\r
85 std::vector<Struct> structs;
\r
86 std::vector<Function> functions;
\r
91 Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot
\r
96 std::string functionName;
\r
97 std::vector<Expr> arguments;
\r
102 Int, Decimal, String, Bool
\r
111 std::string _string;
\r
115 // TODO: accessExpr
\r
116 struct IdentifierExpr
\r
121 struct BracketsExpr
\r
123 std::shared_ptr<Expr> lexpr;
\r
124 std::shared_ptr<Expr> rexpr;
\r
127 enum class UnaryOperatorType
\r
129 Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost,
\r
130 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
134 enum class BinaryOperatorType
\r
136 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
137 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
138 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
139 LeftShiftEquals, RightShiftEquals,
\r
142 static std::string UnaryOperatorTypeStrings[] =
\r
144 "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };
\r
146 static std::string BinaryOperatorTypeStrings[] =
\r
148 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
149 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
150 "+=","-=","*=","/=","%=",
\r
153 struct UnaryOperatorExpr
\r
155 UnaryOperatorType type;
\r
156 std::shared_ptr<Expr> expr;
\r
159 struct BinaryOperatorExpr
\r
161 BinaryOperatorType type;
\r
162 std::shared_ptr<Expr> lexpr;
\r
163 std::shared_ptr<Expr> rexpr;
\r
166 struct TernaryOperatorExpr
\r
168 std::shared_ptr<Expr> lexpr;
\r
169 std::shared_ptr<Expr> rexprTrue;
\r
170 std::shared_ptr<Expr> rexprFalse;
\r
175 std::shared_ptr<Expr> expr;
\r
176 IdentifierExpr ident;
\r
179 // TODO: paren expr
\r
184 bool parenthesized;
\r
188 IdentifierExpr _identifier;
\r
189 BracketsExpr _brackets;
\r
190 UnaryOperatorExpr _unaryOperator;
\r
191 BinaryOperatorExpr _binaryOperator;
\r
192 TernaryOperatorExpr _ternaryOperator;
\r
196 enum class StmtType
\r
198 If, Switch, For, While, Assign, Return, Expr
\r
204 std::shared_ptr<Expr> expr;
\r
211 std::vector<ElseStmt> elses;
\r
216 std::shared_ptr<Expr> expr;
\r
222 IdentifierExpr ident;
\r
223 std::vector<SwitchCase> cases;
\r
226 // TODO: int i = 0 (var decl)
\r
229 std::string varName;
\r
230 std::shared_ptr<Expr> initValue;
\r
231 std::shared_ptr<Expr> condition;
\r
232 std::shared_ptr<Expr> action;
\r
258 SwitchStmt _switch;
\r
261 AssignStmt _assign;
\r
262 ReturnStmt _return;
\r