+ let p_bindings, p_atoms, p_names, p_action = inner_pattern p in
+ let action (env_opt : env_type option) (loc : location) =
+ match env_opt with
+ | Some env -> List.map opt_binding_some env
+ | None -> List.map opt_binding_of_name p_names
+ in
+ [ Env (List.map opt_name p_names),
+ Gramext.srules
+ [ [ Gramext.Sopt (Gramext.srules [ p_atoms, p_action ]) ],
+ Gramext.action action ] ]
+ | List0 (p, _)
+ | List1 (p, _) ->
+ let p_bindings, p_atoms, p_names, p_action = inner_pattern p in
+ let env0 = List.map list_binding_of_name p_names in
+ let grow_env_entry env n v =
+ prerr_endline "grow_env_entry";
+ List.map
+ (function
+ | (n', (ty, ListValue vl)) as entry ->
+ if n' = n then n', (ty, ListValue (v :: vl)) else entry
+ | _ -> assert false)
+ env
+ in
+ let grow_env env_i env =
+ prerr_endline "grow_env";
+ List.fold_left
+ (fun env (n, (_, v)) -> grow_env_entry env n v)
+ env env_i
+ in
+ let action (env_list : env_type list) (loc : location) =
+ prerr_endline "list action";
+ List.fold_right grow_env env_list env0
+ in
+ let g_symbol s =
+ match magic with
+ | List0 (_, None) -> Gramext.Slist0 s
+ | List1 (_, None) -> Gramext.Slist1 s
+ | List0 (_, Some l) -> Gramext.Slist0sep (s, g_symbol_of_literal l)
+ | List1 (_, Some l) -> Gramext.Slist1sep (s, g_symbol_of_literal l)
+ | _ -> assert false
+ in
+ [ Env (List.map list_name p_names),