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::optional<std::string> name;
\r
43 std::shared_ptr<Context> parent;
\r
44 std::vector<Variable> variables;
\r
45 std::vector<Function> functions;
\r
46 std::vector<Struct> structs;
\r
49 enum class TypeModifierType
\r
56 TypeModifierType type;
\r
64 std::vector<std::string> namespacePrefixes;
\r
66 std::vector<TypeModifier> modifiers;
\r
67 std::vector<Type> genericInstantiation;
\r
78 std::shared_ptr<Context> ctx;
\r
79 std::vector<Stmt> statements;
\r
86 std::vector<Variable> parameters;
\r
89 std::vector<std::string> genericTypeNames;
\r
90 std::vector<std::vector<Type>> genericInstantiations;
\r
95 template<typename T>
\r
100 operator T() { return t; }
\r
106 std::vector<std::string> genericTypeNames;
\r
107 std::vector<std::vector<Type>> genericInstantiations;
\r
108 std::vector<StructMember<Variable>> members;
\r
109 std::vector<StructMember<Function>> methods;
\r
115 std::shared_ptr<Context> ctx;
\r
116 std::vector<Namespace> namespaces;
\r
121 std::shared_ptr<Context> ctx;
\r
122 std::vector<Namespace> namespaces;
\r
125 enum class ExprType
\r
127 Func, Method, Lit, Paren, Dot, PrefixOp, PostfixOp, BinaryOp, TernaryOp, Bracket, Identifier
\r
132 std::vector<std::string> namespacePrefixes;
\r
133 std::string functionName;
\r
134 std::vector<Expr> arguments;
\r
135 std::vector<Type> genericInstantiation;
\r
140 std::shared_ptr<Expr> expr;
\r
141 std::string methodName;
\r
142 std::vector<Expr> arguments;
\r
143 std::vector<Type> genericInstantiation;
\r
148 Int, Decimal, String, Bool
\r
157 std::string _string;
\r
163 std::shared_ptr<Expr> expr;
\r
169 std::shared_ptr<Expr> expr;
\r
170 std::string identifier;
\r
173 enum class PrefixOperatorType
\r
175 Plus, Minus, Increment, Decrement,
\r
176 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
179 static std::string PrefixOperatorTypeStrings[] =
\r
181 "+", "-", "++", "--", "!", "~", "*", "&" };
\r
183 struct PrefixOperatorExpr
\r
185 PrefixOperatorType type;
\r
186 std::shared_ptr<Expr> expr;
\r
189 enum class PostfixOperatorType
\r
191 Increment, Decrement,
\r
194 static std::string PostfixOperatorTypeStrings[] =
\r
198 struct PostfixOperatorExpr
\r
200 PostfixOperatorType type;
\r
201 std::shared_ptr<Expr> expr;
\r
204 enum class BinaryOperatorType
\r
206 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
207 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
208 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
209 LeftShiftEquals, RightShiftEquals,
\r
212 static std::string BinaryOperatorTypeStrings[] =
\r
214 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
215 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
216 "+=","-=","*=","/=","%=",
\r
219 struct BinaryOperatorExpr
\r
221 BinaryOperatorType type;
\r
222 std::shared_ptr<Expr> lexpr;
\r
223 std::shared_ptr<Expr> rexpr;
\r
226 struct TernaryOperatorExpr
\r
228 std::shared_ptr<Expr> lexpr;
\r
229 std::shared_ptr<Expr> rexprTrue;
\r
230 std::shared_ptr<Expr> rexprFalse;
\r
233 struct BracketsExpr
\r
235 std::shared_ptr<Expr> lexpr;
\r
236 std::shared_ptr<Expr> rexpr;
\r
239 struct IdentifierExpr
\r
241 std::vector<std::string> namespacePrefixes;
\r
242 std::string identifier;
\r
250 MethodExpr _method;
\r
254 PrefixOperatorExpr _prefixOp;
\r
255 PostfixOperatorExpr _postfixOp;
\r
256 BinaryOperatorExpr _binaryOp;
\r
257 TernaryOperatorExpr _ternaryOp;
\r
258 BracketsExpr _brackets;
\r
259 IdentifierExpr _identifier;
\r
262 enum class StmtType
\r
264 If, Switch, For, While, Assign, Return, Expr
\r
270 std::shared_ptr<Expr> expr;
\r
277 std::vector<ElseStmt> elses;
\r
282 std::shared_ptr<Expr> expr;
\r
288 std::shared_ptr<Expr> ident;
\r
289 std::vector<SwitchCase> cases;
\r
292 // TODO: int i = 0 (var decl)
\r
295 std::shared_ptr<AssignStmt> init;
\r
296 std::shared_ptr<Expr> condition;
\r
297 std::shared_ptr<Expr> action;
\r
322 SwitchStmt _switch;
\r
325 AssignStmt _assign;
\r
326 ReturnStmt _return;
\r