summaryrefslogtreecommitdiff
path: root/src/ast.mli
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.mli')
-rw-r--r--src/ast.mli55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/ast.mli b/src/ast.mli
index 557b3f6..29a6293 100644
--- a/src/ast.mli
+++ b/src/ast.mli
@@ -26,4 +26,59 @@ type expr =
| EThis
| ENull
| EMem of expr * ident
+and str_expr =
+ | SEExpr of expr
+ | SEStr of string
+and instr =
+ | IEmpty
+ | IExpr of expr
+ | IIf of expr * instr * instr
+ | IWhile of expr * instr
+ | IFor of expr list * expr option * expr list * instr
+ | IBlock of block
+ | IStdCoutWrite of str_expr list
+ | IReturn of expr option
+ | IDeclVar of ty_expr * ident * expr option
+ | IDeclVarAssignConstruct of ty_expr * ident * ident * expr list
+and block = instr list
+and ty_expr =
+ | TVoid
+ | TInt
+ | TId of ident
+ | TPtr of ty_expr
+ | TRef of ty_expr
+and var =
+ | VId of ident
+ | VClsMem of ident * ident
+
+type proto =
+ | PConstructor of constructor_proto
+ | PFunction of function_proto
+and constructor_proto = {
+ cc_class : ident;
+ cc_args : arg list;
+}
+and function_proto = {
+ f_type : ty_expr;
+ f_name : var;
+ f_args : arg list;
+}
+and arg = {
+ arg_ty : ty_expr;
+ arg_name : ident;
+}
+and var_decl = ty_expr * ident
+
+type cls = {
+ c_name : ident;
+ c_supers : ident list;
+ c_vars : var_decl list;
+ c_protos : proto list;
+}
+
+type program = {
+ p_classes : cls list;
+ p_vars : var_decl list;
+ p_functions : (proto * block) list; (* class methods included in here *)
+}