fix(parser): handle {} properly

This commit is contained in:
Simon Cruanes 2022-10-07 21:40:50 -04:00
parent 32d268822d
commit 1bc6f0ef5c
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
3 changed files with 11 additions and 4 deletions

View file

@ -179,8 +179,8 @@ let rec pp_proof out (p : proof) : unit =
and pp_proof_step out (step : proof_step) : unit = and pp_proof_step out (step : proof_step) : unit =
let s = step.view in let s = step.view in
Fmt.fprintf out "@[<2>have %s := %a@ proof %a@]" s.name pp_term s.goal Fmt.fprintf out "@[<2>have %s := %a@ %a@]" s.name pp_term s.goal pp_proof
pp_proof s.proof s.proof
let pp_decl out (d : decl) = let pp_decl out (d : decl) =
match d.view with match d.view with
@ -195,5 +195,5 @@ let pp_decl out (d : decl) =
args pp_tyret () pp_term rhs args pp_tyret () pp_term rhs
| D_hash (name, t) -> Fmt.fprintf out "@[<2>#%s@ %a@];" name pp_term t | D_hash (name, t) -> Fmt.fprintf out "@[<2>#%s@ %a@];" name pp_term t
| D_theorem { name; goal; proof } -> | D_theorem { name; goal; proof } ->
Fmt.fprintf out "@[<hv2>theorem %s :=@ %a@ @[<hv2>proof %a@]@];" name Fmt.fprintf out "@[<hv2>theorem %s :=@ %a@ @[<hv>%a@]@];" name pp_term goal
pp_term goal pp_proof proof pp_proof proof

View file

@ -24,6 +24,8 @@ rule token = parse
| ":" { COLON } | ":" { COLON }
| "(" { LPAREN } | "(" { LPAREN }
| ")" { RPAREN } | ")" { RPAREN }
| "{" { LBRACE }
| "}" { RBRACE }
| ":=" { EQDEF } | ":=" { EQDEF }
| "->" { ARROW } | "->" { ARROW }
| "." { DOT } | "." { DOT }

View file

@ -8,6 +8,11 @@ module Error = struct
let pp out (self : t) = let pp out (self : t) =
Fmt.fprintf out "parse error: %s@ %a" self.msg Loc.pp self.loc Fmt.fprintf out "parse error: %s@ %a" self.msg Loc.pp self.loc
let pp_with_loc ~input out (self : t) =
Fmt.fprintf out "parse error: %s@ %a" self.msg
(Loc.pp_loc ~max_lines:5 ~input)
[ self.loc ]
let to_string = Fmt.to_string pp let to_string = Fmt.to_string pp
end end