Skip to content

Instantly share code, notes, and snippets.

@danfinch
danfinch / gist:846706
Created February 27, 2011 23:49
simple whitespace indentation parser
open System
module Whitespace =
type Node = { Text : string; Nodes : Node ResizeArray; Parent : Node option }
type private Line = { Text : string; Indentation : int }
type private Token = Begin | Text of string | End
let parseTree (src : string) =
let lines =
src.Split ([| "\n"; "\r" |], StringSplitOptions.RemoveEmptyEntries)
|> Array.filter (fun s -> s.Trim () = "" |> not)