7 #include "TocParser.h"
\r
24 struct PrefixOperatorExpr;
\r
25 struct PostfixOperatorExpr;
\r
26 struct BinaryOperatorExpr;
\r
27 struct TernaryOperatorExpr;
\r
28 struct BracketsExpr;
\r
29 struct IdentifierExpr;
\r
42 std::shared_ptr<Context> parent;
\r
43 std::vector<Variable> variables;
\r
46 enum class TypeModifierType
\r
53 TypeModifierType type;
\r
61 std::vector<std::string> namespacePrefixes;
\r
63 std::vector<TypeModifier> modifiers;
\r
74 std::shared_ptr<Context> ctx;
\r
75 std::vector<Stmt> statements;
\r
82 std::vector<Variable> parameters;
\r
87 template<typename T>
\r
92 operator T() { return t; }
\r
98 std::vector<StructMember<Variable>> members;
\r
99 std::vector<StructMember<Function>> methods;
\r
105 std::shared_ptr<Context> ctx;
\r
106 std::vector<Struct> structs;
\r
107 std::vector<Function> functions;
\r
108 std::vector<Namespace> namespaces;
\r
113 std::shared_ptr<Context> ctx;
\r
114 std::vector<Struct> structs;
\r
115 std::vector<Function> functions;
\r
116 std::vector<Namespace> namespaces;
\r
119 enum class ExprType
\r
121 Func, Method, Lit, Paren, Dot, PrefixOp, PostfixOp, BinaryOp, TernaryOp, Bracket, Identifier
\r
126 std::vector<std::string> namespacePrefixes;
\r
127 std::string functionName;
\r
128 std::vector<Expr> arguments;
\r
133 std::shared_ptr<Expr> expr;
\r
134 std::string methodName;
\r
135 std::vector<Expr> arguments;
\r
140 Int, Decimal, String, Bool
\r
149 std::string _string;
\r
155 std::shared_ptr<Expr> expr;
\r
160 std::shared_ptr<Expr> expr;
\r
161 std::string identifier;
\r
164 enum class PrefixOperatorType
\r
166 Plus, Minus, Increment, Decrement,
\r
167 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
170 static std::string PrefixOperatorTypeStrings[] =
\r
172 "+", "-", "++", "--", "!", "~", "*", "&" };
\r
174 struct PrefixOperatorExpr
\r
176 PrefixOperatorType type;
\r
177 std::shared_ptr<Expr> expr;
\r
180 enum class PostfixOperatorType
\r
182 Increment, Decrement,
\r
185 static std::string PostfixOperatorTypeStrings[] =
\r
189 struct PostfixOperatorExpr
\r
191 PostfixOperatorType type;
\r
192 std::shared_ptr<Expr> expr;
\r
195 enum class BinaryOperatorType
\r
197 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
198 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
199 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
200 LeftShiftEquals, RightShiftEquals,
\r
203 static std::string BinaryOperatorTypeStrings[] =
\r
205 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
206 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
207 "+=","-=","*=","/=","%=",
\r
210 struct BinaryOperatorExpr
\r
212 BinaryOperatorType type;
\r
213 std::shared_ptr<Expr> lexpr;
\r
214 std::shared_ptr<Expr> rexpr;
\r
217 struct TernaryOperatorExpr
\r
219 std::shared_ptr<Expr> lexpr;
\r
220 std::shared_ptr<Expr> rexprTrue;
\r
221 std::shared_ptr<Expr> rexprFalse;
\r
224 struct BracketsExpr
\r
226 std::shared_ptr<Expr> lexpr;
\r
227 std::shared_ptr<Expr> rexpr;
\r
230 struct IdentifierExpr
\r
232 std::vector<std::string> namespacePrefixes;
\r
233 std::string identifier;
\r
241 MethodExpr _method;
\r
245 PrefixOperatorExpr _prefixOp;
\r
246 PostfixOperatorExpr _postfixOp;
\r
247 BinaryOperatorExpr _binaryOp;
\r
248 TernaryOperatorExpr _ternaryOp;
\r
249 BracketsExpr _brackets;
\r
250 IdentifierExpr _identifier;
\r
253 enum class StmtType
\r
255 If, Switch, For, While, Assign, Return, Expr
\r
261 std::shared_ptr<Expr> expr;
\r
268 std::vector<ElseStmt> elses;
\r
273 std::shared_ptr<Expr> expr;
\r
279 std::shared_ptr<Expr> ident;
\r
280 std::vector<SwitchCase> cases;
\r
283 // TODO: int i = 0 (var decl)
\r
286 std::shared_ptr<AssignStmt> init;
\r
287 std::shared_ptr<Expr> condition;
\r
288 std::shared_ptr<Expr> action;
\r
313 SwitchStmt _switch;
\r
316 AssignStmt _assign;
\r
317 ReturnStmt _return;
\r