mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-05 19:00:33 -05:00
add another test, improve parser AST
This commit is contained in:
parent
4140739b93
commit
3317171971
3 changed files with 12 additions and 1 deletions
|
|
@ -104,7 +104,7 @@ let rec pp_term out (e : term) : unit =
|
|||
let ppb out (x, t) = Fmt.fprintf out "@[<2>%s :=@ %a@]" x.name pp t in
|
||||
Fmt.fprintf out "@[@[<2>let@ %a@] in@ %a@]"
|
||||
(Util.pp_list ~sep:"and" ppb)
|
||||
bs pp_sub bod
|
||||
bs pp bod
|
||||
| Lambda (args, bod) ->
|
||||
Fmt.fprintf out "@[lam %a.@ %a@]" (Util.pp_list pp_tyvar) args pp_sub bod
|
||||
| Pi (args, bod) ->
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ and p_term_atomic ?else_ ~f () =
|
|||
P.suspend @@ fun () ->
|
||||
P.try_or_l ?else_ ~msg:"expected atomic term" @@ p_term_atomic_cases ~f ()
|
||||
|
||||
(* TODO: handle infix symbols, with a table (sym -> precedence * parser).
|
||||
Start by registering "=" and "->" in there. *)
|
||||
(* TODO: handle lambda and pi *)
|
||||
|
||||
(* parse application of [t] to 0 or more arguments *)
|
||||
and p_term_apply t args : A.term P.t =
|
||||
P.suspend @@ fun () ->
|
||||
|
|
|
|||
|
|
@ -18,3 +18,10 @@ let test_str what s =
|
|||
|
||||
let () = test_str "t1" "f (g x) y"
|
||||
let () = test_str "t2" "let x:= 1 in f (f x 2)"
|
||||
|
||||
let () =
|
||||
test_str "t3"
|
||||
{|
|
||||
let l := map f (list 1 2 3) in
|
||||
let l2 := rev l in eq (rev l2) l
|
||||
|}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue