7 #include "TocParser.h"
\r
19 struct IdentifierExpr;
\r
20 struct BracketsExpr;
\r
21 struct UnaryOperatorExpr;
\r
22 struct BinaryOperatorExpr;
\r
23 struct TernaryOperatorExpr;
\r
34 enum class TypeModifierType {
\r
38 struct TypeModifier {
\r
39 TypeModifierType type;
\r
46 std::vector<TypeModifier> modifiers;
\r
55 std::vector<Variable> variables;
\r
56 std::vector<Stmt> statements;
\r
62 std::vector<Variable> parameters;
\r
68 std::vector<Variable> members;
\r
69 std::vector<Function> methods;
\r
73 std::vector<Variable> variables;
\r
74 std::vector<Struct> structs;
\r
75 std::vector<Function> functions;
\r
78 enum class ExprType {
\r
79 Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot
\r
83 std::string functionName;
\r
84 std::vector<Expr> arguments;
\r
87 enum class LitType {
\r
88 Int, Decimal, String, Bool
\r
96 std::string _string;
\r
100 struct IdentifierExpr {
\r
104 struct BracketsExpr {
\r
105 std::shared_ptr<Expr> lexpr;
\r
106 std::shared_ptr<Expr> rexpr;
\r
109 enum class UnaryOperatorType {
\r
110 Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost, LogicalNot, BitwiseNot, Dereference, AddressOf
\r
113 enum class BinaryOperatorType {
\r
114 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
115 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
116 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
117 LeftShiftEquals, RightShiftEquals
\r
119 static std::string UnaryOperatorTypeStrings[] = {
\r
120 "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };
\r
122 static std::string BinaryOperatorTypeStrings[] = {
\r
123 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
124 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
125 "+=","-=","*=","/=","%=",
\r
128 struct UnaryOperatorExpr {
\r
129 UnaryOperatorType type;
\r
130 std::shared_ptr<Expr> expr;
\r
133 struct BinaryOperatorExpr {
\r
134 BinaryOperatorType type;
\r
135 std::shared_ptr<Expr> lexpr;
\r
136 std::shared_ptr<Expr> rexpr;
\r
139 struct TernaryOperatorExpr {
\r
140 std::shared_ptr<Expr> lexpr;
\r
141 std::shared_ptr<Expr> rexprTrue;
\r
142 std::shared_ptr<Expr> rexprFalse;
\r
146 std::shared_ptr<Expr> lexpr;
\r
147 IdentifierExpr ident;
\r
155 IdentifierExpr _identifier;
\r
156 BracketsExpr _brackets;
\r
157 UnaryOperatorExpr _unaryOperator;
\r
158 BinaryOperatorExpr _binaryOperator;
\r
159 TernaryOperatorExpr _ternaryOperator;
\r
163 enum class StmtType {
\r
164 If, Switch, For, While, Assign, Return, Expr
\r
169 std::shared_ptr<Expr> expr;
\r
175 std::vector<ElseStmt> elses;
\r
178 struct SwitchCase {
\r
179 std::shared_ptr<Expr> expr;
\r
183 struct SwitchStmt {
\r
184 IdentifierExpr ident;
\r
185 std::vector<SwitchCase> cases;
\r
190 std::shared_ptr<Expr> condition;
\r
191 std::shared_ptr<Expr> action;
\r
200 struct AssignStmt {
\r
205 struct ReturnStmt {
\r
213 SwitchStmt _switch;
\r
216 AssignStmt _assign;
\r
217 ReturnStmt _return;
\r