Skip to content

Commit

Permalink
parse from string now works for more complex expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
disconcision committed Nov 4, 2024
1 parent d239a24 commit ad1c917
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/web/Store.re
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ let insert: (Zipper.t, string) => Zipper.t =
};
};

let parse: string => Zipper.t = insert(Zipper.empty);
let parse = (str: string): Zipper.t =>
str
|> Labeler.label
|> List.map((x: Token.Unmolded.t) => x.text)
|> List.fold_left(insert, Zipper.empty);

let serialize = z => z |> Zipper.sexp_of_t |> Sexplib.Sexp.to_string;

Expand All @@ -31,10 +35,10 @@ let editor_defaults = [
serialize(parse("3 + 3")),
serialize(parse("(4)")),
serialize(parse("(5 + 5) * 5")),
serialize(parse("6")),
serialize(parse("7")),
serialize(parse("8")),
serialize(parse("9")),
serialize(parse("let x = 6 in x")),
serialize(parse("case 7\n| x => 7")),
serialize(parse("let (a, b) =\n(8*9<6, 17==6) in\n(a,(a, b))")),
serialize(parse("let f = fun z -> 9 in f(9)")),
serialize(parse("0")),
//serialize(parse("let x = 3 in x")),
//serialize(parse("let f = fun x -> 4 in f(4)")),
Expand Down

0 comments on commit ad1c917

Please sign in to comment.