]> gitweb.ps.run Git - toc/blobdiff - src/repr.h
add namespace, private struct member grammar, change bracket style
[toc] / src / repr.h
index eb46e3a6a3f22e9536d06d8dc1290aa8a083230b..47a78d7f795bc0be4e75edf13b5e175c8f3639e7 100644 (file)
@@ -33,65 +33,77 @@ struct AssignStmt;
 struct ReturnStmt;\r
 struct Stmt;\r
 \r
-enum class TypeModifierType {\r
+enum class TypeModifierType\r
+{\r
   Pointer, Array\r
 };\r
 \r
-struct TypeModifier {\r
+struct TypeModifier\r
+{\r
   TypeModifierType type;\r
 \r
   bool _staticArray;\r
   int _arraySize;\r
 };\r
 \r
-struct Type {\r
+struct Type\r
+{\r
   std::string name;\r
   std::vector<TypeModifier> modifiers;\r
 };\r
 \r
-struct Variable {\r
+struct Variable\r
+{\r
   std::string name;\r
   Type type;\r
 };\r
 \r
-struct Body {\r
+struct Body\r
+{\r
   std::vector<Variable> variables;\r
   std::vector<Stmt> statements;\r
 };\r
 \r
-struct Function {\r
+struct Function\r
+{\r
   Type returnType;\r
   std::string name;\r
   std::vector<Variable> parameters;\r
   Body body;\r
 };\r
 \r
-struct Struct {\r
+struct Struct\r
+{\r
   std::string name;\r
   std::vector<Variable> members;\r
   std::vector<Function> methods;\r
 };\r
 \r
-struct Program {\r
+struct Program\r
+{\r
   std::vector<Variable> variables;\r
   std::vector<Struct> structs;\r
   std::vector<Function> functions;\r
 };\r
 \r
-enum class ExprType {\r
+enum class ExprType\r
+{\r
   Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot\r
 };\r
 \r
-struct FuncExpr {\r
+struct FuncExpr\r
+{\r
   std::string functionName;\r
   std::vector<Expr> arguments;\r
 };\r
 \r
-enum class LitType {\r
+enum class LitType\r
+{\r
   Int, Decimal, String, Bool\r
 };\r
 \r
-struct LitExpr {\r
+struct LitExpr\r
+{\r
   LitType type;\r
 \r
   int _int;\r
@@ -101,61 +113,72 @@ struct LitExpr {
 };\r
 \r
 // TODO: accessExpr\r
-struct IdentifierExpr {\r
+struct IdentifierExpr\r
+{\r
   std::string name;\r
 };\r
 \r
-struct BracketsExpr {\r
+struct BracketsExpr\r
+{\r
   std::shared_ptr<Expr> lexpr;\r
   std::shared_ptr<Expr> rexpr;\r
 };\r
 \r
-enum class UnaryOperatorType {\r
+enum class UnaryOperatorType\r
+{\r
   Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost,\r
   LogicalNot, BitwiseNot, Dereference, AddressOf,\r
   COUNT\r
 };\r
 \r
-enum class BinaryOperatorType {\r
+enum class BinaryOperatorType\r
+{\r
   Plus, Minus, Multiply, Divide, Modulo, BitwiseAnd, BitwiseOr, BitwiseXor, LessThan, GreaterThan,\r
   LeftShift, RightShift, LogicalAnd, LogicalOr, Equals, NotEquals, LessThanEquals, GreaterThanEquals, BitwiseAndEquals, BitwiseOrEquals, BitwiseXorEquals,\r
   PlusEquals, MinusEquals, MultiplyEquals, DivideEquals, ModuloEquals,\r
   LeftShiftEquals, RightShiftEquals,\r
   COUNT\r
 };\r
-static std::string UnaryOperatorTypeStrings[] = {\r
+static std::string UnaryOperatorTypeStrings[] =\r
+{\r
   "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };\r
 \r
-static std::string BinaryOperatorTypeStrings[] = {\r
+static std::string BinaryOperatorTypeStrings[] =\r
+{\r
   "+", "-", "*", "/", "%", "&", "|", "^", "<", ">",\r
   "<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",\r
   "+=","-=","*=","/=","%=",\r
   "<<=",">>=" };\r
 \r
-struct UnaryOperatorExpr {\r
+struct UnaryOperatorExpr\r
+{\r
   UnaryOperatorType type;\r
   std::shared_ptr<Expr> expr;\r
 };\r
 \r
-struct BinaryOperatorExpr {\r
+struct BinaryOperatorExpr\r
+{\r
   BinaryOperatorType type;\r
   std::shared_ptr<Expr> lexpr;\r
   std::shared_ptr<Expr> rexpr;\r
 };\r
 \r
-struct TernaryOperatorExpr {\r
+struct TernaryOperatorExpr\r
+{\r
   std::shared_ptr<Expr> lexpr;\r
   std::shared_ptr<Expr> rexprTrue;\r
   std::shared_ptr<Expr> rexprFalse;\r
 };\r
 \r
-struct DotExpr {\r
+struct DotExpr\r
+{\r
   std::shared_ptr<Expr> expr;\r
   IdentifierExpr ident;\r
 };\r
 \r
 // TODO: paren expr\r
-struct Expr {\r
+struct Expr\r
+{\r
   ExprType type;\r
 \r
   bool parenthesized;\r
@@ -170,33 +193,39 @@ struct Expr {
   DotExpr             _dot;\r
 };\r
 \r
-enum class StmtType {\r
+enum class StmtType\r
+{\r
   If, Switch, For, While, Assign, Return, Expr\r
 };\r
 \r
-struct ElseStmt {\r
+struct ElseStmt\r
+{\r
   bool _if;\r
   std::shared_ptr<Expr> expr;\r
   Body body;\r
 };\r
-struct IfStmt {\r
+struct IfStmt\r
+{\r
   Expr condition;\r
   Body body;\r
   std::vector<ElseStmt> elses;\r
 };\r
 \r
-struct SwitchCase {\r
+struct SwitchCase\r
+{\r
   std::shared_ptr<Expr> expr;\r
   Body body;\r
 };\r
 \r
-struct SwitchStmt {\r
+struct SwitchStmt\r
+{\r
   IdentifierExpr ident;\r
   std::vector<SwitchCase> cases;\r
 };\r
 \r
 // TODO: int i = 0 (var decl)\r
-struct ForStmt {\r
+struct ForStmt\r
+{\r
   std::string varName;\r
   std::shared_ptr<Expr> initValue;\r
   std::shared_ptr<Expr> condition;\r
@@ -204,21 +233,25 @@ struct ForStmt {
   Body body;\r
 };\r
 \r
-struct WhileStmt {\r
+struct WhileStmt\r
+{\r
   Expr condition;\r
   Body body;\r
 };\r
 \r
-struct AssignStmt {\r
+struct AssignStmt\r
+{\r
   std::string name;\r
   Expr expr;\r
 };\r
 \r
-struct ReturnStmt {\r
+struct ReturnStmt\r
+{\r
   Expr expr;\r
 };\r
 \r
-struct Stmt {\r
+struct Stmt\r
+{\r
   StmtType type;\r
   \r
   IfStmt      _if;\r