Prechádzať zdrojové kódy

Documented Print phase

Taddeus Kroes 12 rokov pred
rodič
commit
c41cb56442
2 zmenil súbory, kde vykonal 15 pridanie a 1 odobranie
  1. 2 1
      phases/print.ml
  2. 13 0
      phases/print.mli

+ 2 - 1
phases/print.ml

@@ -1,7 +1,7 @@
 open Types
 open Util
 
-let tab = "  "
+let tab = "    "
 let max_instr_width = 26
 
 let si = string_of_int
@@ -132,6 +132,7 @@ let rec instr2str = function
 
   | EmptyLine -> ""
 
+(* Print assembly instructions to the given file pointer. *)
 let rec print_assembly oc instrs =
   let output_line line =
     output_string oc line;

+ 13 - 0
phases/print.mli

@@ -1,3 +1,16 @@
+(** Output any intermediate representation to [stdout] or [stderr]. *)
+
+(** The printing phase takes as input any intermediate representation, and
+    prints its stringification. The input of the phase is also its output.
+
+    Since node stringification is implemented by {!Stringify}, the phase simply
+    calls {!Stringify.node2str} for [Ast] inputs. Stringification of assembly
+    instructions is implemented in the module itself: {!print_assembly}.
+
+    The output starts and ends with a separation line ({!Util.hline}). *)
+
+(** Print assembly instructions to the given file pointer. *)
 val print_assembly : out_channel -> Types.instr list -> unit
 
+(** Main phase function, called by {!Main}. *)
 val phase : Main.phase_func