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
86 template<typename T>
\r
91 operator T() { return t; }
\r
97 std::vector<StructMember<Variable>> members;
\r
98 std::vector<StructMember<Function>> methods;
\r
104 std::shared_ptr<Context> ctx;
\r
105 std::vector<Struct> structs;
\r
106 std::vector<Function> functions;
\r
107 std::vector<Namespace> namespaces;
\r
112 std::shared_ptr<Context> ctx;
\r
113 std::vector<Struct> structs;
\r
114 std::vector<Function> functions;
\r
115 std::vector<Namespace> namespaces;
\r
118 enum class ExprType
\r
120 Func, Method, Lit, Paren, Dot, PrefixOp, PostfixOp, BinaryOp, TernaryOp, Bracket, Identifier
\r
125 std::vector<std::string> namespacePrefixes;
\r
126 std::string functionName;
\r
127 std::vector<Expr> arguments;
\r
132 std::shared_ptr<Expr> expr;
\r
133 std::string methodName;
\r
134 std::vector<Expr> arguments;
\r
139 Int, Decimal, String, Bool
\r
148 std::string _string;
\r
154 std::shared_ptr<Expr> expr;
\r
159 std::shared_ptr<Expr> expr;
\r
160 std::string identifier;
\r
163 enum class PrefixOperatorType
\r
165 Plus, Minus, Increment, Decrement,
\r
166 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
169 static std::string PrefixOperatorTypeStrings[] =
\r
171 "+", "-", "++", "--", "!", "~", "*", "&" };
\r
173 struct PrefixOperatorExpr
\r
175 PrefixOperatorType type;
\r
176 std::shared_ptr<Expr> expr;
\r
179 enum class PostfixOperatorType
\r
181 Increment, Decrement,
\r
184 static std::string PostfixOperatorTypeStrings[] =
\r
188 struct PostfixOperatorExpr
\r
190 PostfixOperatorType type;
\r
191 std::shared_ptr<Expr> expr;
\r
194 enum class BinaryOperatorType
\r
196 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
197 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
198 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
199 LeftShiftEquals, RightShiftEquals,
\r
202 static std::string BinaryOperatorTypeStrings[] =
\r
204 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
205 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
206 "+=","-=","*=","/=","%=",
\r
209 struct BinaryOperatorExpr
\r
211 BinaryOperatorType type;
\r
212 std::shared_ptr<Expr> lexpr;
\r
213 std::shared_ptr<Expr> rexpr;
\r
216 struct TernaryOperatorExpr
\r
218 std::shared_ptr<Expr> lexpr;
\r
219 std::shared_ptr<Expr> rexprTrue;
\r
220 std::shared_ptr<Expr> rexprFalse;
\r
223 struct BracketsExpr
\r
225 std::shared_ptr<Expr> lexpr;
\r
226 std::shared_ptr<Expr> rexpr;
\r
229 struct IdentifierExpr
\r
231 std::vector<std::string> namespacePrefixes;
\r
232 std::string identifier;
\r
240 MethodExpr _method;
\r
244 PrefixOperatorExpr _prefixOp;
\r
245 PostfixOperatorExpr _postfixOp;
\r
246 BinaryOperatorExpr _binaryOp;
\r
247 TernaryOperatorExpr _ternaryOp;
\r
248 BracketsExpr _brackets;
\r
249 IdentifierExpr _identifier;
\r
252 enum class StmtType
\r
254 If, Switch, For, While, Assign, Return, Expr
\r
260 std::shared_ptr<Expr> expr;
\r
267 std::vector<ElseStmt> elses;
\r
272 std::shared_ptr<Expr> expr;
\r
278 std::shared_ptr<Expr> ident;
\r
279 std::vector<SwitchCase> cases;
\r
282 // TODO: int i = 0 (var decl)
\r
285 std::shared_ptr<AssignStmt> init;
\r
286 std::shared_ptr<Expr> condition;
\r
287 std::shared_ptr<Expr> action;
\r
312 SwitchStmt _switch;
\r
315 AssignStmt _assign;
\r
316 ReturnStmt _return;
\r