diff --git a/bootstrap/bin/hocc/code.ml b/bootstrap/bin/hocc/code.ml index b0c5a316..c08ba173 100644 --- a/bootstrap/bin/hocc/code.ml +++ b/bootstrap/bin/hocc/code.ml @@ -124,22 +124,31 @@ let hmi_template = {|{ include IdentifiableIntf.S with type t := t } - Prec = { + PrecSet = { type t: t = { - index: uns # Index in `precs` array. - name: string + index: uns # Index in `precSets` array. + names: array string assoc: option Assoc.t - doms: Ordset.t uns Uns.cmper_witness # Indices in `precs` array of dominator - # precedences. + doms: Ordset.t uns Uns.cmper_witness # Indices in `precSets` array of dominator + # precedence sets. } include IdentifiableIntf.S with type t := t } - precs: array Prec.t - [@@doc "Array of precedences, where each element's `index` field corresponds to the + precSets: array PrecSet.t + [@@doc "Array of precedence sets, where each element's `index` field corresponds to the element's array index."] + Prec = { + type t: t = { + name_index: uns # Index of precedence name in precedence set. + prec_set_index: uns # Index of precedence set in `precSets`. + } + + include IdentifiableIntf.S with type t := t + } + Prod = { type t: t = { index: uns # Index in `prods` array. diff --git a/bootstrap/bin/hocc/description.ml b/bootstrap/bin/hocc/description.ml index 2e78d1a5..0f2e92cb 100644 --- a/bootstrap/bin/hocc/description.ml +++ b/bootstrap/bin/hocc/description.ml @@ -72,7 +72,7 @@ let generate_description conf io description Spec.{algorithm; precs; symbols; pr match do_pp_prec, prec with | false, _ | _, None -> formatter - | true, Some {name; _} -> formatter |> Fmt.fmt " " |> pp_prec name + | true, Some prec -> formatter |> Fmt.fmt " " |> pp_prec (Prec.name prec) ) end in let pp_lr0item lr0item formatter = begin @@ -121,7 +121,7 @@ let generate_description conf io description Spec.{algorithm; precs; symbols; pr match do_pp_prec, prec with | false, _ | _, None -> formatter - | true, Some {name; _} -> formatter |> Fmt.fmt " " |> pp_prec name + | true, Some prec -> formatter |> Fmt.fmt " " |> pp_prec (Prec.name prec) ) end in let pp_state_index state_index formatter = begin @@ -136,7 +136,7 @@ let generate_description conf io description Spec.{algorithm; precs; symbols; pr let symbol = Symbols.symbol_of_symbol_index symbol_index symbols in match symbol.prec with | None -> formatter - | Some Prec.{name; _} -> formatter |> Fmt.fmt " " |> pp_prec name + | Some prec -> formatter |> Fmt.fmt " " |> pp_prec (Prec.name prec) end in let pp_reduce_prec Prod.{lhs_index; prec; _} formatter = begin match prec with @@ -241,7 +241,7 @@ let generate_description conf io description Spec.{algorithm; precs; symbols; pr | Some Right -> "right" ) |> (fun formatter -> - List.fold ~init:formatter ~f:(fun formatter name -> + Array.fold ~init:formatter ~f:(fun formatter name -> formatter |> Fmt.fmt " " |> html " html name |> html "\">" |> Fmt.fmt name @@ -254,7 +254,7 @@ let generate_description conf io description Spec.{algorithm; precs; symbols; pr | false -> begin let _, formatter = Ordset.fold ~init:(true, formatter) ~f:(fun (first, formatter) prec_ind -> - List.fold ~init:(first, formatter) ~f:(fun (first, formatter) name -> + Array.fold ~init:(first, formatter) ~f:(fun (first, formatter) name -> let formatter = formatter |> Fmt.fmt (match first with @@ -303,7 +303,7 @@ let generate_description conf io description Spec.{algorithm; precs; symbols; pr |> (fun formatter -> match prec with | None -> formatter - | Some {name; _} -> formatter |> Fmt.fmt " " |> pp_prec name + | Some prec -> formatter |> Fmt.fmt " " |> pp_prec (Prec.name prec) ) |> Fmt.fmt "\n" |> html "