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
83 std::vector<Variable> parameters;
\r
86 std::vector<std::string> genericTypeNames;
\r
87 std::vector<std::vector<Type>> genericInstantiations;
\r
92 template<typename T>
\r
97 operator T() { return t; }
\r
103 std::vector<std::string> genericTypeNames;
\r
104 std::vector<std::vector<Type>> genericInstantiations;
\r
105 std::vector<StructMember<Variable>> members;
\r
106 std::vector<StructMember<Function>> methods;
\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
120 std::shared_ptr<Context> ctx;
\r
121 std::vector<Struct> structs;
\r
122 std::vector<Function> functions;
\r
123 std::vector<Namespace> namespaces;
\r
126 enum class ExprType
\r
128 Func, Method, Lit, Paren, Dot, PrefixOp, PostfixOp, BinaryOp, TernaryOp, Bracket, Identifier
\r
133 std::vector<std::string> namespacePrefixes;
\r
134 std::string functionName;
\r
135 std::vector<Expr> arguments;
\r
136 std::vector<Type> genericInstantiation;
\r
141 std::shared_ptr<Expr> expr;
\r
142 std::string methodName;
\r
143 std::vector<Expr> arguments;
\r
144 std::vector<Type> genericInstantiation;
\r
149 Int, Decimal, String, Bool
\r
158 std::string _string;
\r
164 std::shared_ptr<Expr> expr;
\r
170 std::shared_ptr<Expr> expr;
\r
171 std::string identifier;
\r
174 enum class PrefixOperatorType
\r
176 Plus, Minus, Increment, Decrement,
\r
177 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
180 static std::string PrefixOperatorTypeStrings[] =
\r
182 "+", "-", "++", "--", "!", "~", "*", "&" };
\r
184 struct PrefixOperatorExpr
\r
186 PrefixOperatorType type;
\r
187 std::shared_ptr<Expr> expr;
\r
190 enum class PostfixOperatorType
\r
192 Increment, Decrement,
\r
195 static std::string PostfixOperatorTypeStrings[] =
\r
199 struct PostfixOperatorExpr
\r
201 PostfixOperatorType type;
\r
202 std::shared_ptr<Expr> expr;
\r
205 enum class BinaryOperatorType
\r
207 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
208 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
209 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
210 LeftShiftEquals, RightShiftEquals,
\r
213 static std::string BinaryOperatorTypeStrings[] =
\r
215 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
216 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
217 "+=","-=","*=","/=","%=",
\r
220 struct BinaryOperatorExpr
\r
222 BinaryOperatorType type;
\r
223 std::shared_ptr<Expr> lexpr;
\r
224 std::shared_ptr<Expr> rexpr;
\r
227 struct TernaryOperatorExpr
\r
229 std::shared_ptr<Expr> lexpr;
\r
230 std::shared_ptr<Expr> rexprTrue;
\r
231 std::shared_ptr<Expr> rexprFalse;
\r
234 struct BracketsExpr
\r
236 std::shared_ptr<Expr> lexpr;
\r
237 std::shared_ptr<Expr> rexpr;
\r
240 struct IdentifierExpr
\r
242 std::vector<std::string> namespacePrefixes;
\r
243 std::string identifier;
\r
251 MethodExpr _method;
\r
255 PrefixOperatorExpr _prefixOp;
\r
256 PostfixOperatorExpr _postfixOp;
\r
257 BinaryOperatorExpr _binaryOp;
\r
258 TernaryOperatorExpr _ternaryOp;
\r
259 BracketsExpr _brackets;
\r
260 IdentifierExpr _identifier;
\r
263 enum class StmtType
\r
265 If, Switch, For, While, Assign, Return, Expr
\r
271 std::shared_ptr<Expr> expr;
\r
278 std::vector<ElseStmt> elses;
\r
283 std::shared_ptr<Expr> expr;
\r
289 std::shared_ptr<Expr> ident;
\r
290 std::vector<SwitchCase> cases;
\r
293 // TODO: int i = 0 (var decl)
\r
296 std::shared_ptr<AssignStmt> init;
\r
297 std::shared_ptr<Expr> condition;
\r
298 std::shared_ptr<Expr> action;
\r
323 SwitchStmt _switch;
\r
326 AssignStmt _assign;
\r
327 ReturnStmt _return;
\r