Commits

Paweł Wieczorek  committed 5f3feb7

added interface for the Prioritized module, Makefile can install library via findlib

  • Participants
  • Parent commits 75aa64b

Comments (0)

Files changed (6)

+name            = "stringpainter"
+version         = "0.1"
+description     = "Pretty printing combinators, designed for printing ASTs."
+
+archive(native) = "StringPainter.cmxa"
+archive(byte)   = "StringPainter.cma"
+
 	-Is demo\
 
 LIBS_=src/StringPainter.cma src/StringPainter.cmxa
+
 LIBS =_build/src/StringPainter.cma _build/src/StringPainter.cmxa
 
+CMI=\
+	_build/src/StringPainter.cmi
+
+LIB_FILES=\
+	${CMI}\
+	${LIBS}\
+	_build/src/StringPainter.a
+
 DEMO=demo/Demo.native
 
 all: ${LIBS}
 
 install: ${LIBS}
-	${OCAMLFIND} install stringpainter META ${LIBS}
+	${OCAMLFIND} install stringpainter META ${LIB_FILES}
 
 ${LIBS}:
 	${OCAMLBUILD} ${SOURCE_DIRS} ${LIBS_}
+<src/*.cmx>: for-pack(StringPainter)

File src/Basic.ml

     then sp_indent sp
     else sp_nested sp
 
-let sp_value_int x = sp_value (string_of_int x)
+let sp_value_int  x = sp_value (string_of_int x)
+let sp_value_bool x = sp_value (string_of_bool x)
 
 
 let sp_list opening closing separator = function

File src/Prioritized.ml

  *)
 
 let psp_break           = with_priority psp_max_priority Engine.sp_break
+let psp_newline         = with_priority psp_max_priority Engine.sp_newline
 
 let psp_word            = embed_sp1 psp_max_priority Engine.sp_word
 let psp_keyword         = embed_sp1 psp_max_priority Engine.sp_keyword
 let psp_syntax          = embed_sp1 psp_max_priority Engine.sp_syntax
 
 let psp_value_int       = embed_sp1 psp_max_priority Basic.sp_value_int
+let psp_value_bool      = embed_sp1 psp_max_priority Basic.sp_value_bool
 
 
 (*--------------------------------------------------------------------------------------------------------------------
  *)
 
 let print_painter_nl psp = Engine.print_painter_nl (get_painter psp)
+let print_painter psp = Engine.print_painter (get_painter psp)
+let render_painter psp = Engine.render_painter (get_painter psp)
 
 

File src/Prioritized.mli

+type painter
+
+type associativity
+    = LeftAssociative
+    | RightAssociative
+    | NoAssociative
+
+val get_priority : painter -> int
+val get_painter :  painter -> Basic.painter
+
+val psp_nested : int -> painter list -> painter
+
+val psp_indent : int->  painter list -> painter
+
+val psp_reprioritize : int -> painter -> painter
+
+val psp_max_priority : int
+
+val psp_break : painter
+val psp_newline : painter
+val psp_word : string -> painter
+val psp_keyword : string -> painter
+val psp_value : string -> painter
+val psp_value_keyword : string -> painter
+val psp_operator : string -> painter
+val psp_syntax : string -> painter
+val psp_value_int : int -> painter
+val psp_value_bool : bool -> painter
+val psp_bracket : painter -> painter -> int -> painter -> painter
+val psp_std_bracket : painter -> painter
+val psp_square_bracket : painter -> painter
+val psp_no_bracket : painter -> int * Engine.painter
+
+val psp_decide_bracket : (painter -> painter) -> bool -> painter -> painter
+
+val psp_decide_std_bracket : bool -> painter -> painter
+
+val psp_associative_infix : (int -> int -> bool) ->
+  (int -> int -> bool) -> int -> painter -> painter -> painter -> painter
+
+val psp_left_associative_infix :
+  int -> painter -> painter -> painter -> painter
+
+val psp_right_associative_infix :
+  int -> painter -> painter -> painter -> painter
+
+val psp_no_associative_infix :
+  int -> painter -> painter -> painter -> painter
+
+val psp_infix : associativity -> int -> painter -> painter -> painter -> painter
+
+val print_painter_nl  : painter -> unit
+
+val print_painter     : painter -> unit
+
+val render_painter    : painter -> string