Commit | Line | Data |
---|---|---|
ed3a12f5 PS |
1 | module Printer |
2 | open System.Text | |
3 | open Reader | |
4 | open Types | |
5 | ||
6 | let pr_str data = | |
7 | let acc = StringBuilder() | |
8 | let rec pr_node = function | |
9 | | List(nodes) | |
10 | -> acc.Append("(") |> ignore | |
11 | pr_list "" nodes | |
12 | | Symbol(symbol) -> acc.Append(symbol) |> ignore | |
13 | | Number(num) -> acc.Append(num) |> ignore | |
14 | ||
15 | and pr_list prefix = function | |
16 | | head::rest | |
17 | -> acc.Append(prefix) |> ignore | |
18 | pr_node head | |
19 | pr_list " " rest | |
20 | | [] -> acc.Append(")") |> ignore | |
21 | ||
22 | pr_node data | |
23 | acc.ToString() |