feat: use withoutPosition consistently (part 2)
This commit is contained in:
parent
8b8fc64fa0
commit
d7d61bfb55
8 changed files with 32 additions and 27 deletions
|
|
@ -18,7 +18,7 @@ only on the left side of an equality. -/
|
|||
declare_syntax_cat conv (behavior := both)
|
||||
|
||||
syntax convSeq1Indented := sepBy1IndentSemicolon(conv)
|
||||
syntax convSeqBracketed := "{" sepByIndentSemicolon(conv) "}"
|
||||
syntax convSeqBracketed := "{" withoutPosition(sepByIndentSemicolon(conv)) "}"
|
||||
-- Order is important: a missing `conv` proof should not be parsed as `{ <missing> }`,
|
||||
-- automatically closing goals
|
||||
syntax convSeq := convSeqBracketed <|> convSeq1Indented
|
||||
|
|
@ -122,7 +122,8 @@ syntax (name := rewrite) "rewrite" (config)? rwRuleSeq : conv
|
|||
|
||||
/-- `simp [thm]` performs simplification using `thm` and marked `@[simp]` lemmas.
|
||||
See the `simp` tactic for more information. -/
|
||||
syntax (name := simp) "simp" (config)? (discharger)? (&" only")? (" [" (simpStar <|> simpErase <|> simpLemma),* "]")? : conv
|
||||
syntax (name := simp) "simp" (config)? (discharger)? (&" only")?
|
||||
(" [" withoutPosition((simpStar <|> simpErase <|> simpLemma),*) "]")? : conv
|
||||
|
||||
/--
|
||||
`dsimp` is the definitional simplifier in `conv`-mode. It differs from `simp` in that it only
|
||||
|
|
@ -138,7 +139,8 @@ example (a : Nat): (0 + 0) = a - a := by
|
|||
rw [← Nat.sub_self a]
|
||||
```
|
||||
-/
|
||||
syntax (name := dsimp) "dsimp " (config)? (discharger)? (&"only ")? ("[" (simpErase <|> simpLemma),* "]")? : conv
|
||||
syntax (name := dsimp) "dsimp " (config)? (discharger)? (&"only ")?
|
||||
("[" withoutPosition((simpErase <|> simpLemma),*) "]")? : conv
|
||||
|
||||
/-- `simp_match` simplifies match expressions. For example,
|
||||
```
|
||||
|
|
@ -165,7 +167,7 @@ syntax (name := nestedConv) convSeqBracketed : conv
|
|||
|
||||
/-- `(convs)` runs the `convs` in sequence on the current list of targets.
|
||||
This is pure grouping with no added effects. -/
|
||||
syntax (name := paren) "(" convSeq ")" : conv
|
||||
syntax (name := paren) "(" withoutPosition(convSeq) ")" : conv
|
||||
|
||||
/-- `rfl` closes one conv goal "trivially", by using reflexivity
|
||||
(that is, no rewriting). -/
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ end Array
|
|||
|
||||
export Array (mkArray)
|
||||
|
||||
syntax "#[" sepBy(term, ", ") "]" : term
|
||||
syntax "#[" withoutPosition(sepBy(term, ", ")) "]" : term
|
||||
|
||||
macro_rules
|
||||
| `(#[ $elems,* ]) => `(List.toArray [ $elems,* ])
|
||||
|
|
|
|||
|
|
@ -132,9 +132,9 @@ def extract (as : Array α) (start stop : Nat) : Array α :=
|
|||
|
||||
instance : Coe (Subarray α) (Array α) := ⟨ofSubarray⟩
|
||||
|
||||
syntax:max term noWs "[" term ":" term "]" : term
|
||||
syntax:max term noWs "[" term ":" "]" : term
|
||||
syntax:max term noWs "[" ":" term "]" : term
|
||||
syntax:max term noWs "[" withoutPosition(term ":" term) "]" : term
|
||||
syntax:max term noWs "[" withoutPosition(term ":") "]" : term
|
||||
syntax:max term noWs "[" withoutPosition(":" term) "]" : term
|
||||
|
||||
macro_rules
|
||||
| `($a[$start : $stop]) => `(Array.toSubarray $a $start $stop)
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ instance : ForIn' m Range Nat inferInstance where
|
|||
instance : ForM m Range Nat where
|
||||
forM := Range.forM
|
||||
|
||||
syntax:max "[" ":" term "]" : term
|
||||
syntax:max "[" term ":" term "]" : term
|
||||
syntax:max "[" ":" term ":" term "]" : term
|
||||
syntax:max "[" term ":" term ":" term "]" : term
|
||||
syntax:max "[" withoutPosition(":" term) "]" : term
|
||||
syntax:max "[" withoutPosition(term ":" term) "]" : term
|
||||
syntax:max "[" withoutPosition(":" term ":" term) "]" : term
|
||||
syntax:max "[" withoutPosition(term ":" term ":" term) "]" : term
|
||||
|
||||
macro_rules
|
||||
| `([ : $stop]) => `({ stop := $stop : Range })
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ macro_rules
|
|||
| `($f $args* $ $a) => `($f $args* $a)
|
||||
| `($f $ $a) => `($f $a)
|
||||
|
||||
@[inherit_doc Subtype] syntax "{ " ident (" : " term)? " // " term " }" : term
|
||||
@[inherit_doc Subtype] syntax "{ " withoutPosition(ident (" : " term)? " // " term) " }" : term
|
||||
|
||||
macro_rules
|
||||
| `({ $x : $type // $p }) => ``(Subtype (fun ($x:ident : $type) => $p))
|
||||
|
|
@ -448,7 +448,7 @@ which uses let bindings as intermediates as in
|
|||
Note that this changes the order of evaluation, although it should not be observable
|
||||
unless you use side effecting operations like `dbg_trace`.
|
||||
-/
|
||||
syntax "[" term,* "]" : term
|
||||
syntax "[" withoutPosition(term,*) "]" : term
|
||||
|
||||
/--
|
||||
Auxiliary syntax for implementing `[$elem,*]` list literal syntax.
|
||||
|
|
@ -456,7 +456,7 @@ The syntax `%[a,b,c|tail]` constructs a value equivalent to `a::b::c::tail`.
|
|||
It uses binary partitioning to construct a tree of intermediate let bindings as in
|
||||
`let left := [d, e, f]; a :: b :: c :: left` to avoid creating very deep expressions.
|
||||
-/
|
||||
syntax "%[" term,* "|" term "]" : term
|
||||
syntax "%[" withoutPosition(term,* "|" term) "]" : term
|
||||
|
||||
namespace Lean
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ macro "Macro.trace[" id:ident "]" s:interpolatedStr(term) : term =>
|
|||
-- Auxiliary parsers and functions for declaring notation with binders
|
||||
|
||||
syntax unbracketedExplicitBinders := binderIdent+ (" : " term)?
|
||||
syntax bracketedExplicitBinders := "(" binderIdent+ " : " term ")"
|
||||
syntax bracketedExplicitBinders := "(" withoutPosition(binderIdent+ " : " term) ")"
|
||||
syntax explicitBinders := bracketedExplicitBinders+ <|> unbracketedExplicitBinders
|
||||
|
||||
open TSyntax.Compat in
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ syntax (name := failIfSuccess) "fail_if_success " tacticSeq : tactic
|
|||
the goal be closed at the end like `· tacs`. Like `by` itself, the tactics
|
||||
can be either separated by newlines or `;`.
|
||||
-/
|
||||
syntax (name := paren) "(" tacticSeq ")" : tactic
|
||||
syntax (name := paren) "(" withoutPosition(tacticSeq) ")" : tactic
|
||||
|
||||
/--
|
||||
`with_reducible tacs` excutes `tacs` using the reducible transparency setting.
|
||||
|
|
@ -295,7 +295,7 @@ It synthesizes a value of any target type by typeclass inference.
|
|||
macro "infer_instance" : tactic => `(tactic| exact inferInstance)
|
||||
|
||||
/-- Optional configuration option for tactics -/
|
||||
syntax config := atomic(" (" &"config") " := " term ")"
|
||||
syntax config := atomic(" (" &"config") " := " withoutPosition(term) ")"
|
||||
|
||||
/-- The `*` location refers to all hypotheses and the goal. -/
|
||||
syntax locationWildcard := "*"
|
||||
|
|
@ -339,7 +339,7 @@ If `thm` is a theorem `a = b`, then as a rewrite rule,
|
|||
-/
|
||||
syntax rwRule := ("← " <|> "<- ")? term
|
||||
/-- A `rwRuleSeq` is a list of `rwRule` in brackets. -/
|
||||
syntax rwRuleSeq := " [" rwRule,*,? "]"
|
||||
syntax rwRuleSeq := " [" withoutPosition(rwRule,*,?) "]"
|
||||
|
||||
/--
|
||||
`rewrite [e]` applies identity `e` as a rewrite rule to the target of the main goal.
|
||||
|
|
@ -388,7 +388,7 @@ syntax (name := injections) "injections" (colGt (ident <|> hole))* : tactic
|
|||
The discharger clause of `simp` and related tactics.
|
||||
This is a tactic used to discharge the side conditions on conditional rewrite rules.
|
||||
-/
|
||||
syntax discharger := atomic(" (" (&"discharger" <|> &"disch")) " := " tacticSeq ")"
|
||||
syntax discharger := atomic(" (" (&"discharger" <|> &"disch")) " := " withoutPosition(tacticSeq) ")"
|
||||
|
||||
/-- Use this rewrite rule before entering the subterms -/
|
||||
syntax simpPre := "↓"
|
||||
|
|
@ -426,14 +426,14 @@ non-dependent hypotheses. It has many variants:
|
|||
other hypotheses.
|
||||
-/
|
||||
syntax (name := simp) "simp" (config)? (discharger)? (&" only")?
|
||||
(" [" (simpStar <|> simpErase <|> simpLemma),* "]")? (location)? : tactic
|
||||
(" [" withoutPosition((simpStar <|> simpErase <|> simpLemma),*) "]")? (location)? : tactic
|
||||
/--
|
||||
`simp_all` is a stronger version of `simp [*] at *` where the hypotheses and target
|
||||
are simplified multiple times until no simplication is applicable.
|
||||
Only non-dependent propositional hypotheses are considered.
|
||||
-/
|
||||
syntax (name := simpAll) "simp_all" (config)? (discharger)? (&" only")?
|
||||
(" [" (simpErase <|> simpLemma),* "]")? : tactic
|
||||
(" [" withoutPosition((simpErase <|> simpLemma),*) "]")? : tactic
|
||||
|
||||
/--
|
||||
The `dsimp` tactic is the definitional simplifier. It is similar to `simp` but only
|
||||
|
|
@ -441,7 +441,7 @@ applies theorems that hold by reflexivity. Thus, the result is guaranteed to be
|
|||
definitionally equal to the input.
|
||||
-/
|
||||
syntax (name := dsimp) "dsimp" (config)? (discharger)? (&" only")?
|
||||
(" [" (simpErase <|> simpLemma),* "]")? (location)? : tactic
|
||||
(" [" withoutPosition((simpErase <|> simpLemma),*) "]")? (location)? : tactic
|
||||
|
||||
/--
|
||||
`delta id1 id2 ...` delta-expands the definitions `id1`, `id2`, ....
|
||||
|
|
@ -789,7 +789,8 @@ It is useful for referring to hypotheses without accessible names.
|
|||
`t` may contain holes that are solved by unification with the expected type;
|
||||
in particular, `‹_›` is a shortcut for `by assumption`.
|
||||
-/
|
||||
macro "‹" type:term "›" : term => `((by assumption : $type))
|
||||
syntax "‹" withoutPosition(term) "›" : term
|
||||
macro_rules | `(‹$type›) => `((by assumption : $type))
|
||||
|
||||
/--
|
||||
`get_elem_tactic_trivial` is an extensible tactic automatically called
|
||||
|
|
@ -822,7 +823,9 @@ macro "get_elem_tactic" : tactic =>
|
|||
)
|
||||
|
||||
@[inherit_doc getElem]
|
||||
macro:max x:term noWs "[" i:term "]" : term => `(getElem $x $i (by get_elem_tactic))
|
||||
syntax:max term noWs "[" withoutPosition(term) "]" : term
|
||||
macro_rules | `($x[$i]) => `(getElem $x $i (by get_elem_tactic))
|
||||
|
||||
@[inherit_doc getElem]
|
||||
macro x:term noWs "[" i:term "]'" h:term:max : term => `(getElem $x $i $h)
|
||||
syntax term noWs "[" withoutPosition(term) "]'" term:max : term
|
||||
macro_rules | `($x[$i]'$h) => `(getElem $x $i $h)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ partial def interpolatedStrFn (p : ParserFn) : ParserFn := fun c s =>
|
|||
parse startPos c s
|
||||
|
||||
@[inline] def interpolatedStrNoAntiquot (p : Parser) : Parser := {
|
||||
fn := interpolatedStrFn p.fn,
|
||||
fn := interpolatedStrFn (withoutPosition p).fn,
|
||||
info := mkAtomicInfo "interpolatedStr"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue