feat: delaborator: do not set whitespace information
This commit is contained in:
parent
b28eedbd98
commit
3d891be49e
6 changed files with 7 additions and 10 deletions
|
|
@ -194,11 +194,8 @@ def withProj {α} (d : DelabM α) : DelabM α := do
|
|||
Expr.app fn _ _ ← getExpr | unreachable!;
|
||||
descend fn 0 d
|
||||
|
||||
def infoForPos (pos : Nat) : SourceInfo :=
|
||||
{ leading := " ".toSubstring, pos := pos, trailing := " ".toSubstring }
|
||||
|
||||
partial def annotatePos (pos : Nat) : Syntax → Syntax
|
||||
| stx@(Syntax.ident _ _ _ _) => stx.setInfo (infoForPos pos)
|
||||
| stx@(Syntax.ident _ _ _ _) => stx.setInfo { pos := pos }
|
||||
-- Term.ids => annotate ident
|
||||
-- TODO: universes?
|
||||
| stx@(Syntax.node `Lean.Parser.Term.id args) => stx.modifyArg 0 annotatePos
|
||||
|
|
@ -206,7 +203,7 @@ partial def annotatePos (pos : Nat) : Syntax → Syntax
|
|||
| stx@(Syntax.node `Lean.Parser.Term.app args) => stx.modifyArg 0 annotatePos
|
||||
-- otherwise, annotate first direct child token if any
|
||||
| stx => match stx.getArgs.findIdx? Syntax.isAtom with
|
||||
| some idx => stx.modifyArg idx (Syntax.setInfo (infoForPos pos))
|
||||
| some idx => stx.modifyArg idx (Syntax.setInfo { pos := pos })
|
||||
| none => stx
|
||||
|
||||
def annotateCurPos (stx : Syntax) : Delab := do
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ partial def quoteAutoTactic : Syntax → TermElabM Syntax
|
|||
arg ← quoteAutoTactic arg;
|
||||
`(Array.push $args $arg)) empty;
|
||||
`(Syntax.node $(quote k) $args)
|
||||
| Syntax.atom info val => `(Syntax.atom none $(quote val))
|
||||
| Syntax.atom info val => `(Syntax.atom {} $(quote val))
|
||||
| Syntax.missing => unreachable!
|
||||
|
||||
def declareTacticSyntax (tactic : Syntax) : TermElabM Name :=
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import Init.Lean.KeyedDeclsAttribute
|
|||
namespace Lean
|
||||
|
||||
def Syntax.prettyPrint (stx : Syntax) : Format :=
|
||||
match stx.truncateTrailing.reprint with -- TODO use syntax pretty printer
|
||||
match stx.unsetTrailing.reprint with -- TODO use syntax pretty printer
|
||||
| some str => format str.toFormat
|
||||
| none => format stx
|
||||
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ match setTailInfoAux info stx with
|
|||
| some stx => stx
|
||||
| none => stx
|
||||
|
||||
def truncateTrailing (stx : Syntax) : Syntax :=
|
||||
def unsetTrailing (stx : Syntax) : Syntax :=
|
||||
match stx.getTailInfo with
|
||||
| none => stx
|
||||
| some info => stx.setTailInfo { info with trailing := none }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ open Lean
|
|||
|
||||
macro_rules [mycheck]
|
||||
| `(#check $es*) =>
|
||||
let cmds := es.getSepElems.map $ fun e => Syntax.node `Lean.Parser.Command.check #[Syntax.atom none "#check", e];
|
||||
let cmds := es.getSepElems.map $ fun e => Syntax.node `Lean.Parser.Command.check #[Syntax.atom {} "#check", e];
|
||||
pure $ mkNullNode cmds
|
||||
|
||||
#check true
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ open Lean
|
|||
syntax [myintro] "intros" (sepBy ident ",") : tactic
|
||||
|
||||
macro_rules [myintro]
|
||||
| `(tactic| intros $x*) => pure $ Syntax.node `Lean.Parser.Tactic.intros #[Syntax.atom none "intros", mkNullNode x.getSepElems]
|
||||
| `(tactic| intros $x*) => pure $ Syntax.node `Lean.Parser.Tactic.intros #[Syntax.atom {} "intros", mkNullNode x.getSepElems]
|
||||
|
||||
theorem tst1 {p q : Prop} : p → q → p :=
|
||||
begin
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue