Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnevers committed Mar 13, 2021
1 parent bd2476d commit cd1d94c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ let terminal () =
return =<< (identifier <?> int)
let rec lambda () =
ignore_spaces ();
let pos = get_position () in
let* id = str "λ" >> spaces >> identifier in
let* ex = spaces >> str "->" >> expression in
Expand All @@ -48,13 +47,12 @@ and non_app () =
lambda <?> terminal <?> parens expression >>= return
and app l r =
ignore_spaces ();
Apply (get_position (), l, r)
Apply (get_position (), l, r)
and expression () = return =<< chainl (spaces >> non_app) (lift app)
and expression () = return =<< chainl (spaces >> non_app) (spaces >> lift app)
let () =
from_string "(λ chrisNevers -> chrisNevers (λ shamone -> hehe)) (λ whenTheImposterIsSus -> 54235)";
from_string "( λ chrisNevers -> chrisNevers (λ shamone -> hehe) ) (λ whenTheImposterIsSus -> 54235)";
match expression () with
| Ok e -> print_endline (show_exp e)
| _ -> print_endline "Failed to parse expression"
Expand Down
8 changes: 3 additions & 5 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ let terminal () =
return =<< (identifier <?> int)

let rec lambda () =
ignore_spaces ();
let pos = get_position () in
let* id = str "λ" >> spaces >> identifier in
let* ex = spaces >> str "->" >> expression in
Expand All @@ -39,13 +38,12 @@ and non_app () =
lambda <?> terminal <?> parens expression >>= return

and app l r =
ignore_spaces ();
Apply (get_position (), l, r)
Apply (get_position (), l, r)

and expression () = return =<< chainl (spaces >> non_app) (lift app)
and expression () = return =<< chainl (spaces >> non_app) (spaces >> lift app)

let () =
from_string "(λ chrisNevers -> chrisNevers (λ shamone -> hehe)) (λ whenTheImposterIsSus -> 54235)";
from_string "( λ chrisNevers -> chrisNevers (λ shamone -> hehe) ) (λ whenTheImposterIsSus -> 54235)";
match expression () with
| Ok e -> print_endline (show_exp e)
| _ -> print_endline "Failed to parse expression"

0 comments on commit cd1d94c

Please sign in to comment.