-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemo.lean
28 lines (23 loc) · 969 Bytes
/
Memo.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Lean
open Lean Elab Term
open Command
syntax (name := mycommand1) "#mycommand1" : command -- declare the syntax
@[commandElab mycommand1]
def mycommand1Impl : CommandElab := fun stx => do -- declare and register the elaborator
logInfo "Hello World"
#mycommand1 -- Hello World
@[commandElab Lean.Parser.Command.«def»]
def defOverroad : CommandElab := fun stx => do
logInfo "def over"
def a: String := "a"
elab "#findCElab " c:command : command => do
let macroRes ← liftMacroM <| expandMacroImpl? (←getEnv) c
match macroRes with
| some (name, _) => logInfo s!"Next step is a macro: {name.toString}"
| none =>
let kind := c.raw.getKind
let elabs := commandElabAttribute.getEntries (←getEnv) kind
match elabs with
| [] => logInfo s!"There is no elaborators for your syntax, looks like its bad :("
| _ => logInfo s!"Your syntax may be elaborated by: {elabs.map (fun el => el.declName.toString)}"
#findCElab def aaa := "a"