Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004452OCamlCamlp4public2007-11-19 00:262013-07-28 03:46
Reportereaubin 
Assigned Tohongboz 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionno change required 
PlatformOSOS Version
Product Version3.10.0 
Target Version4.01.0+devFixed in Version 
Summary0004452: print_implem loops printing record contents
DescriptionCamlp4.PreCast.Printers.OCaml.print_implem loops printing

  module rec b :
             sig
               type record =
                 { key : int; f1 : f1.record; f2 : f2.record;
                   (((((((((((((((((((((((((((((((((((((((((((...

I'm probably doing something wrong creating the list of fields. How should this be done? Thanks
Additional Informationopen Camlp4.PreCast

let _loc = Loc.mk "?"

let base base fields ty =
  let fields = List.fold_right (fun field acc ->
    let c = <:ctyp< $lid:field$ : $uid:field$.record >> in
    <:ctyp< $c$ ; $acc$ >>) fields <:ctyp< >>
  in
  <:module_binding< $uid:base$ :
    sig type record = {
        key : $ty$;
        $fields$
      } end = struct
        type record = {
        key : $ty$;
        $fields$
      } end
    >>

let _ =
  let b = base "b" ["f1"; "f2"] <:ctyp< int >> in
  Camlp4.PreCast.Printers.OCaml.print_implem
    <:str_item< module rec $b$ >>
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0004325)
ertai (developer)
2007-11-19 11:35

You should use CleanAst to remove useless nil nodes.

module CleanAst = Camlp4.Struct.CleanAst.Make(Ast)
let _ =
  let b = base "b" ["f1"; "f2"] <:ctyp< int >> in
  Camlp4.PreCast.Printers.OCaml.print_implem
    ((new CleanAst.clean_ast)#str_item
      <:str_item< module rec $b$ >>)

However I don't know if clean ast should be called by print_implem. I've not done it since I don't want it to be called too often since it costs. For now it's called in the main of camlp4 before printing (camlp4/Camlp4Bin.ml).

- Issue History
Date Modified Username Field Change
2007-11-19 00:26 eaubin New Issue
2007-11-19 11:35 ertai Note Added: 0004325
2007-11-19 11:36 ertai Assigned To => ertai
2007-11-19 11:36 ertai Status new => feedback
2012-07-11 16:01 doligez Target Version => 4.01.0+dev
2012-07-12 11:28 doligez Assigned To ertai =>
2012-07-31 13:37 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-15 11:23 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-07-22 03:06 hongboz Assigned To => hongboz
2013-07-28 03:46 hongboz Status feedback => resolved
2013-07-28 03:46 hongboz Resolution open => no change required


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker