diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-25 15:06:21 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-25 15:06:21 +0100 |
commit | f9ac80d948ecedcf9e04b94b5b529a31f23589a9 (patch) | |
tree | ac566d8756c19367a7eecc39363bd979c61bf8c5 /src/ast.ml | |
parent | 415f94f0978fbf3104f93033fe21ec88f2ec454f (diff) | |
download | LPC-Projet-f9ac80d948ecedcf9e04b94b5b529a31f23589a9.tar.gz LPC-Projet-f9ac80d948ecedcf9e04b94b5b529a31f23589a9.zip |
Added localisation for expressions and statements.
Diffstat (limited to 'src/ast.ml')
-rw-r--r-- | src/ast.ml | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -12,6 +12,8 @@ let type_names = ref Sset.empty type ident = string type tident = string +type loc = Lexing.position * Lexing.position + type binop = | Equal | NotEqual | Lt | Le | Gt | Ge @@ -31,7 +33,10 @@ type var_type = | TRef of var_type | TIdent of tident -type expression = +type expression = { + e_loc: loc; + e_desc: expr_desc } +and expr_desc = | EInt of int | EBool of bool | ENull @@ -42,13 +47,19 @@ type expression = | EUnary of unop * expression | EBinary of expression * binop * expression | EMember of expression * ident - | ENew of ident * expression list + | ENew of tident * expression list -type str_expression = - | SEExpr of expression +type str_expression = { + se_loc: loc; + se_desc : se_desc } +and se_desc = + | SEExpr of expr_desc | SEStr of string -type statement = +type statement = { + s_loc: loc; + s_desc: s_desc } +and s_desc = | SEmpty | SExpr of expression | SIf of expression * statement * statement @@ -58,14 +69,15 @@ type statement = | SReturn of expression option | SDeclare of var_type * ident | SDeclareAssignExpr of var_type * ident * expression - | SDeclareAssignConstructor of var_type * ident * ident * expression list + | SDeclareAssignConstructor of var_type * ident * tident * expression list (* Type of variable, variable name, constructor class name, constructor arguments *) | SWriteCout of str_expression list and block = statement list type proto = { + p_loc : loc; p_name : ident; - p_class : ident option; (* p_class = none : standalone function *) + p_class : tident option; (* p_class = none : standalone function *) p_ret_type : var_type option; (* p_class = some and p_ret_type = none : constructor *) p_args : (var_type * ident) list; } @@ -76,8 +88,8 @@ type cls_mem = | CVirtualMethod of proto type cls = { - c_name : ident; - c_supers : ident list option; + c_name : tident; + c_supers : tident list option; c_members : cls_mem list; } |