- std::vector<Variable> members;\r
- std::vector<Function> methods;\r
+ std::vector<std::string> genericTypeNames;\r
+ std::vector<std::vector<Type>> genericInstantiations;\r
+ std::vector<StructMember<Variable>> members;\r
+ std::vector<StructMember<Function>> methods;\r
-struct Program {\r
- std::vector<Variable> variables;\r
+struct Namespace\r
+{\r
+ std::string name;\r
+ std::shared_ptr<Context> ctx;\r
+ std::vector<Struct> structs;\r
+ std::vector<Function> functions;\r
+ std::vector<Namespace> namespaces;\r
+};\r
+\r
+struct Program\r
+{\r
+ std::shared_ptr<Context> ctx;\r
-enum class ExprType {\r
- Func, Lit, Identifier, Brackets, UnaryOperator, BinaryOperator, TernaryOperator, Dot\r
+enum class ExprType\r
+{\r
+ Func, Method, Lit, Paren, Dot, PrefixOp, PostfixOp, BinaryOp, TernaryOp, Bracket, Identifier\r
+ std::vector<Type> genericInstantiation;\r
+};\r
+\r
+struct MethodExpr\r
+{\r
+ std::shared_ptr<Expr> expr;\r
+ std::string methodName;\r
+ std::vector<Expr> arguments;\r
+ std::vector<Type> genericInstantiation;\r
Int, Decimal, String, Bool\r
};\r
\r
Int, Decimal, String, Bool\r
};\r
\r
-enum class UnaryOperatorType {\r
- Plus, Minus, IncrementPre, DecrementPre, IncrementPost, DecrementPost, LogicalNot, BitwiseNot, Dereference, AddressOf\r
+enum class PrefixOperatorType\r
+{\r
+ Plus, Minus, Increment, Decrement,\r
+ LogicalNot, BitwiseNot, Dereference, AddressOf,\r
+ COUNT\r
+static std::string PrefixOperatorTypeStrings[] =\r
+{\r
+ "+", "-", "++", "--", "!", "~", "*", "&" };\r
-enum class BinaryOperatorType {\r
+struct PrefixOperatorExpr\r
+{\r
+ PrefixOperatorType type;\r
+ std::shared_ptr<Expr> expr;\r
+};\r
+\r
+enum class PostfixOperatorType\r
+{\r
+ Increment, Decrement,\r
+ COUNT\r
+};\r
+static std::string PostfixOperatorTypeStrings[] =\r
+{\r
+ "++", "--" };\r
+\r
+struct PostfixOperatorExpr\r
+{\r
+ PostfixOperatorType type;\r
+ std::shared_ptr<Expr> expr;\r
+};\r
+\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
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
-static std::string UnaryOperatorTypeStrings[] = {\r
- "+", "-", "++", "--", "++", "--", "!", "~", "*", "&" };\r
-\r
-static std::string BinaryOperatorTypeStrings[] = {\r
+static std::string BinaryOperatorTypeStrings[] =\r
+{\r
"+", "-", "*", "/", "%", "&", "|", "^", "<", ">",\r
"<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",\r
"+=","-=","*=","/=","%=",\r
"<<=",">>=" };\r
\r
"+", "-", "*", "/", "%", "&", "|", "^", "<", ">",\r
"<<",">>","&&","||","==","!=","<=",">=","&=","|=","^=",\r
"+=","-=","*=","/=","%=",\r
"<<=",">>=" };\r
\r
-struct UnaryOperatorExpr {\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
BinaryOperatorType type;\r
std::shared_ptr<Expr> lexpr;\r
std::shared_ptr<Expr> rexpr;\r
};\r
\r
std::shared_ptr<Expr> lexpr;\r
std::shared_ptr<Expr> rexprTrue;\r
std::shared_ptr<Expr> rexprFalse;\r
};\r
\r
std::shared_ptr<Expr> lexpr;\r
std::shared_ptr<Expr> rexprTrue;\r
std::shared_ptr<Expr> rexprFalse;\r
};\r
\r
- IdentifierExpr _identifier;\r
- BracketsExpr _brackets;\r
- UnaryOperatorExpr _unaryOperator;\r
- BinaryOperatorExpr _binaryOperator;\r
- TernaryOperatorExpr _ternaryOperator;\r
+ PrefixOperatorExpr _prefixOp;\r
+ PostfixOperatorExpr _postfixOp;\r
+ BinaryOperatorExpr _binaryOp;\r
+ TernaryOperatorExpr _ternaryOp;\r
+ BracketsExpr _brackets;\r
+ IdentifierExpr _identifier;\r
If, Switch, For, While, Assign, Return, Expr\r
};\r
\r
If, Switch, For, While, Assign, Return, Expr\r
};\r
\r