aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-01-25 10:03:11 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2016-01-25 10:03:11 +0100
commit4467453e0edca993c175690b7141d4916af3dc19 (patch)
tree15bd43200c36a5bc5d57c87a3e1220e378df07aa /lib
parent507f000343636e1e300b1f3af71177726926292c (diff)
downloadcompcert-4467453e0edca993c175690b7141d4916af3dc19.tar.gz
compcert-4467453e0edca993c175690b7141d4916af3dc19.zip
Started implementing a printer for Clflags.
Diffstat (limited to 'lib')
-rw-r--r--lib/Json.ml33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Json.ml b/lib/Json.ml
new file mode 100644
index 00000000..db2de5d4
--- /dev/null
+++ b/lib/Json.ml
@@ -0,0 +1,33 @@
+(* *********************************************************************)
+(* *)
+(* The Compcert verified compiler *)
+(* *)
+(* Bernhard Schommer, AbsInt Angewandte Informatik GmbH *)
+(* *)
+(* AbsInt Angewandte Informatik GmbH. All rights reserved. This file *)
+(* is distributed under the terms of the INRIA Non-Commercial *)
+(* License Agreement. *)
+(* *)
+(* *********************************************************************)
+
+open Printf
+
+(* Simple functions for JSON printing *)
+
+(* Print a string as json string *)
+let p_jstring oc s = fprintf oc "\"%s\"" s
+
+(* Print a list as json array *)
+let p_jarray elem oc l =
+ match l with
+ | [] -> fprintf oc "[]"
+ | hd::tail ->
+ output_string oc "["; elem oc hd;
+ List.iter (fprintf oc ",%a" elem) tail;
+ output_string oc "]"
+
+(* Print a bool as json bool *)
+let p_jbool oc = fprintf oc "%B"
+
+(* Print a int as json int *)
+let p_jint oc = fprintf oc "%d"