about summary refs log tree commit diff stats
path: root/modal/ocaml/_build/default/src/ast.ml
diff options
context:
space:
mode:
Diffstat (limited to 'modal/ocaml/_build/default/src/ast.ml')
-rw-r--r--modal/ocaml/_build/default/src/ast.ml22
1 files changed, 22 insertions, 0 deletions
diff --git a/modal/ocaml/_build/default/src/ast.ml b/modal/ocaml/_build/default/src/ast.ml
new file mode 100644
index 0000000..bf2f275
--- /dev/null
+++ b/modal/ocaml/_build/default/src/ast.ml
@@ -0,0 +1,22 @@
+(* AST for Modal trees and rules *)
+
+type node =
+  | Atom of string
+  | List of node list
+
+type rule = { left : node; right : node }
+
+let atom s = Atom s
+let list xs = List xs
+
+let rec pp fmt = function
+  | Atom s -> Format.fprintf fmt "%s" s
+  | List xs ->
+      Format.fprintf fmt "(";
+      List.iteri
+        (fun i n ->
+          if i > 0 then Format.fprintf fmt " "; pp fmt n)
+        xs;
+      Format.fprintf fmt ")"
+
+