diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-10-31 15:35:11 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-10-31 15:35:11 +0100 |
commit | 0b269f32dd9b8d349f94793dad44e728473e9f0a (patch) | |
tree | 066a30fee1efe19d897f5e153d7ea9aa3d7448af /minijazz/src/global/ast.ml | |
download | SystDigit-Projet-0b269f32dd9b8d349f94793dad44e728473e9f0a.tar.gz SystDigit-Projet-0b269f32dd9b8d349f94793dad44e728473e9f0a.zip |
First commit ; includes first TP and minijazz compiler
Diffstat (limited to 'minijazz/src/global/ast.ml')
-rw-r--r-- | minijazz/src/global/ast.ml | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/minijazz/src/global/ast.ml b/minijazz/src/global/ast.ml new file mode 100644 index 0000000..cc29486 --- /dev/null +++ b/minijazz/src/global/ast.ml @@ -0,0 +1,107 @@ +open Location +open Static + +type ident = Ident.t +type name = string + +module IdentEnv = Map.Make (struct type t = ident let compare = compare end) +module IdentSet = Set.Make (struct type t = ident let compare = compare end) + +module NameEnv = Map.Make (struct type t = name let compare = compare end) +module NameSet = Set.Make (struct type t = name let compare = compare end) + +type ty = + | TUnit | TBit | TBitArray of static_exp | TProd of ty list + | TVar of link ref +and link = + | TIndex of int + | TLink of ty +let invalid_type = TUnit + +type mem_kind = MRom | MRam + +type value = + | VBit of bool + | VBitArray of bool array + +type edesc = + | Econst of value + | Evar of ident + | Ereg of exp + | Ecall of name * static_exp list * exp list + (* function * params * args *) + | Emem of mem_kind * static_exp * static_exp * string option * exp list + (* ro * address size * word size * input file * args *) + +and exp = { + e_desc : edesc; + e_ty : ty; + e_loc: location; +} + +type pat = + | Evarpat of ident + | Etuplepat of ident list + +type equation = pat * exp + +type var_dec = { + v_ident : ident; + v_ty : ty; +} + +type param = { + p_name : name; +} + +type block = + | BEqs of equation list * var_dec list + | BIf of static_exp * block * block + +type inlined_status = Inlined | NotInlined + +type node_dec = { + n_name : name; + n_loc: location; + n_inlined : inlined_status; + n_inputs : var_dec list; + n_outputs : var_dec list; + n_params : param list; + n_constraints : static_exp list; + n_body : block; + n_probes : ident list; +} + +type const_dec = { + c_name : name; + c_loc : location; + c_value : static_exp; +} + +type program = { + p_consts : const_dec list; + p_nodes : node_dec list; +} + + +let mk_exp ?(loc = no_location) ?(ty = invalid_type) desc = + { e_desc = desc; e_loc = loc; e_ty = ty } + +let mk_const_dec ?(loc = no_location) n se = + { c_name = n; c_loc = loc; c_value = se } + +let mk_equation pat e = (pat, e) + +let mk_var_dec n ty = + { v_ident = n; v_ty = ty } + +let mk_param n = + { p_name = n } + +let mk_node n loc inlined inputs outputs params b probes = + { n_name = n; n_inputs = inputs; n_outputs = outputs; + n_body = b; n_params = params; n_constraints = []; + n_loc = loc; n_inlined = inlined; n_probes = probes } + +let mk_program cds nds = + { p_consts = cds; p_nodes = nds } |