5.8.2.1. Pattern extractor

This type is used to extract components of a value, corresponding to a match.
Start ocaml section to src/flx_types.mli[3 /3 ] Prev First
    23: # 809 "./lpsrc/flx_types.ipk"
    24: type dir_t =
    25:   | DIR_open of qualified_name_t
    26:   | DIR_inject_module of qualified_name_t
    27:   | DIR_use of id_t * qualified_name_t
    28: 
    29: type dcl_t =
    30:   [
    31: 
    32:   (* data structures *)
    33:   | `DCL_axiom of       parameter_t list * expr_t
    34:   | `DCL_reduce of       parameter_t list * expr_t * expr_t
    35:   | `DCL_function of     params_t * typecode_t * property_t list * asm_t list
    36:   | `DCL_union of        (id_t * int option * typecode_t) list
    37:   | `DCL_struct of       (id_t * typecode_t) list
    38:   | `DCL_cstruct of      (id_t * typecode_t) list
    39:   | `DCL_cclass of       class_member_t list
    40:   | `DCL_typeclass of    typeclass_member_t list
    41:   | `DCL_match_check of pattern_t * (string * int)
    42:   | `DCL_match_handler of pattern_t * (string * int) * asm_t list
    43:   | `DCL_glr of          typecode_t * (reduced_production_t * expr_t)
    44: 
    45:   (* variables *)
    46:   | `DCL_val of          typecode_t
    47:   | `DCL_var of          typecode_t
    48:   | `DCL_lazy of          typecode_t * expr_t
    49:   | `DCL_type_alias of   typecode_t
    50:   | `DCL_inherit of   qualified_name_t
    51:   | `DCL_inherit_fun of   qualified_name_t
    52: 
    53:   (* module system *)
    54:   | `DCL_module of       asm_t list
    55:   | `DCL_class of        asm_t list
    56: 
    57:   (* binding structures [prolog] *)
    58:   | `DCL_abs of          type_qual_t list * c_t * named_req_expr_t
    59:   | `DCL_const of        typecode_t * c_t * named_req_expr_t
    60:   | `DCL_fun of          property_t list * typecode_t list * typecode_t * c_t * named_req_expr_t * prec_t
    61:   | `DCL_callback of     property_t list * typecode_t list * typecode_t * named_req_expr_t
    62:   | `DCL_insert of      c_t * ikind_t * named_req_expr_t
    63:   | `DCL_regdef of      regexp_t
    64:   | `DCL_regmatch of    (regexp_t * expr_t) list
    65:   | `DCL_reglex of      (regexp_t * expr_t) list
    66:   ]
    67: 
    68: and access_t = [`Private | `Public ]
    69: 
    70: and asm_t =
    71: 
    72:   | Exe of range_srcref * exe_t
    73:   | Dcl of range_srcref * id_t * int option * access_t * vs_list_t * dcl_t
    74:   | Iface of range_srcref * iface_t
    75:   | Dir of range_srcref * dir_t
    76: 
    77: and entry_kind_t = int
    78: 
    79: and entry_set_t =
    80:   | FunctionEntry of entry_kind_t list
    81:   | NonFunctionEntry of entry_kind_t
    82: 
    83: and module_rep_t =
    84:   | Simple_module of bid_t * typecode_t list * name_map_t * dir_t list
    85: 
    86: and name_map_t = (string, entry_set_t) Hashtbl.t
    87: 
    88: and iface_t =
    89:   [
    90:   | `IFACE_export_fun of suffixed_name_t * string
    91:   | `IFACE_export_type of typecode_t * string
    92:   ]
    93: 
    94: (** value typing *)
    95: type 't b0typecode_t' =
    96:   [
    97:   | `BTYP_inst of bid_t * 't list
    98:   | `BTYP_tuple of 't list
    99:   | `BTYP_record of (string * 't) list
   100:   | `BTYP_variant of (string * 't) list
   101:   | `BTYP_unitsum of int
   102:   | `BTYP_sum of 't list
   103:   | `BTYP_function of 't * 't
   104:   | `BTYP_cfunction of 't * 't
   105:   | `BTYP_pointer  of 't
   106:   | `BTYP_lvalue  of 't
   107:   | `BTYP_array of 't * 't
   108:   | `BTYP_void
   109:   | `BTYP_fix of int
   110:   | `BTYP_intersect of 't list (** intersection type *)
   111:   ]
   112: 
   113: type 't btpattern_t' = {
   114:   pattern: 't;
   115:   pattern_vars: IntSet.t; (* pattern type variables, including 'any' vars *)
   116:   assignments : (int * 't) list (* assignments for 'as' vars *)
   117: }
   118: 
   119: 
   120: (** meta typing *)
   121: type 't b1typecode_t' =
   122:   [
   123:   | `BTYP_var of int * 't
   124:   | `BTYP_apply of 't * 't
   125:   | `BTYP_typefun of (int * 't) list * 't * 't
   126:   | `BTYP_type
   127:   | `BTYP_type_tuple of 't list
   128:   | `BTYP_type_match of 't * ('t btpattern_t' * 't) list
   129: 
   130:   (* type sets *)
   131:   | `BTYP_typeset of 't list (** open union *)
   132:   | `BTYP_typesetunion of 't list (** open union *)
   133:   | `BTYP_typesetintersection of 't list (** open union *)
   134:   ]
   135: 
   136: (** general typing *)
   137: type 't btypecode_t' =
   138:   [
   139:   | 't b0typecode_t'
   140:   | 't b1typecode_t'
   141:   ]
   142: 
   143: type b0typecode_t = 't b0typecode_t' as 't
   144: type btypecode_t = 't btypecode_t' as 't
   145: type btpattern_t = btypecode_t btpattern_t'
   146: 
   147: type biface_t =
   148:   [
   149:   | `BIFACE_export_fun of range_srcref * bid_t * string
   150:   | `BIFACE_export_type of range_srcref * btypecode_t * string
   151:   ]
   152: 
   153: type regular_args_t =
   154:     int list * (* alphabet *)
   155:     int *      (* state count *)
   156:     (int, tbexpr_t) Hashtbl.t * (* state->expression map *)
   157:     (int * int, int) Hashtbl.t (* transition matrix *)
   158: 
   159: and bexe_t =
   160:   [
   161:   | `BEXE_label of range_srcref * string
   162:   | `BEXE_comment of range_srcref * string (* for documenting generated code *)
   163:   | `BEXE_halt of range_srcref * string  (* for internal use only *)
   164:   | `BEXE_goto of range_srcref * string  (* for internal use only *)
   165:   | `BEXE_ifgoto of range_srcref * tbexpr_t * string  (* for internal use only *)
   166:   | `BEXE_ifnotgoto of range_srcref * tbexpr_t * string  (* for internal use only *)
   167:   | `BEXE_call of range_srcref * tbexpr_t * tbexpr_t
   168:   | `BEXE_call_direct of range_srcref * bid_t * btypecode_t list * tbexpr_t
   169:   | `BEXE_call_method_direct of range_srcref * tbexpr_t * bid_t * btypecode_t list * tbexpr_t
   170:   | `BEXE_call_method_stack of range_srcref * tbexpr_t * bid_t * btypecode_t list * tbexpr_t
   171:   | `BEXE_call_stack of range_srcref * bid_t * btypecode_t list * tbexpr_t
   172:   | `BEXE_call_prim of range_srcref * bid_t * btypecode_t list * tbexpr_t
   173:   | `BEXE_jump of range_srcref * tbexpr_t * tbexpr_t
   174:   | `BEXE_jump_direct of range_srcref * bid_t * btypecode_t list * tbexpr_t
   175:   | `BEXE_loop of range_srcref * int * tbexpr_t
   176:   | `BEXE_svc of range_srcref * bid_t
   177:   | `BEXE_fun_return of range_srcref * tbexpr_t
   178:   | `BEXE_proc_return of range_srcref
   179:   | `BEXE_nop of range_srcref * string
   180:   | `BEXE_code of range_srcref * c_t
   181:   | `BEXE_nonreturn_code of range_srcref * c_t
   182:   | `BEXE_assign of range_srcref * tbexpr_t * tbexpr_t
   183:   | `BEXE_init of range_srcref * bid_t * tbexpr_t
   184:   | `BEXE_begin
   185:   | `BEXE_end
   186:   | `BEXE_assert of range_srcref * tbexpr_t
   187:   | `BEXE_assert2 of range_srcref * range_srcref * tbexpr_t
   188:   | `BEXE_axiom_check of range_srcref * tbexpr_t
   189: 
   190:   | `BEXE_apply_ctor of range_srcref * bid_t * bid_t * btypecode_t list * bid_t * tbexpr_t
   191:   | `BEXE_apply_ctor_stack of range_srcref * bid_t * bid_t * btypecode_t list * bid_t * tbexpr_t
   192:     (* For classes! Note this case works as so:
   193:      * arg0 denotes a variable to store the closure pointer in
   194:      * arg1 and 2 denote the closure to be created,
   195:      * arg3 and 4 s a procedure call executed in the
   196:        context of the closure to initialise the frame.
   197:      * The expression just returns the initialised closure.
   198:      * This is rougly equivalent to (in Ocaml notation):
   199: 
   200:       let frame = closure (arg1,arg2) in
   201:       closure(arg3,arg2).call(arg4).run();
   202:       closure
   203: 
   204:       except that the second closure create takes
   205:       the first as its parent. This combinator is
   206:       needed to intervene in the construction of
   207:       the display (list of environment pointers)
   208:       to ensure that the first closure is passed
   209:       as a display variable to the second, so that
   210:       the class constructor can refer to the class object
   211:       as its parent, that is, so references to member variables
   212:       resolve correctly to the instance object.
   213: 
   214:       NOTE: the stack version applies to the constructor procedure
   215:       NOT the class, which is always heaped
   216:     *)
   217:    ]
   218: 
   219: and bexpr_t =
   220:   [
   221:   | `BEXPR_parse of tbexpr_t * int list
   222:   | `BEXPR_deref of tbexpr_t
   223:   | `BEXPR_name of bid_t * btypecode_t list
   224:   | `BEXPR_ref of bid_t * btypecode_t list
   225:   | `BEXPR_literal of literal_t
   226:   | `BEXPR_apply of tbexpr_t * tbexpr_t
   227:   | `BEXPR_apply_prim of bid_t * btypecode_t list * tbexpr_t
   228:   | `BEXPR_apply_direct of bid_t * btypecode_t list * tbexpr_t
   229:   | `BEXPR_apply_stack of bid_t * btypecode_t list * tbexpr_t
   230:   | `BEXPR_apply_method_direct of tbexpr_t * bid_t * btypecode_t list * tbexpr_t
   231:   | `BEXPR_apply_method_stack of tbexpr_t * bid_t * btypecode_t list * tbexpr_t
   232:   | `BEXPR_apply_struct of bid_t * btypecode_t list * tbexpr_t
   233: 
   234:   | `BEXPR_tuple of tbexpr_t list
   235:   | `BEXPR_record of (string * tbexpr_t) list
   236:   | `BEXPR_variant of string * tbexpr_t
   237:   | `BEXPR_get_n of int * tbexpr_t (* tuple projection *)
   238:   | `BEXPR_get_named of int * tbexpr_t (* struct/class projection *)
   239:   | `BEXPR_closure of bid_t * btypecode_t list
   240:   | `BEXPR_method_closure of tbexpr_t * bid_t * btypecode_t list
   241:   | `BEXPR_case of int * btypecode_t
   242:   | `BEXPR_match_case of int * tbexpr_t
   243:   | `BEXPR_case_arg of int * tbexpr_t
   244:   | `BEXPR_case_index of tbexpr_t
   245:   | `BEXPR_expr of string * btypecode_t
   246:   | `BEXPR_range_check of tbexpr_t * tbexpr_t * tbexpr_t
   247:   | `BEXPR_coerce of tbexpr_t * btypecode_t
   248:   ]
   249: 
   250: and tbexpr_t = bexpr_t * btypecode_t
   251: 
   252: and glr_symbol_t = [`Term of int | `Nonterm of int list]
   253: and bglr_entry_t = string option * glr_symbol_t
   254: and bproduction_t = bglr_entry_t list
   255: 
   256: and bparameter_t = string * (int * btypecode_t)
   257: and breqs_t = (bid_t * btypecode_t list) list
   258: and bvs_t = (string * int) list
   259: and bparams_t = bparameter_t list * tbexpr_t option
   260: and bclass_member_t = [
   261:   | `BMemberVal of id_t * btypecode_t
   262:   | `BMemberVar of id_t * btypecode_t
   263:   | `BMemberFun of id_t * bvs_t * btypecode_t
   264:   | `BMemberProc of id_t * bvs_t * btypecode_t
   265:   | `BMemberCtor of id_t * btypecode_t
   266: ]
   267: 
   268: and btype_qual_t = [
   269:   | base_type_qual_t
   270:   | `Bound_needs_shape of btypecode_t
   271: ]
   272: 
   273: and bbdcl_t =
   274:   [
   275:   | `BBDCL_function of   property_t list * bvs_t * bparams_t * btypecode_t * bexe_t list
   276:   | `BBDCL_procedure of  property_t list * bvs_t * bparams_t * bexe_t list
   277:   | `BBDCL_val of        bvs_t * btypecode_t
   278:   | `BBDCL_var of        bvs_t * btypecode_t
   279:   | `BBDCL_tmp of        bvs_t * btypecode_t
   280:   | `BBDCL_glr of        property_t list * bvs_t * btypecode_t * (bproduction_t * bexe_t list)
   281:   | `BBDCL_regmatch of   property_t list * bvs_t * bparams_t * btypecode_t * regular_args_t
   282:   | `BBDCL_reglex of     property_t list * bvs_t * bparams_t * int * btypecode_t * regular_args_t
   283: 
   284:   (* binding structures [prolog] *)
   285:   | `BBDCL_abs of        bvs_t * btype_qual_t list * c_t * breqs_t
   286:   | `BBDCL_const of      bvs_t * btypecode_t * c_t * breqs_t
   287:   | `BBDCL_fun of        property_t list * bvs_t * btypecode_t list * btypecode_t * c_t  * breqs_t * prec_t
   288:   | `BBDCL_callback of   property_t list * bvs_t * btypecode_t list * btypecode_t list * int * btypecode_t * breqs_t * prec_t
   289:   | `BBDCL_proc of       property_t list * bvs_t * btypecode_t list * c_t  * breqs_t
   290:   | `BBDCL_insert of     bvs_t * c_t * ikind_t * breqs_t
   291: 
   292:   | `BBDCL_union of      bvs_t * (id_t * int * btypecode_t) list
   293:   | `BBDCL_struct of     bvs_t * (id_t * btypecode_t) list
   294:   | `BBDCL_cstruct of     bvs_t * (id_t * btypecode_t) list
   295:   | `BBDCL_cclass of     bvs_t * bclass_member_t list
   296:   | `BBDCL_class of      property_t list * bvs_t
   297:   | `BBDCL_nonconst_ctor of bvs_t * int * btypecode_t * int * btypecode_t
   298:   ]
   299: 
   300: and reduction_t = id_t * bvs_t * bparameter_t list * tbexpr_t * tbexpr_t
   301: and axiom_t = id_t * range_srcref * bvs_t * bparameter_t list * tbexpr_t
   302: 
   303: and typevarmap_t = (int,btypecode_t) Hashtbl.t
   304: 
   305: type env_t = (bid_t * id_t * name_map_t * name_map_t list) list
   306: 
   307: type symbol_definition_t =
   308:   [
   309:   | `SYMDEF_abs of type_qual_t list * c_t * named_req_expr_t
   310:   | `SYMDEF_regdef of regexp_t
   311:   | `SYMDEF_regmatch of params_t * (regexp_t * expr_t) list
   312:   | `SYMDEF_reglex of params_t * int * (regexp_t * expr_t) list
   313:   | `SYMDEF_glr of typecode_t * (reduced_production_t * sexe_t list)
   314: 
   315:   | `SYMDEF_parameter of  typecode_t
   316:   | `SYMDEF_typevar of typecode_t (* usually type TYPE *)
   317: 
   318:   | `SYMDEF_axiom of parameter_t list * expr_t
   319:   | `SYMDEF_reduce of parameter_t list * expr_t * expr_t
   320:   | `SYMDEF_function of params_t * typecode_t * property_t list * sexe_t list
   321: 
   322:   | `SYMDEF_match_check of  pattern_t * (string *int)
   323:   | `SYMDEF_module
   324:   | `SYMDEF_class
   325: 
   326:   | `SYMDEF_const_ctor of int * typecode_t * int
   327:   | `SYMDEF_nonconst_ctor of int * typecode_t * int * typecode_t
   328: 
   329:   | `SYMDEF_const of typecode_t * c_t * named_req_expr_t
   330:   | `SYMDEF_var of  typecode_t
   331:   | `SYMDEF_val of  typecode_t
   332:   | `SYMDEF_lazy of  typecode_t * expr_t
   333:   | `SYMDEF_fun of property_t list * typecode_t list * typecode_t * c_t  * named_req_expr_t * prec_t
   334:   | `SYMDEF_callback of property_t list * typecode_t list * typecode_t * named_req_expr_t
   335:   | `SYMDEF_insert of c_t  * ikind_t * named_req_expr_t
   336:   | `SYMDEF_union of  (id_t * int *  typecode_t) list
   337:   | `SYMDEF_struct of  (id_t * typecode_t) list
   338:   | `SYMDEF_cstruct of  (id_t * typecode_t) list
   339:   | `SYMDEF_cclass of  class_member_t list
   340:   | `SYMDEF_typeclass of  typeclass_member_t list
   341:   | `SYMDEF_type_alias of   typecode_t
   342:   | `SYMDEF_inherit of   qualified_name_t
   343:   | `SYMDEF_inherit_fun of   qualified_name_t
   344:   ]
   345: 
   346: type symbol_data_t = {
   347:   id:string;
   348:   sr:range_srcref;
   349:   parent:int option;
   350:   vs:ivs_list_t;
   351:   pubmap:name_map_t;
   352:   privmap:name_map_t;
   353:   dirs:dir_t list;
   354:   symdef:symbol_definition_t;
   355: }
   356: 
   357: type symbol_table_t = (int, symbol_data_t) Hashtbl.t
   358: 
   359: type symbol_data3_t = string * int option * range_srcref * bbdcl_t
   360: type fully_bound_symbol_table_t = (int, symbol_data3_t) Hashtbl.t
   361: 
   362: type type_registry_t = (btypecode_t,int) Hashtbl.t
   363: 
End ocaml section to src/flx_types.mli[3]