7 #include "TocParser.h"
\r
19 struct IdentifierExpr;
\r
21 struct BracketsExpr;
\r
22 struct UnaryOperatorExpr;
\r
23 struct BinaryOperatorExpr;
\r
24 struct TernaryOperatorExpr;
\r
36 enum class TypeModifierType {
\r
40 struct TypeModifier {
\r
41 TypeModifierType type;
\r
49 std::vector<TypeModifier> modifiers;
\r
58 std::vector<Variable> variables;
\r
59 std::vector<Stmt> statements;
\r
65 std::vector<Variable> parameters;
\r
71 std::vector<Variable> members;
\r
72 std::vector<Function> methods;
\r
76 std::vector<Variable> variables;
\r
77 std::vector<Struct> structs;
\r
78 std::vector<Function> functions;
\r
81 enum class ExprType {
\r
82 Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot
\r
86 std::string functionName;
\r
87 std::vector<Expr> arguments;
\r
90 enum class LitType {
\r
91 Int, Decimal, String, Bool
\r
99 std::string _string;
\r
103 // TODO: accessExpr
\r
104 struct IdentifierExpr {
\r
108 struct BracketsExpr {
\r
109 std::shared_ptr<Expr> lexpr;
\r
110 std::shared_ptr<Expr> rexpr;
\r
113 enum class UnaryOperatorType {
\r
114 Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost,
\r
115 LogicalNot, BitwiseNot, Dereference, AddressOf,
\r
119 enum class BinaryOperatorType {
\r
120 Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,
\r
121 LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,
\r
122 PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,
\r
123 LeftShiftEquals, RightShiftEquals,
\r
126 static std::string UnaryOperatorTypeStrings[] = {
\r
127 "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };
\r
129 static std::string BinaryOperatorTypeStrings[] = {
\r
130 "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",
\r
131 "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",
\r
132 "+=","-=","*=","/=","%=",
\r
135 struct UnaryOperatorExpr {
\r
136 UnaryOperatorType type;
\r
137 std::shared_ptr<Expr> expr;
\r
140 struct BinaryOperatorExpr {
\r
141 BinaryOperatorType type;
\r
142 std::shared_ptr<Expr> lexpr;
\r
143 std::shared_ptr<Expr> rexpr;
\r
146 struct TernaryOperatorExpr {
\r
147 std::shared_ptr<Expr> lexpr;
\r
148 std::shared_ptr<Expr> rexprTrue;
\r
149 std::shared_ptr<Expr> rexprFalse;
\r
153 std::shared_ptr<Expr> expr;
\r
154 IdentifierExpr ident;
\r
157 // TODO: paren expr
\r
161 bool parenthesized;
\r
165 IdentifierExpr _identifier;
\r
166 BracketsExpr _brackets;
\r
167 UnaryOperatorExpr _unaryOperator;
\r
168 BinaryOperatorExpr _binaryOperator;
\r
169 TernaryOperatorExpr _ternaryOperator;
\r
173 enum class StmtType {
\r
174 If, Switch, For, While, Assign, Return, Expr
\r
179 std::shared_ptr<Expr> expr;
\r
185 std::vector<ElseStmt> elses;
\r
188 struct SwitchCase {
\r
189 std::shared_ptr<Expr> expr;
\r
193 struct SwitchStmt {
\r
194 IdentifierExpr ident;
\r
195 std::vector<SwitchCase> cases;
\r
198 // TODO: int i = 0 (var decl)
\r
200 std::string varName;
\r
201 std::shared_ptr<Expr> initValue;
\r
202 std::shared_ptr<Expr> condition;
\r
203 std::shared_ptr<Expr> action;
\r
212 struct AssignStmt {
\r
217 struct ReturnStmt {
\r
225 SwitchStmt _switch;
\r
228 AssignStmt _assign;
\r
229 ReturnStmt _return;
\r