refactor: add BindersUtil.lean
This commit is contained in:
parent
7e1bb3e65b
commit
712206f80e
3 changed files with 22 additions and 14 deletions
|
|
@ -5,6 +5,7 @@ Authors: Leonardo de Moura
|
|||
-/
|
||||
import Lean.Elab.Quotation.Precheck
|
||||
import Lean.Elab.Term
|
||||
import Lean.Elab.BindersUtil
|
||||
import Lean.Parser.Term
|
||||
|
||||
namespace Lean.Elab.Term
|
||||
|
|
@ -101,19 +102,6 @@ private def getBinderIds (ids : Syntax) : TermElabM (Array Syntax) :=
|
|||
else
|
||||
throwErrorAt id "identifier or `_` expected"
|
||||
|
||||
/-
|
||||
Recall that
|
||||
```
|
||||
def typeSpec := leading_parser " : " >> termParser
|
||||
def optType : Parser := optional typeSpec
|
||||
```
|
||||
-/
|
||||
def expandOptType (ref : Syntax) (optType : Syntax) : Syntax :=
|
||||
if optType.isNone then
|
||||
mkHole ref
|
||||
else
|
||||
optType[0][1]
|
||||
|
||||
private def matchBinder (stx : Syntax) : TermElabM (Array BinderView) := do
|
||||
let k := stx.getKind
|
||||
if k == `Lean.Parser.Term.simpleBinder then
|
||||
|
|
|
|||
20
src/Lean/Elab/BindersUtil.lean
Normal file
20
src/Lean/Elab/BindersUtil.lean
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/-
|
||||
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
Authors: Leonardo de Moura
|
||||
-/
|
||||
namespace Lean.Elab.Term
|
||||
/-
|
||||
Recall that
|
||||
```
|
||||
def typeSpec := leading_parser " : " >> termParser
|
||||
def optType : Parser := optional typeSpec
|
||||
```
|
||||
-/
|
||||
def expandOptType (ref : Syntax) (optType : Syntax) : Syntax :=
|
||||
if optType.isNone then
|
||||
mkHole ref
|
||||
else
|
||||
optType[0][1]
|
||||
|
||||
end Lean.Elab.Term
|
||||
|
|
@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
|||
Authors: Leonardo de Moura
|
||||
-/
|
||||
import Lean.Elab.Term
|
||||
import Lean.Elab.Binders
|
||||
import Lean.Elab.BindersUtil
|
||||
import Lean.Elab.PatternVar
|
||||
import Lean.Elab.Quotation.Util
|
||||
import Lean.Parser.Do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue