Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse tspps from ast export #136

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Mathport/Syntax/AST3.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1149,12 +1149,12 @@ def Goals_repr (gs : Array Goal) : Format :=
structure TacticInvocation where
declName : Name
ast : Option #Tactic
start : Array Goal
«end» : Array Goal
start : Array Goal × Option String
«end» : Array Goal × Option String
success : Bool

instance : Repr TacticInvocation where reprPrec
| ⟨declName, tac, start, end_, success⟩, _ =>
| ⟨declName, tac, start, _⟩, ⟨end_, _⟩, success⟩, _ =>
"in declaration " ++ toString declName ++ " " ++
"invoking " ++ repr tac ++ ":\n" ++
"before:\n" ++ Goals_repr start ++
Expand Down
8 changes: 5 additions & 3 deletions Mathport/Syntax/Parse.lean
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ structure RawAST3 where
expr : Array (Option RawExpr)
tactics : Option (Array RawTacticInvocation)
states : Option (Array RawTacticState)
tspps : Option (Array String)
comments : Array AST3.Comment
deriving FromJson

Expand Down Expand Up @@ -1019,22 +1020,23 @@ def RawTacticState.build : RawTacticState → Name × Array AST3.Goal

def RawTacticInvocation.build
(states : Array (Name × Array AST3.Goal))
(statePPs : Array String)
(tacs : HashMap AstId (Spanned AST3.Tactic)) :
RawTacticInvocation → AST3.TacticInvocation
| ⟨ast, start, end_, success⟩ => ⟨states[start].1, tacs.find? ast, states[start].2, states[end_].2, success⟩
| ⟨ast, start, end_, success⟩ => ⟨states[start].1, tacs.find? ast, states[start].2, statePPs[start]⟩, ⟨states[end_].2, statePPs[end_]⟩, success⟩

end

def RawAST3.build : RawAST3 → (invocs :_:= true) → Except String (AST3 × Array AST3.TacticInvocation)
| ⟨ast, file, level, expr, tactics, states, comments⟩, invocs => do
| ⟨ast, file, level, expr, tactics, states, statePPs, comments⟩, invocs => do
let level := buildLevels level
let expr := buildExprs level expr
M.run ast expr $ do
let (ast, tacs) ← getAST comments file
let invocs :=
if invocs then
let states := (states.getD #[]).map (fun (s : RawTacticState) => s.build expr)
(tactics.getD #[]).map (·.build states tacs)
(tactics.getD #[]).map (·.build states (statePPs.getD #[]) tacs)
else #[]
pure (ast, invocs)

Expand Down