Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit 8d56ba1adb67927af22fee747c483552db68e9e5 0 parents
@alavrik authored
Showing with 23,424 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +105 −0 INSTALL
  3. +178 −0 LICENSE
  4. +29 −0 Makefile
  5. +55 −0 NOTICE
  6. +65 −0 README
  7. +1 −0  VERSION
  8. +1 −0  bin/piqi
  9. +1 −0  bin/piqic
  10. +1 −0  bin/piqicc
  11. +5 −0 camlp4/META.templ
  12. +28 −0 camlp4/Makefile
  13. +95 −0 camlp4/pa_labelscope.ml
  14. +34 −0 camlp4/pa_openin.ml
  15. +33 −0 deps/Makefile
  16. +21 −0 deps/easy-format-1.0.0/Changes
  17. +24 −0 deps/easy-format-1.0.0/LICENSE
  18. +5 −0 deps/easy-format-1.0.0/META
  19. +4 −0 deps/easy-format-1.0.0/META.tpl
  20. +87 −0 deps/easy-format-1.0.0/Makefile
  21. +25 −0 deps/easy-format-1.0.0/README
  22. +3 −0  deps/easy-format-1.0.0/TODO
  23. +555 −0 deps/easy-format-1.0.0/easy_format.ml
  24. +225 −0 deps/easy-format-1.0.0/easy_format.mli
  25. +6 −0 deps/easy-format-1.0.0/examples/Makefile
  26. +164 −0 deps/easy-format-1.0.0/examples/jsonpp.ml
  27. +224 −0 deps/easy-format-1.0.0/examples/sample.json
  28. +122 −0 deps/easy-format-1.0.0/lambda_example.ml
  29. +237 −0 deps/easy-format-1.0.0/simple_example.ml
  30. +111 −0 deps/easy-format-1.0.0/test_easy_format.ml
  31. +55 −0 deps/easy-format-1.0.0/test_format.ml
  32. +854 −0 deps/ocaml-make-release-6.29.3/Changelog
  33. +502 −0 deps/ocaml-make-release-6.29.3/LICENSE
  34. +1,277 −0 deps/ocaml-make-release-6.29.3/OCamlMakefile
  35. +640 −0 deps/ocaml-make-release-6.29.3/README.txt
  36. +37 −0 deps/ulex-1.1/CHANGES
  37. +22 −0 deps/ulex-1.1/LICENSE
  38. +7 −0 deps/ulex-1.1/META
  39. +59 −0 deps/ulex-1.1/Makefile
  40. +161 −0 deps/ulex-1.1/README
  41. +3 −0  deps/ulex-1.1/_tags
  42. +404 −0 deps/ulex-1.1/cset.ml
  43. +48 −0 deps/ulex-1.1/custom_ulexing.ml
  44. +9 −0 deps/ulex-1.1/myocamlbuild.ml
  45. +270 −0 deps/ulex-1.1/pa_ulex.ml
  46. +31 −0 deps/ulex-1.1/test.ml
  47. +134 −0 deps/ulex-1.1/ulex.ml
  48. +11 −0 deps/ulex-1.1/ulex.mli
  49. +203 −0 deps/ulex-1.1/ulexing.ml
  50. +203 −0 deps/ulex-1.1/ulexing.mli
  51. +146 −0 deps/ulex-1.1/utf16.ml
  52. +100 −0 deps/ulex-1.1/utf16.mli
  53. +139 −0 deps/ulex-1.1/utf8.ml
  54. +13 −0 deps/ulex-1.1/utf8.mli
  55. +18 −0 deps/ulex-1.1/utf8_test.ml
  56. +16 −0 editors/vim/piq.vim
  57. +37 −0 examples/Makefile
  58. +19 −0 examples/addressbook/Makefile
  59. +42 −0 examples/addressbook/Makefile.ocaml
  60. +26 −0 examples/addressbook/README
  61. +107 −0 examples/addressbook/add_person.ml
  62. +54 −0 examples/addressbook/addressbook.piq
  63. +33 −0 examples/addressbook/addressbook.proto
  64. +84 −0 examples/addressbook/addressbook.proto.piqi
  65. +32 −0 examples/addressbook/addressbook.proto.piqi.proto
  66. +50 −0 examples/addressbook/list_people.ml
  67. +58 −0 examples/addressbook/test_ocaml
  68. +4 −0 examples/bool.piq
  69. +11 −0 examples/comment.piq
  70. +12 −0 examples/complex.piq
  71. +30 −0 examples/complex.piqi
  72. +151 −0 examples/def.piqi
  73. 0  examples/empty.piq
  74. +6 −0 examples/flag.piq
  75. +45 −0 examples/float.piq
  76. +60 −0 examples/int.piq
  77. +9 −0 examples/list.piq
  78. +19 −0 examples/person.piq
  79. +43 −0 examples/person.piqi
  80. +33 −0 examples/piq-text.piq
  81. +8 −0 examples/piq-word.piq
  82. +43 −0 examples/proto/def.piqi.proto
  83. +14 −0 examples/record-variant-list.piq
  84. +16 −0 examples/record-variant-list.piqi
  85. +28 −0 examples/string.piq
  86. +38 −0 examples/test_piq
  87. +38 −0 examples/test_piqi
  88. +21 −0 examples/test_piqi_proto
  89. +20 −0 make/Makefile.dirs
  90. +3 −0  make/Makefile.ocaml
  91. +1 −0  make/OCamlMakefile
  92. +48 −0 piqi.org/Makefile
  93. +121 −0 piqi.org/piqast.piqi
  94. +85 −0 piqi.org/piqi-base.piqi
  95. +135 −0 piqi.org/piqi-boot.piqi
  96. +46 −0 piqi.org/piqi-proto.piqi
  97. +23 −0 piqi.org/piqi.piqi
  98. +109 −0 piqi.org/piqtype-core.piqi
  99. +49 −0 piqi.org/piqtype-wire.piqi
  100. +148 −0 piqi.org/piqtype.piqi
  101. +61 −0 piqi/Makefile
  102. +74 −0 piqi/Makefile.piqi_common
  103. +631 −0 piqi/descriptor.piqi
  104. +263 −0 piqi/piq.ml
  105. +332 −0 piqi/piq_gen.ml
  106. +379 −0 piqi/piq_lexer.ml
  107. +553 −0 piqi/piq_parser.ml
  108. +45 −0 piqi/piqi-impl.piqi
  109. +1,138 −0 piqi/piqi.ml
  110. +1 −0  piqi/piqi_c.idl
  111. +6 −0 piqi/piqi_c.ml
  112. +6 −0 piqi/piqi_c.mli
  113. +60 −0 piqi/piqi_c_impl.c
  114. +65 −0 piqi/piqi_check.ml
  115. +261 −0 piqi/piqi_common.ml
  116. +61 −0 piqi/piqi_config.ml
  117. +202 −0 piqi/piqi_convert.ml
  118. +106 −0 piqi/piqi_db.ml
  119. +143 −0 piqi/piqi_expand.ml
  120. +64 −0 piqi/piqi_file.ml
  121. +94 −0 piqi/piqi_iolist.ml
  122. +283 −0 piqi/piqi_main.ml
  123. +104 −0 piqi/piqi_name.ml
  124. +682 −0 piqi/piqi_of_proto.ml
  125. +188 −0 piqi/piqi_pp.ml
  126. +21 −0 piqi/piqi_run.ml
  127. +487 −0 piqi/piqi_to_proto.ml
  128. +222 −0 piqi/piqi_wire.ml
  129. +133 −0 piqi/piqloc.ml
  130. +124 −0 piqi/piqobj.ml.m4
  131. +142 −0 piqi/piqobj.piqi
  132. +89 −0 piqi/piqobj_common.ml
  133. +652 −0 piqi/piqobj_of_piq.ml
  134. +336 −0 piqi/piqobj_of_wire.ml
  135. +158 −0 piqi/piqobj_to_piq.ml
  136. +255 −0 piqi/piqobj_to_wire.ml
  137. +41 −0 piqic/Makefile
  138. +22 −0 piqic/piqi-boot-ocaml.piqi
  139. +37 −0 piqic/piqi-ocaml.piqi
  140. +3 −0  piqic/piqic-boot.piqi
  141. +8 −0 piqic/piqic.piqi
  142. +19 −0 piqic/piqic_common.ml
  143. +268 −0 piqic/piqic_ocaml.ml
  144. +302 −0 piqic/piqic_ocaml_in.ml
  145. +283 −0 piqic/piqic_ocaml_out.ml
  146. +343 −0 piqic/piqic_ocaml_types.ml
  147. +21 −0 piqic/piqic_run.ml
  148. +51 −0 piqicc/Makefile
  149. +17 −0 piqicc/Makefile.boot
  150. +24 −0 piqicc/Makefile.boot2
  151. +23 −0 piqicc/Makefile.piqicc_common
  152. +26 −0 piqicc/Makefile.reboot
  153. +94 −0 piqicc/boot.ml
  154. +102 −0 piqicc/boot/piqast.ml.m4
  155. +588 −0 piqicc/boot/piqdefs.ml
  156. +146 −0 piqicc/boot/piqi-boot.piqi
  157. +218 −0 piqicc/boot/piqtype.ml.m4
  158. +3 −0  piqicc/piqicc-boot.piqi
  159. +178 −0 piqicc/piqicc.ml
  160. +8 −0 piqicc/piqicc.piqi
  161. +19 −0 piqicc/piqicc_run.ml
  162. +4 −0 piqirun-ocaml/META.templ
  163. +57 −0 piqirun-ocaml/Makefile
  164. +354 −0 piqirun-ocaml/piqirun_gen.ml
  165. +561 −0 piqirun-ocaml/piqirun_parser.ml
  166. +124 −0 piqirun-ocaml/test.ml
  167. +19 −0 piqirun-ocaml/test.ocaml
  168. +26 −0 setenv.sh
  169. +15 −0 tests/Makefile
  170. +21 −0 tests/README
  171. +1 −0  tests/addressbook
  172. +34 −0 tests/boot_proto2piqi/Makefile
  173. +10 −0 tests/boot_proto2piqi/README
  174. +433 −0 tests/boot_proto2piqi/descriptor.proto
  175. +79 −0 tests/boot_proto2piqi/main.cc
  176. +378 −0 tests/boot_proto2piqi/proto2piqi.cc
  177. +38 −0 tests/boot_proto2piqi/proto2piqi.h
  178. +23 −0 tests/cpp/Makefile
  179. +5 −0 tests/cpp/Makefile.cpp
  180. +7 −0 tests/cpp/README
  181. +31 −0 tests/cpp/test.cpp
  182. +1 −0  tests/examples
  183. +24 −0 tests/ocaml/Makefile
  184. +16 −0 tests/ocaml/Makefile.ocaml
  185. +13 −0 tests/ocaml/README
  186. +16 −0 tests/ocaml/test.ml
  187. +1 −0  tests/piqi.org
  188. +1 −0  tests/piqi_proto/.gitignore
  189. +8 −0 tests/piqi_proto/Makefile
  190. +9 −0 tests/piqi_proto/README
  191. +84 −0 tests/piqi_proto/test
1  .gitignore
@@ -0,0 +1 @@
+build
105 INSTALL
@@ -0,0 +1,105 @@
+SUPPORTED PLATFORMS
+===================
+
+Piqi is written in Objective Caml language so theoretically it should work on
+platforms and hardware architectures supported by Objective Caml. See the page
+below for the list of supported platforms:
+
+ http://caml.inria.fr/ocaml/portability.en.html
+
+
+So far, Piqi has been tested only on Debian Linux (Lenny and Squeeze, i386 and
+amd64 architectures).
+
+Current build procedure is likely not going to work on Windows out of the box,
+but it shouldn't be hard to adapt it.
+
+
+PREREQUISITES
+=============
+
+* Objective Caml compiler and standard library
+
+ Recommended (tested) version is 3.11.2. Older versions may not work
+ properly.
+
+ OCaml is available in most Linux distributions. It can also be
+ downloaded from here:
+
+ http://caml.inria.fr/download.en.html
+
+
+* CamlP4 -- Caml Preprocessor and Pretty Printer
+
+ It comes as a part of OCaml source distribution. It should be
+ prepackaged in major Linux distributions as well.
+
+
+* Ocamlfind/Findlib -- library manager for Objective Caml
+
+ If installed separately form prepackaged OCaml distribution, it is
+ recommended to build it from sources after you build/install OCaml. It
+ can be downloaded from here:
+
+ http://projects.camlcity.org/projects/findlib.html
+
+* C compiler
+
+ GCC works. Other compilers should work if they are able to build OCaml.
+
+
+* GNU make, m4, sed and probably some other tools.
+
+
+On Debian Squeeze, the above dependencies can be installed using the following
+command:
+
+ apt-get install ocaml camlp4-extra ocaml-findlib gcc m4 make sed
+
+
+INSTALLATION INSTRUCTIONS
+=========================
+
+NOTE: these instruction are applicable only to Unix/Linux systems.
+
+
+1. Edit setenv.sh file to set build configuration variables if necessary.
+
+2. Apply build configuration by running
+
+ . setenv.sh
+
+ or
+
+ source setenv.sh
+
+3. Make sure that "ocamlfind" program is in PATH
+
+4. Build third-party components
+
+ cd deps
+ make
+ cd ..
+
+5. Build piqi
+
+ make
+
+6. Install "piqi" and "piqic" binaries (optional)
+
+ make install
+
+
+The following steps are necessary only is you are going to use piqi interface
+compiler (piqic) for OCaml.
+
+7. Install piqi runtime library and piqi camlp4 extensions
+
+ make libinstall
+
+
+RUNNING TESTS
+=============
+
+See tests/README for instructions.
+
178 LICENSE
@@ -0,0 +1,178 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
29 Makefile
@@ -0,0 +1,29 @@
+include $(PIQI_ROOT)/make/Makefile.dirs
+
+
+DIRS = \
+ camlp4 \
+ piqirun-ocaml \
+ piqicc piqic piqi \
+
+
+install:
+ -install -d $(PIQI_PREFIX)/bin
+ install piqi/piqi $(PIQI_PREFIX)/bin
+ install piqic/piqic $(PIQI_PREFIX)/bin
+
+
+libinstall:
+ $(MAKE) -C piqirun-ocaml libinstall
+ $(MAKE) -C camlp4 libinstall
+
+
+libuninstall:
+ $(MAKE) -C piqirun-ocaml libuninstall
+ $(MAKE) -C camlp4 libuninstall
+
+
+clean::
+ $(MAKE) -C deps clean
+ $(MAKE) -C tests clean
+
55 NOTICE
@@ -0,0 +1,55 @@
+
+Piq interfaces and tools
+Copyright 2009, 2010 Anton Lavrik
+
+This distribution includes software originally developed by Anton Lavrik as a
+part of the Piqi project (http://piqi.org).
+
+Except where otherwise noted, content of this distribution is licensed under the
+terms of Apache License Version 2 (see "LICENSE" file).
+
+Current distribution includes several third-party components which are used by
+Piqi implementation. They are provided as a part of the distribution for the
+convenience of Piqi users.
+
+Below is the list of the third-party components with their descriptions and
+locations in the directory tree. Look for their license terms in correspondent
+directories.
+
+
+ulex
+====
+ Unicode lexer generator for OCaml written by Alain Frisch.
+
+ Location: deps/ulex-1.1/
+ Homepage: http://alain.frisch.fr/soft.html
+ License: MIT
+
+
+open-in
+=======
+ Camlp4 syntax extension implementing locally open modules written by
+ Alain Frisch.
+
+ Location: camlp4/pa_openin.ml
+ Homepage: http://alain.frisch.fr/soft.html
+ License: Public Domain
+
+
+ocaml-make
+==========
+ Automated compilation of complex OCaml-projects written by Markus Mottl.
+
+ Location: deps/ocaml-make-release-6.29.3
+ Homepage: http://www.ocaml.info/home/ocaml_sources.html
+ License: LGPL
+
+
+easy-format
+===========
+ Pretty-printing library for OCaml written by Martin Jambon.
+
+ Location: deps/easy-format-1.0.0/
+ Homepage: http://martin.jambon.free.fr/easy-format.html
+ License: BSD
+
65 README
@@ -0,0 +1,65 @@
+OVERVIEW
+========
+
+Piqi is a set of languages and tools for working with structured data. It
+includes:
+
+ * High-level data representation and data definition languages.
+
+ * Universal binary encoding.
+
+ * Tools for validating, pretty-printing and converting data into
+ different formats.
+
+ * Mappings to various programing languages allowing programs to
+ serialize and deserialize data in a portable manner.
+
+ * Open-source implementation.
+
+
+The combination of data presentation (Piq) and data definition (Piqi) languages
+is similar to the concept of "valid XML" (i.e. XML with XML Schema). However,
+unlike XML, Piq has a concise, clean syntax and a data model similar to data
+models of high-level programming languages such as ML.
+
+Piqi also supports binary encoding and language mappings which makes it similar
+to cross-language data serialization tools like Google Protocol Buffers or
+ASN.1.
+
+
+FURTHER INFORMATION
+===================
+
+Full description, documentation and binary builds can be found at
+
+ http://piqi.org
+
+
+INSTALLATION
+============
+
+See INSTALL file for installation instructions.
+
+
+FILES
+=====
+
+ README this file
+ INSTALL installation instructions
+ setenv.sh installation configuration file
+ LICENSE license
+ NOTICE copyright notice
+ VERSION current version
+ Makefile main Makefile
+ make/ make files for building the project
+ deps/ third-party components
+ camlp4/ camlp4 extensions
+ piqicc/ piqi compiler compiler
+ piqic/ piq interface compiler
+ piqi/ piqi command line utility (piqi tools)
+ piqi.org/ .piqi specifications of piqi
+ piqirun-ocaml/ runtime library for stubs generated by "piqic ocaml"
+ examples/ examples
+ tests/ tests for various piqi functionality; see tests/README
+ editors/ text editor plugins for .piq and .piqi files
+
1  VERSION
@@ -0,0 +1 @@
+0.5.0-dev
1  bin/piqi
1  bin/piqic
1  bin/piqicc
5 camlp4/META.templ
@@ -0,0 +1,5 @@
+name = "piqi.camlp4"
+requires = "camlp4"
+description = "Useful Camlp4 macro for dealing with OCaml types genereated by 'piqic ocaml'"
+archive(syntax,toploop) = "pa_labelscope.cmo pa_openin.cmo"
+archive(syntax,preprocessor) = "pa_labelscope.cmo pa_openin.cmo"
28 camlp4/Makefile
@@ -0,0 +1,28 @@
+OCAMLMAKEFILE = $(PIQI_ROOT)/make/OCamlMakefile
+
+
+RESULT = piqi
+
+
+INCDIRS = +camlp4
+PRE_TARGETS = \
+ META \
+ pa_labelscope.cmo pa_labelscope.cmi \
+ pa_openin.cmo pa_openin.cmi
+
+
+LIBINSTALL_FILES = $(PRE_TARGETS)
+
+
+all: $(PRE_TARGETS)
+
+
+install: libinstall
+uninstall: libuninstall
+
+
+META: META.templ ../VERSION
+ echo "version = \"`cat ../VERSION`\"" > $@; cat $< >> $@
+
+
+include $(OCAMLMAKEFILE)
95 camlp4/pa_labelscope.ml
@@ -0,0 +1,95 @@
+(*pp camlp4orf *)
+(* This code is in public domain. Written by Anton Lavrik.
+ *
+ * Tested with OCaml 3.11.2; also works with 3.10.2 with some modifications (see
+ * comments below).
+ *
+ * Based on pa_openin.ml written by Alain Frisch and adapted to OCaml 3.10 by
+ * Till Varoquaux
+ *)
+
+open Camlp4.PreCast
+open Syntax
+open Ast
+
+
+let fresh () = Printf.sprintf "LABELSCOPE_%i" (Oo.id (object end))
+
+let local_struct _loc st e =
+ let x = fresh () in
+ <:expr< let module $x$ = struct $st$; value res = $e$; end in $uid:x$.res >>
+
+
+let stream_peek_nth n strm =
+ let rec loop n =
+ function
+ | [] -> None
+ | [ (x, _) ] -> if n = 1 then Some x else None
+ | _ :: l -> loop (n - 1) l
+ in
+ loop n (Stream.npeek n strm)
+
+
+let test_label_eq =
+ Gram.Entry.of_parser "test_label_eq"
+ (
+ let rec test lev strm =
+ match stream_peek_nth lev strm with
+ Some (UIDENT _ | LIDENT _ | KEYWORD "." | KEYWORD "#") ->
+ test (lev + 1) strm
+ | Some (KEYWORD "=") -> ()
+ | _ -> raise Stream.Failure
+ in test 1
+ )
+
+
+let test_record_cons =
+ Gram.Entry.of_parser "test_record_cons"
+ (
+ fun strm ->
+ match Stream.npeek 5 strm with
+ [(UIDENT _,_); (KEYWORD "#",_); (KEYWORD "{",_); _; _] -> ()
+ | [(UIDENT _,_); (KEYWORD ".",_); (UIDENT _,_); (KEYWORD "#",_); (KEYWORD "{",_)] -> ()
+ | _ -> raise Stream.Failure
+ )
+
+
+(* In OCaml 3.10.2 the rule uses differernt names: "label_expr" instead of
+ "label_expr_list"
+
+DELETE_RULE Gram expr: "{"; test_label_eq; label_expr; "}" END;
+*)
+
+DELETE_RULE Gram expr: "{"; test_label_eq; label_expr_list; "}" END;
+
+
+EXTEND Gram
+ GLOBAL: expr label_longident val_longident a_UIDENT a_LIDENT;
+
+ expr: LEVEL "simple" [
+ [
+ "{"; test_label_eq; le = label_expr_list; "}" ->
+ (* Ast.ExRec (_loc, lel, (Ast.ExNil _loc)) *)
+ <:expr< { $le$ } >>
+
+ | test_record_cons; i = module_longident; "#"; e = expr LEVEL "simple" ->
+ local_struct _loc <:str_item< open $i$ >> e
+ ]
+ ];
+
+ val_longident: [
+ [
+ m = a_UIDENT; "#"; f = a_LIDENT -> <:ident< $uid:m$.$lid:f$ >>
+ ]
+ ];
+
+ label_longident: [
+ [
+ m = a_UIDENT; "#"; f = a_LIDENT -> <:ident< $uid:m$.$lid:f$ >>
+ ]
+ ];
+
+
+(* TODO: #-labels in record patterns *)
+
+END
34 camlp4/pa_openin.ml
@@ -0,0 +1,34 @@
+(*pp camlp4of *)
+(* This code is in public domain. Written by Alain Frisch. 2006-05-16.
+ Updated by Till Varoquaux. 2007-05-2.
+*)
+
+open Camlp4.PreCast
+open Syntax
+open Ast
+
+let fresh () = Printf.sprintf "OPENIN_%i" (Oo.id (object end))
+
+let local_struct _loc st e =
+ let x = fresh () in
+ <:expr< let module $x$ = struct $st$ let res = $e$ end in $uid:x$.res >>
+
+EXTEND Gram
+ GLOBAL: expr;
+
+ expr: LEVEL ";" [
+ ["open"; me = module_expr; "in"; e = expr LEVEL "top" ->
+ begin match me with
+ | <:module_expr< $id:i$ >> ->
+ local_struct _loc <:str_item< open $i$ >> e
+ | _ ->
+ let x = fresh () in
+ local_struct _loc <:str_item< module $x$ = $me$ open $uid:x$ >> e
+ end
+ | "struct"; st = LIST0 [ s = str_item; OPT ";;" -> s ]; "end"; "in";
+ e = expr LEVEL "top" ->
+ local_struct _loc (stSem_of_list st) e
+ ]
+ ];
+
+END
33 deps/Makefile
@@ -0,0 +1,33 @@
+
+DIRS = ulex-1.1 easy-format-1.0.0
+
+
+.PHONY: all build-install clean install uninstall install-dir
+
+
+build-install: $(DIRS) install-dir
+ set -e; \
+ for i in $(DIRS); do \
+ $(MAKE) -C $$i; \
+ $(MAKE) -C $$i install; \
+ done
+
+
+install: install-dir all
+uninstall: install-dir all
+clean: all
+
+
+all: $(DIRS)
+ set -e; \
+ for i in $(DIRS); do \
+ $(MAKE) -C $$i $(MAKECMDGOALS); \
+ done
+
+
+install-dir: $(OCAMLFIND_DESTDIR)
+
+
+$(OCAMLFIND_DESTDIR):
+ mkdir -p $@
+
21 deps/easy-format-1.0.0/Changes
@@ -0,0 +1,21 @@
+2008-07-13: Release 1.0.0, slightly incompatible with 0.9.0
+
+Incompatibilities:
+- Deprecated use of Easy_format.Param. Instead, inherit from Easy_format.list,
+ Easy_format.label or Easy_format.atom.
+- Atom nodes have now one additional argument for parameters.
+- All record types have been extended with more fields.
+ Using the "with" mechanism for inheritance is the best way of limiting
+ future incompatibilities.
+
+New features:
+- Support for separators that stick to the next list item
+- More wrapping options
+- Added Custom kind of nodes for using Format directly or existing
+ pretty-printers
+- Support for markup and escaping, allowing to produce colorized output
+ (HTML, terminal, ...) without interfering with the computation of
+ line breaks and spacing.
+
+
+2008-07-09: First release 0.9.0
24 deps/easy-format-1.0.0/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2008 Martin Jambon
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5 deps/easy-format-1.0.0/META
@@ -0,0 +1,5 @@
+version = "1.0.0"
+name = "easy-format"
+description = "Indentation made easy(ier)"
+archive(byte) = "easy_format.cmo"
+archive(native) = "easy_format.cmx"
4 deps/easy-format-1.0.0/META.tpl
@@ -0,0 +1,4 @@
+name = "easy-format"
+description = "Indentation made easy(ier)"
+archive(byte) = "easy_format.cmo"
+archive(native) = "easy_format.cmx"
87 deps/easy-format-1.0.0/Makefile
@@ -0,0 +1,87 @@
+VERSION = 1.0.0
+export VERSION
+
+.PHONY: default all opt test doc soft-clean clean
+default: all opt
+all:
+ ocamlc -c easy_format.mli
+ ocamlc -c -dtypes easy_format.ml
+ touch bytecode
+opt:
+ ocamlc -c easy_format.mli
+ ocamlopt -c -dtypes easy_format.ml
+ touch nativecode
+test: all simple_example.out
+ ocamlc -o test_easy_format -dtypes easy_format.cmo test_easy_format.ml
+ ./test_easy_format > test_easy_format.out
+ ocamlc -o lambda_example -dtypes easy_format.cmo lambda_example.ml
+ ./lambda_example > lambda_example.out
+
+simple_example: all simple_example.ml
+ ocamlc -o simple_example -dtypes easy_format.cmo simple_example.ml
+simple_example.out: simple_example
+ ./simple_example > simple_example.out
+
+doc: ocamldoc/index.html easy_format_example.html
+ocamldoc/index.html: easy_format.mli
+ ocamldoc -d ocamldoc -html $<
+easy_format_example.html: simple_example.out simple_example.ml
+ cat simple_example.ml > easy_format_example.ml
+ echo '(* Output: ' >> easy_format_example.ml
+ cat simple_example.out >> easy_format_example.ml
+ echo '*)' >> easy_format_example.ml
+ ocamlc -c -dtypes easy_format_example.ml
+ caml2html easy_format_example.ml -t -o easy_format_example.html
+
+soft-clean:
+ rm -f *.cm[iox] *.o *.annot \
+ test_easy_format lambda_example simple_example \
+ bytecode nativecode
+
+clean: soft-clean
+ rm -f *.out ocamldoc/* \
+ easy_format_example.*
+ cd examples; $(MAKE) clean
+
+
+COMMON_INSTALL_FILES = META easy_format.cmi easy_format.mli
+BC_INSTALL_FILES = easy_format.cmo
+NC_INSTALL_FILES = easy_format.cmx easy_format.o
+
+install:
+ echo "version = \"$(VERSION)\"" > META; cat META.tpl >> META
+ INSTALL_FILES="$(COMMON_INSTALL_FILES)"; \
+ if test -f bytecode; then \
+ INSTALL_FILES="$$INSTALL_FILES $(BC_INSTALL_FILES)"; \
+ fi; \
+ if test -f nativecode; then \
+ INSTALL_FILES="$$INSTALL_FILES $(NC_INSTALL_FILES)"; \
+ fi; \
+ ocamlfind install easy-format $$INSTALL_FILES
+
+uninstall:
+ ocamlfind remove easy-format
+
+archive:
+ @echo "Making archive for version $(VERSION)"
+ $(MAKE) doc
+ rm -rf /tmp/easy-format /tmp/easy-format-$(VERSION) && \
+ cp -r . /tmp/easy-format && \
+ cd /tmp/easy-format && \
+ $(MAKE) clean && \
+ rm -f *~ examples/*~ easy-format*.tar* && \
+ cd /tmp && cp -r easy-format easy-format-$(VERSION) && \
+ tar czf easy-format.tar.gz easy-format && \
+ tar cjf easy-format.tar.bz2 easy-format && \
+ tar czf easy-format-$(VERSION).tar.gz easy-format-$(VERSION) && \
+ tar cjf easy-format-$(VERSION).tar.bz2 easy-format-$(VERSION)
+ mv /tmp/easy-format.tar.gz /tmp/easy-format.tar.bz2 .
+ mv /tmp/easy-format-$(VERSION).tar.gz /tmp/easy-format-$(VERSION).tar.bz2 .
+ cp easy-format.tar.gz easy-format.tar.bz2 $$WWW/
+ cp easy-format-$(VERSION).tar.gz easy-format-$(VERSION).tar.bz2 $$WWW/
+ cp LICENSE $$WWW/easy-format-license.txt
+ cp Changes $$WWW/easy-format-changes.txt
+ cp easy_format_example.ml easy_format_example.html $$WWW/
+ cp ocamldoc/* $$WWW/easy-format-doc/
+ echo 'let easy_format_version = "$(VERSION)"' \
+ > $$WWW/easy-format-version.ml
25 deps/easy-format-1.0.0/README
@@ -0,0 +1,25 @@
++------------------------------------+
+| Easy_format: indentation made easy |
++------------------------------------+
+
+
+1. Documentation: http://martin.jambon.free.fr/easy-format.html
+
+2. Installation:
+
+Installation requires ocamlfind:
+
+ make
+ make install
+
+Uninstallation:
+
+ make uninstall
+
+
+3. Examples
+
+Some examples can be run with 'make test' before installing.
+
+More examples that require Easy-format to be installed and possibly
+dependencies on other packages can be found in the examples/ subdirectory.
3  deps/easy-format-1.0.0/TODO
@@ -0,0 +1,3 @@
+$Id: TODO 25 2008-07-13 15:15:00Z mjambon $
+
+
555 deps/easy-format-1.0.0/easy_format.ml
@@ -0,0 +1,555 @@
+(* $Id: easy_format.ml 20 2008-07-13 01:45:02Z mjambon $ *)
+
+open Format
+
+type wrap =
+ [ `Wrap_atoms
+ | `Always_wrap
+ | `Never_wrap
+ | `Force_breaks
+ | `No_breaks ]
+
+
+type style_name = string
+type style = {
+ tag_open : string;
+ tag_close : string
+}
+
+type atom_param = {
+ atom_style : style_name option;
+}
+
+let atom = {
+ atom_style = None
+}
+
+type list_param = {
+ space_after_opening : bool;
+ space_after_separator : bool;
+ space_before_separator : bool;
+ separators_stick_left : bool;
+ space_before_closing : bool;
+ stick_to_label : bool;
+ align_closing : bool;
+ wrap_body : wrap;
+ indent_body : int;
+ list_style : style_name option;
+ opening_style : style_name option;
+ body_style : style_name option;
+ separator_style : style_name option;
+ closing_style : style_name option;
+}
+
+let list = {
+ space_after_opening = true;
+ space_after_separator = true;
+ space_before_separator = false;
+ separators_stick_left = true;
+ space_before_closing = true;
+ stick_to_label = true;
+ align_closing = true;
+ wrap_body = `Wrap_atoms;
+ indent_body = 2;
+ list_style = None;
+ opening_style = None;
+ body_style = None;
+ separator_style = None;
+ closing_style = None;
+}
+
+
+type label_param = {
+ space_after_label : bool;
+ indent_after_label : int;
+ label_style : style_name option;
+}
+
+let label = {
+ space_after_label = true;
+ indent_after_label = 2;
+ label_style = None;
+}
+
+
+type t =
+ Atom of string * atom_param
+ | List of (string * string * string * list_param) * t list
+ | Label of (t * label_param) * t
+ | Custom of (formatter -> unit)
+
+
+type escape =
+ [ `None
+ | `Escape of
+ ((string -> int -> int -> unit) -> string -> int -> int -> unit)
+ | `Escape_string of (string -> string) ]
+
+type styles = (style_name * style) list
+
+
+
+module Pretty =
+struct
+
+ (*
+ Relies on the fact that mark_open_tag and mark_close_tag
+ are called exactly once before calling pp_output_string once.
+ It's a reasonable assumption although not guaranteed by the
+ documentation of the Format module.
+ *)
+ let set_escape fmt escape =
+ let print0, flush0 = pp_get_formatter_output_functions fmt () in
+ let tagf0 = pp_get_formatter_tag_functions fmt () in
+
+ let is_tag = ref false in
+
+ let mot tag =
+ is_tag := true;
+ tagf0.mark_open_tag tag
+ in
+
+ let mct tag =
+ is_tag := true;
+ tagf0.mark_close_tag tag
+ in
+
+ let print s p n =
+ if !is_tag then
+ (print0 s p n;
+ is_tag := false)
+ else
+ escape print0 s p n
+ in
+
+ let tagf = {
+ tagf0 with
+ mark_open_tag = mot;
+ mark_close_tag = mct
+ }
+ in
+ pp_set_formatter_output_functions fmt print flush0;
+ pp_set_formatter_tag_functions fmt tagf
+
+
+ let set_escape_string fmt esc =
+ let escape print s p n =
+ let s0 = String.sub s p n in
+ let s1 = esc s0 in
+ print s1 0 (String.length s1)
+ in
+ set_escape fmt escape
+
+
+ let define_styles fmt escape l =
+ if l <> [] then (
+ pp_set_tags fmt true;
+ let tbl1 = Hashtbl.create (2 * List.length l) in
+ let tbl2 = Hashtbl.create (2 * List.length l) in
+ List.iter (
+ fun (style_name, style) ->
+ Hashtbl.add tbl1 style_name style.tag_open;
+ Hashtbl.add tbl2 style_name style.tag_close
+ ) l;
+ let mark_open_tag style_name =
+ try Hashtbl.find tbl1 style_name
+ with Not_found -> ""
+ in
+ let mark_close_tag style_name =
+ try Hashtbl.find tbl2 style_name
+ with Not_found -> ""
+ in
+
+ let tagf = {
+ (pp_get_formatter_tag_functions fmt ()) with
+ mark_open_tag = mark_open_tag;
+ mark_close_tag = mark_close_tag
+ }
+ in
+ pp_set_formatter_tag_functions fmt tagf
+ );
+
+ (match escape with
+ `None -> ()
+ | `Escape esc -> set_escape fmt esc
+ | `Escape_string esc -> set_escape_string fmt esc)
+
+
+ let pp_open_xbox fmt p indent =
+ match p.wrap_body with
+ `Always_wrap
+ | `Never_wrap
+ | `Wrap_atoms -> pp_open_hvbox fmt indent
+ | `Force_breaks -> pp_open_vbox fmt indent
+ | `No_breaks -> pp_open_hbox fmt ()
+
+ let extra_box p l =
+ let wrap =
+ match p.wrap_body with
+ `Always_wrap -> true
+ | `Never_wrap
+ | `Force_breaks
+ | `No_breaks -> false
+ | `Wrap_atoms ->
+ List.for_all (function Atom _ -> true | _ -> false) l
+ in
+ if wrap then
+ ((fun fmt -> pp_open_hovbox fmt 0),
+ (fun fmt -> pp_close_box fmt ()))
+ else
+ ((fun fmt -> ()),
+ (fun fmt -> ()))
+
+
+ let pp_open_nonaligned_box fmt p indent l =
+ match p.wrap_body with
+ `Always_wrap -> pp_open_hovbox fmt indent
+ | `Never_wrap -> pp_open_hvbox fmt indent
+ | `Wrap_atoms ->
+ if List.for_all (function Atom _ -> true | _ -> false) l then
+ pp_open_hovbox fmt indent
+ else
+ pp_open_hvbox fmt indent
+ | `Force_breaks -> pp_open_vbox fmt indent
+ | `No_breaks -> pp_open_hbox fmt ()
+
+
+ let open_tag fmt = function
+ None -> ()
+ | Some s -> pp_open_tag fmt s
+
+ let close_tag fmt = function
+ None -> ()
+ | Some _ -> pp_close_tag fmt ()
+
+ let tag_string fmt o s =
+ match o with
+ None -> pp_print_string fmt s
+ | Some tag ->
+ pp_open_tag fmt tag;
+ pp_print_string fmt s;
+ pp_close_tag fmt ()
+
+ let rec fprint_t fmt = function
+ Atom (s, p) ->
+ tag_string fmt p.atom_style s;
+
+ | List ((_, _, _, p) as param, l) ->
+ open_tag fmt p.list_style;
+ if p.align_closing then
+ fprint_list fmt None param l
+ else
+ fprint_list2 fmt param l;
+ close_tag fmt p.list_style
+
+ | Label (label, x) -> fprint_pair fmt label x
+ | Custom f -> f fmt
+
+ and fprint_list_body_stick_left fmt p sep hd tl =
+ open_tag fmt p.body_style;
+ fprint_t fmt hd;
+ List.iter (
+ fun x ->
+ if p.space_before_separator then
+ pp_print_string fmt " ";
+ tag_string fmt p.separator_style sep;
+ if p.space_after_separator then
+ pp_print_space fmt ()
+ else
+ pp_print_cut fmt ();
+ fprint_t fmt x
+ ) tl;
+ close_tag fmt p.body_style
+
+ and fprint_list_body_stick_right fmt p sep hd tl =
+ open_tag fmt p.body_style;
+ fprint_t fmt hd;
+ List.iter (
+ fun x ->
+ if p.space_before_separator then
+ pp_print_space fmt ()
+ else
+ pp_print_cut fmt ();
+ tag_string fmt p.separator_style sep;
+ if p.space_after_separator then
+ pp_print_string fmt " ";
+ fprint_t fmt x
+ ) tl;
+ close_tag fmt p.body_style
+
+ and fprint_opt_label fmt = function
+ None -> ()
+ | Some (lab, lp) ->
+ open_tag fmt lp.label_style;
+ fprint_t fmt lab;
+ close_tag fmt lp.label_style;
+ if lp.space_after_label then
+ pp_print_string fmt " "
+
+ (* Either horizontal or vertical list *)
+ and fprint_list fmt label ((op, sep, cl, p) as param) = function
+ [] ->
+ fprint_opt_label fmt label;
+ tag_string fmt p.opening_style op;
+ if p.space_after_opening || p.space_before_closing then
+ pp_print_string fmt " ";
+ tag_string fmt p.closing_style cl
+
+ | hd :: tl as l ->
+
+ if tl = [] || p.separators_stick_left then
+ fprint_list_stick_left fmt label param hd tl l
+ else
+ fprint_list_stick_right fmt label param hd tl l
+
+
+ and fprint_list_stick_left fmt label (op, sep, cl, p) hd tl l =
+ let indent = p.indent_body in
+ pp_open_xbox fmt p indent;
+ fprint_opt_label fmt label;
+
+ tag_string fmt p.opening_style op;
+
+ if p.space_after_opening then
+ pp_print_space fmt ()
+ else
+ pp_print_cut fmt ();
+
+ let open_extra, close_extra = extra_box p l in
+ open_extra fmt;
+ fprint_list_body_stick_left fmt p sep hd tl;
+ close_extra fmt;
+
+ if p.space_before_closing then
+ pp_print_break fmt 1 (-indent)
+ else
+ pp_print_break fmt 0 (-indent);
+ tag_string fmt p.closing_style cl;
+ pp_close_box fmt ()
+
+ and fprint_list_stick_right fmt label (op, sep, cl, p) hd tl l =
+ let base_indent = p.indent_body in
+ let sep_indent =
+ String.length sep + (if p.space_after_separator then 1 else 0)
+ in
+ let indent = base_indent + sep_indent in
+
+ pp_open_xbox fmt p indent;
+ fprint_opt_label fmt label;
+
+ tag_string fmt p.opening_style op;
+
+ if p.space_after_opening then
+ pp_print_space fmt ()
+ else
+ pp_print_cut fmt ();
+
+ let open_extra, close_extra = extra_box p l in
+ open_extra fmt;
+
+ fprint_t fmt hd;
+ List.iter (
+ fun x ->
+ if p.space_before_separator then
+ pp_print_break fmt 1 (-sep_indent)
+ else
+ pp_print_break fmt 0 (-sep_indent);
+ tag_string fmt p.separator_style sep;
+ if p.space_after_separator then
+ pp_print_string fmt " ";
+ fprint_t fmt x
+ ) tl;
+
+ close_extra fmt;
+
+ if p.space_before_closing then
+ pp_print_break fmt 1 (-indent)
+ else
+ pp_print_break fmt 0 (-indent);
+ tag_string fmt p.closing_style cl;
+ pp_close_box fmt ()
+
+
+
+ (* align_closing = false *)
+ and fprint_list2 fmt (op, sep, cl, p) = function
+ [] ->
+ tag_string fmt p.opening_style op;
+ if p.space_after_opening || p.space_before_closing then
+ pp_print_string fmt " ";
+ tag_string fmt p.closing_style cl
+
+ | hd :: tl as l ->
+ tag_string fmt p.opening_style op;
+ if p.space_after_opening then
+ pp_print_string fmt " ";
+
+ pp_open_nonaligned_box fmt p 0 l ;
+ if p.separators_stick_left then
+ fprint_list_body_stick_left fmt p sep hd tl
+ else
+ fprint_list_body_stick_right fmt p sep hd tl;
+ pp_close_box fmt ();
+
+ if p.space_before_closing then
+ pp_print_string fmt " ";
+ tag_string fmt p.closing_style cl
+
+
+ (* Printing a label:value pair.
+
+ The opening bracket stays on the same line as the key, no matter what,
+ and the closing bracket is either on the same line
+ or vertically aligned with the beginning of the key.
+ *)
+ and fprint_pair fmt ((lab, lp) as label) x =
+ match x with
+ List ((op, sep, cl, p), l) when p.stick_to_label && p.align_closing ->
+ fprint_list fmt (Some label) (op, sep, cl, p) l
+
+ | _ ->
+ let indent = lp.indent_after_label in
+ pp_open_hvbox fmt 0;
+
+ open_tag fmt lp.label_style;
+ fprint_t fmt lab;
+ close_tag fmt lp.label_style;
+
+ if lp.space_after_label then
+ pp_print_break fmt 1 indent
+ else
+ pp_print_break fmt 0 indent;
+ fprint_t fmt x;
+ pp_close_box fmt ()
+
+ let to_formatter fmt x =
+ fprint_t fmt x;
+ pp_print_flush fmt ()
+
+ let to_buffer ?(escape = `None) ?(styles = []) buf x =
+ let fmt = Format.formatter_of_buffer buf in
+ define_styles fmt escape styles;
+ to_formatter fmt x
+
+ let to_string ?escape ?styles x =
+ let buf = Buffer.create 500 in
+ to_buffer ?escape ?styles buf x;
+ Buffer.contents buf
+
+ let to_channel ?(escape = `None) ?(styles = []) oc x =
+ let fmt = formatter_of_out_channel oc in
+ define_styles fmt escape styles;
+ to_formatter fmt x
+
+ let to_stdout ?escape ?styles x = to_channel ?escape ?styles stdout x
+ let to_stderr ?escape ?styles x = to_channel ?escape ?styles stderr x
+
+end
+
+
+
+
+module Compact =
+struct
+ open Printf
+
+ let rec fprint_t buf = function
+ Atom (s, _) -> Buffer.add_string buf s
+ | List (param, l) -> fprint_list buf param l
+ | Label (label, x) -> fprint_pair buf label x
+ | Custom f ->
+ (* Will most likely not be compact *)
+ let fmt = formatter_of_buffer buf in
+ f fmt;
+ pp_print_flush fmt ()
+
+ and fprint_list buf (op, sep, cl, _) = function
+ [] -> bprintf buf "%s%s" op cl
+ | x :: tl ->
+ Buffer.add_string buf op;
+ fprint_t buf x;
+ List.iter (
+ fun x ->
+ Buffer.add_string buf sep;
+ fprint_t buf x
+ ) tl;
+ Buffer.add_string buf cl
+
+ and fprint_pair buf (label, _) x =
+ fprint_t buf label;
+ fprint_t buf x
+
+
+ let to_buffer buf x = fprint_t buf x
+
+ let to_string x =
+ let buf = Buffer.create 500 in
+ to_buffer buf x;
+ Buffer.contents buf
+
+ let to_formatter fmt x =
+ let s = to_string x in
+ Format.fprintf fmt "%s" s;
+ pp_print_flush fmt ()
+
+ let to_channel oc x =
+ let buf = Buffer.create 500 in
+ to_buffer buf x;
+ Buffer.output_buffer oc buf
+
+ let to_stdout x = to_channel stdout x
+ let to_stderr x = to_channel stderr x
+end
+
+
+
+
+(* Obsolete *)
+module Param =
+struct
+ let list_true = {
+ space_after_opening = true;
+ space_after_separator = true;
+ space_before_separator = true;
+ separators_stick_left = true;
+ space_before_closing = true;
+ stick_to_label = true;
+ align_closing = true;
+ wrap_body = `Wrap_atoms;
+ indent_body = 2;
+ list_style = None;
+ opening_style = None;
+ body_style = None;
+ separator_style = None;
+ closing_style = None;
+ }
+
+ let list_false = {
+ space_after_opening = false;
+ space_after_separator = false;
+ space_before_separator = false;
+ separators_stick_left = false;
+ space_before_closing = false;
+ stick_to_label = false;
+ align_closing = false;
+ wrap_body = `Wrap_atoms;
+ indent_body = 2;
+ list_style = None;
+ opening_style = None;
+ body_style = None;
+ separator_style = None;
+ closing_style = None;
+ }
+
+ let label_true = {
+ space_after_label = true;
+ indent_after_label = 2;
+ label_style = None;
+ }
+
+ let label_false = {
+ space_after_label = false;
+ indent_after_label = 2;
+ label_style = None;
+ }
+end
225 deps/easy-format-1.0.0/easy_format.mli
@@ -0,0 +1,225 @@
+(* $Id: easy_format.mli 19 2008-07-13 01:39:54Z mjambon $ *)
+
+(**
+ Easy_format: indentation made easy.
+*)
+
+(**
+ This module provides a functional, simplified layer over
+ the Format module of the standard library.
+
+ Input data must be first modelled as a tree using 3 kinds of nodes:
+ - atoms
+ - lists
+ - labelled nodes
+
+ Atoms represent any text that is guaranteed to be printed as-is.
+ Lists can model any sequence of items such as arrays of data
+ or lists of definitions that are labelled with something
+ like "int main", "let x =" or "x:".
+*)
+
+type wrap =
+ [ `Wrap_atoms
+ | `Always_wrap
+ | `Never_wrap
+ | `Force_breaks
+ | `No_breaks ]
+(** List wrapping conditions:
+ - [`Wrap_atoms]: wrap if the list contains only atoms
+ - [`Always_wrap]: always wrap when needed
+ - [`Never_wrap]: never wrap,
+ i.e. the list is either horizontal or vertical
+ - [`Force_breaks]: align vertically,
+ i.e. always break line between list items and
+ align the left edge of each item.
+ - [`No_breaks]: align horizontally,
+ i.e. never break line between list items
+*)
+
+
+type style_name = string
+
+type style = {
+ tag_open : string;
+ tag_close : string
+}
+ (** Pair of opening and closing tags that are inserted around
+ text after pretty-printing. *)
+
+type atom_param = {
+ atom_style : style_name option; (** Default: [None] *)
+}
+
+val atom : atom_param
+
+
+(** List-formatting parameters.
+ Always derive a new set of parameters from an existing record.
+ See {!Easy_format.list}.
+*)
+type list_param = {
+ space_after_opening : bool; (** Whether there must be some whitespace
+ after the opening string.
+ Default: [true] *)
+ space_after_separator : bool; (** Whether there must be some whitespace
+ after the item separators.
+ Default: [true] *)
+ space_before_separator : bool; (** Whether there must be some whitespace
+ before the item separators.
+ Default: [false] *)
+ separators_stick_left : bool; (** Whether the separators must
+ stick to the item on the left.
+ Default: [true] *)
+ space_before_closing : bool; (** Whether there must be some whitespace
+ before the closing string.
+ Default: [true] *)
+ stick_to_label : bool; (** Whether the opening string should be fused
+ with the preceding label.
+ Default: [true] *)
+ align_closing : bool; (** Whether the beginning of the
+ closing string must be aligned
+ with the beginning of the opening string
+ (stick_to_label = false) or
+ with the beginning of the label if any
+ (stick_to_label = true).
+ Default: [true] *)
+ wrap_body : wrap; (** Defines under which conditions the list body
+ may be wrapped, i.e. allow several lines
+ and several list items per line.
+ Default: [`Wrap_atom_list] *)
+ indent_body : int; (** Extra indentation of the list body.
+ Default: [2] *)
+
+ list_style : style_name option; (** Default: [None] *)
+ opening_style : style_name option; (** Default: [None] *)
+ body_style : style_name option; (** Default: [None] *)
+ separator_style : style_name option; (** Default: [None] *)
+ closing_style : style_name option; (** Default: [None] *)
+}
+
+val list : list_param
+ (** Default list-formatting parameters, using the default values
+ described in the type definition above.
+
+ In order to make code compatible with future versions of the library,
+ the record inheritance syntax should be used, e.g.
+ [ { list with align_closing = false } ].
+ If new record fields are added, the program would still compile
+ and work as before.
+ *)
+
+(** Label-formatting parameters.
+ Always derive a new set of parameters from an existing record.
+ See {!Easy_format.label}.
+*)
+type label_param = {
+ space_after_label : bool; (** Whether there must be some whitespace
+ after the label.
+ Default: [true] *)
+ indent_after_label : int; (** Extra indentation before the item
+ that comes after a label.
+ Default: [2]
+ *)
+ label_style : style_name option; (** Default: [None] *)
+}
+
+val label : label_param
+ (** Default label-formatting parameters, using the default values
+ described in the type definition above.
+
+ In order to make code compatible with future versions of the library,
+ the record inheritance syntax should be used, e.g.
+ [ { label with indent_after_label = 0 } ].
+ If new record fields are added, the program would still compile
+ and work as before.
+ *)
+
+
+
+type t =
+ Atom of string * atom_param (** Plain string normally
+ without line breaks. *)
+
+ | List of
+ (
+ string (* opening *)
+ * string (* separator *)
+ * string (* closing *)
+ * list_param
+ )
+ * t list
+ (** [List ((opening, separator, closing, param), nodes)] *)
+
+ | Label of (t * label_param) * t
+ (** [Label ((label, param), node)]: labelled node. *)
+
+ | Custom of (Format.formatter -> unit)
+ (** User-defined printing function that allows to use the
+ Format module directly if necessary. It is responsible
+ for leaving the formatter in a clean state. *)
+(** The type of the tree to be pretty-printed. Each node contains
+ its own formatting parameters.
+
+ Detail of a list node
+ [List ((opening, separator, closing, param), nodes)]:
+
+ - [opening]: opening string such as ["\{"] ["\["] ["("] ["begin"] [""] etc.
+ - [separator]: node separator such as [";"] [","] [""] ["+"] ["|"] etc.
+ - [closing]: closing string such as ["\}"] ["\]"] [")"] ["end"] [""] etc.
+ - [nodes]: elements of the list.
+
+*)
+
+type escape =
+ [ `None
+ | `Escape of
+ ((string -> int -> int -> unit) -> string -> int -> int -> unit)
+ | `Escape_string of (string -> string) ]
+
+type styles = (style_name * style) list
+
+(** The regular pretty-printing functions *)
+module Pretty :
+sig
+ val define_styles : Format.formatter -> escape -> styles -> unit
+ val to_formatter : Format.formatter -> t -> unit
+
+ val to_buffer : ?escape:escape -> ?styles:styles -> Buffer.t -> t -> unit
+ val to_string : ?escape:escape -> ?styles:styles -> t -> string
+ val to_channel : ?escape:escape -> ?styles:styles -> out_channel -> t -> unit
+ val to_stdout : ?escape:escape -> ?styles:styles -> t -> unit
+ val to_stderr : ?escape:escape -> ?styles:styles -> t -> unit
+end
+
+(** No spacing or newlines other than those in the input data
+ or those produced by [Custom] printing. *)
+module Compact :
+sig
+ val to_buffer : Buffer.t -> t -> unit
+ val to_string : t -> string
+ val to_channel : out_channel -> t -> unit
+ val to_stdout : t -> unit
+ val to_stderr : t -> unit
+ val to_formatter : Format.formatter -> t -> unit
+ end
+
+
+(**/**)
+
+(** Deprecated. Predefined sets of parameters *)
+module Param :
+sig
+ val list_true : list_param
+ (** Deprecated. All boolean fields set to true. indent_body = 2. *)
+
+ val label_true : label_param
+ (** Deprecated. All boolean fields set to true. indent_after_label = 2. *)
+
+ val list_false : list_param
+ (** Deprecated. All boolean fields set to false. indent_body = 2. *)
+
+ val label_false : label_param
+ (** Deprecated. All boolean fields set to false. indent_after_label = 2. *)
+end
+
6 deps/easy-format-1.0.0/examples/Makefile
@@ -0,0 +1,6 @@
+# $Id: Makefile 22 2008-07-13 14:41:19Z mjambon $
+.PHONY: clean jsonpp
+jsonpp:
+ ocamlscript jsonpp.ml sample.json > sample.html
+clean:
+ rm -f *.exe sample.html
164 deps/easy-format-1.0.0/examples/jsonpp.ml
@@ -0,0 +1,164 @@
+#! /usr/bin/env ocamlscript
+Ocaml.packs := ["json-wheel"; "easy-format"]
+--
+(* $Id: jsonpp.ml 21 2008-07-13 14:35:17Z mjambon $ *)
+
+open Json_type
+open Easy_format
+
+(* JSON does not allow rendering floats with a trailing dot: that is,
+ 1234. is not allowed, but 1234.0 is ok. here, we add a '0' if
+ string_of_int result in a trailing dot *)
+let jstring_of_float f =
+ let s = string_of_float f in
+ let s_len = String.length s in
+ if s.[ s_len - 1 ] = '.' then
+ s ^ "0"
+ else
+ s
+
+let escape_json_string buf s =
+ for i = 0 to String.length s - 1 do
+ let c = String.unsafe_get s i in
+ match c with
+ | '"' -> Buffer.add_string buf "\\\""
+ | '\t' -> Buffer.add_string buf "\\t"
+ | '\r' -> Buffer.add_string buf "\\r"
+ | '\b' -> Buffer.add_string buf "\\b"
+ | '\n' -> Buffer.add_string buf "\\n"
+ | '\012' -> Buffer.add_string buf "\\f"
+ | '\\' -> Buffer.add_string buf "\\\\"
+ (* | '/' -> "\\/" *) (* Forward slash can be escaped
+ but doesn't have to *)
+ | '\x00'..'\x1F' (* Control characters that must be escaped *)
+ | '\x7F' (* DEL *) ->
+ Printf.bprintf buf "\\u%04X" (int_of_char c)
+ | _ ->
+ (* Don't bother detecting or escaping multibyte chars *)
+ Buffer.add_char buf c
+ done
+
+let jstring_of_string s =
+ let buf = Buffer.create (String.length s) in
+ Buffer.add_char buf '"';
+ escape_json_string buf s;
+ Buffer.add_char buf '"';
+ Buffer.contents buf
+
+
+
+let null = { atom_style = Some "null" }
+let bool = { atom_style = Some "bool" }
+let int = { atom_style = Some "int" }
+let float = { atom_style = Some "float" }
+let string = { atom_style = Some "string" }
+let label_string = { atom_style = Some "label" }
+let colon = { atom_style = Some "punct" }
+
+let array =
+ { list with
+ opening_style = Some "punct";
+ separator_style = Some "punct";
+ closing_style = Some "punct" }
+
+let label_with_colon =
+ { list with
+ space_after_opening = false;
+ space_before_closing = false;
+ space_after_separator = false;
+ wrap_body = `No_breaks }
+
+let rec format = function
+ Null -> Atom ("null", null)
+ | Bool b -> Atom (string_of_bool b, bool)
+ | Int i -> Atom (string_of_int i, int)
+ | Float f -> Atom (jstring_of_float f, float)
+ | String s -> Atom (jstring_of_string s, string)
+ | Array l -> List (("[", ",", "]", array), List.map format l)
+ | Object l -> List (("{", ",", "}", array), List.map format_field l)
+
+and format_field (s, x) =
+ let lab =
+ List (("", "", "", label_with_colon),
+ [ Atom (jstring_of_string s, label_string);
+ Atom (":", colon) ])
+ in
+ Label ((lab, label), format x)
+
+
+
+let html_escape_string s =
+ let buf = Buffer.create (2 * String.length s) in
+ for i = 0 to String.length s - 1 do
+ match s.[i] with
+ '&' -> Buffer.add_string buf "&amp;"
+ | '<' -> Buffer.add_string buf "&lt;"
+ | '>' -> Buffer.add_string buf "&gt;"
+ | c -> Buffer.add_char buf c
+ done;
+ Buffer.contents buf
+
+let html_escape = `Escape_string html_escape_string
+let html_style = [
+ "null", { tag_open = "<span class=\"json-null\">";
+ tag_close = "</span>" };
+ "bool", { tag_open = "<span class=\"json-bool\">";
+ tag_close = "</span>" };
+ "int", { tag_open = "<span class=\"json-int\">";
+ tag_close = "</span>" };
+ "float", { tag_open = "<span class=\"json-float\">";
+ tag_close = "</span>" };
+ "string", { tag_open = "<span class=\"json-string\">";
+ tag_close = "</span>" };
+ "label", { tag_open = "<span class=\"json-label\">";
+ tag_close = "</span>" };
+ "punct", { tag_open = "<span class=\"json-punct\">";
+ tag_close = "</span>" };
+]
+
+
+
+let print_html json =
+ print_string "\
+<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
+ \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
+<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
+<head>
+<title>JSON</title>
+<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />
+<meta name=\"generator\" content=\"Easy-format\" />
+<style type=\"text/css\">
+body,code,pre { color:black;background-color:white }
+.json-null { color: #808080; }
+.json-bool { color: black; }
+.json-int { color: black; }
+.json-float { color: black; }
+.json-string { color: black; }
+.json-label { color: #0033cc; }
+.json-punct { color: black; }
+</style>
+</head>
+<body>
+<pre>
+";
+ Pretty.to_stdout ~escape: html_escape ~styles: html_style (format json);
+ print_string "\
+</pre>
+</body>
+</html>
+"
+
+let _ =
+ let options = [] in
+ let files = ref [] in
+ let anon_fun s = files := s :: !files in
+ let usage_msg = Printf.sprintf "Usage: %s <file>" Sys.argv.(0) in
+ Arg.parse options anon_fun usage_msg;
+ let file =
+ match !files with
+ [s] -> s
+ | _ -> Arg.usage options usage_msg; exit 1
+ in
+ let json = Json_io.load_json ~allow_comments:true file in
+ print_html json
+
224 deps/easy-format-1.0.0/examples/sample.json
@@ -0,0 +1,224 @@
+[
+ {
+ "abc":
+ [
+ {
+ "x": "y",
+ "y": { "z": "aaa" },
+ "a":
+ [
+ "abc",
+ "long long long.........................................................................................."
+ ],
+ "a long label ...............................................":
+ [
+ 123, 456,
+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+ ]
+ },
+ [ "a", "b", "c", "d" ],
+ {
+ "x": true,
+ "y": { "z": false },
+ "a":
+ [
+ null,
+ "long long long.........................................................................................."
+ ],
+ "a long label ...............................................":
+ [
+ 1.23, 4.56, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+ ]
+ },
+ "xyz"
+ ]
+ },
+
+
+// From this point, examples were taken from http://www.json.org/example.html
+
+ {
+ "glossary": {
+ "title": "example glossary",
+ "GlossDiv": {
+ "title": "S",
+ "GlossList": {
+ "GlossEntry": {
+ "ID": "SGML",
+ "SortAs": "SGML",
+ "GlossTerm": "Standard Generalized Markup Language",
+ "Acronym": "SGML",
+ "Abbrev": "ISO 8879:1986",
+ "GlossDef": {
+ "para": "A meta-markup language, used to create markup languages such as DocBook.",
+ "GlossSeeAlso": ["GML", "XML"]
+ },
+ "GlossSee": "markup"
+ }
+ }
+ }
+ }
+ },
+
+
+
+{"menu": {
+ "id": "file",
+ "value": "File",
+ "popup": {
+ "menuitem": [
+ {"value": "New", "onclick": "CreateNewDoc()"},
+ {"value": "Open", "onclick": "OpenDoc()"},
+ {"value": "Close", "onclick": "CloseDoc()"}
+ ]
+ }
+}},
+
+
+{"widget": {
+ "debug": "on",
+ "window": {
+ "title": "Sample Konfabulator Widget",
+ "name": "main_window",
+ "width": 500,
+ "height": 500
+ },
+ "image": {
+ "src": "Images/Sun.png",
+ "name": "sun1",
+ "hOffset": 250,
+ "vOffset": 250,
+ "alignment": "center"
+ },
+ "text": {
+ "data": "Click Here",
+ "size": 36,
+ "style": "bold",
+ "name": "text1",
+ "hOffset": 250,
+ "vOffset": 100,
+ "alignment": "center",
+ "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
+ }
+}},
+
+
+{"web-app": {
+ "servlet": [
+ {
+ "servlet-name": "cofaxCDS",
+ "servlet-class": "org.cofax.cds.CDSServlet",
+ "init-param": {
+ "configGlossary:installationAt": "Philadelphia, PA",
+ "configGlossary:adminEmail": "ksm@pobox.com",
+ "configGlossary:poweredBy": "Cofax",
+ "configGlossary:poweredByIcon": "/images/cofax.gif",
+ "configGlossary:staticPath": "/content/static",
+ "templateProcessorClass": "org.cofax.WysiwygTemplate",
+ "templateLoaderClass": "org.cofax.FilesTemplateLoader",
+ "templatePath": "templates",
+ "templateOverridePath": "",
+ "defaultListTemplate": "listTemplate.htm",
+ "defaultFileTemplate": "articleTemplate.htm",
+ "useJSP": false,
+ "jspListTemplate": "listTemplate.jsp",
+ "jspFileTemplate": "articleTemplate.jsp",
+ "cachePackageTagsTrack": 200,
+ "cachePackageTagsStore": 200,
+ "cachePackageTagsRefresh": 60,
+ "cacheTemplatesTrack": 100,
+ "cacheTemplatesStore": 50,
+ "cacheTemplatesRefresh": 15,
+ "cachePagesTrack": 200,
+ "cachePagesStore": 100,
+ "cachePagesRefresh": 10,
+ "cachePagesDirtyRead": 10,
+ "searchEngineListTemplate": "forSearchEnginesList.htm",
+ "searchEngineFileTemplate": "forSearchEngines.htm",
+ "searchEngineRobotsDb": "WEB-INF/robots.db",
+ "useDataStore": true,
+ "dataStoreClass": "org.cofax.SqlDataStore",
+ "redirectionClass": "org.cofax.SqlRedirection",
+ "dataStoreName": "cofax",
+ "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
+ "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
+ "dataStoreUser": "sa",
+ "dataStorePassword": "dataStoreTestQuery",
+ "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
+ "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
+ "dataStoreInitConns": 10,
+ "dataStoreMaxConns": 100,
+ "dataStoreConnUsageLimit": 100,
+ "dataStoreLogLevel": "debug",
+ "maxUrlLength": 500}},
+ {
+ "servlet-name": "cofaxEmail",
+ "servlet-class": "org.cofax.cds.EmailServlet",
+ "init-param": {
+ "mailHost": "mail1",
+ "mailHostOverride": "mail2"}},
+ {
+ "servlet-name": "cofaxAdmin",
+ "servlet-class": "org.cofax.cds.AdminServlet"},
+
+ {
+ "servlet-name": "fileServlet",
+ "servlet-class": "org.cofax.cds.FileServlet"},
+ {
+ "servlet-name": "cofaxTools",
+ "servlet-class": "org.cofax.cms.CofaxToolsServlet",
+ "init-param": {
+ "templatePath": "toolstemplates/",
+ "log": 1,
+ "logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
+ "logMaxSize": "",
+ "dataLog": 1,
+ "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
+ "dataLogMaxSize": "",
+ "removePageCache": "/content/admin/remove?cache=pages&id=",
+ "removeTemplateCache": "/content/admin/remove?cache=templates&id=",
+ "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
+ "lookInContext": 1,
+ "adminGroupID": 4,
+ "betaServer": true}}],
+ "servlet-mapping": {
+ "cofaxCDS": "/",
+ "cofaxEmail": "/cofaxutil/aemail/*",
+ "cofaxAdmin": "/admin/*",
+ "fileServlet": "/static/*",
+ "cofaxTools": "/tools/*"},
+
+ "taglib": {
+ "taglib-uri": "cofax.tld",
+ "taglib-location": "/WEB-INF/tlds/cofax.tld"}}},
+
+{"menu": {
+ "header": "SVG Viewer",
+ "items": [
+ {"id": "Open"},
+ {"id": "OpenNew", "label": "Open New"},
+ null,
+ {"id": "ZoomIn", "label": "Zoom In"},
+ {"id": "ZoomOut", "label": "Zoom Out"},
+ {"id": "OriginalView", "label": "Original View"},
+ null,
+ {"id": "Quality"},
+ {"id": "Pause"},
+ {"id": "Mute"},
+ null,
+ {"id": "Find", "label": "Find..."},
+ {"id": "FindAgain", "label": "Find Again"},
+ {"id": "Copy"},
+ {"id": "CopyAgain", "label": "Copy Again"},
+ {"id": "CopySVG", "label": "Copy SVG"},
+ {"id": "ViewSVG", "label": "View SVG"},
+ {"id": "ViewSource", "label": "View Source"},
+ {"id": "SaveAs", "label": "Save As"},
+ null,
+ {"id": "Help"},
+ {"id": "About", "label": "About Adobe CVG Viewer..."}
+ ]
+}}
+
+
+]
122 deps/easy-format-1.0.0/lambda_example.ml
@@ -0,0 +1,122 @@
+type lambda =
+ Lambda of string * lambda
+ | Var of string
+ | Apply of lambda * lambda
+
+
+(* We make the page more narrow for illustration purposes *)
+let _ = Format.set_margin 20
+
+
+
+(* \n f x. n (\g h. h (g f)) (\u. x) (\u. u) *)
+(* \n. \f. \x. n (\g. \h. h (g f)) (\u. x) (\u. u) *)
+
+let sample_data =
+ Lambda (
+ "n",
+ (Lambda (
+ "f",
+ (Lambda (
+ "x",
+ Apply (
+ Apply (
+ Apply (
+ Var "n",
+ (Lambda (
+ "g",
+ (Lambda (
+ "h",
+ Apply (Var "h", Apply (Var "g", Var "f"))
+ )
+ )
+ )
+ )
+ ),
+ (Lambda ("u", Var "x"))
+ ),
+ (Lambda ("u", Var "u"))
+ )
+ )
+ )
+ )
+ )
+ )
+
+
+(****************************************************************************)
+(* Example from http://caml.inria.fr/resources/doc/guides/format.html
+ using Format directly. *)
+
+open Format
+
+let ident = pp_print_string;;
+let kwd = pp_print_string;;
+