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
64 std::vector<Type> genericInstantiation;
\r
75 std::shared_ptr<Context> ctx;
\r
76 std::vector<Stmt> statements;
\r
82 std::vector<std::string> genericTypeNames;
\r
83 std::vector<std::vector<Type>> genericInstantiations;
\r
85 std::vector<Variable> parameters;
\r
90 template<typename T>
\r
95 operator T() { return t; }
\r
101 std::vector<std::string> genericTypeNames;
\r
102 std::vector<std::vector<Type>> genericInstantiations;
\r
103 std::vector<StructMember<Variable>> members;
\r
104 std::vector<StructMember<Function>> methods;
\r
110 std::shared_ptr<Context> ctx;
\r
111 std::vector<Struct> structs;
\r
112 std::vector<Function> functions;
\r
113 std::vector<Namespace> namespaces;
\r
118 std::shared_ptr<Context> ctx;
\r
119 std::vector<Struct> structs;
\r
120 std::vector<Function> functions;
\r
121 std::vector<Namespace> namespaces;
\r
124 enum class ExprType
\r
126 Func, Method, Lit, Paren, Dot, PrefixOp, PostfixOp, BinaryOp, TernaryOp, Bracket, Identifier
\r
131 std::vector<std::string> namespacePrefixes;
\r
132 std::string functionName;
\r
133 std::vector<Expr> arguments;
\r
134 std::vector<Type> genericInstantiation;
\r
139 std::shared_ptr<Expr> expr;
\r
140 std::string methodName;
\r
141 std::vector<Expr> arguments;
\r
142 std::vector<Type> genericInstantiation;
\r
147 Int, Decimal, String, Bool
\r
156 std::string _string;
\r
162 std::shared_ptr<Expr> expr;
\r
168 std::shared_ptr<Expr> expr;
\r
169 std::string identifier;
\r
172 enum class PrefixOperatorType
\r
174 Plus, Minus, Increment, Decrement,
\r
175 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
178 static std::string PrefixOperatorTypeStrings[] =
\r
180 "+", "-", "++", "--", "!", "~", "*", "&" };
\r
182 struct PrefixOperatorExpr
\r
184 PrefixOperatorType type;
\r
185 std::shared_ptr<Expr> expr;
\r
188 enum class PostfixOperatorType
\r
190 Increment, Decrement,
\r
193 static std::string PostfixOperatorTypeStrings[] =
\r
197 struct PostfixOperatorExpr
\r
199 PostfixOperatorType type;
\r
200 std::shared_ptr<Expr> expr;
\r
203 enum class BinaryOperatorType
\r
205 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
206 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
207 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
208 LeftShiftEquals, RightShiftEquals,
\r
211 static std::string BinaryOperatorTypeStrings[] =
\r
213 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
214 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
215 "+=","-=","*=","/=","%=",
\r
218 struct BinaryOperatorExpr
\r
220 BinaryOperatorType type;
\r
221 std::shared_ptr<Expr> lexpr;
\r
222 std::shared_ptr<Expr> rexpr;
\r
225 struct TernaryOperatorExpr
\r
227 std::shared_ptr<Expr> lexpr;
\r
228 std::shared_ptr<Expr> rexprTrue;
\r
229 std::shared_ptr<Expr> rexprFalse;
\r
232 struct BracketsExpr
\r
234 std::shared_ptr<Expr> lexpr;
\r
235 std::shared_ptr<Expr> rexpr;
\r
238 struct IdentifierExpr
\r
240 std::vector<std::string> namespacePrefixes;
\r
241 std::string identifier;
\r
249 MethodExpr _method;
\r
253 PrefixOperatorExpr _prefixOp;
\r
254 PostfixOperatorExpr _postfixOp;
\r
255 BinaryOperatorExpr _binaryOp;
\r
256 TernaryOperatorExpr _ternaryOp;
\r
257 BracketsExpr _brackets;
\r
258 IdentifierExpr _identifier;
\r
261 enum class StmtType
\r
263 If, Switch, For, While, Assign, Return, Expr
\r
269 std::shared_ptr<Expr> expr;
\r
276 std::vector<ElseStmt> elses;
\r
281 std::shared_ptr<Expr> expr;
\r
287 std::shared_ptr<Expr> ident;
\r
288 std::vector<SwitchCase> cases;
\r
291 // TODO: int i = 0 (var decl)
\r
294 std::shared_ptr<AssignStmt> init;
\r
295 std::shared_ptr<Expr> condition;
\r
296 std::shared_ptr<Expr> action;
\r
321 SwitchStmt _switch;
\r
324 AssignStmt _assign;
\r
325 ReturnStmt _return;
\r