smlformat.1 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .de EX
  2. .nf
  3. .ft CW
  4. ..
  5. .de EE
  6. .br
  7. .fi
  8. .ft
  9. ..
  10. .TH SMLFORMAT 1
  11. .SH NAME
  12. smlformat
  13. \- the pretty printer generator for SML#
  14. .SH SYNOPSIS
  15. .B smlformat
  16. [\fB--stdout\fP|\fB--output=\fP\fIfile\fP]
  17. [\fB--with-line-directive\fP]
  18. .I filename ...
  19. .
  20. .SH DESCRIPTION
  21. .I SMLFormat
  22. generates pretty printing functions for ML types and datatypes.
  23. The input file is an SML# program, each type and datatype of which is
  24. annotated by formatting comments.
  25. The
  26. .B smlformat
  27. command interprets the definition of types and its formatting comments
  28. and inserts formatting functions into the input program.
  29. Generated programs can be compiled by the SML# compiler.
  30. .PP
  31. When multiple input files are given,
  32. each input file is separately read and yields a separate program.
  33. By default, the output file name is obtained by appending
  34. .I .sml
  35. suffix to the input file name.
  36. .PP
  37. .
  38. .SS OPTIONS
  39. .TP
  40. \fB--stdout\fP
  41. Output the result to the standard output.
  42. .TP
  43. \fB--output=\fP\fIfilename\fP
  44. Output the result to the specified file.
  45. .TP
  46. \fB--with-line-directive\fP
  47. Insert comments about the line number of the input file into the output.
  48. .TP
  49. \fB--separate=\fP\fIstructureName\fP
  50. Output formatters in a separate structure.
  51. .
  52. .SH EXAMPLES
  53. The following is a minimal example of an input file
  54. .IR ex.ppg :
  55. .PP
  56. .RS
  57. .EX
  58. (*% *)
  59. datatype intlist = NIL | CONS of int * intlist
  60. fun pretty_intlist x =
  61. SMLFormat.prettyPrint nil (format_intlist x)
  62. .EE
  63. .RE
  64. .PP
  65. where \f[CW](*% *)\fP is the formatting comment of the \f[CW]intlist\fP type.
  66. By invoking
  67. .BR smlformat ,
  68. .PP
  69. .RS
  70. .EX
  71. smlformat ex.ppg
  72. .EE
  73. .RE
  74. .PP
  75. it interprets the formatting comment
  76. and generates \f[CW]format_intlist\fP function of type
  77. \f[CW]intlist -> SMLFormat.format\fP.
  78. In the output file
  79. .IR ex.ppg.sml ,
  80. the definition of \f[CW]format_intlist\fP is inserted just after
  81. the definition of the \f[CW]intlist\fP type.
  82. .PP
  83. To compile the generated program, you need to write an interface file
  84. .I ex.ppg.smi
  85. by yourself.
  86. In the interface file,
  87. the SMLFormat library
  88. .I smlformat-lib.smi
  89. must be required.
  90. The content of
  91. .I ex.ppg.smi
  92. must be as follows:
  93. .PP
  94. .RS
  95. .EX
  96. _require "basis.smi"
  97. _require "smlformat-lib.smi"
  98. datatype intlist = NIL | CONS of int * intlist
  99. val format_intlist : intlist -> SMLFormat.format
  100. val pretty_intlist : intlist -> string
  101. .EE
  102. .RE
  103. .
  104. .SH SEE ALSO
  105. .IR "SML# Document" ,
  106. available at
  107. https://www.pllab.riec.tohoku.ac.jp/smlsharp/docs/