X-Git-Url: https://gitweb.ps.run/toc/blobdiff_plain/5f9668526491332f62c05ad831dbf6d5fdc2b6d0..17fac686375c2823d22415e32e5b7e63bbfe7c54:/src/repr.h diff --git a/src/repr.h b/src/repr.h index c745ba1..eb46e3a 100644 --- a/src/repr.h +++ b/src/repr.h @@ -17,11 +17,13 @@ struct Program; struct FuncExpr; struct LitExpr; struct IdentifierExpr; +struct AccessExpr; struct BracketsExpr; struct UnaryOperatorExpr; struct BinaryOperatorExpr; struct TernaryOperatorExpr; struct DotExpr; +struct ParenExpr; struct Expr; struct IfStmt; struct SwitchStmt; @@ -38,6 +40,7 @@ enum class TypeModifierType { struct TypeModifier { TypeModifierType type; + bool _staticArray; int _arraySize; }; @@ -97,6 +100,7 @@ struct LitExpr { bool _bool; }; +// TODO: accessExpr struct IdentifierExpr { std::string name; }; @@ -107,14 +111,17 @@ struct BracketsExpr { }; enum class UnaryOperatorType { - Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost, LogicalNot, BitwiseNot, Dereference, AddressOf + Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost, + LogicalNot, BitwiseNot, Dereference, AddressOf, + COUNT }; enum class BinaryOperatorType { Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan, LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals, PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals, - LeftShiftEquals, RightShiftEquals + LeftShiftEquals, RightShiftEquals, + COUNT }; static std::string UnaryOperatorTypeStrings[] = { "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" }; @@ -143,13 +150,16 @@ struct TernaryOperatorExpr { }; struct DotExpr { - std::shared_ptr lexpr; + std::shared_ptr expr; IdentifierExpr ident; }; +// TODO: paren expr struct Expr { ExprType type; + bool parenthesized; + FuncExpr _func; LitExpr _lit; IdentifierExpr _identifier; @@ -185,8 +195,10 @@ struct SwitchStmt { std::vector cases; }; +// TODO: int i = 0 (var decl) struct ForStmt { - AssignStmt assign; + std::string varName; + std::shared_ptr initValue; std::shared_ptr condition; std::shared_ptr action; Body body; @@ -198,8 +210,8 @@ struct WhileStmt { }; struct AssignStmt { - Expr lexpr; - Expr rexpr; + std::string name; + Expr expr; }; struct ReturnStmt {