about summary refs log tree commit diff stats
path: root/modal/ocaml/_build/default/src/ast.ml
blob: bf2f2757bfdcc882feca282a55fe101618fb724b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 ")"