Skip to content

Commit 696ce49

Browse files
committed
cleanup
1 parent ce18a34 commit 696ce49

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/Lean/Elab/Tactic/Grind/Main.lean

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,19 @@ def getGrindParams (stx : TSyntax `tactic) : Array Syntax :=
202202
stx.raw[grindParamsPos][1].getSepArgs
203203

204204
/-- Filter out `+premises` from the config syntax -/
205-
def filterPremisesFromConfig (config : TSyntax ``Lean.Parser.Tactic.optConfig) : MetaM (TSyntax ``Lean.Parser.Tactic.optConfig) := do
205+
def filterPremisesFromConfig (config : TSyntax ``Lean.Parser.Tactic.optConfig) : TSyntax ``Lean.Parser.Tactic.optConfig :=
206206
let configItems := config.raw.getArgs
207207
let filteredItems := configItems.filter fun item =>
208-
-- The structure is: null node -> configItem node -> posConfigItem node
209-
-- We need to check if this is a +premises config item
210-
if let some configItem := item[0]? then
211-
if let some innerItem := configItem[0]? then
212-
if innerItem.getKind == ``Lean.Parser.Tactic.posConfigItem then
213-
if let some ident := innerItem[1]? then
214-
ident.getId != `premises
215-
else
216-
true
217-
else
218-
true
219-
else
220-
true
221-
else
222-
true
223-
return ⟨config.raw.setArgs filteredItems⟩
208+
-- Keep all items except +premises
209+
-- Structure: null node -> configItem -> posConfigItem -> ["+", ident]
210+
match item[0]? with
211+
| some configItem => match configItem[0]? with
212+
| some posConfigItem => match posConfigItem[1]? with
213+
| some ident => !(posConfigItem.getKind == ``Lean.Parser.Tactic.posConfigItem && ident.getId == `premises)
214+
| none => true
215+
| none => true
216+
| none => true
217+
⟨config.raw.setArgs filteredItems⟩
224218

225219
def mkGrindOnly
226220
(config : TSyntax ``Lean.Parser.Tactic.optConfig)
@@ -238,7 +232,7 @@ def mkGrindOnly
238232
else
239233
let param ← Grind.globalDeclToGrindParamSyntax declName kind minIndexable
240234
params := params.push param
241-
let filteredConfig filterPremisesFromConfig config
235+
let filteredConfig := filterPremisesFromConfig config
242236
let result ← `(tactic| grind $filteredConfig:optConfig only)
243237
return setGrindParams result params
244238

0 commit comments

Comments
 (0)